github: Update to match fiscal host reporting.

In general the fiscal host reporting isn't as nice as the project reporting,
so I hope someday we can revert this change, but until then that's what
we're using.
This commit is contained in:
Brett Smith 2020-10-05 13:40:29 -04:00
parent 4bdea41c3f
commit fcd14f3c44
4 changed files with 22 additions and 33 deletions

View file

@ -232,23 +232,19 @@ GitHub
^^^^^^
``github sponsors ledger entry``
Imports one transaction per processed sponsorship. Generated from CSV export of GitHub Sponsors report.
Imports one transaction per processed sponsorship. Generated from CSV export of GitHub Sponsors report for fiscal hosts (NOTE: Not the project reports!)
This template can use these variables. Note that name and email may both be empty if the sponsor chooses not to make that information public.
================ ===========================================================
Name Contents
================ ===========================================================
email From the ``Sponsor Public Email`` column
email From the ``sponsor email`` column
---------------- -----------------------------------------------------------
handle From the ``Sponsor Handle`` column, their username on
handle From the ``sponsor handle`` column, their username on
GitHub
---------------- -----------------------------------------------------------
name From the ``Sponsor Public Name`` column
---------------- -----------------------------------------------------------
start_date A date, from the ``Sponsorship Started On`` column
---------------- -----------------------------------------------------------
transaction_id From the ``Transaction ID`` column
transaction_id From the ``transaction id`` column
================ ===========================================================
O'Reilly Media

View file

@ -6,25 +6,24 @@ from .. import strparse
class SponsorsImporter(_csv.CSVImporterBase):
DATE_FMT = '%Y-%m-%d %H:%M:%S %z'
NEEDED_FIELDS = frozenset([
'Processed Amount',
'Status',
'Transaction Date',
'processed amount',
'status',
'transaction date',
])
COPIED_FIELDS = {
'Sponsor Handle': 'handle',
'Sponsor Profile Name': 'name',
'Sponsor Public Email': 'email',
'Transaction ID': 'transaction_id',
'sponsor handle': 'handle',
# 'sponsor profile name': 'name',
'sponsor email': 'email',
'transaction id': 'transaction_id',
}
ENTRY_SEED = {'currency': 'USD'}
def _read_row(self, row):
amount = strparse.currency_decimal(row['Processed Amount'])
if (not amount) or row['Status'] != 'settled':
amount = strparse.currency_decimal(row['processed amount'])
if (not amount) or row['status'] != 'settled':
return None
return {
'amount': amount,
'date': strparse.date(row['Transaction Date'], self.DATE_FMT),
'payee': row['Sponsor Profile Name'] or row['Sponsor Handle'],
'start_date': strparse.date(row['Sponsorship Started On'], self.DATE_FMT),
'date': strparse.date(row['transaction date'], self.DATE_FMT),
'payee': row.get('sponsor profile name') or row['sponsor handle'],
}

View file

@ -1,5 +1,5 @@
Sponsor Handle,Sponsor Profile Name,Sponsor Public Email,Sponsorship Started On,Is Public?,Is Yearly?,Transaction ID,Tier Name,Tier Monthly Amount,Processed Amount,Is Prorated?,Status,Transaction Date
exampleA,Alex Jones,ajones@example.com,2019-10-01 10:00:00 -0400,TRUE,FALSE,ch_1Gabcdefghijklmnopqrstuv,$1/month,$1.00,$1.00,FALSE,settled,2020-01-02 14:02:00 -0500
exampleB,,,2019-11-01 11:00:00 -0400,FALSE,FALSE,1023ABCD5678EFGHI,$10/month,$10.00,$10.00,FALSE,settled,2020-01-03 15:03:00 -0500
exampleC,Example Co,info@example.com,2019-12-01 12:00:00 -0500,TRUE,TRUE,ch_1Gabcdefghijklmnopqrstuw,$10/month,$10.00,$120.00,FALSE,settled,2020-01-04 16:04:00 -0500
exampleD,Declined Smith,dsmith@example.com,2020-01-01 01:00:00 -0500,TRUE,FALSE,1023ABCD5678EFGHJ,$1/month,$1.00,$1.00,FALSE,processor_declined,2020-01-05 17:05:00 -0500
sponsor handle,sponsor email,sponsorship started on,is public?,is yearly?,transaction id,tier name,tier monthly amount,processed amount,is prorated?,status,transaction date
exampleA,ajones@example.com,2019-10-01 10:00:00 -0400,TRUE,FALSE,ch_1Gabcdefghijklmnopqrstuv,$1/month,$1.00,$1.00,FALSE,settled,2020-01-02 14:02:00 -0500
exampleB,,2019-11-01 11:00:00 -0400,FALSE,FALSE,1023ABCD5678EFGHI,$10/month,$10.00,$10.00,FALSE,settled,2020-01-03 15:03:00 -0500
exampleC,info@example.com,2019-12-01 12:00:00 -0500,TRUE,TRUE,ch_1Gabcdefghijklmnopqrstuw,$10/month,$10.00,$120.00,FALSE,settled,2020-01-04 16:04:00 -0500
exampleD,dsmith@example.com,2020-01-01 01:00:00 -0500,TRUE,FALSE,1023ABCD5678EFGHJ,$1/month,$1.00,$1.00,FALSE,processor_declined,2020-01-05 17:05:00 -0500

1 Sponsor Handle sponsor handle Sponsor Profile Name sponsor email Sponsor Public Email sponsorship started on Sponsorship Started On is public? Is Public? is yearly? Is Yearly? transaction id Transaction ID tier name Tier Name tier monthly amount Tier Monthly Amount processed amount Processed Amount is prorated? Is Prorated? status Status transaction date Transaction Date
2 exampleA exampleA Alex Jones ajones@example.com ajones@example.com 2019-10-01 10:00:00 -0400 2019-10-01 10:00:00 -0400 TRUE TRUE FALSE FALSE ch_1Gabcdefghijklmnopqrstuv ch_1Gabcdefghijklmnopqrstuv $1/month $1/month $1.00 $1.00 $1.00 $1.00 FALSE FALSE settled settled 2020-01-02 14:02:00 -0500 2020-01-02 14:02:00 -0500
3 exampleB exampleB 2019-11-01 11:00:00 -0400 2019-11-01 11:00:00 -0400 FALSE FALSE FALSE FALSE 1023ABCD5678EFGHI 1023ABCD5678EFGHI $10/month $10/month $10.00 $10.00 $10.00 $10.00 FALSE FALSE settled settled 2020-01-03 15:03:00 -0500 2020-01-03 15:03:00 -0500
4 exampleC exampleC Example Co info@example.com info@example.com 2019-12-01 12:00:00 -0500 2019-12-01 12:00:00 -0500 TRUE TRUE TRUE TRUE ch_1Gabcdefghijklmnopqrstuw ch_1Gabcdefghijklmnopqrstuw $10/month $10/month $10.00 $10.00 $120.00 $120.00 FALSE FALSE settled settled 2020-01-04 16:04:00 -0500 2020-01-04 16:04:00 -0500
5 exampleD exampleD Declined Smith dsmith@example.com dsmith@example.com 2020-01-01 01:00:00 -0500 2020-01-01 01:00:00 -0500 TRUE TRUE FALSE FALSE 1023ABCD5678EFGHJ 1023ABCD5678EFGHJ $1/month $1/month $1.00 $1.00 $1.00 $1.00 FALSE FALSE processor_declined processor_declined 2020-01-05 17:05:00 -0500 2020-01-05 17:05:00 -0500

View file

@ -927,29 +927,23 @@
importer: github.SponsorsImporter
expect:
- date: !!python/object/apply:datetime.date [2020, 1, 2]
payee: Alex Jones
payee: exampleA
handle: exampleA
name: Alex Jones
email: ajones@example.com
start_date: !!python/object/apply:datetime.date [2019, 10, 1]
transaction_id: ch_1Gabcdefghijklmnopqrstuv
amount: !!python/object/apply:decimal.Decimal ["1"]
currency: USD
- date: !!python/object/apply:datetime.date [2020, 1, 3]
payee: exampleB
handle: exampleB
name: ""
email: ""
start_date: !!python/object/apply:datetime.date [2019, 11, 1]
transaction_id: 1023ABCD5678EFGHI
amount: !!python/object/apply:decimal.Decimal ["10"]
currency: USD
- date: !!python/object/apply:datetime.date [2020, 1, 4]
payee: Example Co
payee: exampleC
handle: exampleC
name: Example Co
email: info@example.com
start_date: !!python/object/apply:datetime.date [2019, 12, 1]
transaction_id: ch_1Gabcdefghijklmnopqrstuw
amount: !!python/object/apply:decimal.Decimal ["120"]
currency: USD