2020-05-11 10:10:52 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-05-24 11:38:25 +02:00
|
|
|
require 'integrity/archive_helper'
|
|
|
|
|
2020-05-11 10:10:52 +02:00
|
|
|
# regenerate the accounting periods affected by the current bug (period totals are wrong due to wrong VAT computation)
|
|
|
|
class FixAccountingPeriods < ActiveRecord::Migration[5.2]
|
|
|
|
def change
|
|
|
|
# first, check the footprints
|
2021-05-24 11:38:25 +02:00
|
|
|
Integrity::ArchiveHelper.check_footprints
|
2020-05-11 10:10:52 +02:00
|
|
|
|
|
|
|
# if everything is ok, proceed with migration
|
|
|
|
# remove periods (backup their parameters in memory)
|
2021-05-24 11:38:25 +02:00
|
|
|
periods = Integrity::ArchiveHelper.backup_and_remove_periods(range_start: '2019-08-01', range_end: '2020-05-12')
|
2020-05-11 10:10:52 +02:00
|
|
|
# recreate periods from memory dump
|
2021-05-24 11:38:25 +02:00
|
|
|
Integrity::ArchiveHelper.restore_periods(periods)
|
2020-05-11 10:10:52 +02:00
|
|
|
end
|
|
|
|
end
|