Include transport insurance cost in shipping estimates
Add 0.35% of the net base currency (EUR) value and add it to the shipping cost quote from the shipcloud API.
This commit is contained in:
parent
05a867cc55
commit
fb5e942d45
|
@ -204,7 +204,18 @@ class SCDeliveryCarrier(models.Model):
|
|||
except shipcloud.ApiError as err:
|
||||
raise Warning(str(err))
|
||||
# { "shipment_quote": { "price": 42.12 } }
|
||||
return result['shipment_quote']['price']
|
||||
shipping_cost = result['shipment_quote']['price']
|
||||
# determine net value in EUR of order
|
||||
if order.currency_id != order.company_id.currency_id:
|
||||
eur_amount = order.currency_id.compute(order.amount_untaxed, order.company_id.currency_id)
|
||||
_logger.info("Converted %5.2f %s -> %5.2f %s" % (order.amount_untaxed, order.currency_id.name, eur_amount, order.company_id.currency_id.name))
|
||||
else:
|
||||
eur_amount = order.amount_untaxed
|
||||
# compute 0.35% of net value for transport insurance
|
||||
insurance_cost = eur_amount * 0.0035
|
||||
_logger.info("Order %s, Shipping Service %s, cost=%5.2f, insurance=%5.2f", order.name, carrier_service.name, shipping_cost, insurance_cost)
|
||||
# return sum of shipcloud shipping cost + insurance cost
|
||||
return shipping_cost + insurance_cost
|
||||
|
||||
def _is_outside_eu(self, country):
|
||||
if country.code == 'DE':
|
||||
|
|
Loading…
Reference in New Issue