Class: BitcoinPayable::BitcoinPayment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- BitcoinPayable::BitcoinPayment
- Defined in:
- lib/bitcoin_payable/bitcoin_payment.rb
Instance Method Summary collapse
Instance Method Details
#calculate_btc_amount_due ⇒ Object
41 42 43 44 |
# File 'lib/bitcoin_payable/bitcoin_payment.rb', line 41 def calculate_btc_amount_due btc_rate = BitcoinPayable::CurrencyConversion.last.btc BitcoinPayable::BitcoinCalculator.exchange_price currency_amount_due, btc_rate end |
#currency_amount_due ⇒ Object
37 38 39 |
# File 'lib/bitcoin_payable/bitcoin_payment.rb', line 37 def currency_amount_due self.price - currency_amount_paid end |
#currency_amount_paid ⇒ Object
33 34 35 |
# File 'lib/bitcoin_payable/bitcoin_payment.rb', line 33 def currency_amount_paid self.transactions.inject(0) { |sum, tx| sum + (BitcoinPayable::BitcoinCalculator.convert_satoshis_to_bitcoin(tx.estimated_value) * tx.btc_conversion) }.round(2) end |