Calculate Price Based on Associated Costs

I would like to build a pricing tool script that allows me to provide a few inputs, and then the script would calculate the price based on a series of calculations that run in the background. This is a for a trucking company whose job is to haul materials from the customer to a processing location. Each processing location charges a different rate to process the hauled materials. The pricing calculator needs to calculate the distance from the customer’s site to the processing location and the cost to process that material.

[Project Table]
input project address
input material hauled
input market location

[Processing Table]
list or processing locations containing address, materials accepted, processing rate, and market location

I would like for this script to run a calculation for each record w/in a particular view of the Processing Table, and produce the lowest rate and associated Processing location that is driving that cost.

The script would need to leverage the Google Maps Distance Matrix API to find the estimated drive time from the project address and the processing location.

I have experience building the tables, but not building these types of scripts. Any help would be greatly appreciated.