Skip to content

Commit

Permalink
fix: apply discount on item after applying price list (#36125)
Browse files Browse the repository at this point in the history
  • Loading branch information
anandbaburajan committed Jul 25, 2023
1 parent e4f28e8 commit bde9e89
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
13 changes: 13 additions & 0 deletions erpnext/public/js/controllers/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,16 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
this.frm.set_df_property("conversion_rate", "read_only", erpnext.stale_rate_allowed() ? 0 : 1);
},

apply_discount_on_item: function(doc, cdt, cdn, field) {
var item = frappe.get_doc(cdt, cdn);
if(!item.price_list_rate) {
item[field] = 0.0;
} else {
this.price_list_rate(doc, cdt, cdn);
}
this.set_gross_profit(item);
},

shipping_rule: function() {
var me = this;
if(this.frm.doc.shipping_rule) {
Expand Down Expand Up @@ -1720,6 +1730,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
() => {
if(args.items.length) {
me._set_values_for_item_list(r.message.children);
$.each(r.message.children || [], function(i, d) {
me.apply_discount_on_item(d, d.doctype, d.name, 'discount_percentage');
});
}
},
() => { me.in_apply_price_list = false; }
Expand Down
10 changes: 0 additions & 10 deletions erpnext/selling/sales_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
this.apply_discount_on_item(doc, cdt, cdn, 'discount_amount');
},

apply_discount_on_item: function(doc, cdt, cdn, field) {
var item = frappe.get_doc(cdt, cdn);
if(!item.price_list_rate) {
item[field] = 0.0;
} else {
this.price_list_rate(doc, cdt, cdn);
}
this.set_gross_profit(item);
},

commission_rate: function() {
this.calculate_commission();
},
Expand Down

0 comments on commit bde9e89

Please sign in to comment.