patreon: Import VAT withholdings.
This commit is contained in:
parent
dd155749c3
commit
cebd1481ec
4 changed files with 57 additions and 4 deletions
11
README.rst
11
README.rst
|
@ -65,6 +65,17 @@ Patreon
|
|||
``template patreon svcfees``
|
||||
Imports one expense transaction per month for that month's Patreon service fees. Generated from Patreon's earnings report CSV.
|
||||
|
||||
``template patreon vat``
|
||||
Imports one transaction per country per month each time Patreon withheld VAT. Generated from Patreon's VAT report CSV.
|
||||
|
||||
This template can use these variables:
|
||||
|
||||
``country_name``
|
||||
The full name of the country VAT was withheld for
|
||||
|
||||
``country_code``
|
||||
The two-letter ISO country code of the country VAT was withheld for
|
||||
|
||||
Template variables
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -53,11 +53,14 @@ class IncomeImporter(ImporterBase):
|
|||
|
||||
class FeeImporterBase(ImporterBase):
|
||||
def _read_row(self, row):
|
||||
return {
|
||||
'amount': row[self.AMOUNT_FIELD].lstrip('$'),
|
||||
'date': util.strpdate(row['Month'], '%Y-%m'),
|
||||
'payee': "Patreon",
|
||||
retval = {
|
||||
key.lower().replace(' ', '_'): row[key]
|
||||
for key in self.NEEDED_FIELDS.difference([self.AMOUNT_FIELD, 'Month'])
|
||||
}
|
||||
retval['amount'] = row[self.AMOUNT_FIELD].lstrip('$')
|
||||
retval['date'] = util.strpdate(row['Month'], '%Y-%m')
|
||||
retval['payee'] = "Patreon"
|
||||
return retval
|
||||
|
||||
|
||||
class PatreonFeeImporter(FeeImporterBase):
|
||||
|
@ -70,3 +73,9 @@ class CardFeeImporter(FeeImporterBase):
|
|||
AMOUNT_FIELD = 'Processing Fees'
|
||||
NEEDED_FIELDS = frozenset(['Month', AMOUNT_FIELD])
|
||||
TEMPLATE_KEY = 'template patreon cardfees'
|
||||
|
||||
|
||||
class VATImporter(FeeImporterBase):
|
||||
AMOUNT_FIELD = 'Vat Charged'
|
||||
NEEDED_FIELDS = frozenset(['Country Code', 'Country Name', 'Month', AMOUNT_FIELD])
|
||||
TEMPLATE_KEY = 'template patreon vat'
|
||||
|
|
5
tests/data/PatreonVat.csv
Normal file
5
tests/data/PatreonVat.csv
Normal file
|
@ -0,0 +1,5 @@
|
|||
Country Code,Country Name,Month,Vat Charged
|
||||
AT,Austria,2017-09,$2
|
||||
BE,Belgium,2017-09,$3.30
|
||||
BG,Bulgaria,2017-10,$0.40
|
||||
CZ,Czech Republic,2017-10,$6.05
|
|
|
@ -33,3 +33,31 @@
|
|||
date: [2017, 10, 1]
|
||||
amount: "99.47"
|
||||
currency: USD
|
||||
|
||||
- source: PatreonVat.csv
|
||||
importer: patreon.VATImporter
|
||||
expect:
|
||||
- payee: Patreon
|
||||
date: [2017, 9, 1]
|
||||
amount: "2"
|
||||
currency: USD
|
||||
country_code: AT
|
||||
country_name: Austria
|
||||
- payee: Patreon
|
||||
date: [2017, 9, 1]
|
||||
amount: "3.30"
|
||||
currency: USD
|
||||
country_code: BE
|
||||
country_name: Belgium
|
||||
- payee: Patreon
|
||||
date: [2017, 10, 1]
|
||||
amount: "0.40"
|
||||
currency: USD
|
||||
country_code: BG
|
||||
country_name: Bulgaria
|
||||
- payee: Patreon
|
||||
date: [2017, 10, 1]
|
||||
amount: "6.05"
|
||||
currency: USD
|
||||
country_code: CZ
|
||||
country_name: Czech Republic
|
||||
|
|
Loading…
Reference in a new issue