Class: MercuryBanking::CLI::Financials::FinancialsCommand
- Inherits:
-
Thor
- Object
- Thor
- MercuryBanking::CLI::Financials::FinancialsCommand
- Includes:
- BalanceSheetHelper, Base, Formatters::ExportFormatter
- Defined in:
- lib/mercury_banking/cli/financials.rb
Overview
Define the financials command class
Class Attribute Summary collapse
-
.parent_class ⇒ Object
Returns the value of attribute parent_class.
Instance Method Summary collapse
Methods included from BalanceSheetHelper
#display_balance_cross_check, #get_mercury_balances
Methods included from Formatters::ExportFormatter
#export_to_beancount, #export_to_csv, #export_to_hledger, #export_to_ledger, #sort_transactions_chronologically, #verify_ledger_file
Methods included from Base
#api_key, #command_exists?, #get_api_key, #log_transfer, #with_api_client
Class Attribute Details
.parent_class ⇒ Object
Returns the value of attribute parent_class.
206 207 208 |
# File 'lib/mercury_banking/cli/financials.rb', line 206 def parent_class @parent_class end |
Instance Method Details
#balancecheck ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/mercury_banking/cli/financials.rb', line 118 def balancecheck with_api_client do |client| accounts = client.accounts unless [:ledger_file] && File.exist?([:ledger_file]) puts "Error: You must provide a valid ledger file to check. Use --ledger-file option." return end # Get balances from the ledger file ledger_file = [:ledger_file] format = [:format] || File.extname(ledger_file).delete('.').downcase # Get ledger balances ledger_balances = get_ledger_balances(ledger_file, format) if ledger_balances.empty? puts "No account balances found in the ledger file." return end # Get current balances for all Mercury accounts mercury_balances = get_mercury_balances(accounts) # Display cross-check between Mercury and ledger balances display_balance_cross_check(mercury_balances, ledger_balances, [:verbose]) end end |