1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

fix stripe_ids data migration

This commit is contained in:
Sylvain 2021-06-07 14:15:39 +02:00
parent 39fe153267
commit 5d7c024056
2 changed files with 5 additions and 6 deletions

View File

@ -3,12 +3,7 @@
# Validates that all invoices in the current accounting period are chained with footprints which ensure their integrity
class PeriodIntegrityValidator < ActiveModel::Validator
def validate(record)
the_end = record.end_at
the_start = record.start_at
invoices = Invoice.where('created_at >= :start_date AND created_at < :end_date', start_date: the_start, end_date: the_end)
.includes(:invoice_items)
invoices = record.invoices.includes(:invoice_items)
invoices.each do |i|
record.errors["invoice_#{i.reference}".to_sym] << I18n.t('errors.messages.invalid_footprint') unless i.check_footprint

View File

@ -34,6 +34,8 @@ class MigrateStripeIdsToPaymentGatewayObjects < ActiveRecord::Migration[5.2]
end
remove_column :invoices, :stp_invoice_id
remove_column :invoices, :stp_payment_intent_id
Invoice.connection.schema_cache.clear!
Invoice.reset_column_information
## INVOICE ITEMS
puts 'Migrating invoices items...'
@ -48,6 +50,8 @@ class MigrateStripeIdsToPaymentGatewayObjects < ActiveRecord::Migration[5.2]
)
end
remove_column :invoice_items, :stp_invoice_item_id
InvoiceItem.connection.schema_cache.clear!
InvoiceItem.reset_column_information
## SUBSCRIPTIONS
# stp_subscription_id is not used anymore.