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
(grafted from 693c3aa598a48c64b74d8bfe328c928ac9757564)

--HG--
branch : 8.0
This commit is contained in:
Cédric Krier
2026-09-17 17:02:06 +02:00
parent 2fb5c8f53e
commit b22a72940e
+22 -10
View File
@@ -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):