Class: Gera::PaymentSystem

Inherits:
ApplicationRecord show all
Includes:
Archivable, Authority::Abilities, Mathematic
Defined in:
app/models/gera/payment_system.rb

Instance Method Summary collapse

Methods included from Mathematic

#calculate_base_rate, #calculate_comission, #calculate_finite_rate, #calculate_profits, #calculate_total_using_regular_comission, #calculate_total_using_reverse_comission, #diff_percents, #money_exchange, #money_reverse_exchange

Instance Method Details

#currencyObject

TODO: rename type_cy to currency



34
35
36
37
38
# File 'app/models/gera/payment_system.rb', line 34

def currency
  return unless type_cy

  @currency ||= Money::Currency.find_by_local_id(type_cy) || raise("Не найдена валюта #{type_cy}")
end

#currency=(cur) ⇒ Object



40
41
42
43
# File 'app/models/gera/payment_system.rb', line 40

def currency=(cur)
  cur = Money::Currency.find cur unless cur.is_a? Money::Currency
  self.type_cy = cur.is_a?(Money::Currency) ? cur.local_id : nil
end

#to_sObject



45
46
47
# File 'app/models/gera/payment_system.rb', line 45

def to_s
  name
end

#total_with_fee(money) ⇒ Object

TODO: move to kassa-admin



50
51
52
# File 'app/models/gera/payment_system.rb', line 50

def total_with_fee(money)
  calculate_total(money: money, fee: transfer_fee)
end

#unverified_total_with_fee(money) ⇒ Object



54
55
56
# File 'app/models/gera/payment_system.rb', line 54

def unverified_total_with_fee(money)
  calculate_total(money: money, fee: unverified_transfer_fee)
end