mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
fix data migrations + update test fixtures
This commit is contained in:
parent
c79078c8e1
commit
16df7f9506
@ -72,7 +72,7 @@
|
||||
|
||||
.payment-pending {
|
||||
@extend .validate-btn;
|
||||
@extend .validate-btn[disabled];
|
||||
background-color: lighten(#1d98ec, 20%);
|
||||
text-align: center;
|
||||
padding: 4px;
|
||||
}
|
||||
|
@ -24,30 +24,38 @@ class AddObjectToInvoiceItem < ActiveRecord::Migration[5.2]
|
||||
add_column :invoice_items, :main, :boolean
|
||||
# migrate data
|
||||
Invoice.where.not(invoiced_type: 'Reservation').each do |invoice|
|
||||
invoice.invoice_items.first.update_attributes(
|
||||
object_id: invoice.invoiced_id,
|
||||
object_type: invoice.invoiced_type,
|
||||
main: true
|
||||
execute %(
|
||||
UPDATE invoice_items
|
||||
SET object_id = #{invoice.invoiced_id},
|
||||
object_type = '#{invoice.invoiced_type}',
|
||||
main = true
|
||||
WHERE id = #{invoice.invoice_items.first.id}
|
||||
)
|
||||
end
|
||||
Invoice.where(invoiced_type: 'Reservation').each do |invoice|
|
||||
invoice.invoice_items.where(subscription_id: nil).first.update_attributes(
|
||||
object_id: invoice.invoiced_id,
|
||||
object_type: invoice.invoiced_type,
|
||||
main: true
|
||||
execute %(
|
||||
UPDATE invoice_items
|
||||
SET object_id = #{invoice.invoiced_id},
|
||||
object_type = '#{invoice.invoiced_type}',
|
||||
main = true
|
||||
WHERE id = #{invoice.invoice_items.where(subscription_id: nil).first.id}
|
||||
)
|
||||
invoice.invoice_items.where(subscription_id: nil)[1..-1].each do |ii|
|
||||
ii.update_attributes(
|
||||
object_id: invoice.invoiced_id,
|
||||
object_type: invoice.invoiced_type
|
||||
execute %(
|
||||
UPDATE invoice_items
|
||||
SET object_id = #{invoice.invoiced_id},
|
||||
object_type = '#{invoice.invoiced_type}'
|
||||
WHERE id = #{ii.id}
|
||||
)
|
||||
end
|
||||
subscription_item = invoice.invoice_items.where.not(subscription_id: nil).first
|
||||
next unless subscription_item
|
||||
|
||||
subscription_item.update_attributes(
|
||||
object_id: subscription_item.subscription_id,
|
||||
object_type: 'Subscription'
|
||||
execute %(
|
||||
UPDATE invoice_items
|
||||
SET object_id = #{subscription_item.subscription_id},
|
||||
object_type = 'Subscription'
|
||||
WHERE id = #{subscription_item.id}
|
||||
)
|
||||
end
|
||||
remove_column :invoice_items, :subscription_id
|
||||
@ -73,14 +81,18 @@ class AddObjectToInvoiceItem < ActiveRecord::Migration[5.2]
|
||||
add_reference :invoices, :invoiced, polymorphic: true
|
||||
# migrate data
|
||||
InvoiceItem.where(main: true).each do |ii|
|
||||
ii.invoice.update_attributes(
|
||||
invoiced_id: ii.object_id,
|
||||
invoiced_type: ii.object_type
|
||||
execute %(
|
||||
UPDATE invoices
|
||||
SET invoiced_id = #{ii.object_id},
|
||||
invoiced_type = '#{ii.object_type}'
|
||||
WHERE id = #{ii.invoice.id}
|
||||
)
|
||||
end
|
||||
InvoiceItem.where(object_type: 'Subscription').each do |ii|
|
||||
ii.update_attributes(
|
||||
subscription_id: ii.object_id
|
||||
execute %(
|
||||
UPDATE invoice_items
|
||||
SET subscription_id = #{ii.object_id}
|
||||
WHERE id = #{ii.id}
|
||||
)
|
||||
end
|
||||
remove_column :invoice_items, :main
|
||||
|
@ -46,15 +46,17 @@ class CreatePaymentScheduleObjects < ActiveRecord::Migration[5.2]
|
||||
|
||||
# migrate data
|
||||
PaymentScheduleObject.where(main: true).each do |pso|
|
||||
pso.payment_schedule.update_attributes(
|
||||
scheduled_id: pso.object_id,
|
||||
scheduled_type: pso.object_type
|
||||
execute %(
|
||||
UPDATE payment_schedules
|
||||
SET scheduled_id = #{pso.object_id},
|
||||
scheduled_type = '#{pso.object_type}'
|
||||
WHERE id = #{pso.payment_schedule.id}
|
||||
)
|
||||
end
|
||||
PaymentScheduleObject.where(object_type: 'Subscription').each do |pso|
|
||||
pso.payment_schedule.payment_schedule_items.each do |psi|
|
||||
psi.details['subscription_id'] = pso.object_id
|
||||
pdi.save!
|
||||
psi.save(validate: false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,12 @@
|
||||
# This was limiting to one item only, was redundant with (Invoice|PaymentSchedule).wallet_transaction_id, and anyway
|
||||
# this data was not used anywhere in the application so we remove it.
|
||||
class RemoveTransactableFromWalletTransaction < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
def up
|
||||
remove_reference :wallet_transactions, :transactable, polymorphic: true
|
||||
end
|
||||
|
||||
def down
|
||||
index_opts = { name: 'index_wallet_transactions_on_transactable'}
|
||||
add_reference :wallet_transactions, :transactable, polymorphic: true, index: index_opts
|
||||
end
|
||||
end
|
||||
|
@ -5221,14 +5221,6 @@ CREATE RULE accounting_periods_del_protect AS
|
||||
ON DELETE TO public.accounting_periods DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- Name: accounting_periods accounting_periods_upd_protect; Type: RULE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE RULE accounting_periods_upd_protect AS
|
||||
ON UPDATE TO public.accounting_periods DO INSTEAD NOTHING;
|
||||
|
||||
|
||||
--
|
||||
-- Name: projects projects_search_content_trigger; Type: TRIGGER; Schema: public; Owner: -
|
||||
--
|
||||
|
67
test/fixtures/invoice_items.yml
vendored
67
test/fixtures/invoice_items.yml
vendored
@ -3,67 +3,72 @@ invoice_item_1:
|
||||
id: 1
|
||||
invoice_id: 1
|
||||
amount: 10000
|
||||
created_at: 2012-03-12 11:03:31.651441000 Z
|
||||
updated_at: 2012-03-12 11:03:31.651441000 Z
|
||||
created_at: '2012-03-12 11:03:31.651441'
|
||||
updated_at: '2021-05-27 09:26:26.450083'
|
||||
description: Sleede - standard, association - month
|
||||
subscription_id: 1
|
||||
invoice_item_id:
|
||||
footprint: a8159facb52418d4b5e9089c6b5d63260d364e506e42959bf593e22b9fbc75e3
|
||||
|
||||
footprint: 45c215f761aa7a3dae48f52ab5c5e34e1d33f309779ed91a0008040b9bce7eec
|
||||
object_type: Subscription
|
||||
object_id: 1
|
||||
main: true
|
||||
invoice_item_2:
|
||||
id: 2
|
||||
invoice_id: 2
|
||||
amount: 2000
|
||||
created_at: 2012-03-12 13:40:22.342717000 Z
|
||||
updated_at: 2012-03-12 13:40:22.342717000 Z
|
||||
created_at: '2012-03-12 13:40:22.342717'
|
||||
updated_at: '2021-05-27 09:26:26.461737'
|
||||
description: Mensuel tarif réduit - étudiant, - de 25 ans, enseignant, demandeur
|
||||
d'emploi - month
|
||||
subscription_id: 2
|
||||
invoice_item_id:
|
||||
footprint: 647c9f3f4b402cd61d3fbf55dc4be3832b6111f8438dcfc51010d2f626f1e710
|
||||
|
||||
footprint: 3e3666de0195426b73164a1d2593ae6986fb6add76c04d2ede798620f9c7b445
|
||||
object_type: Subscription
|
||||
object_id: 2
|
||||
main: true
|
||||
invoice_item_3:
|
||||
id: 3
|
||||
invoice_id: 3
|
||||
amount: 3000
|
||||
created_at: 2015-06-10 11:20:01.341130000 Z
|
||||
updated_at: 2015-06-10 11:20:01.341130000 Z
|
||||
created_at: '2015-06-10 11:20:01.341130'
|
||||
updated_at: '2021-05-27 09:26:26.465302'
|
||||
description: Mensuel - standard, association - month
|
||||
subscription_id: 3
|
||||
invoice_item_id:
|
||||
footprint: acb83d8083349073da133721f99ad9094d8739cee3b71b58d668f3947ad72a80
|
||||
|
||||
footprint: 036d18dd5a1d6340155d52a85d46074a7119e5e379430e4f1a26c9e7f0f05a97
|
||||
object_type: Subscription
|
||||
object_id: 3
|
||||
main: true
|
||||
invoice_item_4:
|
||||
id: 4
|
||||
invoice_id: 4
|
||||
amount: 0
|
||||
created_at: 2016-04-05 08:35:52.934725000 Z
|
||||
updated_at: 2016-04-05 08:35:52.934725000 Z
|
||||
created_at: '2016-04-05 08:35:52.934725'
|
||||
updated_at: '2021-05-27 09:26:26.468890'
|
||||
description: Formation Laser / Vinyle April 11, 2012 08:00 - 12:00 PM
|
||||
subscription_id:
|
||||
invoice_item_id:
|
||||
footprint: 3f126c4491694667ab27cfdb47c07a09206af53a8b1f1d28d44163eb86af38ec
|
||||
|
||||
footprint: 7d9cad2ae8bcd239ed85def9bb6df3bef6600e6821d2fbf5c897ce4a562c26a5
|
||||
object_type: Reservation
|
||||
object_id: 1
|
||||
main: true
|
||||
invoice_item_5:
|
||||
id: 5
|
||||
invoice_id: 5
|
||||
amount: 1500
|
||||
created_at: 2016-04-05 08:36:46.856021000 Z
|
||||
updated_at: 2016-04-05 08:36:46.856021000 Z
|
||||
created_at: '2016-04-05 08:36:46.856021'
|
||||
updated_at: '2021-05-27 09:26:26.472232'
|
||||
description: Imprimante 3D June 15, 2015 12:00 - 01:00 PM
|
||||
subscription_id:
|
||||
invoice_item_id:
|
||||
footprint: 87d8628ce5a04a4dac5b1ada61efaec6c88b47da7786000f7d0c3473b0fc0b9c
|
||||
|
||||
footprint: e3c924b00bb7c24f7082fb15683660e371b940abe2c8f983b5a60f958652241b
|
||||
object_type: Reservation
|
||||
object_id: 2
|
||||
main: true
|
||||
invoice_item_6:
|
||||
id: 6
|
||||
invoice_id: 6
|
||||
amount: 3000
|
||||
created_at: 2016-04-05 08:36:46.856021000 Z
|
||||
updated_at: 2016-04-05 08:36:46.856021000 Z
|
||||
created_at: '2016-04-05 08:36:46.856021'
|
||||
updated_at: '2021-05-27 09:26:26.475460'
|
||||
description: Mensuel - standard, association - month
|
||||
subscription_id: 3
|
||||
invoice_item_id:
|
||||
footprint: 8260f054db6b70570db87488b3d4ffe170c9b290abead53ecec21ff3d9c78a9e
|
||||
|
||||
|
||||
footprint: ab4277c9ccb4cbe7281646f4043adfe40064f58f5e9a34cf0d822143c02e0d56
|
||||
object_type: Subscription
|
||||
object_id: 4
|
||||
main: true
|
||||
|
98
test/fixtures/invoices.yml
vendored
98
test/fixtures/invoices.yml
vendored
@ -1,13 +1,9 @@
|
||||
|
||||
invoice_1:
|
||||
id: 1
|
||||
invoiced_id: 1
|
||||
invoiced_type: Subscription
|
||||
total: 10000
|
||||
created_at: 2012-03-12 11:03:31.651441000 Z
|
||||
updated_at: 2012-03-12 11:03:31.651441000 Z
|
||||
invoicing_profile_id: 3
|
||||
statistic_profile_id: 3
|
||||
created_at: '2012-03-12 11:03:31.651441'
|
||||
updated_at: '2021-05-27 09:26:26.481266'
|
||||
reference: 1604001/VL
|
||||
payment_method: card
|
||||
avoir_date:
|
||||
@ -15,19 +11,19 @@ invoice_1:
|
||||
type:
|
||||
subscription_to_expire:
|
||||
description:
|
||||
footprint: e5d2e58c7735b8eca8a15bb87847c527806c56f6303eceb252ab1f259c9ccc18
|
||||
wallet_amount:
|
||||
wallet_transaction_id:
|
||||
coupon_id:
|
||||
footprint: cce0e9ca7696065ac4a6ed98b4a98e057bfc4ec936db171f3e64cbe2d2db8dce
|
||||
environment: test
|
||||
invoicing_profile_id: 3
|
||||
operator_profile_id: 3
|
||||
|
||||
statistic_profile_id: 3
|
||||
invoice_2:
|
||||
id: 2
|
||||
invoiced_id: 2
|
||||
invoiced_type: Subscription
|
||||
total: 2000
|
||||
created_at: 2012-03-12 13:40:22.342717000 Z
|
||||
updated_at: 2012-03-12 13:40:22.342717000 Z
|
||||
invoicing_profile_id: 4
|
||||
statistic_profile_id: 4
|
||||
created_at: '2012-03-12 13:40:22.342717'
|
||||
updated_at: '2021-05-27 09:26:26.485839'
|
||||
reference: '1604002'
|
||||
payment_method:
|
||||
avoir_date:
|
||||
@ -35,19 +31,19 @@ invoice_2:
|
||||
type:
|
||||
subscription_to_expire:
|
||||
description:
|
||||
footprint: ddd6c6ca1e239093745a94de5c72a229841f48e047ca4615f4df618008243913
|
||||
wallet_amount:
|
||||
wallet_transaction_id:
|
||||
coupon_id:
|
||||
footprint: a52f746c7010b30be4affbfb155efe2c601ee9f6264c2f47fbf6397db9bf77c3
|
||||
environment: test
|
||||
invoicing_profile_id: 4
|
||||
operator_profile_id: 1
|
||||
|
||||
statistic_profile_id: 4
|
||||
invoice_3:
|
||||
id: 3
|
||||
invoiced_id: 3
|
||||
invoiced_type: Subscription
|
||||
total: 3000
|
||||
created_at: 2015-06-10 11:20:01.341130000 Z
|
||||
updated_at: 2015-06-10 11:20:01.341130000 Z
|
||||
invoicing_profile_id: 7
|
||||
statistic_profile_id: 7
|
||||
created_at: '2015-06-10 11:20:01.341130'
|
||||
updated_at: '2021-05-27 09:26:26.489945'
|
||||
reference: '1203001'
|
||||
payment_method:
|
||||
avoir_date:
|
||||
@ -55,20 +51,19 @@ invoice_3:
|
||||
type:
|
||||
subscription_to_expire:
|
||||
description:
|
||||
footprint: 14e4182aed0e62b75797918f51b0019ce6a5537bcd750f3fac3e21a23eaf058b
|
||||
wallet_amount:
|
||||
wallet_transaction_id:
|
||||
coupon_id:
|
||||
footprint: 55a339b3e10e0d5f1a1047898fa11b64a05088c9c1f0a2fd3108af4a03ac9330
|
||||
environment: test
|
||||
invoicing_profile_id: 7
|
||||
operator_profile_id: 1
|
||||
|
||||
|
||||
statistic_profile_id: 7
|
||||
invoice_4:
|
||||
id: 4
|
||||
invoiced_id: 1
|
||||
invoiced_type: Reservation
|
||||
total: 0
|
||||
created_at: 2016-04-05 08:35:52.931187000 Z
|
||||
updated_at: 2016-04-05 08:35:52.931187000 Z
|
||||
invoicing_profile_id: 7
|
||||
statistic_profile_id: 7
|
||||
created_at: '2016-04-05 08:35:52.931187'
|
||||
updated_at: '2021-05-27 09:26:26.494005'
|
||||
reference: '1203002'
|
||||
payment_method:
|
||||
avoir_date:
|
||||
@ -76,19 +71,19 @@ invoice_4:
|
||||
type:
|
||||
subscription_to_expire:
|
||||
description:
|
||||
footprint: ed8c9d3d44e7366c41aee308630697b04072251775760752faabddc6838bdefc
|
||||
wallet_amount:
|
||||
wallet_transaction_id:
|
||||
coupon_id:
|
||||
footprint: db3e6d35ff48c8b86a81fe40fc62547839d91e6d7b80c56a69e3c4bcc9a8aabf
|
||||
environment: test
|
||||
invoicing_profile_id: 7
|
||||
operator_profile_id: 1
|
||||
|
||||
statistic_profile_id: 7
|
||||
invoice_5:
|
||||
id: 5
|
||||
invoiced_id: 2
|
||||
invoiced_type: Reservation
|
||||
total: 1500
|
||||
created_at: 2016-04-05 08:36:46.853368000 Z
|
||||
updated_at: 2016-04-05 08:36:46.853368000 Z
|
||||
invoicing_profile_id: 3
|
||||
statistic_profile_id: 3
|
||||
created_at: '2016-04-05 08:36:46.853368'
|
||||
updated_at: '2021-05-27 09:26:26.498207'
|
||||
reference: '1506031'
|
||||
payment_method:
|
||||
avoir_date:
|
||||
@ -96,19 +91,19 @@ invoice_5:
|
||||
type:
|
||||
subscription_to_expire:
|
||||
description:
|
||||
footprint: 6f485d579c1ed782f5ebe3069425cb06d634fcf4928f594c17daa3e7ebff7e45
|
||||
wallet_amount:
|
||||
wallet_transaction_id:
|
||||
coupon_id:
|
||||
footprint: e9afb3ba8863ab640d704996e2c6667c43815a38400fd31be58b764e106f9949
|
||||
environment: test
|
||||
invoicing_profile_id: 3
|
||||
operator_profile_id: 1
|
||||
|
||||
statistic_profile_id: 3
|
||||
invoice_6:
|
||||
id: 6
|
||||
invoiced_id: 4
|
||||
invoiced_type: Subscription
|
||||
total: 3000
|
||||
created_at: 2021-01-04 14:51:21.616153182 Z
|
||||
updated_at: 2021-01-04 14:51:21.616153182 Z
|
||||
invoicing_profile_id: 8
|
||||
statistic_profile_id: 8
|
||||
created_at: '2021-01-04 14:51:21.616153'
|
||||
updated_at: '2021-05-27 09:26:26.502330'
|
||||
reference: '2101041'
|
||||
payment_method:
|
||||
avoir_date:
|
||||
@ -116,8 +111,11 @@ invoice_6:
|
||||
type:
|
||||
subscription_to_expire:
|
||||
description:
|
||||
footprint: c2145b1c5f1da55643e84cc8e37f82f6327220bf51d58558ab092b70db54b115
|
||||
wallet_amount:
|
||||
wallet_transaction_id:
|
||||
coupon_id:
|
||||
footprint: 80a06501ce96d2743aa917d17793fd31267122c11e01639b0e0fc7799e6526c0
|
||||
environment: test
|
||||
invoicing_profile_id: 8
|
||||
operator_profile_id: 1
|
||||
|
||||
|
||||
statistic_profile_id: 8
|
||||
|
Loading…
x
Reference in New Issue
Block a user