Module: MercuryBanking::CLI::Reconciliation::ReconcileCommand
- Defined in:
- lib/mercury_banking/cli/reconciliation.rb
Overview
Module for reconcile command
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/mercury_banking/cli/reconciliation.rb', line 133 def self.included(base) base.class_eval do desc 'reconcile ACCOUNT_ID_OR_NUMBER TRANSACTION_ID', 'Mark a transaction as reconciled' def reconcile(account_identifier, transaction_id) with_api_client do |client| # Resolve account identifier to account ID account_id = resolve_account_id(client, account_identifier) # Verify the transaction exists but don't need to store it client.transaction(account_id, transaction_id) # Mark the transaction as reconciled reconciliation = MercuryBanking::Reconciliation.new result = reconciliation.mark_reconciled(account_id, transaction_id) if [:json] puts JSON.pretty_generate({ 'account_id' => account_id, 'transaction_id' => transaction_id, 'reconciled' => true, 'already_reconciled' => !result }) elsif result puts "Transaction #{transaction_id} marked as reconciled." else puts "Transaction #{transaction_id} was already reconciled." end end end end end |