Class: Dscf::Payment::SettlementAccountService

Inherits:
Object
  • Object
show all
Defined in:
app/services/dscf/payment/settlement_account_service.rb

Constant Summary collapse

SETTLEMENT_ACCOUNT_NAME =
"DSCF Payment Settlement Account"

Class Method Summary collapse

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 (currency: "ETB")
   = Dscf::Banking::.find_by(
    name: ,
    currency: currency,
    system_account: true
  )

  return  if 

  # Create new settlement account
  Dscf::Banking::.create!(
    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 (currency: "ETB")
   = (currency: currency)
  raise SettlementAccountError.new("Settlement account not found for currency #{currency}") unless 
  
end