Skip to content
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: Fixed multiple tickets error & refactored order invoice logic #6133

Merged
merged 2 commits into from
Jul 2, 2019

Conversation

mrsaicharan1
Copy link
Member

@mrsaicharan1 mrsaicharan1 commented Jul 2, 2019

Fixes #6132

Short description of what this resolves:

The order invoice function was trying to query for one entry alluding to the order ID. But, It found multiple entries pertaining to the order. Fixed this by taking only the first entry going into the model.

Changes proposed in this pull request:

  • Refactored order invoice logic to loop through OrderTicket objects
  • Queried all the OrderTicket instances to ensure everything was getting transmitted

Checklist

  • I have read the Contribution & Best practices Guide and my PR follows them.
  • My branch is up-to-date with the Upstream development branch.
  • The unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • All the functions created/modified in this PR contain relevant docstrings.

@auto-label auto-label bot added the fix label Jul 2, 2019
app/api/helpers/order.py Outdated Show resolved Hide resolved
app/api/helpers/order.py Outdated Show resolved Hide resolved
@mrsaicharan1 mrsaicharan1 force-pushed the multiple-tickets branch 2 times, most recently from 39e12f3 to c856375 Compare July 2, 2019 05:58
@codecov
Copy link

codecov bot commented Jul 2, 2019

Codecov Report

Merging #6133 into development will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff              @@
##           development    #6133   +/-   ##
============================================
  Coverage        66.37%   66.37%           
============================================
  Files              286      286           
  Lines            14359    14359           
============================================
  Hits              9531     9531           
  Misses            4828     4828
Impacted Files Coverage Δ
app/api/helpers/order.py 40.9% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94489bb...f26c422. Read the comment docs.

@iamareebjamal
Copy link
Member

Then you should filter by user_id as well. Current approach looks brittle, it'll just select first

@mrsaicharan1
Copy link
Member Author

mrsaicharan1 commented Jul 2, 2019

Then you should filter by user_id as well. Current approach looks brittle, it'll just select first

I agree. Changing it right now.

@mrsaicharan1
Copy link
Member Author

mrsaicharan1 commented Jul 2, 2019

Then you should filter by user_id as well. Current approach looks brittle, it'll just select first

The problem is that there is no user_id field associated with OrderTicket Model. Also, we just require the quantity of the a specific ticket associated with an Order ID. So whichever entry gets filtered, the quantity would be the same.

@iamareebjamal
Copy link
Member

Let's say there are 3 OrderTicket associated with an order, meaning there are 3 tickets, then quantity of all 3 tickets can be different. Right? Even the price can be different

@mrsaicharan1
Copy link
Member Author

mrsaicharan1 commented Jul 2, 2019

Let's say there are 3 OrderTicket associated with an order, meaning there are 3 tickets, then quantity of all 3 tickets can be different. Right? Even the price can be different

Sorry for the confusion. The quantity will be different. I agree. The thing is, to represent each ticket with their quantity in a table in the order invoice, I had used OrderTicket Model. I will think of another approach.

@iamareebjamal
Copy link
Member

Then first will give wrong results, right? You need to loop over each ticket in OrderTicket relation

@mrsaicharan1
Copy link
Member Author

mrsaicharan1 commented Jul 2, 2019 via email

@mrsaicharan1 mrsaicharan1 changed the title fix: Fixed multiple tickets error fix: Fixed multiple tickets error & refactored order invoice logic Jul 2, 2019
Add try except block for other cases
@mrsaicharan1
Copy link
Member Author

mrsaicharan1 commented Jul 2, 2019

@iamareebjamal Refactored the jinja logic to match the OrderTicket loop too.

@mrsaicharan1
Copy link
Member Author

mrsaicharan1 commented Jul 2, 2019

@mrsaicharan1
Copy link
Member Author

mrsaicharan1 commented Jul 2, 2019 via email

@iamareebjamal
Copy link
Member

If there is ticket_id, there is ticket as related model

@mrsaicharan1
Copy link
Member Author

mrsaicharan1 commented Jul 2, 2019

If there is ticket_id, there is ticket as related model

@iamareebjamal Oh yeah! SQLalchmey relations. I'm updating it right now.

@iamareebjamal iamareebjamal merged commit 72ddafb into fossasia:development Jul 2, 2019
iamareebjamal pushed a commit to iamareebjamal/open-event-server that referenced this pull request Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to order multiple types of tickets at once
3 participants