Compare commits
2 Commits
b5c1846f2c
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 580b24bbed | |||
| a8d3bc12ae |
@@ -126,15 +126,6 @@ class OrdersController < ApplicationController
|
|||||||
@total_amount = @order.total_amount_cents
|
@total_amount = @order.total_amount_cents
|
||||||
@expiring_soon = @order.expiring_soon?
|
@expiring_soon = @order.expiring_soon?
|
||||||
|
|
||||||
# For free orders, automatically mark as paid and redirect to success
|
|
||||||
if @order.free?
|
|
||||||
@order.mark_as_paid!
|
|
||||||
session.delete(:pending_cart)
|
|
||||||
session.delete(:ticket_names)
|
|
||||||
session.delete(:draft_order_id)
|
|
||||||
return redirect_to order_path(@order), notice: "Vos billets gratuits ont été confirmés !"
|
|
||||||
end
|
|
||||||
|
|
||||||
# Create Stripe checkout session if Stripe is configured
|
# Create Stripe checkout session if Stripe is configured
|
||||||
if Rails.application.config.stripe[:secret_key].present?
|
if Rails.application.config.stripe[:secret_key].present?
|
||||||
begin
|
begin
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
class Promoter::EventsController < ApplicationController
|
class Promoter::EventsController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
before_action :ensure_can_manage_events!
|
before_action :ensure_can_manage_events!
|
||||||
before_action :set_event, only: [ :show, :edit, :update, :destroy, :publish, :unpublish, :cancel, :mark_sold_out, :mark_available, :duplicate ]
|
before_action :set_event, only: [ :show, :edit, :update, :destroy, :publish, :unpublish, :cancel, :mark_sold_out, :duplicate ]
|
||||||
|
|
||||||
# Display all events for the current promoter
|
# Display all events for the current promoter
|
||||||
def index
|
def index
|
||||||
@@ -93,16 +93,6 @@ class Promoter::EventsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Mark event as available again
|
|
||||||
def mark_available
|
|
||||||
if @event.sold_out?
|
|
||||||
@event.update(state: :published)
|
|
||||||
redirect_to promoter_event_path(@event), notice: "Event marqué comme disponible!"
|
|
||||||
else
|
|
||||||
redirect_to promoter_event_path(@event), alert: "Cet event ne peut pas être marqué comme disponible."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Duplicate an event and all its ticket types
|
# Duplicate an event and all its ticket types
|
||||||
def duplicate
|
def duplicate
|
||||||
clone_ticket_types = params[:clone_ticket_types] == "true"
|
clone_ticket_types = params[:clone_ticket_types] == "true"
|
||||||
|
|||||||
@@ -1,9 +1,2 @@
|
|||||||
module TicketsHelper
|
module TicketsHelper
|
||||||
def format_ticket_price(price_cents)
|
|
||||||
if price_cents == 0
|
|
||||||
"Gratuit"
|
|
||||||
else
|
|
||||||
number_to_currency(price_cents / 100.0, unit: "€")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
class TicketMailer < ApplicationMailer
|
class TicketMailer < ApplicationMailer
|
||||||
helper :tickets
|
|
||||||
|
|
||||||
def purchase_confirmation_order(order)
|
def purchase_confirmation_order(order)
|
||||||
@order = order
|
@order = order
|
||||||
@user = order.user
|
@user = order.user
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class Event < ApplicationRecord
|
|||||||
# Scope for published events ordered by start time
|
# Scope for published events ordered by start time
|
||||||
scope :upcoming, -> { published.where("start_time >= ?", Time.current).order(start_time: :asc) }
|
scope :upcoming, -> { published.where("start_time >= ?", Time.current).order(start_time: :asc) }
|
||||||
|
|
||||||
|
|
||||||
# === Instance Methods ===
|
# === Instance Methods ===
|
||||||
|
|
||||||
# Check if coordinates were successfully geocoded or are fallback coordinates
|
# Check if coordinates were successfully geocoded or are fallback coordinates
|
||||||
|
|||||||
@@ -116,11 +116,6 @@ class Order < ApplicationRecord
|
|||||||
promoter_payout_cents / 100.0
|
promoter_payout_cents / 100.0
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if order contains only free tickets
|
|
||||||
def free?
|
|
||||||
total_amount_cents == 0
|
|
||||||
end
|
|
||||||
|
|
||||||
# Create Stripe invoice for accounting records
|
# Create Stripe invoice for accounting records
|
||||||
#
|
#
|
||||||
# This method creates a post-payment invoice in Stripe for accounting purposes
|
# This method creates a post-payment invoice in Stripe for accounting purposes
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class Ticket < ApplicationRecord
|
|||||||
validates :qr_code, presence: true, uniqueness: true
|
validates :qr_code, presence: true, uniqueness: true
|
||||||
validates :order_id, presence: true
|
validates :order_id, presence: true
|
||||||
validates :ticket_type_id, presence: true
|
validates :ticket_type_id, presence: true
|
||||||
validates :price_cents, presence: true, numericality: { greater_than_or_equal_to: 0 }
|
validates :price_cents, presence: true, numericality: { greater_than: 0 }
|
||||||
validates :status, presence: true, inclusion: { in: %w[draft active used expired refunded] }
|
validates :status, presence: true, inclusion: { in: %w[draft active used expired refunded] }
|
||||||
validates :first_name, presence: true
|
validates :first_name, presence: true
|
||||||
validates :last_name, presence: true
|
validates :last_name, presence: true
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class TicketType < ApplicationRecord
|
|||||||
# Validations
|
# Validations
|
||||||
validates :name, presence: true, length: { minimum: 3, maximum: 50 }
|
validates :name, presence: true, length: { minimum: 3, maximum: 50 }
|
||||||
validates :description, presence: true, length: { minimum: 10, maximum: 500 }
|
validates :description, presence: true, length: { minimum: 10, maximum: 500 }
|
||||||
validates :price_cents, presence: true, numericality: { greater_than_or_equal_to: 0 }
|
validates :price_cents, presence: true, numericality: { greater_than: 0 }
|
||||||
validates :quantity, presence: true, numericality: { only_integer: true, greater_than: 0 }
|
validates :quantity, presence: true, numericality: { only_integer: true, greater_than: 0 }
|
||||||
validates :sale_start_at, presence: true
|
validates :sale_start_at, presence: true
|
||||||
validates :sale_end_at, presence: true
|
validates :sale_end_at, presence: true
|
||||||
@@ -48,10 +48,6 @@ class TicketType < ApplicationRecord
|
|||||||
[ quantity - tickets.count, 0 ].max
|
[ quantity - tickets.count, 0 ].max
|
||||||
end
|
end
|
||||||
|
|
||||||
def free?
|
|
||||||
price_cents == 0
|
|
||||||
end
|
|
||||||
|
|
||||||
def sales_status
|
def sales_status
|
||||||
return :draft if sale_start_at.nil? || sale_end_at.nil?
|
return :draft if sale_start_at.nil? || sale_end_at.nil?
|
||||||
return :expired if sale_end_at < Time.current
|
return :expired if sale_end_at < Time.current
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<p class="text-xl font-bold text-purple-700 <%= "text-gray-400" if sold_out %>">
|
<p class="text-xl font-bold text-purple-700 <%= "text-gray-400" if sold_out %>">
|
||||||
<%= format_ticket_price(price_cents) %>
|
<%= number_to_currency(price_cents / 100.0, unit: "€") %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -135,9 +135,11 @@
|
|||||||
controller: "ticket-selection",
|
controller: "ticket-selection",
|
||||||
ticket_selection_target: "form",
|
ticket_selection_target: "form",
|
||||||
ticket_selection_event_slug_value: @event.slug,
|
ticket_selection_event_slug_value: @event.slug,
|
||||||
ticket_selection_event_id_value: @event.id,
|
ticket_selection_event_id_value: @event.id,
|
||||||
ticket_selection_order_new_url_value: event_order_new_path(@event.slug, @event.id),
|
ticket_selection_order_new_url_value: event_order_new_path(@event.slug, @event.id),
|
||||||
ticket_selection_store_cart_url_value: api_v1_store_cart_path
|
ticket_selection_store_cart_url_value: api_v1_store_cart_path,
|
||||||
|
ticket_selection_order_new_url_value: event_order_new_path(@event.slug, @event.id),
|
||||||
|
ticket_selection_store_cart_url_value: api_v1_store_cart_path
|
||||||
} do |form| %>
|
} do |form| %>
|
||||||
|
|
||||||
<div class="bg-gradient-to-br from-purple-50 to-indigo-50 rounded-2xl border border-purple-100 p-6 shadow-sm">
|
<div class="bg-gradient-to-br from-purple-50 to-indigo-50 rounded-2xl border border-purple-100 p-6 shadow-sm">
|
||||||
|
|||||||
@@ -132,14 +132,10 @@
|
|||||||
<div class="bg-blue-50 border border-blue-200 rounded-2xl p-4">
|
<div class="bg-blue-50 border border-blue-200 rounded-2xl p-4">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<i data-lucide="users" class="w-5 h-5 text-blue-400 mr-3"></i>
|
<i data-lucide="users" class="w-5 h-5 text-blue-400 mr-3"></i>
|
||||||
<div class="flex-1">
|
<div>
|
||||||
<h3 class="text-sm font-medium text-blue-900">Événement complet</h3>
|
<h3 class="text-sm font-medium text-blue-900">Événement complet</h3>
|
||||||
<p class="text-sm text-blue-700">Tous les billets pour cet événement ont été vendus.</p>
|
<p class="text-sm text-blue-700">Tous les billets pour cet événement ont été vendus.</p>
|
||||||
</div>
|
</div>
|
||||||
<%= button_to mark_available_promoter_event_path(@event), method: :patch, class: "ml-4 inline-flex items-center px-3 py-1 bg-white border border-blue-300 text-blue-700 text-sm font-medium rounded-lg hover:bg-blue-50 transition-colors duration-200" do %>
|
|
||||||
<i data-lucide="refresh-ccw" class="w-4 h-4 mr-1"></i>
|
|
||||||
Marquer comme disponible
|
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -277,19 +273,10 @@
|
|||||||
<i data-lucide="ticket" class="w-4 h-4 mr-2"></i>
|
<i data-lucide="ticket" class="w-4 h-4 mr-2"></i>
|
||||||
Gérer les types de billets
|
Gérer les types de billets
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<%= button_to mark_sold_out_promoter_event_path(@event), method: :patch, class: "w-full inline-flex items-center justify-center px-4 py-3 bg-gray-50 text-gray-700 font-medium text-sm rounded-lg hover:bg-gray-100 transition-colors duration-200", disabled: !@event.published? do %>
|
||||||
<% if @event.sold_out? %>
|
<i data-lucide="users" class="w-4 h-4 mr-2"></i>
|
||||||
<%= button_to mark_available_promoter_event_path(@event), method: :patch, class: "w-full inline-flex items-center justify-center px-4 py-3 bg-blue-50 text-blue-700 font-medium text-sm rounded-lg hover:bg-blue-100 transition-colors duration-200" do %>
|
Marquer comme complet
|
||||||
<i data-lucide="refresh-ccw" class="w-4 h-4 mr-2"></i>
|
|
||||||
Marquer comme disponible
|
|
||||||
<% end %>
|
|
||||||
<% elsif @event.published? %>
|
|
||||||
<%= button_to mark_sold_out_promoter_event_path(@event), method: :patch, class: "w-full inline-flex items-center justify-center px-4 py-3 bg-gray-50 text-gray-700 font-medium text-sm rounded-lg hover:bg-gray-100 transition-colors duration-200" do %>
|
|
||||||
<i data-lucide="users" class="w-4 h-4 mr-2"></i>
|
|
||||||
Marquer comme complet
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<hr class="border-gray-200">
|
<hr class="border-gray-200">
|
||||||
<%= button_to promoter_event_path(@event), method: :delete,
|
<%= button_to promoter_event_path(@event), method: :delete,
|
||||||
data: { confirm: "Êtes-vous sûr de vouloir supprimer cet événement ? Cette action est irréversible." },
|
data: { confirm: "Êtes-vous sûr de vouloir supprimer cet événement ? Cette action est irréversible." },
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
<div class="relative">
|
<div class="relative">
|
||||||
<%= form.number_field :price_euros,
|
<%= form.number_field :price_euros,
|
||||||
step: 0.01,
|
step: 0.01,
|
||||||
min: 0,
|
min: 0.01,
|
||||||
class: "w-full px-4 py-2 pl-8 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent",
|
class: "w-full px-4 py-2 pl-8 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent",
|
||||||
data: { "ticket-type-form-target": "price", action: "input->ticket-type-form#updateTotal" } %>
|
data: { "ticket-type-form-target": "price", action: "input->ticket-type-form#updateTotal" } %>
|
||||||
<div class="absolute left-3 top-2.5 text-gray-500">€</div>
|
<div class="absolute left-3 top-2.5 text-gray-500">€</div>
|
||||||
@@ -91,8 +91,6 @@
|
|||||||
<i data-lucide="alert-triangle" class="w-4 h-4 inline mr-1"></i>
|
<i data-lucide="alert-triangle" class="w-4 h-4 inline mr-1"></i>
|
||||||
Modifier le prix n'affectera pas les billets déjà vendus
|
Modifier le prix n'affectera pas les billets déjà vendus
|
||||||
</p>
|
</p>
|
||||||
<% else %>
|
|
||||||
<p class="mt-1 text-sm text-gray-500">Prix unitaire du billet (0€ pour un billet gratuit)</p>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -165,10 +163,8 @@
|
|||||||
<div class="flex">
|
<div class="flex">
|
||||||
<i data-lucide="info" class="w-5 h-5 text-blue-400 mt-0.5 mr-2"></i>
|
<i data-lucide="info" class="w-5 h-5 text-blue-400 mt-0.5 mr-2"></i>
|
||||||
<p class="text-sm text-blue-800">
|
<p class="text-sm text-blue-800">
|
||||||
<strong>Début d'événement :</strong> <%= @event.start_time.strftime("%d/%m/%Y à %H:%M") %><br>
|
<strong>Événement:</strong> <%= @event.start_time.strftime("%d/%m/%Y à %H:%M") %><br>
|
||||||
<% unless @event.allow_booking_during_event? %>
|
Les ventes doivent se terminer avant le début de l'événement.
|
||||||
Les ventes doivent se terminer avant le début de l'événement.
|
|
||||||
<% end %>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -212,6 +208,12 @@
|
|||||||
<%= link_to promoter_event_ticket_type_path(@event, @ticket_type), class: "text-gray-500 hover:text-gray-700 transition-colors" do %>
|
<%= link_to promoter_event_ticket_type_path(@event, @ticket_type), class: "text-gray-500 hover:text-gray-700 transition-colors" do %>
|
||||||
Annuler
|
Annuler
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if @ticket_type.tickets.any? %>
|
||||||
|
<p class="text-sm text-yellow-600">
|
||||||
|
<i data-lucide="info" class="w-4 h-4 inline mr-1"></i>
|
||||||
|
<%= pluralize(@ticket_type.tickets.count, 'billet') %> déjà vendu(s)
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center space-x-3">
|
<div class="flex items-center space-x-3">
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
<!-- Basic Information -->
|
<!-- Basic Information -->
|
||||||
<div class="bg-white rounded-lg border border-gray-200 p-6">
|
<div class="bg-white rounded-lg border border-gray-200 p-6">
|
||||||
<h3 class="text-lg font-semibold text-gray-900 mb-6">Informations générales</h3>
|
<h3 class="text-lg font-semibold text-gray-900 mb-6">Informations générales</h3>
|
||||||
|
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
<div>
|
<div>
|
||||||
<%= form.label :name, "Nom du type de billet", class: "block text-sm font-medium text-gray-700 mb-2" %>
|
<%= form.label :name, "Nom du type de billet", class: "block text-sm font-medium text-gray-700 mb-2" %>
|
||||||
@@ -61,25 +61,25 @@
|
|||||||
<!-- Pricing & Quantity -->
|
<!-- Pricing & Quantity -->
|
||||||
<div class="bg-white rounded-lg border border-gray-200 p-6">
|
<div class="bg-white rounded-lg border border-gray-200 p-6">
|
||||||
<h3 class="text-lg font-semibold text-gray-900 mb-6">Prix et quantité</h3>
|
<h3 class="text-lg font-semibold text-gray-900 mb-6">Prix et quantité</h3>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
<div>
|
<div>
|
||||||
<%= form.label :price_euros, "Prix (€)", class: "block text-sm font-medium text-gray-700 mb-2" %>
|
<%= form.label :price_euros, "Prix (€)", class: "block text-sm font-medium text-gray-700 mb-2" %>
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<%= form.number_field :price_euros,
|
<%= form.number_field :price_euros,
|
||||||
step: 0.01,
|
step: 0.01,
|
||||||
min: 0,
|
min: 0.01,
|
||||||
class: "w-full px-4 py-2 pl-8 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent",
|
class: "w-full px-4 py-2 pl-8 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent",
|
||||||
data: { "ticket-type-form-target": "price", action: "input->ticket-type-form#updateTotal" } %>
|
data: { "ticket-type-form-target": "price", action: "input->ticket-type-form#updateTotal" } %>
|
||||||
<div class="absolute left-3 top-2.5 text-gray-500">€</div>
|
<div class="absolute left-3 top-2.5 text-gray-500">€</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-1 text-sm text-gray-500">Prix unitaire du billet (0€ pour un billet gratuit)</p>
|
<p class="mt-1 text-sm text-gray-500">Prix unitaire du billet</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<%= form.label :quantity, "Quantité disponible", class: "block text-sm font-medium text-gray-700 mb-2" %>
|
<%= form.label :quantity, "Quantité disponible", class: "block text-sm font-medium text-gray-700 mb-2" %>
|
||||||
<%= form.number_field :quantity,
|
<%= form.number_field :quantity,
|
||||||
min: 1,
|
min: 1,
|
||||||
class: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent",
|
class: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent",
|
||||||
data: { "ticket-type-form-target": "quantity", action: "input->ticket-type-form#updateTotal" } %>
|
data: { "ticket-type-form-target": "quantity", action: "input->ticket-type-form#updateTotal" } %>
|
||||||
<p class="mt-1 text-sm text-gray-500">Nombre total de billets de ce type</p>
|
<p class="mt-1 text-sm text-gray-500">Nombre total de billets de ce type</p>
|
||||||
@@ -100,18 +100,18 @@
|
|||||||
<!-- Sales Period -->
|
<!-- Sales Period -->
|
||||||
<div class="bg-white rounded-lg border border-gray-200 p-6">
|
<div class="bg-white rounded-lg border border-gray-200 p-6">
|
||||||
<h3 class="text-lg font-semibold text-gray-900 mb-6">Période de vente</h3>
|
<h3 class="text-lg font-semibold text-gray-900 mb-6">Période de vente</h3>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
<div>
|
<div>
|
||||||
<%= form.label :sale_start_at, "Début des ventes", class: "block text-sm font-medium text-gray-700 mb-2" %>
|
<%= form.label :sale_start_at, "Début des ventes", class: "block text-sm font-medium text-gray-700 mb-2" %>
|
||||||
<%= form.datetime_local_field :sale_start_at,
|
<%= form.datetime_local_field :sale_start_at,
|
||||||
value: @ticket_type.sale_start_at&.strftime("%Y-%m-%dT%H:%M"),
|
value: @ticket_type.sale_start_at&.strftime("%Y-%m-%dT%H:%M"),
|
||||||
class: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent" %>
|
class: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<%= form.label :sale_end_at, "Fin des ventes", class: "block text-sm font-medium text-gray-700 mb-2" %>
|
<%= form.label :sale_end_at, "Fin des ventes", class: "block text-sm font-medium text-gray-700 mb-2" %>
|
||||||
<%= form.datetime_local_field :sale_end_at,
|
<%= form.datetime_local_field :sale_end_at,
|
||||||
value: @ticket_type.sale_end_at&.strftime("%Y-%m-%dT%H:%M"),
|
value: @ticket_type.sale_end_at&.strftime("%Y-%m-%dT%H:%M"),
|
||||||
class: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent" %>
|
class: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent" %>
|
||||||
<p class="mt-1 text-sm text-gray-500">Les ventes s'arrêtent automatiquement à cette date</p>
|
<p class="mt-1 text-sm text-gray-500">Les ventes s'arrêtent automatiquement à cette date</p>
|
||||||
@@ -123,11 +123,8 @@
|
|||||||
<div class="flex">
|
<div class="flex">
|
||||||
<i data-lucide="info" class="w-5 h-5 text-blue-400 mt-0.5 mr-2"></i>
|
<i data-lucide="info" class="w-5 h-5 text-blue-400 mt-0.5 mr-2"></i>
|
||||||
<p class="text-sm text-blue-800">
|
<p class="text-sm text-blue-800">
|
||||||
<strong>Début d'événement :</strong> <%= @event.start_time.strftime("%d/%m/%Y à %H:%M") %><br>
|
<strong>Événement:</strong> <%= @event.start_time.strftime("%d/%m/%Y à %H:%M") %><br>
|
||||||
|
Les ventes doivent se terminer avant le début de l'événement.
|
||||||
<% unless @event.allow_booking_during_event? %>
|
|
||||||
Les ventes doivent se terminer avant le début de l'événement.
|
|
||||||
<% end %>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -137,13 +134,13 @@
|
|||||||
<!-- Access Requirements -->
|
<!-- Access Requirements -->
|
||||||
<div class="bg-white rounded-lg border border-gray-200 p-6">
|
<div class="bg-white rounded-lg border border-gray-200 p-6">
|
||||||
<h3 class="text-lg font-semibold text-gray-900 mb-6">Conditions d'accès</h3>
|
<h3 class="text-lg font-semibold text-gray-900 mb-6">Conditions d'accès</h3>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
<div>
|
<div>
|
||||||
<%= form.label :minimum_age, "Âge minimum", class: "block text-sm font-medium text-gray-700 mb-2" %>
|
<%= form.label :minimum_age, "Âge minimum", class: "block text-sm font-medium text-gray-700 mb-2" %>
|
||||||
<%= form.number_field :minimum_age,
|
<%= form.number_field :minimum_age,
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 120,
|
max: 120,
|
||||||
class: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent",
|
class: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent",
|
||||||
placeholder: "Laisser vide si aucune restriction" %>
|
placeholder: "Laisser vide si aucune restriction" %>
|
||||||
<p class="mt-1 text-sm text-gray-500">Âge minimum requis (optionnel)</p>
|
<p class="mt-1 text-sm text-gray-500">Âge minimum requis (optionnel)</p>
|
||||||
@@ -170,11 +167,11 @@
|
|||||||
Annuler
|
Annuler
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center space-x-3">
|
<div class="flex items-center space-x-3">
|
||||||
<%= form.submit "Créer le type de billet", class: "inline-flex items-center px-6 py-3 bg-purple-600 text-white font-medium rounded-lg hover:bg-purple-700 transition-colors duration-200" %>
|
<%= form.submit "Créer le type de billet", class: "inline-flex items-center px-6 py-3 bg-purple-600 text-white font-medium rounded-lg hover:bg-purple-700 transition-colors duration-200" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -138,7 +138,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<p class="text-sm font-medium text-gray-900">
|
<p class="text-sm font-medium text-gray-900">
|
||||||
<%= format_ticket_price(ticket.price_cents) %>
|
<%= number_to_currency(ticket.price_cents / 100.0, unit: "€") %>
|
||||||
</p>
|
</p>
|
||||||
<p class="text-xs text-gray-500">
|
<p class="text-xs text-gray-500">
|
||||||
<%= ticket.created_at.strftime("%d/%m/%Y") %>
|
<%= ticket.created_at.strftime("%d/%m/%Y") %>
|
||||||
@@ -164,7 +164,7 @@
|
|||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
<div class="text-center p-4 bg-purple-50 rounded-lg">
|
<div class="text-center p-4 bg-purple-50 rounded-lg">
|
||||||
<div class="text-3xl font-bold text-purple-600">
|
<div class="text-3xl font-bold text-purple-600">
|
||||||
<%= format_ticket_price(@ticket_type.price_cents) %>
|
<%= number_to_currency(@ticket_type.price_euros, unit: "€") %>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-sm text-gray-500">Prix unitaire</div>
|
<div class="text-sm text-gray-500">Prix unitaire</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
<p style="margin: 5px 0 0;"><a href="<%= ticket_url(ticket) %>" style="color: #4c1d95; text-decoration: none; font-size: 14px;">📱 Voir le détail et le code QR</a></p>
|
<p style="margin: 5px 0 0;"><a href="<%= ticket_url(ticket) %>" style="color: #4c1d95; text-decoration: none; font-size: 14px;">📱 Voir le détail et le code QR</a></p>
|
||||||
</div>
|
</div>
|
||||||
<div style="text-align: right;">
|
<div style="text-align: right;">
|
||||||
<p style="margin: 0; font-weight: bold; color: #212529;"><%= format_ticket_price(ticket.price_cents) %></p>
|
<p style="margin: 0; font-weight: bold; color: #212529;"><%= number_to_currency(ticket.price_cents / 100.0, unit: "€") %></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div style="text-align: right;">
|
<div style="text-align: right;">
|
||||||
<p style="margin: 0; color: #6c757d; font-size: 14px;">Prix</p>
|
<p style="margin: 0; color: #6c757d; font-size: 14px;">Prix</p>
|
||||||
<p style="margin: 5px 0 0; font-weight: bold; color: #212529;"><%= format_ticket_price(@ticket.price_cents) %></p>
|
<p style="margin: 5px 0 0; font-weight: bold; color: #212529;"><%= number_to_currency(@ticket.price_cents / 100.0, unit: "€") %></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ DÉTAILS DE VOTRE COMMANDE
|
|||||||
Événement : <%= @event.name %>
|
Événement : <%= @event.name %>
|
||||||
Date & heure : <%= @event.start_time.strftime("%d %B %Y à %H:%M") %>
|
Date & heure : <%= @event.start_time.strftime("%d %B %Y à %H:%M") %>
|
||||||
Nombre de billets : <%= @tickets.count %>
|
Nombre de billets : <%= @tickets.count %>
|
||||||
Total : <%= @order.free? ? "Gratuit" : number_to_currency(@order.total_amount_euros, unit: "€") %>
|
Total : <%= number_to_currency(@order.total_amount_euros, unit: "€") %>
|
||||||
|
|
||||||
BILLETS INCLUS :
|
BILLETS INCLUS :
|
||||||
<% @tickets.each_with_index do |ticket, index| %>
|
<% @tickets.each_with_index do |ticket, index| %>
|
||||||
- Billet #<%= index + 1 %> : <%= ticket.ticket_type.name %> - <%= format_ticket_price(ticket.price_cents) %>
|
- Billet #<%= index + 1 %> : <%= ticket.ticket_type.name %> - <%= number_to_currency(ticket.price_cents / 100.0, unit: "€") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
Vos billets sont attachés à cet email en format PDF. Présentez-les à l'entrée de l'événement pour y accéder.
|
Vos billets sont attachés à cet email en format PDF. Présentez-les à l'entrée de l'événement pour y accéder.
|
||||||
@@ -32,7 +32,7 @@ DÉTAILS DE VOTRE BILLET
|
|||||||
Événement : <%= @event.name %>
|
Événement : <%= @event.name %>
|
||||||
Type de billet : <%= @ticket.ticket_type.name %>
|
Type de billet : <%= @ticket.ticket_type.name %>
|
||||||
Date & heure : <%= @event.start_time.strftime("%d %B %Y à %H:%M") %>
|
Date & heure : <%= @event.start_time.strftime("%d %B %Y à %H:%M") %>
|
||||||
Prix : <%= format_ticket_price(@ticket.price_cents) %>
|
Prix : <%= number_to_currency(@ticket.price_cents / 100.0, unit: "€") %>
|
||||||
|
|
||||||
Votre billet est attaché à cet email en format PDF. Présentez-le à l'entrée de l'événement pour y accéder.
|
Votre billet est attaché à cet email en format PDF. Présentez-le à l'entrée de l'événement pour y accéder.
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-500 mb-1">Prix</label>
|
<label class="block text-sm font-medium text-gray-500 mb-1">Prix</label>
|
||||||
<p class="text-xl font-bold text-gray-900">
|
<p class="text-xl font-bold text-gray-900">
|
||||||
<%= format_ticket_price(@ticket.price_cents) %>
|
<%= number_to_currency(@ticket.price_euros, unit: "€", separator: ",", delimiter: " ", format: "%n %u") %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ Rails.application.routes.draw do
|
|||||||
patch :unpublish
|
patch :unpublish
|
||||||
patch :cancel
|
patch :cancel
|
||||||
patch :mark_sold_out
|
patch :mark_sold_out
|
||||||
patch :mark_available
|
|
||||||
post :duplicate
|
post :duplicate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ class OrdersControllerTest < ActionDispatch::IntegrationTest
|
|||||||
assert_equal "draft", new_order.status
|
assert_equal "draft", new_order.status
|
||||||
assert_equal @user, new_order.user
|
assert_equal @user, new_order.user
|
||||||
assert_equal @event, new_order.event
|
assert_equal @event, new_order.event
|
||||||
assert_equal @ticket_type.price_cents, new_order.total_amount_cents # Service fee deducted from promoter payout, not added to customer
|
assert_equal @ticket_type.price_cents + 100, new_order.total_amount_cents # includes 1€ service fee
|
||||||
|
|
||||||
assert_redirected_to checkout_order_path(new_order)
|
assert_redirected_to checkout_order_path(new_order)
|
||||||
assert_equal new_order.id, session[:draft_order_id]
|
assert_equal new_order.id, session[:draft_order_id]
|
||||||
|
|||||||
@@ -603,22 +603,4 @@ class OrderTest < ActiveSupport::TestCase
|
|||||||
result = order.stripe_invoice_pdf_url
|
result = order.stripe_invoice_pdf_url
|
||||||
assert_nil result
|
assert_nil result
|
||||||
end
|
end
|
||||||
|
|
||||||
test "free? should return true for zero amount orders" do
|
|
||||||
free_order = Order.create!(
|
|
||||||
user: @user, event: @event, total_amount_cents: 0,
|
|
||||||
status: "draft", payment_attempts: 0
|
|
||||||
)
|
|
||||||
|
|
||||||
assert free_order.free?
|
|
||||||
end
|
|
||||||
|
|
||||||
test "free? should return false for non-zero amount orders" do
|
|
||||||
paid_order = Order.create!(
|
|
||||||
user: @user, event: @event, total_amount_cents: 1000,
|
|
||||||
status: "draft", payment_attempts: 0
|
|
||||||
)
|
|
||||||
|
|
||||||
assert_not paid_order.free?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -244,38 +244,4 @@ class TicketTypeTest < ActiveSupport::TestCase
|
|||||||
)
|
)
|
||||||
assert_not ticket_type.save
|
assert_not ticket_type.save
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should allow free tickets with zero price" do
|
|
||||||
user = User.create!(
|
|
||||||
email: "test@example.com",
|
|
||||||
password: "password123",
|
|
||||||
password_confirmation: "password123"
|
|
||||||
)
|
|
||||||
|
|
||||||
event = Event.create!(
|
|
||||||
name: "Test Event",
|
|
||||||
slug: "test-event",
|
|
||||||
description: "Valid description for the event that is long enough",
|
|
||||||
latitude: 48.8566,
|
|
||||||
longitude: 2.3522,
|
|
||||||
venue_name: "Test Venue",
|
|
||||||
venue_address: "123 Test Street",
|
|
||||||
user: user
|
|
||||||
)
|
|
||||||
|
|
||||||
ticket_type = TicketType.new(
|
|
||||||
name: "Free Ticket",
|
|
||||||
description: "Valid description for the free ticket type",
|
|
||||||
price_cents: 0,
|
|
||||||
quantity: 50,
|
|
||||||
sale_start_at: Time.current,
|
|
||||||
sale_end_at: Time.current + 1.day,
|
|
||||||
event: event
|
|
||||||
)
|
|
||||||
|
|
||||||
assert ticket_type.save
|
|
||||||
assert ticket_type.free?
|
|
||||||
assert_equal 0, ticket_type.price_cents
|
|
||||||
assert_equal 0.0, ticket_type.price_euros
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -210,12 +210,25 @@ class StripeInvoiceServiceTest < ActiveSupport::TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expected_service_fee_line_item = {
|
||||||
|
customer: "cus_test123",
|
||||||
|
invoice: "in_test123",
|
||||||
|
amount: 100,
|
||||||
|
currency: "eur",
|
||||||
|
description: "Frais de service - Frais de traitement de la commande",
|
||||||
|
metadata: {
|
||||||
|
item_type: "service_fee",
|
||||||
|
amount_cents: 100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mock_invoice = mock("invoice")
|
mock_invoice = mock("invoice")
|
||||||
mock_invoice.stubs(:id).returns("in_test123")
|
mock_invoice.stubs(:id).returns("in_test123")
|
||||||
mock_invoice.stubs(:finalize_invoice).returns(mock_invoice)
|
mock_invoice.stubs(:finalize_invoice).returns(mock_invoice)
|
||||||
mock_invoice.expects(:pay)
|
mock_invoice.expects(:pay)
|
||||||
Stripe::Invoice.expects(:create).returns(mock_invoice)
|
Stripe::Invoice.expects(:create).returns(mock_invoice)
|
||||||
Stripe::InvoiceItem.expects(:create).with(expected_ticket_line_item) # Only for tickets, no service fee
|
Stripe::InvoiceItem.expects(:create).with(expected_ticket_line_item)
|
||||||
|
Stripe::InvoiceItem.expects(:create).with(expected_service_fee_line_item)
|
||||||
|
|
||||||
result = @service.create_post_payment_invoice
|
result = @service.create_post_payment_invoice
|
||||||
assert_not_nil result
|
assert_not_nil result
|
||||||
|
|||||||
Reference in New Issue
Block a user