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



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_amountObject



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_amountObject



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_nameObject



79
80
81
# File 'app/models/bitsy/payment_depot.rb', line 79

def 
  self.uuid
end

#has_balance?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'app/models/bitsy/payment_depot.rb', line 75

def has_balance?
  self.balance > 0
end

#initial_fee_receivedObject



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_rateObject



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_amountObject



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

Returns:

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



43
44
45
# File 'app/models/bitsy/payment_depot.rb', line 43

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

#total_received_amountObject



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_sentObject



39
40
41
# File 'app/models/bitsy/payment_depot.rb', line 39

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