Skip to content

Commit 580e983

Browse files
committed
Update products.py
1 parent 524ade1 commit 580e983

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

function-calling-tools/solution-files/products.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ def calculate_bulk_price(product_id: str, quantity: int) -> dict:
4848
else:
4949
discount = Decimal("0")
5050

51-
unit_price = base_price * (Decimal("1") - discount)
52-
total_price = unit_price * quantity
51+
unit_price = unit_price.quantize(Decimal("0.01"))
52+
total_price = total_price.quantize(Decimal("0.01"))
53+
discount_percent = (discount * 100).quantize(Decimal("0.01"))
5354

5455
return {
5556
"quantity": quantity,
56-
"discount_percent": discount * 100,
57-
"unit_price": unit_price,
58-
"total_price": total_price
57+
"discount_percent": str(discount_percent),
58+
"unit_price": str(unit_price),
59+
"total_price": str(total_price),
5960
}

0 commit comments

Comments
 (0)