From 83087bbb97bcfbb4f1c2046ca6ab43165c12e6ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 17 Sep 2026 17:02:06 +0200 Subject: [PATCH] Use BillThirdParty tag when requesting UPS to bill charge to customs agent It is not allowed to use BillShipper or BillReceiver with different accounts for different charges. Closes #15105 --- modules/stock_package_shipping_ups/stock.py | 32 ++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/modules/stock_package_shipping_ups/stock.py b/modules/stock_package_shipping_ups/stock.py index 66bcdaf4ed..c10f9595f2 100644 --- a/modules/stock_package_shipping_ups/stock.py +++ b/modules/stock_package_shipping_ups/stock.py @@ -421,17 +421,29 @@ class CreateShippingUPS_Customs_Incoterm(metaclass=PoolMeta): if (shipment.customs_international and shipment.incoterm and shipment.incoterm.import_duties == 'seller'): - if customs_agent := shipment.customs_agent: - account_number = customs_agent.ups_account_number - else: - account_number = credential.account_number - payment_information['ShipmentCharge'].append({ - # Type 02 is for Duties and Taxes - 'Type': '02', - 'BillShipper': { - 'AccountNumber': account_number, + charge = { + # Type 02 is for Duties and Taxes + 'Type': '02', + } + if ((customs_agent := shipment.customs_agent) + and (customs_agent.ups_account_number + != credential.account_number)): + address = customs_agent.address + charge['BillThirdParty'] = { + 'AccountNumber': customs_agent.ups_account_number, + 'Address': { + 'CountryCode': ( + address.country.code if address.country else ''), }, - }) + } + if address.postal_code: + charge['BillThirdParty']['Address']['PostalCode'] = ( + (address.postal_code or '').replace(' ', '')[:9]) + else: + charge['BillShipper'] = { + 'AccountNumber': credential.account_number, + } + payment_information['ShipmentCharge'].append(charge) return payment_information def get_international_form(self, shipment, credential):