update GitHub Sponsors importer

This commit is contained in:
Rosanne DiMesio 2021-10-25 11:29:41 -05:00
parent ac2359101b
commit 8b0fd52602
2 changed files with 7 additions and 8 deletions

View file

@ -6,15 +6,14 @@ from .. import strparse
class SponsorsImporter(_csv.CSVImporterBase):
DATE_FMT = '%Y-%m-%d %H:%M:%S %z'
NEEDED_FIELDS = frozenset([
'processed amount',
'status',
'transaction date',
'transferred amount',
'transaction timestamp',
])
COPIED_FIELDS = {
'sponsor handle': 'handle',
# 'sponsor profile name': 'name',
'sponsor email': 'email',
'transaction id': 'transaction_id',
'stripe transfer id': 'transaction_id',
}
ENTRY_SEED = {'currency': 'USD'}
PAYEE_MAP = {
@ -22,12 +21,12 @@ class SponsorsImporter(_csv.CSVImporterBase):
}
def _read_row(self, row):
amount = strparse.currency_decimal(row['processed amount'])
if (not amount) or row['status'] != 'settled':
amount = strparse.currency_decimal(row['transferred amount'])
if (not amount):
return None
payee = row.get('sponsor profile name') or row['sponsor handle']
return {
'amount': amount,
'date': strparse.date(row['transaction date'], self.DATE_FMT),
'date': strparse.date(row['transaction timestamp'], self.DATE_FMT),
'payee': self.PAYEE_MAP.get(payee, payee),
}

View file

@ -30,7 +30,7 @@ REQUIREMENTS['tests_require'] = [
setup(
name='import2ledger',
description="Import different sources of financial data to Ledger",
version='1.4.4',
version='1.4.5',
author='Brett Smith',
author_email='brettcsmith@brettcsmith.org',
license='GNU AGPLv3+',