class MudratProjector::TaxCalculator::TransactionWrapper

Constants

ADJUSTMENTS_VALUES
CREDITS_VALUES
DEDUCTIONS_VALUES
INCOME_VALUES
VALUES

Attributes

calculator[RW]

Public Class Methods

new(calculator, transaction) click to toggle source
# 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

Public Instance Methods

calculate!() click to toggle source
# File lib/mudrat_projector/tax_calculator.rb, line 54
def calculate!
  @transaction.entries.each do |entry|
    account = calculator.projector.fetch entry.account_id
    if account.type == :revenue
      @salaries_and_wages += entry.delta if account.tag? :salary
      @business_profit    += entry.delta if account.tag? :self_employed
      @dividend_income    += entry.delta if account.tag? :dividend
    elsif account.type == :expense
      @business_profit    -= entry.delta if account.tag? :self_employed
      @charitable_contributions +=
                             entry.delta if account.tag? "501c".to_sym
      @interest_paid      += entry.delta if account.tag? :mortgage_interest
      @taxes_paid         += entry.delta if account.tag? :tax
      @taxes_withheld     += entry.delta if entry.account_id == EXPENSE_ACCOUNT_ID
    elsif account.type == :asset
      @other_adjustments  += entry.delta if account.tag?(:hsa) && entry.debit?
    end
  end
end
credits() click to toggle source
# File lib/mudrat_projector/tax_calculator.rb, line 78
def credits
  @transaction.credits
end
debits() click to toggle source
# File lib/mudrat_projector/tax_calculator.rb, line 74
def debits
  @transaction.debits
end