fix: don't club same free item
This commit is contained in:
parent
fce552b811
commit
0486276789
@ -517,6 +517,7 @@ def get_product_discount_rule(pricing_rule, item_details, args=None, doc=None):
|
||||
free_item_data_args = {
|
||||
'item_code': free_item,
|
||||
'qty': qty,
|
||||
'pricing_rules': pricing_rule.name,
|
||||
'rate': pricing_rule.free_item_rate or 0,
|
||||
'price_list_rate': pricing_rule.free_item_rate or 0,
|
||||
'is_free_item': 1
|
||||
@ -540,10 +541,10 @@ def get_product_discount_rule(pricing_rule, item_details, args=None, doc=None):
|
||||
|
||||
def apply_pricing_rule_for_free_items(doc, pricing_rule_args, set_missing_values=False):
|
||||
if pricing_rule_args:
|
||||
items = tuple([d.item_code for d in doc.items if d.is_free_item])
|
||||
items = tuple([(d.item_code, d.pricing_rules) for d in doc.items if d.is_free_item])
|
||||
|
||||
for args in pricing_rule_args:
|
||||
if not items or args.get('item_code') not in items:
|
||||
if not items or (args.get('item_code'), args.get('pricing_rules')) not in items:
|
||||
doc.append('items', args)
|
||||
|
||||
def get_pricing_rule_items(pr_doc):
|
||||
|
@ -12,7 +12,7 @@ from frappe.model.document import Document
|
||||
pricing_rule_fields = ['apply_on', 'mixed_conditions', 'is_cumulative', 'other_item_code', 'other_item_group'
|
||||
'apply_rule_on_other', 'other_brand', 'selling', 'buying', 'applicable_for', 'valid_from',
|
||||
'valid_upto', 'customer', 'customer_group', 'territory', 'sales_partner', 'campaign', 'supplier',
|
||||
'supplier_group', 'company', 'currency']
|
||||
'supplier_group', 'company', 'currency', 'apply_multiple_pricing_rules']
|
||||
|
||||
other_fields = ['min_qty', 'max_qty', 'min_amt',
|
||||
'max_amt', 'priority','warehouse', 'threshold_percentage', 'rule_description']
|
||||
|
@ -1544,17 +1544,18 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
apply_product_discount: function(args) {
|
||||
const items = this.frm.doc.items.filter(d => (d.is_free_item)) || [];
|
||||
|
||||
const exist_items = items.map(row => row.item_code);
|
||||
const exist_items = items.map(row => (row.item_code, row.pricing_rules));
|
||||
|
||||
args.free_item_data.forEach(pr_row => {
|
||||
let row_to_modify = {};
|
||||
if (!items || !in_list(exist_items, pr_row.item_code)) {
|
||||
if (!items || !in_list(exist_items, (pr_row.item_code, pr_row.pricing_rules))) {
|
||||
|
||||
row_to_modify = frappe.model.add_child(this.frm.doc,
|
||||
this.frm.doc.doctype + ' Item', 'items');
|
||||
|
||||
} else if(items) {
|
||||
row_to_modify = items.filter(d => d.item_code === pr_row.item_code)[0];
|
||||
row_to_modify = items.filter(d => (d.item_code === pr_row.item_code
|
||||
&& d.pricing_rules === pr_row.pricing_rules))[0];
|
||||
}
|
||||
|
||||
for (let key in pr_row) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user