Class: Bitsy::PaymentDepot

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/bitsy/payment_depot.rb

Instance Method Summary collapse

Instance Method Details

#added_fee_receivedObject



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_amountObject



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_amountObject



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_nameObject



99
100
101
# File 'app/models/bitsy/payment_depot.rb', line 99

def 
  self.uuid
end

#has_balance?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'app/models/bitsy/payment_depot.rb', line 95

def has_balance?
  self.balance > 0
end

#initial_fee_receivedObject



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_rateObject



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_amountObject



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

Returns:

  • (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_sentObject



63
64
65
# File 'app/models/bitsy/payment_depot.rb', line 63

def total_owner_sent
  owner_transactions.sum(:amount).abs
end

#total_received_amountObject



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_sentObject



59
60
61
# File 'app/models/bitsy/payment_depot.rb', line 59

def total_tax_sent
  tax_transactions.sum(:amount).abs
end