Class: MudratProjector::TaxCalculator::TransactionWrapper
- Inherits:
-
Object
- Object
- MudratProjector::TaxCalculator::TransactionWrapper
- 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
- #calculate! ⇒ Object
- #credits ⇒ Object
- #debits ⇒ Object
-
#initialize(calculator, transaction) ⇒ TransactionWrapper
constructor
A new instance of TransactionWrapper.
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| 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 ⇒ Object
78 79 80 |
# File 'lib/mudrat_projector/tax_calculator.rb', line 78 def credits @transaction.credits end |
#debits ⇒ Object
74 75 76 |
# File 'lib/mudrat_projector/tax_calculator.rb', line 74 def debits @transaction.debits end |