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

feat: Implementation of event invoice generation & calculation #6121

Merged
merged 2 commits into from
Jul 8, 2019

Conversation

mrsaicharan1
Copy link
Member

@mrsaicharan1 mrsaicharan1 commented Jun 28, 2019

Fixes #6120
Fixes #6124

Short description of what this resolves:

This implements a module for event invoice where the monthly gross amount & net amount are calculated and sent to every organizer on the 1st of every month.

Changes proposed in this pull request:

  • Provides helper functions to show invoices on organizer dashboard
  • Calculates event invoice
  • Schedules event invoice generation job for every 1st of the month.

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 feature label Jun 28, 2019
app/api/helpers/event_invoices.py Outdated Show resolved Hide resolved
app/api/helpers/event_invoices.py Outdated Show resolved Hide resolved
app/api/helpers/event_invoices.py Outdated Show resolved Hide resolved
app/api/helpers/event_invoices.py Outdated Show resolved Hide resolved
app/api/helpers/event_invoices.py Outdated Show resolved Hide resolved
@mrsaicharan1 mrsaicharan1 force-pushed the event-invoice-fix branch 2 times, most recently from b1ddf94 to e0fc90c Compare June 28, 2019 06:52
@codecov
Copy link

codecov bot commented Jun 28, 2019

Codecov Report

Merging #6121 into development will decrease coverage by 0.08%.
The diff coverage is 24.13%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #6121      +/-   ##
===============================================
- Coverage        66.41%   66.32%   -0.09%     
===============================================
  Files              286      286              
  Lines            14380    14408      +28     
===============================================
+ Hits              9550     9556       +6     
- Misses            4830     4852      +22
Impacted Files Coverage Δ
app/api/helpers/storage.py 59.29% <ø> (ø) ⬆️
app/__init__.py 87% <100%> (+0.07%) ⬆️
app/models/event.py 79.25% <16.66%> (-1.43%) ⬇️
app/api/helpers/scheduled_jobs.py 21.66% <22.72%> (-0.56%) ⬇️

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 50a615f...97f4db9. Read the comment docs.

@mrsaicharan1
Copy link
Member Author

@uds5501 @shreyanshdwivedi Please have a look

@iamareebjamal
Copy link
Member

Implement completely, you have just added helpers

@mrsaicharan1
Copy link
Member Author

mrsaicharan1 commented Jun 28, 2019 via email

@mrsaicharan1
Copy link
Member Author

@iamareebjamal Is it okay if I implement the invoice generation in a follow up PR?

@iamareebjamal
Copy link
Member

I don't recommend breaking up same feature into multiple PRs. 1 commit = 1 complete feature

@mrsaicharan1
Copy link
Member Author

mrsaicharan1 commented Jun 29, 2019 via email

@mrsaicharan1 mrsaicharan1 changed the title feat: Implemented helper functions for invoice dashboard feat: Implementation of invoice generation & calculation Jun 30, 2019
@mrsaicharan1 mrsaicharan1 changed the title feat: Implementation of invoice generation & calculation [WIP]feat: Implementation of invoice generation & calculation Jun 30, 2019
@auto-label auto-label bot removed the feature label Jun 30, 2019
app/api/helpers/scheduled_jobs.py Outdated Show resolved Hide resolved
app/api/helpers/scheduled_jobs.py Outdated Show resolved Hide resolved
ticket_fee_object = db.session.query(TicketFee).filter_by(currency=currency).one()
ticket_fee_percentage = ticket_fee_object.service_fee
ticket_fee_maximum = ticket_fee_object.maximum_fee
orders = Order.query.filter_by(event=event).all()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local variable 'orders' is assigned to but never used

currency = event.payment_currency
ticket_fee_object = db.session.query(TicketFee).filter_by(currency=currency).one()
ticket_fee_percentage = ticket_fee_object.service_fee
ticket_fee_maximum = ticket_fee_object.maximum_fee

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local variable 'ticket_fee_maximum' is assigned to but never used

for event in events:
currency = event.payment_currency
ticket_fee_object = db.session.query(TicketFee).filter_by(currency=currency).one()
ticket_fee_percentage = ticket_fee_object.service_fee

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local variable 'ticket_fee_percentage' is assigned to but never used

app/api/helpers/scheduled_jobs.py Outdated Show resolved Hide resolved
app/api/helpers/scheduled_jobs.py Outdated Show resolved Hide resolved
app/api/helpers/scheduled_jobs.py Outdated Show resolved Hide resolved
ticket_fees = event.tickets_sold * ticket_fee_percentage
if ticket_fees > ticket_fee_maximum:
ticket_fees = ticket_fee_maximum
net_revenue = gross_revenue - ticket_fees

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local variable 'net_revenue' is assigned to but never used

from app.models.ticket import Ticket
from app.models.ticket_fee import get_fee
from app.models.ticket_fee import TicketFees, get_fee

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redefinition of unused 'TicketFees' from line 19

@fossasia fossasia deleted a comment Jun 30, 2019
@fossasia fossasia deleted a comment Jun 30, 2019
@fossasia fossasia deleted a comment Jun 30, 2019
@fossasia fossasia deleted a comment Jun 30, 2019
@fossasia fossasia deleted a comment Jun 30, 2019
@fossasia fossasia deleted a comment Jun 30, 2019
@fossasia fossasia deleted a comment Jun 30, 2019
@iamareebjamal
Copy link
Member

Solve codacy issues

@@ -82,6 +82,7 @@
'ticket_attendee': 'attendees/tickets/pdf/{identifier}',
'order': 'orders/invoices/pdf/{identifier}',
'tickets_all': 'orders/tickets/pdf/{identifier}'
'event_invoice': 'events/organizer/invoices/pdf/{identifier}'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SyntaxError: invalid syntax

app/api/helpers/scheduled_jobs.py Outdated Show resolved Hide resolved
app/api/helpers/scheduled_jobs.py Outdated Show resolved Hide resolved
@fossasia fossasia deleted a comment Jul 1, 2019
app/api/helpers/scheduled_jobs.py Outdated Show resolved Hide resolved
app/api/helpers/scheduled_jobs.py Outdated Show resolved Hide resolved
app/api/helpers/scheduled_jobs.py Outdated Show resolved Hide resolved
app/api/helpers/scheduled_jobs.py Outdated Show resolved Hide resolved
from app.models.ticket import Ticket
from app.models.ticket_fee import get_fee
from app.models.ticket_fee import TicketFees, get_fee

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redefinition of unused 'TicketFees' from line 22

@fossasia fossasia deleted a comment Jul 1, 2019
@fossasia fossasia deleted a comment Jul 1, 2019
@mrsaicharan1 mrsaicharan1 force-pushed the event-invoice-fix branch 2 times, most recently from c1ab04c to 7e8e4cf Compare July 1, 2019 06:13
app/__init__.py Outdated Show resolved Hide resolved
@mrsaicharan1 mrsaicharan1 changed the title [WIP]feat: Implementation of invoice generation & calculation feat: Implementation of invoice generation & calculation Jul 1, 2019
@auto-label auto-label bot added the feature label Jul 1, 2019
@fossasia fossasia deleted a comment Jul 1, 2019
@mrsaicharan1
Copy link
Member Author

mrsaicharan1 commented Jul 2, 2019

@iamareebjamal @shreyanshdwivedi @uds5501 Please have a look. If this is fine, will continue to implement further sub-issues linked to this.

@mrsaicharan1 mrsaicharan1 changed the title feat: Implementation of invoice generation & calculation feat: Implementation of event invoice generation & calculation Jul 2, 2019
@mrsaicharan1
Copy link
Member Author

I think I need modify the query such that the ticket sales which are queried should Only be restricted to that particular month, for a monthly cycle

app/models/event.py Outdated Show resolved Hide resolved
app/models/event.py Outdated Show resolved Hide resolved
app/models/event.py Outdated Show resolved Hide resolved
app/models/event.py Show resolved Hide resolved
app/models/event.py Outdated Show resolved Hide resolved
app/models/event.py Outdated Show resolved Hide resolved
@mrsaicharan1 mrsaicharan1 force-pushed the event-invoice-fix branch 2 times, most recently from 7796e9f to 3b1c24b Compare July 2, 2019 08:17
app/models/event.py Outdated Show resolved Hide resolved
app/models/event.py Outdated Show resolved Hide resolved
@mrsaicharan1 mrsaicharan1 force-pushed the event-invoice-fix branch 2 times, most recently from 2dece3b to d999881 Compare July 2, 2019 08:21
Implemented function for event invoice calculation

Added net_revenue & gross_revenue

added logic for pdf and saved to DB

Scheduled job on 1st of every month

Hound & codacy

Changed to monthly revenue
@mrsaicharan1
Copy link
Member Author

mrsaicharan1 commented Jul 8, 2019

@CosmicCoder96 @iamareebjamal @uds5501 @shreyanshdwivedi Please have a look as this is a requirement for #6145 to move forward.

@iamareebjamal
Copy link
Member

Fixes #abc, #xyz

doesnt work in GitHub. Separate issues in separate lines

@iamareebjamal iamareebjamal merged commit 28f9fb8 into fossasia:development Jul 8, 2019
iamareebjamal pushed a commit to iamareebjamal/open-event-server that referenced this pull request Aug 2, 2019
…sia#6121)

Implemented function for event invoice calculation

Added net_revenue & gross_revenue

added logic for pdf and saved to DB

Scheduled job on 1st of every month

Hound & codacy

Changed to monthly revenue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants