mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-01 12:24:28 +01:00
WIP: exclude invoice_id from footprint in payment_schedule_item
This commit is contained in:
parent
609d19e5d1
commit
d3a41903cd
@ -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
|
||||
|
5
app/models/footprintable.rb
Normal file
5
app/models/footprintable.rb
Normal file
@ -0,0 +1,5 @@
|
||||
module Footprintable
|
||||
def self.columns_out_of_footprint
|
||||
[]
|
||||
end
|
||||
end
|
@ -4,6 +4,8 @@ require 'checksum'
|
||||
|
||||
# Setting values, kept history of modifications
|
||||
class HistoryValue < ApplicationRecord
|
||||
include Footprintable
|
||||
|
||||
belongs_to :setting
|
||||
belongs_to :invoicing_profile
|
||||
|
||||
|
@ -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) }
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user