2020-10-27 16:02:41 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Represents a due date and the associated amount for a PaymentSchedule
|
|
|
|
class PaymentScheduleItem < ApplicationRecord
|
|
|
|
belongs_to :payment_schedule
|
2020-11-12 16:44:55 +01:00
|
|
|
belongs_to :invoice
|
2020-12-16 18:33:43 +01:00
|
|
|
after_create :chain_record
|
|
|
|
|
|
|
|
def chain_record
|
|
|
|
self.footprint = compute_footprint
|
|
|
|
save!
|
|
|
|
FootprintDebug.create!(
|
|
|
|
footprint: footprint,
|
|
|
|
data: FootprintService.footprint_data(PaymentScheduleItem, self),
|
|
|
|
klass: PaymentScheduleItem.name
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_footprint
|
|
|
|
footprint == compute_footprint
|
|
|
|
end
|
|
|
|
|
|
|
|
def compute_footprint
|
|
|
|
FootprintService.compute_footprint(PaymentScheduleItem, self)
|
|
|
|
end
|
2020-10-27 16:02:41 +01:00
|
|
|
end
|