From a135e71a4a310fc6984c8339aa3a298701224142 2018-09-28 12:31:24 From: Brett Smith Date: 2018-09-28 12:31:24 Subject: [PATCH] nbpy2017: Handle complimentary tickets. The conference is offering these to people who proposed talks this year. --- diff --git a/import2ledger/importers/nbpy2017.py b/import2ledger/importers/nbpy2017.py index 31927c2c28f89784d8585b0424569f916179dda8..0e5f89cd2e8df5f4398be026e7847989566fdb19 100644 --- a/import2ledger/importers/nbpy2017.py +++ b/import2ledger/importers/nbpy2017.py @@ -82,14 +82,17 @@ class Invoice2017: self.shirts_sold = decimal.Decimal(0) self.shirt_rate = self.STANDARD_SHIRT_RATE for description, qty, unit_price, total in rows_text: + if qty is None: + continue + total = strparse.currency_decimal(total) + self.amount += total if description.startswith('Ticket - '): - self.tickets_sold += 1 + if total > 0: + self.tickets_sold += 1 elif description.startswith('T-Shirt - '): self.shirts_sold += 1 elif description.startswith('Early Bird ('): self.ticket_rate = self.DISCOUNT_TICKET_RATE - if qty: - self.amount += strparse.currency_decimal(total) def _read_invoice_activity(self, table, first_row_text, rows_text): self.actions = [{ diff --git a/tests/data/imports.yml b/tests/data/imports.yml index 41dd76032f35b55833a840c547dfdf1f171770d5..f3bfc27322ab69bd7bd6e1b24c9e3e0504dca00e 100644 --- a/tests/data/imports.yml +++ b/tests/data/imports.yml @@ -238,9 +238,9 @@ - payee: Python Person C ledger template: nbpy2017 invoice ledger entry date: !!python/object/apply:datetime.date [2017, 9, 5] - amount: !!python/object/apply:decimal.Decimal ["55.00"] - tickets_sold: !!python/object/apply:decimal.Decimal ["1"] - ticket_rate: !!python/object/apply:decimal.Decimal ["21.25"] + amount: !!python/object/apply:decimal.Decimal ["30.00"] + tickets_sold: !!python/object/apply:decimal.Decimal ["0"] + ticket_rate: !!python/object/apply:decimal.Decimal ["42.50"] shirts_sold: !!python/object/apply:decimal.Decimal ["1"] shirt_rate: !!python/object/apply:decimal.Decimal ["25.50"] status: Invoice @@ -250,9 +250,9 @@ - payee: Python Person C ledger template: nbpy2017 payment ledger entry date: !!python/object/apply:datetime.date [2017, 9, 5] - amount: !!python/object/apply:decimal.Decimal ["55.00"] - tickets_sold: !!python/object/apply:decimal.Decimal ["1"] - ticket_rate: !!python/object/apply:decimal.Decimal ["21.25"] + amount: !!python/object/apply:decimal.Decimal ["30.00"] + tickets_sold: !!python/object/apply:decimal.Decimal ["0"] + ticket_rate: !!python/object/apply:decimal.Decimal ["42.50"] shirts_sold: !!python/object/apply:decimal.Decimal ["1"] shirt_rate: !!python/object/apply:decimal.Decimal ["25.50"] status: Payment diff --git a/tests/data/nbpy2017c.html b/tests/data/nbpy2017c.html index fb7ed95c8df5d5c6e3934722fc08bf53566781d4..cc61c3ab7cef2386952525f30e65f23e6a022db2 100644 --- a/tests/data/nbpy2017c.html +++ b/tests/data/nbpy2017c.html @@ -172,10 +172,10 @@ Total - Ticket - Unaffiliated Individual + Ticket - Talk Proposer 1 - $50.00 - $50.00 + $0.00 + $0.00 T-Shirt - Men's/Straight Cut Size M @@ -184,18 +184,18 @@ $30.00 - Early Bird (Ticket - Unaffiliated Individual) + Tutorials - Notify me when tutorials are open 1 - $-25.00 - $-25.00 + $-0.00 + $-0.00 TOTAL - $55.00 + $30.00 Includes donation eligible for tax deduction in the USA: - $8.25 + $4.25 @@ -210,7 +210,7 @@ Balance due: - $55.00 + $30.00 @@ -227,12 +227,12 @@ Sept. 5, 2017, 9:14 p.m. Paid with Stripe reference: ch_daer0ahwoh9oDeiqu2eimoD7 - 55.00 + 30.00 Sept. 8, 2017, 3:20 p.m. Generated credit note 31 - -55.00 + -30.00