Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Sendcloud): round weight and value to allowed decimal places #24

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading