template: Support variables in account names.
This commit is contained in:
parent
e5a0089eb9
commit
093834dd15
3 changed files with 9 additions and 6 deletions
|
@ -136,8 +136,10 @@ class AccountSplitter:
|
||||||
else:
|
else:
|
||||||
amt_fmt = self.unsigned_currency_fmt
|
amt_fmt = self.unsigned_currency_fmt
|
||||||
for account, amount in amounts.items():
|
for account, amount in amounts.items():
|
||||||
amt_s = babel.numbers.format_currency(amount, template_vars['currency'], amt_fmt)
|
yield ' {:45} {:>19}\n'.format(
|
||||||
yield ' {:45} {:>19}\n'.format(account, amt_s)
|
account.format_map(template_vars),
|
||||||
|
babel.numbers.format_currency(amount, template_vars['currency'], amt_fmt),
|
||||||
|
)
|
||||||
|
|
||||||
def render_next(self, template_vars):
|
def render_next(self, template_vars):
|
||||||
if template_vars is not self._last_template_vars:
|
if template_vars is not self._last_template_vars:
|
||||||
|
|
|
@ -15,8 +15,8 @@ template =
|
||||||
;TransactionID: {txid}
|
;TransactionID: {txid}
|
||||||
Accrued:Accounts Receivable {amount}
|
Accrued:Accounts Receivable {amount}
|
||||||
;Entity: Supplier
|
;Entity: Supplier
|
||||||
Income:Donations:Specific -.955* {amount}
|
Income:Donations:{program} -.955* {amount}
|
||||||
;Program: Specific
|
;Program: {program}
|
||||||
;Entity: {entity}
|
;Entity: {entity}
|
||||||
Income:Donations:General -.045 * {amount}
|
Income:Donations:General -.045 * {amount}
|
||||||
;Entity: {entity}
|
;Entity: {entity}
|
||||||
|
|
|
@ -42,6 +42,7 @@ def test_currency_formatting():
|
||||||
def test_complex_template():
|
def test_complex_template():
|
||||||
template_vars = {
|
template_vars = {
|
||||||
'entity': 'T-T',
|
'entity': 'T-T',
|
||||||
|
'program': 'Spectrum Defense',
|
||||||
'txid': 'ABCDEF',
|
'txid': 'ABCDEF',
|
||||||
}
|
}
|
||||||
tmpl = template_from('Complex', date_fmt='%Y-%m-%d', signed_currencies=['USD'])
|
tmpl = template_from('Complex', date_fmt='%Y-%m-%d', signed_currencies=['USD'])
|
||||||
|
@ -54,8 +55,8 @@ def test_complex_template():
|
||||||
" ;TransactionID: ABCDEF",
|
" ;TransactionID: ABCDEF",
|
||||||
" Accrued:Accounts Receivable $125.50",
|
" Accrued:Accounts Receivable $125.50",
|
||||||
" ;Entity: Supplier",
|
" ;Entity: Supplier",
|
||||||
" Income:Donations:Specific $-119.85",
|
" Income:Donations:Spectrum Defense $-119.85",
|
||||||
" ;Program: Specific",
|
" ;Program: Spectrum Defense",
|
||||||
" ;Entity: T-T",
|
" ;Entity: T-T",
|
||||||
" Income:Donations:General $-5.65",
|
" Income:Donations:General $-5.65",
|
||||||
" ;Entity: T-T",
|
" ;Entity: T-T",
|
||||||
|
|
Loading…
Reference in a new issue