diff --git a/import2ledger/importers/benevity.py b/import2ledger/importers/benevity.py index b1cf0088756ef9339e5c6c52796e9f844fe1ff5a..7891c1f66ee4b327438717793599a952e3aa6157 100644 --- a/import2ledger/importers/benevity.py +++ b/import2ledger/importers/benevity.py @@ -34,6 +34,9 @@ class _DonationsImporterBase(_csv.CSVImporterBase): retval.update((retkey, strparse.currency_decimal(row[rowkey])) for rowkey, retkey in self.DECIMAL_FIELDS.items()) retval['amount'] = retval['donation_amount'] + retval['match_amount'] + retval.setdefault('net_amount', retval['amount'] - sum( + fee for key, fee in retval.items() if key.endswith('_fee') + )) return retval @@ -43,6 +46,7 @@ class Donations2018Importer(_DonationsImporterBase): 'donation_fee': ZERO_DECIMAL, 'match_fee': ZERO_DECIMAL, 'merchant_fee': ZERO_DECIMAL, + 'fee_comment': None, } DATE_FIELD = 'Date of Donation' DATE_FMT = '%Y-%m-%d' @@ -72,6 +76,7 @@ class Donations2018Importer(_DonationsImporterBase): class Donations2019Importer(_DonationsImporterBase): ENTRY_SEED = { 'ledger template': 'benevity donations ledger entry', + 'fee_comment': None, } DATE_FIELD = 'Donation Date' DATE_FMT = '%Y-%m-%dT%H:%M:%SZ' @@ -99,3 +104,35 @@ class Donations2019Importer(_DonationsImporterBase): 'Transaction ID': 'transaction_id', 'Donation Frequency': 'frequency', } + + +class Donations2020Importer(_DonationsImporterBase): + ENTRY_SEED = { + 'ledger template': 'benevity donations ledger entry', + 'match_fee': ZERO_DECIMAL, + } + DATE_FIELD = 'Donation Date' + DATE_FMT = '%Y-%m-%dT%H:%M:%SZ' + HEADER_FIELDS = { + 'Disbursement ID': 'disbursement_id', + } + DECIMAL_FIELDS = { + 'Total Donation to be Acknowledged': 'donation_amount', + 'Cause Support Fee': 'donation_fee', + 'Match Amount': 'match_amount', + 'Merchant Fee': 'merchant_fee', + } + NEEDED_FIELDS = frozenset([ + DATE_FIELD, + *_DonationsImporterBase.NAME_FIELDS, + *DECIMAL_FIELDS, + ]) + COPIED_FIELDS = { + 'Company': 'corporation', + 'Currency': 'currency', + 'Project': 'project', + 'Comment': 'comment', + 'Transaction ID': 'transaction_id', + 'Donation Frequency': 'frequency', + 'Fee Comment': 'fee_comment', + }