Changeset - f56571219b87
[Not reviewed]
0 2 0
Brett Smith - 7 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
...
 
@@ -84,5 +84,5 @@ class Invoice2017:
 
        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 = {
...
 
@@ -91,7 +91,5 @@ class Invoice2017:
 
                }
 
            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.
...
 
@@ -143,9 +141 @@ class Payment2017Importer(ImporterBase):
 
        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
...
 
@@ -128,20 +128 @@
 
      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)