def list_transactions(self, args=None): args = util.parse_args(args) if args and args[0].lower() == 'all': show_all = True else: show_all = False self.current_listing = {} count = 0 for thing in self.open_transactions: if thing.thing_date > self.ending_date \ and not show_all \ and not thing.is_pending(): continue if not self.current_listing: print() # only print one buffer line at top if items count += 1 self.current_listing[str(count)] = thing count_str = '{:-4}.'.format(count) print( '{number} {date} {amount} {status:1} {payee} ' '{code:>7}'.format( number=util.get_cyan_text(count_str), date=thing.get_date_string(), code=thing.transaction_code, payee=util.get_cyan_text( thing.payee, column_width=40 ), amount=util.get_colored_amount( thing.rec_amount, 10 ), status=thing.rec_status ) ) end_date = util.get_cyan_text( util.get_date_string(self.ending_date) ) if self.ending_balance is None: end_balance = util.get_cyan_text('(not set)') else: end_balance = util.get_colored_amount(self.ending_balance) print( '\nending date: {end_date} ending balance: {end_balance} ' 'cleared: {cleared}'.format( end_date=end_date, end_balance=end_balance, cleared=util.get_colored_amount(self.total_cleared) ) ) if self.ending_balance is not None: print('to zero: {}'.format( util.get_colored_amount(self.get_zero_candidate()) )) print()
def test_get_cyan_text(self): self.assertEqual("\x1b[0;36mMEEP\x1b[0m", util.get_cyan_text("MEEP")) self.assertEqual("\x1b[0;36mMEEP \x1b[0m", util.get_cyan_text("MEEP", column_width=20)) self.assertEqual("\x1b[0;36mMEEP \x1b[0m", util.get_cyan_text("MEEP", column_width=20))