Changeset - 8326bd68d92b
[Not reviewed]
1 2 1
Brett Smith - 6 years ago 2019-02-15 16:47:27
brettcsmith@brettcsmith.org
benevity: Version the current importer.

The report format has changed slightly in 2019.
3 files changed with 11 insertions and 3 deletions:
0 comments (0 inline, 0 general)
import2ledger/importers/benevity.py
Show inline comments
 
from . import _csv
 
from .. import strparse
 

	
 
class DonationsImporter(_csv.CSVImporterBase):
 
class Donations2018Importer(_csv.CSVImporterBase):
 
    ENTRY_SEED = {
 
        'ledger template': 'benevity donations ledger entry',
 
    }
 
    HEADER_FIELDS = {
 
        'Currency': 'currency',
 
        'Disbursement ID': 'disbursement_id',
 
        'Reference': 'reference',
 
    }
 
    DATE_FIELD = 'Date of Donation'
 
    NAME_FIELDS = ['Donor First Name', 'Donor Last Name']
 
    DECIMAL_FIELDS = {
 
        'Donation Amount': 'donation_amount',
 
        'Matched Amount': 'match_amount',
 
        'Total': 'amount',
 
    }
 
    NEEDED_FIELDS = frozenset([
 
        DATE_FIELD,
 
        *NAME_FIELDS,
 
        *DECIMAL_FIELDS,
 
    ])
 
    COPIED_FIELDS = {
 
        'Participating Corporation': 'corporation',
 
        'Project': 'project',
 
        'Comment': 'comment',
 
        'Transaction ID': 'transaction_id',
 
        'Donation Frequency': 'frequency',
 
    }
 
    DATE_FMT = '%Y-%m-%d'
 
    NOT_SHARED = 'Not shared by donor'
 

	
 
    @classmethod
 
    def _read_header_row(cls, row):
 
        row_len = len(row)
 
        if row_len > 2:
 
            return None
tests/data/Benevity2018.csv
Show inline comments
 
file renamed from tests/data/Benevity.csv to tests/data/Benevity2018.csv
tests/data/imports.yml
Show inline comments
...
 
@@ -245,127 +245,132 @@
 
      shirt_rate: !!python/object/apply:decimal.Decimal ["25.50"]
 
      status: Invoice
 
      currency: USD
 
      invoice_date: !!python/object/apply:datetime.date [2017, 9, 5]
 
      invoice_id: "11"
 
    - payee: Python Person C
 
      ledger template: nbpy2017 payment ledger entry
 
      date: !!python/object/apply:datetime.date [2017, 9, 5]
 
      amount: !!python/object/apply:decimal.Decimal ["60.00"]
 
      tickets_sold: !!python/object/apply:decimal.Decimal ["0"]
 
      ticket_rate: !!python/object/apply:decimal.Decimal ["42.50"]
 
      shirts_sold: !!python/object/apply:decimal.Decimal ["2"]
 
      shirt_rate: !!python/object/apply:decimal.Decimal ["25.50"]
 
      status: Payment
 
      currency: USD
 
      invoice_date: !!python/object/apply:datetime.date [2017, 9, 5]
 
      payment_id: ch_daer0ahwoh9oDeiqu2eimoD7
 
      stripe_id: ch_daer0ahwoh9oDeiqu2eimoD7
 
      invoice_id: "11"
 

	
 
- source: AmazonAffiliateEarnings.csv
 
  importer: amazon.EarningsImporter
 
  expect:
 
    - payee: Amazon
 
      date: !!python/object/apply:datetime.date [2016, 12, 20]
 
      amount: !!python/object/apply:decimal.Decimal ["4.24"]
 
      currency: USD
 
    - payee: Amazon
 
      date: !!python/object/apply:datetime.date [2017, 1, 7]
 
      amount: !!python/object/apply:decimal.Decimal ["-.08"]
 
      currency: USD
 

	
 
- source: Benevity.csv
 
  importer: benevity.DonationsImporter
 
- source: Benevity2018.csv
 
  importer: benevity.Donations2018Importer
 
  expect:
 
    - date: !!python/object/apply:datetime.date [2017, 10, 28]
 
      currency: USD
 
      disbursement_id: ABCDE12345
 
      amount: !!python/object/apply:decimal.Decimal [20]
 
      donation_amount: !!python/object/apply:decimal.Decimal [20]
 
      match_amount: !!python/object/apply:decimal.Decimal [0]
 
      payee: Dakota Smith
 
      corporation: Company A
 
      project: ""
 
      comment: ""
 
      frequency: One-time
 
      transaction_id: 67890QWERT
 
      ledger template: benevity donations ledger entry
 
    - date: !!python/object/apply:datetime.date [2017, 10, 30]
 
      currency: USD
 
      disbursement_id: ABCDE12345
 
      amount: !!python/object/apply:decimal.Decimal [25]
 
      donation_amount: !!python/object/apply:decimal.Decimal [25]
 
      match_amount: !!python/object/apply:decimal.Decimal [0]
 
      payee: Dakota Smith
 
      corporation: Company A
 
      project: ""
 
      comment: ""
 
      frequency: One-time
 
      transaction_id: 67890WERTY
 
      ledger template: benevity donations ledger entry
 
    - date: !!python/object/apply:datetime.date [2017, 10, 19]
 
      currency: USD
 
      disbursement_id: ABCDE12345
 
      amount: !!python/object/apply:decimal.Decimal [10]
 
      donation_amount: !!python/object/apply:decimal.Decimal [0]
 
      match_amount: !!python/object/apply:decimal.Decimal [10]
 
      payee: Anonymous
 
      corporation: Company B
 
      project: ""
 
      comment: ""
 
      frequency: Unknown
 
      transaction_id: 67890ERTYU
 
      ledger template: benevity donations ledger entry
 
    - date: !!python/object/apply:datetime.date [2017, 10, 19]
 
      currency: USD
 
      disbursement_id: ABCDE12345
 
      amount: !!python/object/apply:decimal.Decimal [20]
 
      donation_amount: !!python/object/apply:decimal.Decimal [0]
 
      match_amount: !!python/object/apply:decimal.Decimal [20]
 
      payee: Anonymous
 
      corporation: Company B
 
      project: ""
 
      comment: ""
 
      frequency: Unknown
 
      transaction_id: 67890RTYUI
 
      ledger template: benevity donations ledger entry
 
    - date: !!python/object/apply:datetime.date [2017, 10, 19]
 
      currency: USD
 
      disbursement_id: ABCDE12345
 
      amount: !!python/object/apply:decimal.Decimal [30]
 
      donation_amount: !!python/object/apply:decimal.Decimal [30]
 
      match_amount: !!python/object/apply:decimal.Decimal [0]
 
      payee: Anonymous
 
      corporation: Company B
 
      project: ""
 
      comment: ""
 
      frequency: Recurring
 
      transaction_id: 67890TYUIO
 
      ledger template: benevity donations ledger entry
 

	
 
- source: BrightFunds.xls
 
  importer: brightfunds.DonorReportImporter
 
  expect:
 
    - date: !!python/object/apply:datetime.date [2017, 10, 20]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal [120]
 
      payee: Dakota Smith
 
      corporation: Company
 
      company_name: ""
 
      designation: ""
 
      donor_name: Company
 
      donor_email: ""
 
      fund: ""
 
      on_behalf_of: Dakota Smith
 
      type: Matched Donation
 

	
 
- source: OReillyRoyalties.csv
 
  importer: oreilly.RoyaltiesImporter
 
  expect:
 
    - date: !!python/object/apply:datetime.date [2018, 3, 31]
 
      start_date: !!python/object/apply:datetime.date [2018, 3, 1]
 
      paid_date: null
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["11.96"]
 
      payee: "O'Reilly Media, Inc."
 
    - date: !!python/object/apply:datetime.date [2018, 2, 28]
 
      start_date: !!python/object/apply:datetime.date [2018, 2, 1]
 
      paid_date: !!python/object/apply:datetime.date [2018, 3, 29]
 
      currency: USD
 
      amount: !!python/object/apply:decimal.Decimal ["20.83"]
 
      payee: "O'Reilly Media, Inc."
0 comments (0 inline, 0 general)