Skip to content

Commit

Permalink
fix: use correct recipient company (packlink)
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Feb 7, 2024
1 parent 1bd9c47 commit 65c1f33
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_available_services(self, pickup_address, delivery_address, shipment_parc

return []

def create_shipment(self, pickup_address, delivery_address, shipment_parcel,
def create_shipment(self, pickup_address, delivery_company_name, delivery_address, shipment_parcel,
description_of_content, pickup_date, value_of_goods, pickup_contact,
delivery_contact, service_info):
# Create a transaction at PackLink
Expand All @@ -79,7 +79,7 @@ def create_shipment(self, pickup_address, delivery_address, shipment_parcel,
'price': {},
'packages': self.get_parcel_list(json.loads(shipment_parcel)),
'service_id': service_info['service_id'],
'to': self.get_shipment_address_contact_dict(delivery_address, delivery_contact)
'to': self.get_shipment_address_contact_dict(delivery_address, delivery_contact, company_name=delivery_company_name)
}

url = 'https://api.packlink.com/v1/shipments'
Expand Down Expand Up @@ -197,11 +197,11 @@ def get_service_dict(self, response):
available_service.available_dates = response['available_dates']
return available_service

def get_shipment_address_contact_dict(self, address, contact):
def get_shipment_address_contact_dict(self, address, contact, company_name=None):
"""Returns a dict with Address and Contact Info for Packlink Payload."""
return {
'city': address.city,
'company': address.address_title,
'company': company_name or address.address_title,
'country': address.country_code,
'email': contact.email,
'name': contact.first_name,
Expand Down
1 change: 1 addition & 0 deletions erpnext_shipping/erpnext_shipping/shipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def create_shipment(shipment, pickup_from_type, delivery_to_type, pickup_address
packlink = PackLinkUtils()
shipment_info = packlink.create_shipment(
pickup_address=pickup_address,
delivery_company_name=delivery_company_name,
delivery_address=delivery_address,
shipment_parcel=shipment_parcel,
description_of_content=description_of_content,
Expand Down

0 comments on commit 65c1f33

Please sign in to comment.