Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Coupon code based # rules are auto applied without checking the coupon code entered in sales order #40013

Open
Rajesh2445 opened this issue Feb 21, 2024 · 2 comments · May be fixed by #44104
Open
Labels

Comments

@Rajesh2445
Copy link

Information about bug

Add two # rules & create coupons for the same
Item 1 - Discount 10%
Item 2 - Discount 25%

In sales order add both Item 1 & Item 2. Apply coupon for Item 1, instead of applying only 10%, it applies both # rules in the sales order

Module

selling

Version

Frappe 14

ERP latest

Installation method

None

Relevant log output / Stack trace / Full Error Message.

No response

@Rajesh2445 Rajesh2445 added the bug label Feb 21, 2024
@nikolas-beckel
Copy link

Push. ⬆️
Is there any news in this regard?

@nikolas-beckel
Copy link

I debugged the code a little bit and I think I found the bug. Line 389 in #_rule.py checks whether a price rule is coupon_code_based (#_rule.coupon_code_based == 1). If this is the case, it is only checked whether any coupon code is set in the args parameter (args.coupon_code). However, there is no specific check as to whether the coupon code used is actually linked to the price rule.
As a result, all price rules with coupon_code_based == 1 that fulfil the other conditions are applied as soon as a coupon code is entered - regardless of whether this code applies to the respective price rule.

image

At the beginning of the loop pass via the #_rules, it should be checked whether the #_rule is coupon_code_based. If this is the case, a database query should be used to verify whether this # rule is actually linked to the transferred coupon code. If there is no match, the # rule can be skipped as it is not relevant.

image

I don't know whether this has side effects that I'm just overlooking. Or is the approach generally wrong?
Btw: I am also on version 14.

Maybe you can help us with this problem: @deepeshgarg007 @ruthra-kumar @sagarvora @Nihantra-Patel 🫶

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants