Class: Accountability::Credit

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

Overview

A Credit represents a single charge to an Account To preserve data integrity, credits should never be modified

Instance Method Summary collapse

Instance Method Details

#base_priceObject



16
17
18
19
20
21
22
# File 'app/models/accountability/credit.rb', line 16

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

#total_deductionsObject



24
25
26
27
28
29
30
# File 'app/models/accountability/credit.rb', line 24

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