File diff ef12c232ada2 → 8abbe3462fda
accounting/storage/ledgercli.py
Show inline comments
...
 
@@ -164,24 +164,36 @@ class Ledger(Storage):
 
            postings=''.join([posting_template.format(
 
                p=p,
 
                account=p.account + ' ' * (
 
                    80 - (len(p.account) + len(p.amount.symbol) +
 
                          len(str(p.amount.amount)) + 1 + 2)
 
                )) for p in transaction.postings
 
            ])
 
        ).encode('utf8')
 

	
 
        with open(self.ledger_file, 'ab') as f:
 
            f.write(output)
 

	
 
        # Check to see that no errors were introduced
 
        try:
 
            self.get_transactions()
 
        except AccountingException as exc:
 
            # TODO: Do a hard reset on the repository using Repository.reset,
 
            # this is on hold because of
 
            # https://github.com/libgit2/pygit2/issues/271.
 
            # This solution will work in the meantime
 
            self.delete_transaction(transaction.id)
 
            setattr(exc, 'transaction', transaction)
 
            raise exc
 

	
 
        self.commit_changes('Added transaction %s' % transaction.id)
 

	
 
        _log.info('Added transaction %s', transaction.id)
 

	
 
        _log.debug('written to file: %s', output)
 

	
 
        return transaction.id
 

	
 
    def bal(self):
 
        output = self.send_command('xml')
 

	
 
        if output is None: