Skip to content

Commit

Permalink
fix(Sendcloud): round weight and value to allowed decimal places
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Jul 24, 2024
1 parent d0cd207 commit 5aa6be1
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
from erpnext_shipping.erpnext_shipping.utils import show_error_alert

SENDCLOUD_PROVIDER = "SendCloud"

WEIGHT_DECIMALS = 3
CURRENCY_DECIMALS = 2

class SendCloud(Document):
pass
Expand Down Expand Up @@ -201,8 +202,8 @@ def get_parcel_items(self, parcel, description_of_content, value_of_goods):
formatted_parcel = {}
formatted_parcel["description"] = description_of_content
formatted_parcel["quantity"] = parcel.get("count")
formatted_parcel["weight"] = parcel.get("weight")
formatted_parcel["value"] = value_of_goods
formatted_parcel["weight"] = flt(parcel.get("weight"), WEIGHT_DECIMALS)
formatted_parcel["value"] = flt(value_of_goods, CURRENCY_DECIMALS)
parcel_list.append(formatted_parcel)
return parcel_list

Expand Down Expand Up @@ -255,7 +256,7 @@ def get_parcel_dict(
"shipment": {"id": service_info["service_id"]},
"order_number": f"{shipment}-{index}",
"external_reference": f"{shipment}-{index}",
"weight": parcel.get("weight"),
"weight": flt(parcel.get("weight"), WEIGHT_DECIMALS),
"parcel_items": self.get_parcel_items(parcel, description_of_content, value_of_goods),
}

Expand Down

0 comments on commit 5aa6be1

Please sign in to comment.