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

database migration to event price category

This commit is contained in:
Sylvain 2016-08-30 18:30:21 +02:00
parent 4c9879768b
commit e281a20ada
4 changed files with 42 additions and 3 deletions

View File

@ -315,4 +315,9 @@ en:
type: "Type"
revenue: "Revenue"
male: "Man"
female: "Woman"
female: "Woman"
price_category:
# initial price's category for events, created to replace the old "reduced amount" property
reduced_fare: "Reduced fare"
reduced_fare_if_you_are_under_25_student_or_unemployed: "Reduced fare if you are under 25, student or unemployed."

View File

@ -315,4 +315,9 @@ fr:
type: "Type"
revenue: "Chiffre d'affaires"
male: "Homme"
female: "Femme"
female: "Femme"
price_category:
# catégorie initiale de prix pour les évènements, en remplacement de l'ancienne propriété "montant réduit"
reduced_fare: "Tarif réduit"
reduced_fare_if_you_are_under_25_student_or_unemployed: "Tarif réduit si vous avez moins de 25 ans, que vous êtes étudiant ou demandeur d'emploi."

View File

@ -0,0 +1,29 @@
class MigrateEventReducedAmountToPriceCategory < ActiveRecord::Migration
def change
pc = PriceCategory.new(
name: I18n.t('price_category.reduced_fare'),
conditions: I18n.t('price_category.reduced_fare_if_you_are_under_25_student_or_unemployed')
)
pc.save!
Event.where.not(reduced_amount: nil).each do |event|
unless event.reduced_amount == 0 and event.amount == 0
epc = EventPriceCategory.new(
event: event,
price_category: pc,
amount: event.reduced_amount
)
epc.save!
Reservation.where(reservable_type: 'Event', reservable_id: event.id).where('nb_reserve_reduced_places > 0').each do |r|
t = Ticket.new(
reservation: r,
event_price_category: epc,
booked: r.nb_reserve_reduced_places
)
t.save!
end
end
end
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160825141326) do
ActiveRecord::Schema.define(version: 20160830154719) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"