New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: enable discount code checks for over consumption #6055
fix: enable discount code checks for over consumption #6055
Conversation
57c9bd2
to
b699630
Compare
Codecov Report
@@ Coverage Diff @@
## development #6055 +/- ##
===============================================
+ Coverage 65.54% 65.54% +<.01%
===============================================
Files 286 286
Lines 14589 14592 +3
===============================================
+ Hits 9562 9564 +2
- Misses 5027 5028 +1
Continue to review full report at Codecov.
|
@mrsaicharan1 @shreyanshdwivedi @prateekj117 Please review |
for holder in ticket_holders: | ||
ticket_holder = TicketHolder.query.filter_by(id=holder).one() | ||
if ticket_holder.ticket.id in discount_code.tickets.split(","): | ||
if ticket_holder.ticket.id in ticket_ids: | ||
qty += 1 | ||
if (qty + old_holders) <= discount_code.tickets_number and \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this condition, what you could do is, suppose the maximum number of tickets on which the discount code can be applied is 3(considering the discounted tickets which have been bought) and you are trying to order 5 tickets, apply the discount only on 3. This is how it's implemented on other platforms, so I believe it would be better if you could do this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrsaicharan1 should I break this into 2 sub-issues?
- This PR could serve as a check for discount code's over consumption
while the second sub issue will focus on application of discount code in the way you suggested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@uds5501 Yeah, that would suffice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrsaicharan1 I have linked it to the appropriate sub-issue. Please take a look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the first sub issue of preventing over consumption, this is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving this for now, but the logic is very naive. This kind of calculations should not be done in python, but using queries in the DB
Please open an issue to refactor this logic
@iamareebjamal Understood, will open an issue regarding this. |
@uds5501 We can merge this and work on DB level queries in a follow-up PR as soon as you resolve the conflicts :D |
4ef4f31
Fixes #6102
Checklist
development
branch.Short description of what this resolves:
This PR fixes the existing tests for checking if Discount Code is exhausted or not upon application