I don't think there is any need for calculation. I see it more as an if/then scenario.
Example:
If
location = location1
and
unit type = type1
and
discount = null
then
cost = price
but
If
location = location1
and
unit type = type1
and
discount = amount
then
price = price
cost = price
And so forth until all the variables and prices are set.