From 1d333645c3f0e02bcfdbcf9bc1d860190a50ab0b Mon Sep 17 00:00:00 2001 From: Areeb Jamal Date: Fri, 27 Nov 2020 21:50:31 +0530 Subject: [PATCH] fix: Do not send invoice if amount < minimum --- app/models/event_invoice.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/models/event_invoice.py b/app/models/event_invoice.py index 1ec5b3a774..f05ac9d4e8 100644 --- a/app/models/event_invoice.py +++ b/app/models/event_invoice.py @@ -22,6 +22,7 @@ class EventInvoice(SoftDeletionModel): DUE_DATE_DAYS = 30 + MIN_AMOUNT = 2 # Minimum amount for which the invoice will be generated __tablename__ = 'event_invoices' @@ -128,6 +129,14 @@ def generate_pdf(self, force=False): self.event, ) return + if not force and self.amount < EventInvoice.MIN_AMOUNT: + logger.warning( + 'Invoice amount of Event %s is %f which is less than %f, hence skipping generation', + self.event, + self.amount, + EventInvoice.MIN_AMOUNT, + ) + return net_revenue = round_money(gross_revenue - invoice_amount) orders_query = self.event.get_orders_query( start=latest_invoice_date, end=self.issued_at