Class: Bitsy::PaymentDepot
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Bitsy::PaymentDepot
- Defined in:
- app/models/bitsy/payment_depot.rb
Instance Method Summary collapse
- #added_fee_received ⇒ Object
- #added_tax_amount ⇒ Object
- #balance_tax_amount ⇒ Object
- #bitcoin_account_name ⇒ Object
- #has_balance? ⇒ Boolean
- #initial_fee_received ⇒ Object
- #initial_owner_rate ⇒ Object
- #initial_tax_amount ⇒ Object
- #min_payment_received? ⇒ Boolean
- #reset_checked_at! ⇒ Object
- #total_owner_sent ⇒ Object
- #total_received_amount ⇒ Object
- #total_tax_sent ⇒ Object
Instance Method Details
#added_fee_received ⇒ Object
79 80 81 82 83 84 85 |
# File 'app/models/bitsy/payment_depot.rb', line 79 def added_fee_received if min_payment_received? self.total_received_amount - self.min_payment else 0.0 end end |
#added_tax_amount ⇒ Object
91 92 93 |
# File 'app/models/bitsy/payment_depot.rb', line 91 def added_tax_amount added_fee_received * self.added_tax_fee end |
#balance_tax_amount ⇒ Object
47 48 49 50 51 52 53 |
# File 'app/models/bitsy/payment_depot.rb', line 47 def balance_tax_amount ForwardTaxCalculator.calculate(self.balance, self.min_payment, self.total_received_amount, self.initial_tax_rate, self.added_tax_rate) end |
#bitcoin_account_name ⇒ Object
99 100 101 |
# File 'app/models/bitsy/payment_depot.rb', line 99 def bitcoin_account_name self.uuid end |
#has_balance? ⇒ Boolean
95 96 97 |
# File 'app/models/bitsy/payment_depot.rb', line 95 def has_balance? self.balance > 0 end |
#initial_fee_received ⇒ Object
71 72 73 74 75 76 77 |
# File 'app/models/bitsy/payment_depot.rb', line 71 def initial_fee_received if min_payment_received? self.min_payment else self.total_received_amount end end |
#initial_owner_rate ⇒ Object
36 37 38 |
# File 'app/models/bitsy/payment_depot.rb', line 36 def initial_owner_rate self.min_payment * (1 - self.initial_tax_rate) end |
#initial_tax_amount ⇒ Object
87 88 89 |
# File 'app/models/bitsy/payment_depot.rb', line 87 def initial_tax_amount initial_fee_received * self.initial_tax_fee end |
#min_payment_received? ⇒ Boolean
67 68 69 |
# File 'app/models/bitsy/payment_depot.rb', line 67 def min_payment_received? self.total_received_amount >= self.min_payment end |
#reset_checked_at! ⇒ Object
40 41 42 43 44 45 |
# File 'app/models/bitsy/payment_depot.rb', line 40 def reset_checked_at! self.update_attributes( check_count: self.check_count + 1, checked_at: (self.check_count**2).seconds.from_now, ) end |
#total_owner_sent ⇒ Object
63 64 65 |
# File 'app/models/bitsy/payment_depot.rb', line 63 def total_owner_sent owner_transactions.sum(:amount).abs end |
#total_received_amount ⇒ Object
55 56 57 |
# File 'app/models/bitsy/payment_depot.rb', line 55 def total_received_amount read_attribute :total_received_amount_cache end |
#total_tax_sent ⇒ Object
59 60 61 |
# File 'app/models/bitsy/payment_depot.rb', line 59 def total_tax_sent tax_transactions.sum(:amount).abs end |