Class: Dscf::Payment::SettlementAccountService
- Inherits:
-
Object
- Object
- Dscf::Payment::SettlementAccountService
- Defined in:
- app/services/dscf/payment/settlement_account_service.rb
Constant Summary collapse
- SETTLEMENT_ACCOUNT_NAME =
"DSCF Payment Settlement Account"
Class Method Summary collapse
- .find_or_create_settlement_account(currency: "ETB") ⇒ Object
- .settlement_account_for(currency: "ETB") ⇒ Object
Class Method Details
.find_or_create_settlement_account(currency: "ETB") ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/services/dscf/payment/settlement_account_service.rb', line 6 def find_or_create_settlement_account(currency: "ETB") account = Dscf::Banking::Account.find_by( name: SETTLEMENT_ACCOUNT_NAME, currency: currency, system_account: true ) return account if account # Create new settlement account Dscf::Banking::Account.create!( name: SETTLEMENT_ACCOUNT_NAME, currency: currency, system_account: true, current_balance: 0, available_balance: 0, minimum_balance: 0, status: :active, active: true ) rescue ActiveRecord::RecordInvalid => e raise SettlementAccountError.new("Failed to create settlement account: #{e.message}") end |
.settlement_account_for(currency: "ETB") ⇒ Object
30 31 32 33 34 |
# File 'app/services/dscf/payment/settlement_account_service.rb', line 30 def settlement_account_for(currency: "ETB") account = find_or_create_settlement_account(currency: currency) raise SettlementAccountError.new("Settlement account not found for currency #{currency}") unless account account end |