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:
parent
4c9879768b
commit
e281a20ada
@ -315,4 +315,9 @@ en:
|
|||||||
type: "Type"
|
type: "Type"
|
||||||
revenue: "Revenue"
|
revenue: "Revenue"
|
||||||
male: "Man"
|
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."
|
@ -315,4 +315,9 @@ fr:
|
|||||||
type: "Type"
|
type: "Type"
|
||||||
revenue: "Chiffre d'affaires"
|
revenue: "Chiffre d'affaires"
|
||||||
male: "Homme"
|
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."
|
@ -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
|
@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user