2019-03-20 11:01:53 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'checksum'
|
|
|
|
|
|
|
|
# Setting values, kept history of modifications
|
2020-03-25 10:16:47 +01:00
|
|
|
class HistoryValue < ApplicationRecord
|
2018-12-17 16:02:02 +01:00
|
|
|
belongs_to :setting
|
2019-06-03 16:51:43 +02:00
|
|
|
belongs_to :invoicing_profile
|
2019-03-20 11:01:53 +01:00
|
|
|
|
2019-04-23 13:04:50 +02:00
|
|
|
after_create :chain_record
|
|
|
|
|
2019-03-20 11:01:53 +01:00
|
|
|
def chain_record
|
|
|
|
self.footprint = compute_footprint
|
|
|
|
save!
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_footprint
|
|
|
|
footprint == compute_footprint
|
|
|
|
end
|
|
|
|
|
2019-06-03 16:51:43 +02:00
|
|
|
def user
|
|
|
|
invoicing_profile.user
|
|
|
|
end
|
|
|
|
|
2019-03-20 11:01:53 +01:00
|
|
|
private
|
|
|
|
|
|
|
|
def compute_footprint
|
2019-09-18 15:09:14 +02:00
|
|
|
FootprintService.compute_footprint(HistoryValue, self, 'created_at')
|
2019-03-20 11:01:53 +01:00
|
|
|
end
|
2018-12-17 16:02:02 +01:00
|
|
|
end
|