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:
|
||||
amt_fmt = self.unsigned_currency_fmt
|
||||
for account, amount in amounts.items():
|
||||
amt_s = babel.numbers.format_currency(amount, template_vars['currency'], amt_fmt)
|
||||
yield ' {:45} {:>19}\n'.format(account, amt_s)
|
||||
yield ' {:45} {:>19}\n'.format(
|
||||
account.format_map(template_vars),
|
||||
babel.numbers.format_currency(amount, template_vars['currency'], amt_fmt),
|
||||
)
|
||||
|
||||
def render_next(self, template_vars):
|
||||
if template_vars is not self._last_template_vars:
|
||||
|
|
|
@ -15,8 +15,8 @@ template =
|
|||
;TransactionID: {txid}
|
||||
Accrued:Accounts Receivable {amount}
|
||||
;Entity: Supplier
|
||||
Income:Donations:Specific -.955* {amount}
|
||||
;Program: Specific
|
||||
Income:Donations:{program} -.955* {amount}
|
||||
;Program: {program}
|
||||
;Entity: {entity}
|
||||
Income:Donations:General -.045 * {amount}
|
||||
;Entity: {entity}
|
||||
|
|
|
@ -42,6 +42,7 @@ def test_currency_formatting():
|
|||
def test_complex_template():
|
||||
template_vars = {
|
||||
'entity': 'T-T',
|
||||
'program': 'Spectrum Defense',
|
||||
'txid': 'ABCDEF',
|
||||
}
|
||||
tmpl = template_from('Complex', date_fmt='%Y-%m-%d', signed_currencies=['USD'])
|
||||
|
@ -54,8 +55,8 @@ def test_complex_template():
|
|||
" ;TransactionID: ABCDEF",
|
||||
" Accrued:Accounts Receivable $125.50",
|
||||
" ;Entity: Supplier",
|
||||
" Income:Donations:Specific $-119.85",
|
||||
" ;Program: Specific",
|
||||
" Income:Donations:Spectrum Defense $-119.85",
|
||||
" ;Program: Spectrum Defense",
|
||||
" ;Entity: T-T",
|
||||
" Income:Donations:General $-5.65",
|
||||
" ;Entity: T-T",
|
||||
|
|
Loading…
Reference in a new issue