Class: MudratProjector::TaxCalculator::TransactionWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/mudrat_projector/tax_calculator.rb

Constant Summary collapse

INCOME_VALUES =
i(business_profit dividend_income salaries_and_wages)
ADJUSTMENTS_VALUES =
i(other_adjustments)
DEDUCTIONS_VALUES =
i(charitable_contributions interest_paid taxes_paid)
CREDITS_VALUES =
i()
VALUES =
[INCOME_VALUES, ADJUSTMENTS_VALUES, DEDUCTIONS_VALUES, CREDITS_VALUES].flatten 1

Instance Method Summary collapse

Constructor Details

#initialize(calculator, transaction) ⇒ TransactionWrapper

Returns a new instance of TransactionWrapper.



45
46
47
48
49
50
# File 'lib/mudrat_projector/tax_calculator.rb', line 45

def initialize calculator, transaction
  @calculator = calculator
  @taxes_withheld = 0
  @transaction = transaction
  VALUES.each do |attr_name| instance_variable_set "@#{attr_name}", 0; end
end

Instance Method Details

#calculate!Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/mudrat_projector/tax_calculator.rb', line 54

def calculate!
  @transaction.entries.each do |entry|
     = calculator.projector.fetch entry.
    if .type == :revenue
      @salaries_and_wages += entry.delta if .tag? :salary
      @business_profit    += entry.delta if .tag? :self_employed
      @dividend_income    += entry.delta if .tag? :dividend
    elsif .type == :expense
      @business_profit    -= entry.delta if .tag? :self_employed
      @charitable_contributions +=
                             entry.delta if .tag? "501c".to_sym
      @interest_paid      += entry.delta if .tag? :mortgage_interest
      @taxes_paid         += entry.delta if .tag? :tax
      @taxes_withheld     += entry.delta if entry. == 
    elsif .type == :asset
      @other_adjustments  += entry.delta if .tag?(:hsa) && entry.debit?
    end
  end
end

#creditsObject



78
79
80
# File 'lib/mudrat_projector/tax_calculator.rb', line 78

def credits
  @transaction.credits
end

#debitsObject



74
75
76
# File 'lib/mudrat_projector/tax_calculator.rb', line 74

def debits
  @transaction.debits
end