Skip to content

Commit

Permalink
fix: use correct recipient company (letmeship)
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Feb 7, 2024
1 parent 543b737 commit 1bd9c47
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 8 additions & 8 deletions erpnext_shipping/erpnext_shipping/doctype/letmeship/letmeship.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def get_available_services(self, delivery_to_type, pickup_address,
return []

self.set_letmeship_specific_fields(pickup_contact, delivery_contact)
pickup_address.address_title = self.trim_address(pickup_address)
delivery_address.address_title = self.trim_address(delivery_address)
pickup_address.address_title = self.first_30_chars(pickup_address.address_title)
delivery_address.address_title = self.first_30_chars(delivery_address.address_title)
parcel_list = self.get_parcel_list(json.loads(shipment_parcel), description_of_content)

url = 'https://api.letmeship.com/v1/available'
Expand Down Expand Up @@ -76,15 +76,15 @@ def get_available_services(self, delivery_to_type, pickup_address,

return []

def create_shipment(self, pickup_address, delivery_address, shipment_parcel, description_of_content,
def create_shipment(self, pickup_address, delivery_company_name, delivery_address, shipment_parcel, description_of_content,
pickup_date, value_of_goods, service_info, pickup_contact=None, delivery_contact=None):
# Create a transaction at LetMeShip
if not self.enabled or not self.api_id or not self.api_password:
return []

self.set_letmeship_specific_fields(pickup_contact, delivery_contact)
pickup_address.address_title = self.trim_address(pickup_address)
delivery_address.address_title = self.trim_address(delivery_address)
pickup_address.address_title = self.first_30_chars(pickup_address.address_title)
delivery_address.address_title = self.first_30_chars(delivery_company_name or delivery_address.address_title)
parcel_list = self.get_parcel_list(json.loads(shipment_parcel), description_of_content)

url = 'https://api.letmeship.com/v1/shipments'
Expand Down Expand Up @@ -253,10 +253,10 @@ def generate_payload(self, pickup_address, pickup_contact, delivery_address, del
payload['labelEmail'] = True
return payload

def trim_address(self, address):
def first_30_chars(self, address_title: str):
# LetMeShip has a limit of 30 characters for Company field
if len(address.address_title) > 30:
return address.address_title[:30]
if len(address_title) > 30:
return address_title[:30]

def get_service_dict(self, response):
"""Returns a dictionary with service info."""
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 @@ -100,6 +100,7 @@ def create_shipment(shipment, pickup_from_type, delivery_to_type, pickup_address
letmeship = LetMeShipUtils()
shipment_info = letmeship.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 1bd9c47

Please sign in to comment.