Class: Dune::Balanced::Bankaccount::TransactionFeeCalculatorBase

Inherits:
Object
  • Object
show all
Defined in:
app/models/dune/balanced/bankaccount/transaction_fee_calculator_base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transaction_value) ⇒ TransactionFeeCalculatorBase

Returns a new instance of TransactionFeeCalculatorBase.



9
10
11
# File 'app/models/dune/balanced/bankaccount/transaction_fee_calculator_base.rb', line 9

def initialize(transaction_value)
  @transaction_value = transaction_value
end

Instance Attribute Details

#transaction_valueObject



13
14
15
# File 'app/models/dune/balanced/bankaccount/transaction_fee_calculator_base.rb', line 13

def transaction_value
  @transaction_value.to_f.floor_with_two_decimal_places
end

Instance Method Details

#feesObject

Base calculation of fees 1% + 30¢ ($5 cap)



27
28
29
30
31
32
# File 'app/models/dune/balanced/bankaccount/transaction_fee_calculator_base.rb', line 27

def fees
  [
    (net_amount * 0.01 + 0.3).ceil_with_two_decimal_places,
    5.0
  ].min
end

#gross_amountObject



17
18
19
# File 'app/models/dune/balanced/bankaccount/transaction_fee_calculator_base.rb', line 17

def gross_amount
  net_amount + fees
end

#net_amountObject

Raises:

  • (NotImplementedError)


21
22
23
# File 'app/models/dune/balanced/bankaccount/transaction_fee_calculator_base.rb', line 21

def net_amount
  raise NotImplementedError
end