Exemple #1
0
 def _parse_account_label(self, text):
     if self.chart:
         try:
             account = self.chart[str(text)]
         except (ValueError, KeyError) as e:
             raise ParseException(text, e)
         if not account.is_substantial():
             raise ParseException(text, 'insubstantial account %r' % account.label)
         return account
     else:
         return str(text)
Exemple #2
0
 def bflines():
     for account in accounts:
         if account.is_substantial() and account.atype is not abo.account.AccountType.ProfitLoss or opts['--bring-forward']:
             if opts['--control']:
                 amount = bf.cbalance(account)
                 if amount != 0:
                     tally.balance += amount
                     yield fmt % ('', '; '.join(filter(bool, ['Brought forward', account.relative_name(common_root_account)])),
                             config.format_money(-amount) if amount < 0 else '',
                             config.format_money(amount) if amount > 0 else '',
                             config.format_money(tally.balance))
             else:
                 for e in sorted(bf.entries(), key=lambda e: (e.cdate or datetime.date.min, e.amount, e.account)):
                     if chart[e.account] is account and e.amount != 0:
                         tally.balance += e.amount
                         yield fmt % ('', '; '.join(filter(bool, ['Brought forward',
                                                                 'due ' + e.cdate.strftime(r'%-d-%b-%Y') if e.cdate else '',
                                                                 account.relative_name(common_root_account)])),
                                 config.format_money(-e.amount) if e.amount < 0 else '',
                                 config.format_money(e.amount) if e.amount > 0 else '',
                                 config.format_money(tally.balance))