fix: Revert rate calculation

(cherry picked from commit 6937a498e71cffc56cad65141f561b4c8785d185)
This commit is contained in:
Deepesh Garg 2022-03-25 12:28:55 +05:30 committed by mergify-bot
parent 54cdff7947
commit a83a0a03b1

View File

@ -114,17 +114,13 @@ class calculate_taxes_and_totals(object):
for item in self.doc.get("items"): for item in self.doc.get("items"):
self.doc.round_floats_in(item) self.doc.round_floats_in(item)
if not item.rate:
item.rate = item.price_list_rate
if item.discount_percentage == 100: if item.discount_percentage == 100:
item.rate = 0.0 item.rate = 0.0
elif item.price_list_rate: elif item.price_list_rate:
if item.pricing_rules or abs(item.discount_percentage) > 0: if not item.rate or (item.pricing_rules and item.discount_percentage > 0):
item.rate = flt(item.price_list_rate * item.rate = flt(item.price_list_rate *
(1.0 - (item.discount_percentage / 100.0)), item.precision("rate")) (1.0 - (item.discount_percentage / 100.0)), item.precision("rate"))
if abs(item.discount_percentage) > 0:
item.discount_amount = item.price_list_rate * (item.discount_percentage / 100.0) item.discount_amount = item.price_list_rate * (item.discount_percentage / 100.0)
elif item.discount_amount or item.pricing_rules: elif item.discount_amount or item.pricing_rules: