patreon: Update importer for this month's change.
Literally all they did was change the title of the amount column (maybe it doesn't assume USD anymore?).
This commit is contained in:
parent
c13ddd1274
commit
6dfd89e5ec
4 changed files with 36 additions and 8 deletions
|
@ -5,7 +5,7 @@ from . import _csv
|
|||
from .. import strparse
|
||||
|
||||
class IncomeImporter(_csv.CSVImporterBase):
|
||||
AMOUNT_KEY = 'Pledge $'
|
||||
AMOUNT_KEY = 'Pledge Amount'
|
||||
DATE_KEY = 'Last Charge Date'
|
||||
STATUS_KEY = 'Last Charge Status'
|
||||
NEEDED_FIELDS = frozenset([
|
||||
|
@ -23,6 +23,13 @@ class IncomeImporter(_csv.CSVImporterBase):
|
|||
'currency': 'USD',
|
||||
}
|
||||
|
||||
def __init_subclass__(cls):
|
||||
cls.NEEDED_FIELDS = frozenset([
|
||||
cls.AMOUNT_KEY,
|
||||
cls.DATE_KEY,
|
||||
cls.STATUS_KEY,
|
||||
])
|
||||
|
||||
def _read_row(self, row):
|
||||
if row[self.STATUS_KEY] != 'Paid':
|
||||
return None
|
||||
|
@ -93,14 +100,14 @@ class VATImporter(FeeImporterBase):
|
|||
}
|
||||
|
||||
|
||||
class Income2020AugustImporter(IncomeImporter):
|
||||
|
||||
class Income2020OctoberImporter(IncomeImporter):
|
||||
AMOUNT_KEY = 'Pledge $'
|
||||
|
||||
|
||||
class Income2020AugustImporter(Income2020OctoberImporter):
|
||||
DATE_KEY = 'Charged On Date'
|
||||
STATUS_KEY = 'Charge Status'
|
||||
NEEDED_FIELDS = frozenset([
|
||||
IncomeImporter.AMOUNT_KEY,
|
||||
DATE_KEY,
|
||||
STATUS_KEY,
|
||||
])
|
||||
|
||||
|
||||
class Income2017Importer(_csv.CSVImporterBase):
|
||||
|
|
2
setup.py
2
setup.py
|
@ -30,7 +30,7 @@ REQUIREMENTS['tests_require'] = [
|
|||
setup(
|
||||
name='import2ledger',
|
||||
description="Import different sources of financial data to Ledger",
|
||||
version='1.2.0',
|
||||
version='1.3.0',
|
||||
author='Brett Smith',
|
||||
author_email='brettcsmith@brettcsmith.org',
|
||||
license='GNU AGPLv3+',
|
||||
|
|
3
tests/data/PatreonPatronReport_2020-11-01.csv
Normal file
3
tests/data/PatreonPatronReport_2020-11-01.csv
Normal file
|
@ -0,0 +1,3 @@
|
|||
Name,Email,Twitter,Discord,Patron Status,Follows You,Lifetime Amount,Pledge Amount,Charge Frequency,Tier,Addressee,Street,City,State,Zip,Country,Phone,Patronage Since Date,Max Amount,Last Charge Date,Last Charge Status,Additional Details,User ID,Last Updated
|
||||
Alex Jones,ajones@example.com,,,Active patron,No,$28,$2,monthly,Even tier,,,,,,,,2019-10-30 18:25:15.457830,$2,2020-08-01 18:21:04,Paid,,1234567,2020-08-12 12:34:31.348413
|
||||
Breonna,breonna@example.org,patreonb,patreond#0123,Active patron,No,$5,$5,monthly,Odd tier,,,,,,,,2020-08-02 11:59:15.365305,$5,2020-08-02 12:00:02,Paid,,234567,2020-08-12 12:43:08.745681
|
|
|
@ -29,6 +29,24 @@
|
|||
currency: USD
|
||||
|
||||
- source: PatreonPatronReport_2020-10-01.csv
|
||||
importer: patreon.Income2020OctoberImporter
|
||||
expect:
|
||||
- payee: Alex Jones
|
||||
email: ajones@example.com
|
||||
tier: Even tier
|
||||
patreon_id: "1234567"
|
||||
date: !!python/object/apply:datetime.date [2020, 8, 1]
|
||||
amount: !!python/object/apply:decimal.Decimal ["2"]
|
||||
currency: USD
|
||||
- payee: Breonna
|
||||
email: breonna@example.org
|
||||
tier: Odd tier
|
||||
patreon_id: "234567"
|
||||
date: !!python/object/apply:datetime.date [2020, 8, 2]
|
||||
amount: !!python/object/apply:decimal.Decimal ["5.00"]
|
||||
currency: USD
|
||||
|
||||
- source: PatreonPatronReport_2020-11-01.csv
|
||||
importer: patreon.IncomeImporter
|
||||
expect:
|
||||
- payee: Alex Jones
|
||||
|
|
Loading…
Reference in a new issue