lib/bankscrap/cli.rb in bankscrap-2.0.0 vs lib/bankscrap/cli.rb in bankscrap-2.0.1

- old
+ new

@@ -56,13 +56,12 @@ end export_to_file(transactions, options[:format], options[:output]) if options[:format] say "Transactions for: #{account.description} (#{account.iban})", :cyan - transactions.each do |transaction| - say transaction.to_s, (transaction.amount > Money.new(0) ? :green : :red) - end + print_transactions_header + transactions.each { |t| print_transaction(t) } end register(Bankscrap::AdapterGenerator, "generate_adapter", "generate_adapter MyBankName", "generates a template for a new Bankscrap bank adapter") @@ -108,8 +107,25 @@ when 'csv' then BankScrap::Exporter::Csv.new(path) else say 'Sorry, file format not supported.', :red exit end + end + + def print_transactions_header + say "\n" + say "DATE".ljust(13) + say "DESCRIPTION".ljust(50) + "\s\s\s" + say "AMOUNT".rjust(15) + "\s\s\s" + say "BALANCE".rjust(15) + say "-" * 99 + end + + def print_transaction(transaction) + color = (transaction.amount > Money.new(0) ? :green : :red) + say transaction.effective_date.strftime('%d/%m/%Y') + "\s\s\s" + say transaction.description.squish.truncate(50).ljust(50) + "\s\s\s", color + say transaction.amount.format.rjust(15) + "\s\s\s", color + say transaction.balance.format.rjust(15) end end end