update GitHub Sponsors importer
This commit is contained in:
parent
ac2359101b
commit
8b0fd52602
2 changed files with 7 additions and 8 deletions
|
@ -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),
|
||||
}
|
||||
|
|
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.4.4',
|
||||
version='1.4.5',
|
||||
author='Brett Smith',
|
||||
author_email='brettcsmith@brettcsmith.org',
|
||||
license='GNU AGPLv3+',
|
||||
|
|
Loading…
Reference in a new issue