patreon: Exclude tax from full amount.
This makes the balancing logic in entry generation work the way we want.
This commit is contained in:
parent
c1d1e17afb
commit
742fccca0c
4 changed files with 17 additions and 6 deletions
|
@ -5,6 +5,7 @@ import functools
|
|||
import io
|
||||
import logging
|
||||
import operator
|
||||
import pprint
|
||||
import re
|
||||
import tokenize
|
||||
|
||||
|
@ -192,8 +193,18 @@ class AccountSplitter:
|
|||
"template {!r}".format(self.template_name)
|
||||
) from error
|
||||
if sum(amt for _, amt in amounts) != 0:
|
||||
self._balance_amounts(amounts, template_vars['amount'])
|
||||
self._balance_amounts(amounts, -template_vars['amount'])
|
||||
try:
|
||||
self._balance_amounts(amounts, template_vars['amount'])
|
||||
self._balance_amounts(amounts, -template_vars['amount'])
|
||||
except errors.UserInputConfigurationError as error:
|
||||
printer = pprint.PrettyPrinter()
|
||||
logger.debug(
|
||||
"%s\n%s\n%s",
|
||||
error.args[0],
|
||||
printer.pformat(amounts),
|
||||
printer.pformat(dict(template_vars)),
|
||||
)
|
||||
raise
|
||||
return amounts
|
||||
|
||||
def _iter_splits(self, template_vars):
|
||||
|
|
|
@ -31,7 +31,7 @@ class EarningsImporter(_csv.CSVImporterBase):
|
|||
ret_key: strparse.currency_decimal(row[src_key] or 0)
|
||||
for src_key, ret_key in self.AMOUNT_FIELDS.items()
|
||||
}
|
||||
retval['amount'] = sum(retval.values())
|
||||
retval['amount'] = sum(retval.values()) - retval['tax_amount']
|
||||
retval['date'] = strparse.date(row[self.DATE_KEY], self.DATE_FMT)
|
||||
return retval
|
||||
|
||||
|
|
2
setup.py
2
setup.py
|
@ -30,7 +30,7 @@ REQUIREMENTS['tests_require'] = [
|
|||
setup(
|
||||
name='import2ledger',
|
||||
description="Import different sources of financial data to Ledger",
|
||||
version='1.4.0',
|
||||
version='1.4.1',
|
||||
author='Brett Smith',
|
||||
author_email='brettcsmith@brettcsmith.org',
|
||||
license='GNU AGPLv3+',
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
event_id: "30123456"
|
||||
date: !!python/object/apply:datetime.date [2020, 12, 3]
|
||||
currency: USD
|
||||
amount: !!python/object/apply:decimal.Decimal ["6"]
|
||||
amount: !!python/object/apply:decimal.Decimal ["5"]
|
||||
tax_amount: !!python/object/apply:decimal.Decimal ["1"]
|
||||
net_amount: !!python/object/apply:decimal.Decimal ["4.31"]
|
||||
platform_fee: !!python/object/apply:decimal.Decimal ["0.25"]
|
||||
|
@ -97,7 +97,7 @@
|
|||
event_id: "34567890"
|
||||
date: !!python/object/apply:datetime.date [2020, 12, 2]
|
||||
currency: USD
|
||||
amount: !!python/object/apply:decimal.Decimal ["7.33"]
|
||||
amount: !!python/object/apply:decimal.Decimal ["6.06"]
|
||||
tax_amount: !!python/object/apply:decimal.Decimal ["1.27"]
|
||||
net_amount: !!python/object/apply:decimal.Decimal ["5.14"]
|
||||
platform_fee: !!python/object/apply:decimal.Decimal ["0.31"]
|
||||
|
|
Loading…
Reference in a new issue