fix(pos): cannot ignore pricing rule for one particular invoice (#29222)
This commit is contained in:
parent
c62083653b
commit
75c8b2556e
@ -353,7 +353,6 @@ class POSInvoice(SalesInvoice):
|
|||||||
if not for_validate and not self.customer:
|
if not for_validate and not self.customer:
|
||||||
self.customer = profile.customer
|
self.customer = profile.customer
|
||||||
|
|
||||||
self.ignore_pricing_rule = profile.ignore_pricing_rule
|
|
||||||
self.account_for_change_amount = profile.get('account_for_change_amount') or self.account_for_change_amount
|
self.account_for_change_amount = profile.get('account_for_change_amount') or self.account_for_change_amount
|
||||||
self.set_warehouse = profile.get('warehouse') or self.set_warehouse
|
self.set_warehouse = profile.get('warehouse') or self.set_warehouse
|
||||||
|
|
||||||
|
@ -556,6 +556,37 @@ class TestPOSInvoice(unittest.TestCase):
|
|||||||
batch.cancel()
|
batch.cancel()
|
||||||
batch.delete()
|
batch.delete()
|
||||||
|
|
||||||
|
def test_ignore_pricing_rule(self):
|
||||||
|
from erpnext.accounts.doctype.pricing_rule.test_pricing_rule import make_pricing_rule
|
||||||
|
|
||||||
|
item_price = frappe.get_doc({
|
||||||
|
'doctype': 'Item Price',
|
||||||
|
'item_code': '_Test Item',
|
||||||
|
'price_list': '_Test Price List',
|
||||||
|
'price_list_rate': '450',
|
||||||
|
})
|
||||||
|
item_price.insert()
|
||||||
|
pr = make_pricing_rule(selling=1, priority=5, discount_percentage=10)
|
||||||
|
pr.save()
|
||||||
|
pos_inv = create_pos_invoice(qty=1, do_not_submit=1)
|
||||||
|
pos_inv.items[0].rate = 300
|
||||||
|
pos_inv.save()
|
||||||
|
self.assertEquals(pos_inv.items[0].discount_percentage, 10)
|
||||||
|
# rate shouldn't change
|
||||||
|
self.assertEquals(pos_inv.items[0].rate, 405)
|
||||||
|
|
||||||
|
pos_inv.ignore_pricing_rule = 1
|
||||||
|
pos_inv.items[0].rate = 300
|
||||||
|
pos_inv.save()
|
||||||
|
self.assertEquals(pos_inv.ignore_pricing_rule, 1)
|
||||||
|
# rate should change since pricing rules are ignored
|
||||||
|
self.assertEquals(pos_inv.items[0].rate, 300)
|
||||||
|
|
||||||
|
item_price.delete()
|
||||||
|
pos_inv.delete()
|
||||||
|
pr.delete()
|
||||||
|
|
||||||
|
|
||||||
def create_pos_invoice(**args):
|
def create_pos_invoice(**args):
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
pos_profile = None
|
pos_profile = None
|
||||||
|
@ -650,7 +650,7 @@ def make_pricing_rule(**args):
|
|||||||
"rate": args.rate or 0.0,
|
"rate": args.rate or 0.0,
|
||||||
"margin_rate_or_amount": args.margin_rate_or_amount or 0.0,
|
"margin_rate_or_amount": args.margin_rate_or_amount or 0.0,
|
||||||
"condition": args.condition or '',
|
"condition": args.condition or '',
|
||||||
"priority": 1,
|
"priority": args.priority or 1,
|
||||||
"discount_amount": args.discount_amount or 0.0,
|
"discount_amount": args.discount_amount or 0.0,
|
||||||
"apply_multiple_pricing_rules": args.apply_multiple_pricing_rules or 0
|
"apply_multiple_pricing_rules": args.apply_multiple_pricing_rules or 0
|
||||||
})
|
})
|
||||||
@ -676,6 +676,8 @@ def make_pricing_rule(**args):
|
|||||||
if args.get(applicable_for):
|
if args.get(applicable_for):
|
||||||
doc.db_set(applicable_for, args.get(applicable_for))
|
doc.db_set(applicable_for, args.get(applicable_for))
|
||||||
|
|
||||||
|
return doc
|
||||||
|
|
||||||
def setup_pricing_rule_data():
|
def setup_pricing_rule_data():
|
||||||
if not frappe.db.exists('Campaign', '_Test Campaign'):
|
if not frappe.db.exists('Campaign', '_Test Campaign'):
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user