Module: Model::Compute

Extended by:
ActiveSupport::Concern
Included in:
Trade::Card, Trade::Cash
Defined in:
app/models/trade/model/compute.rb

Instance Method Summary collapse

Instance Method Details

#compute_amountObject



16
17
18
# File 'app/models/trade/model/compute.rb', line 16

def compute_amount
  self.amount = self.income_amount - self.expense_amount
end

#reset_amountObject



20
21
22
23
24
25
# File 'app/models/trade/model/compute.rb', line 20

def reset_amount
  self.income_amount = compute_income_amount
  self.expense_amount = compute_expense_amount
  self.valid?
  self.changes
end

#reset_amount!(*args) ⇒ Object



27
28
29
30
# File 'app/models/trade/model/compute.rb', line 27

def reset_amount!(*args)
  self.reset_amount
  self.save(*args)
end