From f56571219b87fa799be46cd9b0e08bdeb2ccdb47 2017-12-18 14:21:31 From: Brett Smith Date: 2017-12-18 14:21:31 Subject: [PATCH] importers.nbpy2017: Don't deal with refunds. Only one refund was actually issued, so we can deal with that manually. But the code did its job of revealing those cases and checking we were handling them well. --- diff --git a/import2ledger/importers/nbpy2017.py b/import2ledger/importers/nbpy2017.py index da969594a28eb970ae9e7883287dd7a3881313bd..993c8b962ce959418583681c7ca0a26d1be255d0 100644 --- a/import2ledger/importers/nbpy2017.py +++ b/import2ledger/importers/nbpy2017.py @@ -82,18 +82,16 @@ class Invoice2017: def _read_invoice_activity(self, table, first_row_text, rows_text): self.actions = [] date_wordcount = self.DATE_FMT.count(' ') + 1 - for timestamp, action, amount in rows_text: - if action.startswith('Paid '): - last_stripe_id = action.rsplit(None, 1)[1] + for timestamp, description, amount in rows_text: + if description.startswith('Paid '): + last_stripe_id = description.rsplit(None, 1)[1] action = { 'multiplier': 1, 'payment_id': last_stripe_id, } - elif action.startswith('Generated credit note '): - action = { - 'multiplier': -1, - 'payment_id': action.rsplit(None, 1)[1], - } + else: + # Refund handling could go here, if we need it. + continue # Trim extraneous text like the time/a.m./p.m. date_words = timestamp.split(' ', date_wordcount + 1)[:date_wordcount] action['date'] = util.strpdate(' '.join(date_words), self.DATE_FMT) @@ -141,11 +139,3 @@ class Payment2017Importer(ImporterBase): def _should_yield_entry(self, entry): return entry['amount'] > 0 - - -class Refund2017Importer(ImporterBase): - TEMPLATE_KEY = 'template nbpy2017 refund' - INVOICE_CLASS = Invoice2017 - - def _should_yield_entry(self, entry): - return entry['amount'] < 0 diff --git a/tests/data/imports.yml b/tests/data/imports.yml index 21d53d9c48ed8f084df041d21bee88ae4714cb2b..d33e00928e2754a2472838d89c35d23830cb65f5 100644 --- a/tests/data/imports.yml +++ b/tests/data/imports.yml @@ -126,22 +126,3 @@ payment_id: ch_daer0ahwoh9oDeiqu2eimoD7 stripe_id: ch_daer0ahwoh9oDeiqu2eimoD7 invoice_id: "11" - -- source: nbpy2017a.html - importer: nbpy2017.Refund2017Importer - expect: [] - -- source: nbpy2017c.html - importer: nbpy2017.Refund2017Importer - expect: - - payee: Python Person C - date: [2017, 10, 8] - amount: "-55.00" - tickets_sold: "-1.0" - ticket_rate: "21.25" - shirts_sold: "-1.0" - shirt_rate: "25.50" - currency: USD - payment_id: "31" - stripe_id: ch_daer0ahwoh9oDeiqu2eimoD7 - invoice_id: "11"