mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 11:19:09 +00:00
fix(discount): Fixed item discount amount calculation
This commit is contained in:
@@ -65,12 +65,13 @@ class calculate_taxes_and_totals(object):
|
|||||||
|
|
||||||
if item.doctype in ['Quotation Item', 'Sales Order Item', 'Delivery Note Item', 'Sales Invoice Item']:
|
if item.doctype in ['Quotation Item', 'Sales Order Item', 'Delivery Note Item', 'Sales Invoice Item']:
|
||||||
item.rate_with_margin, item.base_rate_with_margin = self.calculate_margin(item)
|
item.rate_with_margin, item.base_rate_with_margin = self.calculate_margin(item)
|
||||||
|
if flt(item.rate_with_margin) > 0:
|
||||||
item.rate = flt(item.rate_with_margin * (1.0 - (item.discount_percentage / 100.0)), item.precision("rate"))\
|
item.rate = flt(item.rate_with_margin * (1.0 - (item.discount_percentage / 100.0)), item.precision("rate"))
|
||||||
if item.rate_with_margin > 0 else item.rate
|
item.discount_amount = item.rate_with_margin - item.rate
|
||||||
|
elif flt(item.price_list_rate) > 0:
|
||||||
|
item.discount_amount = item.price_list_rate - item.rate
|
||||||
|
|
||||||
item.net_rate = item.rate
|
item.net_rate = item.rate
|
||||||
item.discount_amount = item.rate_with_margin - item.rate
|
|
||||||
item.amount = flt(item.rate * item.qty, item.precision("amount"))
|
item.amount = flt(item.rate * item.qty, item.precision("amount"))
|
||||||
item.net_amount = item.amount
|
item.net_amount = item.amount
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
|
|||||||
+ flt(effective_item_rate) * ( flt(item.margin_rate_or_amount) / 100);
|
+ flt(effective_item_rate) * ( flt(item.margin_rate_or_amount) / 100);
|
||||||
} else {
|
} else {
|
||||||
item.rate_with_margin = flt(effective_item_rate) + flt(item.margin_rate_or_amount);
|
item.rate_with_margin = flt(effective_item_rate) + flt(item.margin_rate_or_amount);
|
||||||
item.base_rate_with_margin = flt(item.rate_with_margin) * flt(this.frm.doc.conversion_rate);
|
|
||||||
}
|
}
|
||||||
|
item.base_rate_with_margin = flt(item.rate_with_margin) * flt(this.frm.doc.conversion_rate);
|
||||||
|
|
||||||
item.rate = flt(item.rate_with_margin , precision("rate", item));
|
item.rate = flt(item.rate_with_margin , precision("rate", item));
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
item.margin_rate_or_amount = 0;
|
item.margin_rate_or_amount = 0;
|
||||||
item.rate_with_margin = 0;
|
item.rate_with_margin = 0;
|
||||||
}
|
}
|
||||||
|
item.base_rate_with_margin = item.rate_with_margin * flt(this.frm.doc.conversion_rate);
|
||||||
|
|
||||||
cur_frm.cscript.set_gross_profit(item);
|
cur_frm.cscript.set_gross_profit(item);
|
||||||
cur_frm.cscript.calculate_taxes_and_totals();
|
cur_frm.cscript.calculate_taxes_and_totals();
|
||||||
|
|||||||
Reference in New Issue
Block a user