Changeset - f56571219b87
[Not reviewed]
0 2 0
Brett Smith - 6 years ago 2017-12-18 14:21:31
brettcsmith@brettcsmith.org
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.
2 files changed with 6 insertions and 35 deletions:
0 comments (0 inline, 0 general)
import2ledger/importers/nbpy2017.py
Show inline comments
...
 
@@ -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
tests/data/imports.yml
Show inline comments
...
 
@@ -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"
0 comments (0 inline, 0 general)