Changeset - c714b2f41fd2
[Not reviewed]
0 3 0
Brett Smith - 3 years ago 2021-03-18 15:47:56
brettcsmith@brettcsmith.org
patreon: Income2017Importer grabs email address.
3 files changed with 4 insertions and 1 deletions:
0 comments (0 inline, 0 general)
import2ledger/importers/patreon.py
Show inline comments
...
 
@@ -141,24 +141,25 @@ class Income2020AugustImporter(Income2020OctoberImporter):
 
    DATE_KEY = 'Charged On Date'
 
    STATUS_KEY = 'Charge Status'
 

	
 

	
 
class Income2017Importer(_csv.CSVImporterBase):
 
    NEEDED_FIELDS = frozenset([
 
        'FirstName',
 
        'LastName',
 
        'Pledge',
 
        'Status',
 
    ])
 
    COPIED_FIELDS = {
 
        'Email': 'email',
 
        'Pledge': 'amount',
 
    }
 
    ENTRY_SEED = {
 
        'currency': 'USD',
 
    }
 

	
 
    def __init__(self, input_file):
 
        super().__init__(input_file)
 
        match = re.search(r'(?:\b|_)(\d{4}-\d{2}-\d{2})(?:\b|_)',
 
                          pathlib.Path(input_file.name).name)
 
        if match:
 
            self.entry_seed['date'] = strparse.date(match.group(1), '%Y-%m-%d')
setup.py
Show inline comments
...
 
@@ -21,24 +21,24 @@ all_extras_require = [
 
]
 

	
 
REQUIREMENTS['extras_require']['all_importers'] = all_extras_require
 
REQUIREMENTS['tests_require'] = [
 
    'pytest',
 
    'PyYAML',
 
    *all_extras_require,
 
]
 

	
 
setup(
 
    name='import2ledger',
 
    description="Import different sources of financial data to Ledger",
 
    version='1.4.2',
 
    version='1.4.3',
 
    author='Brett Smith',
 
    author_email='brettcsmith@brettcsmith.org',
 
    license='GNU AGPLv3+',
 

	
 
    packages=find_packages(include=['import2ledger', 'import2ledger.*']),
 
    entry_points={
 
        'console_scripts': ['import2ledger = import2ledger.__main__:main'],
 
    },
 

	
 
    **REQUIREMENTS,
 
)
tests/data/imports.yml
Show inline comments
 
- source: PatreonPatronReport_2017-09-01.csv
 
  importer: patreon.Income2017Importer
 
  expect:
 
    - payee: Alex Jones
 
      date: !!python/object/apply:datetime.date [2017, 9, 1]
 
      amount: !!python/object/apply:decimal.Decimal ["1500.00"]
 
      currency: USD
 
      email: alex@example.org
 
    - payee: Dakota Doe
 
      date: !!python/object/apply:datetime.date [2017, 9, 1]
 
      amount: !!python/object/apply:decimal.Decimal ["12.00"]
 
      currency: USD
 
      email: ddoe@example.org
 

	
 
- source: PatreonPatronReport_2020-08-01.csv
 
  importer: patreon.Income2020AugustImporter
 
  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
0 comments (0 inline, 0 general)