From 6a29b66bc9e77bf1cf4e2f98ea273512c26c68d5 Mon Sep 17 00:00:00 2001 From: mrsaicharan1 Date: Sun, 2 Feb 2020 14:31:01 +0530 Subject: [PATCH] fix: Correct Invoice Calculation --- app/api/helpers/scheduled_jobs.py | 4 +--- tests/all/integration/api/helpers/test_scheduled_jobs.py | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/api/helpers/scheduled_jobs.py b/app/api/helpers/scheduled_jobs.py index e46a84e4ea..899da656b5 100644 --- a/app/api/helpers/scheduled_jobs.py +++ b/app/api/helpers/scheduled_jobs.py @@ -263,9 +263,7 @@ def send_monthly_event_invoice(): ticket_fee_maximum = ticket_fee_object.maximum_fee orders = Order.query.filter_by(event=event).all() gross_revenue = event.calc_monthly_revenue() - invoice_amount = ( - event.tickets_sold * gross_revenue * (ticket_fee_percentage / 100) - ) + invoice_amount = gross_revenue * (ticket_fee_percentage / 100) if invoice_amount > ticket_fee_maximum: invoice_amount = ticket_fee_maximum net_revenue = gross_revenue - invoice_amount diff --git a/tests/all/integration/api/helpers/test_scheduled_jobs.py b/tests/all/integration/api/helpers/test_scheduled_jobs.py index 73547fe1cf..38d2f0a5c4 100644 --- a/tests/all/integration/api/helpers/test_scheduled_jobs.py +++ b/tests/all/integration/api/helpers/test_scheduled_jobs.py @@ -87,8 +87,7 @@ def test_send_monthly_invoice(self): """Method to test monthly invoices""" with self.app.test_request_context(): - ticket_fee_test = TicketFeesFactory() - ticket_fee_test.service_fee = 10.23 + TicketFeesFactory(service_fee=10.23, maximum_fee=11) test_event = EventFactoryBasic(state='published')