-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: API to fetch total order amount by passing tickets and discount code #6366
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
feat: API to fetch total order amount by passing tickets and discount code #6366
Conversation
228b048 to
8eb03ed
Compare
|
@uds5501 @kushthedude @mrsaicharan1 can you guys please test and review this PR? |
Codecov Report
@@ Coverage Diff @@
## development #6366 +/- ##
===============================================
- Coverage 64.74% 64.47% -0.28%
===============================================
Files 288 288
Lines 14966 15039 +73
===============================================
+ Hits 9690 9696 +6
- Misses 5276 5343 +67
Continue to review full report at Codecov.
|
|
Great job. Event key should support event ID as well |
|
Secondly, create a function which takes tickets, event and discount_code as arguments and returns the computed dictionary so that it can be tested, and of course there will be several tests for this:
so that we have confidence it is working and fidelity for future |
|
Sure. Will add functions and tests by tonight |
|
Also, use marshmallow for validation |
|
Actually, event ID should not be needed. It can be extracted from ticket. Just verify every ticket has same event ID |
|
Ok. Will make mentioned changes |
|
Also, you can't just return the amount in JSON. You have to return a full object with price breakdown of individual tickets with tax and what not |
Yeah I was thinking about the same. Will return amount for each ticket, tax included in price or on the price, discount and overall total |
8eb03ed to
025d315
Compare
025d315 to
87ead92
Compare
87ead92 to
0f1c2c4
Compare
|
Currently, the response is - If anyone wants anything else to be returned alongwith this info, please comment. Till then I'll test it out for different cases and add test to the |
|
OK, how price of 158 with inclusive tax of 9.87 and discount of 16.59 amount to sub_total of 282.82? grand_total -> total_price Will add more recommendations on tax after seeing more examples |
|
For tax thing -> (158 - 16.59)*2 About discount_percentage, so u need to calculate both % and amount for all cases of discount whether it is amount or percent type or not? Makes sense. Will help others to display on client directly. |
4f9703e to
568f40d
Compare
|
@iamareebjamal I've tested all the cases mentioned by you in PR description. Should I add test for these cases too? If yes, then what should I test, sub-total, by replicating calculation in the helper? |
|
I think adding API documentation will serve both purposes, document it and also test the implementation However, I will add more fields, so hold on to that @anhanh11001 @liveHarshit, Please review the response and if it needs anything else |
How should I test it as it is not merged in development? I think @anhanh11001 has local setup for the server? |
|
Sub_total = (price + tax - discount)*quantity Basically a user can get details of one ticket by adding tax to price (if tax is exclusive) and then subtract discount to get an effective price for a ticket |
|
Also we cannot have exclusive and inclusive tax at the same time for an event. I've made changes to local and will push it once we are have other's feedback too |
26c0db3 to
1bd09aa
Compare
|
@uds5501 @mrsaicharan1 @CosmicCoder96 can you guys check this once? Please refer to the PR description for lastest request and response data format |
|
Please remove the data section in request. It's unneeded |
|
And discount should be null if not applied |
1bd09aa to
16959fb
Compare
|
@iamareebjamal removed data from request and also now if discount code or tax is not applied the discount/tax key have null data |
|
@uds5501 @mrsaicharan1 @iamareebjamal please review this PR |
|
Is the discount code ticket limit and maximum cutoff taken into account? |
|
@iamareebjamal currently they are being checked when we send a POST request to create order. |
|
But the amount will be wrong if you don't check it here |
|
Agreed. Will apply checks here too |
|
Was caught up in finalizing work product and other high priority pending PRs. Will start to finalize this now |
8fea2a5 to
cb31c21
Compare
|
@iamareebjamal I've included checks for overconsumption and service fees. Please have a look to updated response in the PR description |
… code adds function to order helper adds checks for donation tickets adds discount code overconsumption check included ticket service fee calculation
cb31c21 to
ef3a70e
Compare
|
Error should not be produced. Discount code should only be applied to 1 ticket |
|
@iamareebjamal actually the current implementation while ordering tickets follow the same thing and produces error in case of overconsumption. |
Fixes #6323
Changes proposed in this pull request:
Payload
Response
Checklist
Ensure it works: