Class: Accountability::Credit

Inherits:
ApplicationRecord show all
Defined in:
app/models/accountability/credit.rb

Instance Method Summary collapse

Methods inherited from ApplicationRecord

validates_attributes

Instance Method Details

#base_priceObject



19
20
21
22
23
24
25
# File 'app/models/accountability/credit.rb', line 19

def base_price
  if new_record?
    order_item.default_price
  else
    amount + total_deductions + taxes
  end
end

#total_deductionsObject



27
28
29
30
31
32
33
# File 'app/models/accountability/credit.rb', line 27

def total_deductions
  if persisted?
    deductions.sum(:amount)
  else
    deductions.map(&:amount).sum
  end
end