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
- #total_owner_sent ⇒ Object
- #total_received_amount ⇒ Object
- #total_tax_sent ⇒ Object
Instance Method Details
#added_fee_received ⇒ Object
59 60 61 62 63 64 65 |
# File 'app/models/bitsy/payment_depot.rb', line 59 def added_fee_received if min_payment_received? self.total_received_amount - self.min_payment else 0.0 end end |
#added_tax_amount ⇒ Object
71 72 73 |
# File 'app/models/bitsy/payment_depot.rb', line 71 def added_tax_amount added_fee_received * self.added_tax_fee end |
#balance_tax_amount ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/models/bitsy/payment_depot.rb', line 27 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
79 80 81 |
# File 'app/models/bitsy/payment_depot.rb', line 79 def bitcoin_account_name self.uuid end |
#has_balance? ⇒ Boolean
75 76 77 |
# File 'app/models/bitsy/payment_depot.rb', line 75 def has_balance? self.balance > 0 end |
#initial_fee_received ⇒ Object
51 52 53 54 55 56 57 |
# File 'app/models/bitsy/payment_depot.rb', line 51 def initial_fee_received if min_payment_received? self.min_payment else self.total_received_amount end end |
#initial_owner_rate ⇒ Object
23 24 25 |
# File 'app/models/bitsy/payment_depot.rb', line 23 def initial_owner_rate self.min_payment * (1 - self.initial_tax_rate) end |
#initial_tax_amount ⇒ Object
67 68 69 |
# File 'app/models/bitsy/payment_depot.rb', line 67 def initial_tax_amount initial_fee_received * self.initial_tax_fee end |
#min_payment_received? ⇒ Boolean
47 48 49 |
# File 'app/models/bitsy/payment_depot.rb', line 47 def min_payment_received? self.total_received_amount >= self.min_payment end |
#total_owner_sent ⇒ Object
43 44 45 |
# File 'app/models/bitsy/payment_depot.rb', line 43 def total_owner_sent owner_transactions.sum(:amount).abs end |
#total_received_amount ⇒ Object
35 36 37 |
# File 'app/models/bitsy/payment_depot.rb', line 35 def total_received_amount read_attribute :total_received_amount_cache end |
#total_tax_sent ⇒ Object
39 40 41 |
# File 'app/models/bitsy/payment_depot.rb', line 39 def total_tax_sent tax_transactions.sum(:amount).abs end |