importers.patreon: Handle commas in large amounts.

This commit is contained in:
Brett Smith 2017-12-18 14:09:54 -05:00
parent a2120805ab
commit 4796932cb7
3 changed files with 6 additions and 7 deletions

View file

@ -8,11 +8,9 @@ class IncomeImporter(_csv.CSVImporterBase):
NEEDED_FIELDS = frozenset([
'FirstName',
'LastName',
'Pledge',
'Status',
])
COPIED_FIELDS = {
'Pledge': 'amount',
}
ENTRY_SEED = {
'currency': 'USD',
}
@ -30,6 +28,7 @@ class IncomeImporter(_csv.CSVImporterBase):
return None
else:
return {
'amount': row['Pledge'].replace(',', ''),
'payee': '{0[FirstName]} {0[LastName]}'.format(row),
}

View file

@ -1,6 +1,6 @@
FirstName,LastName,Email,Pledge,Lifetime,Status,Twitter,Street,City,State,Zip,Country,Start,MaxAmount,Complete
100 + Reward,Description You donate a lot of money!,,,,,,,,,,,,,
Alex,Jones,alex@example.org,150,300,Processed,,,,,,,2017-08-11 11:28:06.166065,200,0
Alex,Jones,alex@example.org,"1,500.00","3,000.00",Processed,,,,,,,2017-08-11 11:28:06.166065,"2,000.00",0
5 + Reward,Description Youre nice!,,,,,,,,,,,,,
Brett,Smith,brett@example.org,10,30,Declined,Brett20XX,,,,,,2017-08-10 13:24:15.955782,10,0
Dakota,Doe,ddoe@example.org,12,48,Processed,,,,,,,2017-08-10 12:58:31.919341,12,0
Brett,Smith,brett@example.org,10.00,30.00,Declined,Brett20XX,,,,,,2017-08-10 13:24:15.955782,10.00,0
Dakota,Doe,ddoe@example.org,12.00,48.00,Processed,,,,,,,2017-08-10 12:58:31.919341,12.00,0

1 FirstName LastName Email Pledge Lifetime Status Twitter Street City State Zip Country Start MaxAmount Complete
2 100 + Reward Description You donate a lot of money!
3 Alex Jones alex@example.org 150 1,500.00 300 3,000.00 Processed 2017-08-11 11:28:06.166065 200 2,000.00 0
4 5 + Reward Description You’re nice!
5 Brett Smith brett@example.org 10 10.00 30 30.00 Declined Brett20XX 2017-08-10 13:24:15.955782 10 10.00 0
6 Dakota Doe ddoe@example.org 12 12.00 48 48.00 Processed 2017-08-10 12:58:31.919341 12 12.00 0

View file

@ -3,7 +3,7 @@
expect:
- payee: Alex Jones
date: !!python/object/apply:datetime.date [2017, 9, 1]
amount: !!python/object/apply:decimal.Decimal ["150.00"]
amount: !!python/object/apply:decimal.Decimal ["1500.00"]
currency: USD
- payee: Dakota Doe
date: !!python/object/apply:datetime.date [2017, 9, 1]