1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

WIP: exclude invoice_id from footprint in payment_schedule_item

This commit is contained in:
Sylvain 2020-12-21 17:37:58 +01:00
parent 609d19e5d1
commit d3a41903cd
8 changed files with 23 additions and 4 deletions

View File

@ -21,7 +21,8 @@ class OpenAPI::V1::InvoicesController < OpenAPI::V1::BaseController
end
private
def per_page
params[:per_page] || 20
end
def per_page
params[:per_page] || 20
end
end

View File

@ -0,0 +1,5 @@
module Footprintable
def self.columns_out_of_footprint
[]
end
end

View File

@ -4,6 +4,8 @@ require 'checksum'
# Setting values, kept history of modifications
class HistoryValue < ApplicationRecord
include Footprintable
belongs_to :setting
belongs_to :invoicing_profile

View File

@ -5,6 +5,7 @@ require 'checksum'
# Invoice correspond to a single purchase made by an user. This purchase may
# include reservation(s) and/or a subscription
class Invoice < ApplicationRecord
include Footprintable
include NotifyWith::NotificationAttachedObject
require 'fileutils'
scope :only_invoice, -> { where(type: nil) }

View File

@ -4,6 +4,8 @@ require 'checksum'
# A single line inside an invoice. Can be a subscription or a reservation
class InvoiceItem < ApplicationRecord
include Footprintable
belongs_to :invoice
belongs_to :subscription

View File

@ -3,6 +3,8 @@
# PaymentSchedule is a way for members to pay something (especially a Subscription) with multiple payment,
# staged on a long period rather than with a single payment
class PaymentSchedule < ApplicationRecord
include Footprintable
belongs_to :scheduled, polymorphic: true
belongs_to :wallet_transaction
belongs_to :coupon

View File

@ -2,6 +2,8 @@
# Represents a due date and the associated amount for a PaymentSchedule
class PaymentScheduleItem < ApplicationRecord
include Footprintable
belongs_to :payment_schedule
belongs_to :invoice
after_create :chain_record
@ -23,4 +25,8 @@ class PaymentScheduleItem < ApplicationRecord
def compute_footprint
FootprintService.compute_footprint(PaymentScheduleItem, self)
end
def self.columns_out_of_footprint
%w[invoice_id]
end
end

View File

@ -29,7 +29,7 @@ class FootprintService
# Return an ordered array of the columns used in the footprint computation
# @param klass Invoice|InvoiceItem|HistoryValue
def self.footprint_columns(klass)
klass.columns.map(&:name).delete_if { |c| %w[footprint updated_at].include? c }
klass.columns.map(&:name).delete_if { |c| %w[footprint updated_at].concat(klass.columns_out_of_footprint).include? c }
end
# Logs a debugging message to help finding why a footprint is invalid