@@ -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',
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):
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',
'Fee Comment': 'fee_comment',