Compare commits

...

2 Commits

Author SHA1 Message Date
Harald Welte b8decb3ec8 Only 'available' moves in the picking when generating customs info
If we perform a partial shipment, we must only generate customs
information for those items which we are actually going to transfer.
2022-05-03 08:25:13 +02:00
Harald Welte fb5e942d45 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.
2022-03-16 18:54:40 +01:00
1 changed files with 13 additions and 2 deletions

View File

@ -152,7 +152,7 @@ class SCDeliveryCarrier(models.Model):
return res
def build_sc_customs_decl(self, picking, explanation, currency='EUR'):
items = [self.build_sc_customs_item(x) for x in picking.move_lines]
items = [self.build_sc_customs_item(x) for x in picking.move_lines if picking.state == 'assigned']
total = 0.0
for i in items:
total += i['value_amount']
@ -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':