Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/helpers/admin/bake_days_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def variant_image_attachment(variant)

def status_pill_classes(status)
{
"pending" => "bg-yellow-100 text-yellow-800",
"unpaid" => "bg-orange-100 text-orange-800",
"paid" => "bg-blue-100 text-blue-800",
"ready" => "bg-emerald-100 text-emerald-800",
Expand Down
1 change: 0 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module ApplicationHelper
def order_status_label(status)
labels = {
"pending" => "En attente",
"unpaid" => "Non payée",
"paid" => "Payée",
"ready" => "Prête",
Expand Down
3 changes: 1 addition & 2 deletions app/javascript/controllers/order_modal_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default class extends Controller {

// Déterminer la couleur du statut
const statusColors = {
'pending': 'bg-yellow-100 text-yellow-800',
'unpaid': 'bg-orange-100 text-orange-800',
'paid': 'bg-blue-100 text-blue-800',
'ready': 'bg-green-100 text-green-800',
'picked_up': 'bg-gray-100 text-gray-800',
Expand All @@ -134,7 +134,6 @@ export default class extends Controller {
}

const statusLabels = {
'pending': 'En attente',
'unpaid': 'Non payée',
'paid': 'Payée',
'ready': 'Prête',
Expand Down
3 changes: 0 additions & 3 deletions app/models/order.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class Order < ApplicationRecord
enum :status, {
pending: 0,
paid: 1,
ready: 2,
picked_up: 3,
Expand Down Expand Up @@ -47,8 +46,6 @@ def unpaid_ready?

def can_transition_to?(new_status)
case status.to_sym
when :pending
new_status.to_sym == :paid
when :paid, :unpaid
[:ready, :cancelled].include?(new_status.to_sym)
when :ready
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/admin/bake_day_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def kpis
items_count: order_items.sum(&:qty),
revenue_cents: total_cents,
variants_count: variant_stats.size,
open_orders: orders.count { |order| order.pending? || order.unpaid? },
open_orders: orders.count { |order| order.unpaid? },
ready_orders: orders.count { |order| order.ready? || order.picked_up? }
}
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/order_creation_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize(customer:, bake_day:, cart_items:, payment_intent_id: nil, paymen
def call
return false unless valid?

initial_status = @payment_method == 'cash' ? :unpaid : :pending
initial_status = @payment_method == 'cash' ? :unpaid : :paid

@order = Order.create!(
customer: @customer,
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/bake_days/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
.flex.flex-wrap.items-center.gap-2(data-filter-group)
button.rounded-full.border.border-indigo-600.bg-indigo-600.px-3.py-1.5.text-xs.font-semibold.text-white type="button" data-filter="all" data-action="dashboard-filter#change"
| Toutes
- ['pending', 'unpaid', 'paid', 'ready', 'picked_up', 'cancelled', 'no_show'].each do |order_status|
- ['unpaid', 'paid', 'ready', 'picked_up', 'cancelled', 'no_show'].each do |order_status|
button.rounded-full.border.border-slate-300.px-3.py-1.5.text-md.font-semibold.text-slate-600.hover:border-indigo-300.hover:text-indigo-600 type="button" data-filter=order_status data-action="dashboard-filter#change"
= order_status_label(order_status)
.divide-y.divide-slate-100.overflow-hidden.rounded-2xl.border.border-slate-100
Expand Down
3 changes: 1 addition & 2 deletions app/views/admin/customers/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,12 @@
<td class="px-6 py-4 whitespace-nowrap">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
<%= case order.status
when 'pending' then 'bg-yellow-100 text-yellow-800'
when 'unpaid' then 'bg-orange-100 text-orange-800'
when 'paid' then 'bg-blue-100 text-blue-800'
when 'ready' then 'bg-green-100 text-green-800'
when 'picked_up' then 'bg-gray-100 text-gray-800'
when 'no_show' then 'bg-red-100 text-red-800'
when 'cancelled' then 'bg-red-100 text-red-800'
when 'unpaid' then 'bg-orange-100 text-orange-800'
else 'bg-gray-100 text-gray-800'
end %>">
<%= order_status_label(order.status) %>
Expand Down
1 change: 0 additions & 1 deletion app/views/admin/orders/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@
<legend class="block text-sm font-medium text-gray-700">Statut de la commande</legend>
<div class="mt-2 grid grid-cols-2 gap-3">
<% status_options = {
pending: "En attente",
unpaid: "Non payée",
paid: "Payée",
ready: "Prête",
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/orders/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<%= form_with url: admin_orders_path, method: :get, local: true, class: "flex space-x-2" do |f| %>
<%= f.select :status, options_for_select([
['Tous', ''],
['En attente', 'pending'],
['Non payées', 'unpaid'],
['Payées', 'paid'],
['Prêtes', 'ready'],
['Récupérées', 'picked_up'],
Expand Down Expand Up @@ -69,7 +69,7 @@
<td class="px-6 py-4 whitespace-nowrap">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
<%= case order.status
when 'pending' then 'bg-yellow-100 text-yellow-800'
when 'unpaid' then 'bg-orange-100 text-orange-800'
when 'paid' then 'bg-blue-100 text-blue-800'
when 'ready' then 'bg-green-100 text-green-800'
when 'picked_up' then 'bg-gray-100 text-gray-800'
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/orders/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<dd class="mt-1">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
<%= case @order.status
when 'pending' then 'bg-yellow-100 text-yellow-800'
when 'unpaid' then 'bg-orange-100 text-orange-800'
when 'paid' then 'bg-blue-100 text-blue-800'
when 'ready' then 'bg-green-100 text-green-800'
when 'picked_up' then 'bg-gray-100 text-gray-800'
Expand Down
2 changes: 1 addition & 1 deletion app/views/customers/account/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<p class="font-medium text-gray-900"><%= number_to_currency(order.total_euros, unit: "€", separator: ",", delimiter: "") %></p>
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
<%= case order.status
when 'pending' then 'bg-yellow-100 text-yellow-800'
when 'unpaid' then 'bg-orange-100 text-orange-800'
when 'paid' then 'bg-blue-100 text-blue-800'
when 'ready' then 'bg-green-100 text-green-800'
when 'picked_up' then 'bg-gray-100 text-gray-800'
Expand Down
2 changes: 1 addition & 1 deletion app/views/orders/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<h2 class="text-lg font-medium text-gray-900 mb-4">Statut</h2>
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium
<%= case @order.status
when 'pending' then 'bg-yellow-100 text-yellow-800'
when 'unpaid' then 'bg-orange-100 text-orange-800'
when 'paid' then 'bg-blue-100 text-blue-800'
when 'ready' then 'bg-green-100 text-green-800'
when 'picked_up' then 'bg-gray-100 text-gray-800'
Expand Down
9 changes: 5 additions & 4 deletions prd.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Tranches de Vie is a single-tenant web application for one artisan bakery that b
- bake_days(id, baked_on date unique, cut_off_at timestamptz)
- customers(id, phone_e164 unique, first_name, last_name nullable, email nullable)
- phone_verifications(id, phone_e164, code, expires_at)
- orders(id, customer_id FK, bake_day_id FK, status enum[pending,paid,ready,picked_up,no_show,cancelled], total_cents, public_token unique)
- orders(id, customer_id FK, bake_day_id FK, status enum[unpaid,paid,ready,picked_up,no_show,cancelled], total_cents, public_token unique)
- order_items(id, order_id FK, product_variant_id FK, qty int, unit_price_cents)
- payments(id, order_id FK unique, stripe_payment_intent_id unique, status enum[succeeded,failed,refunded])
- sms_messages(id, direction enum[outbound,inbound], to_e164, from_e164, baked_on nullable, body, kind enum[confirmation,ready,refund,other], external_id)
Expand Down Expand Up @@ -134,11 +134,12 @@ Tranches de Vie is a single-tenant web application for one artisan bakery that b

# 6. Status Transitions (allowed)

- `pending` → `paid` (successful Stripe webhook)
- `paid` → `ready` (admin action) → sends ready SMS
- `unpaid` → `ready` (admin action) → sends "ready" SMS
- `paid` → `ready` (admin action) → sends "ready" SMS
- `ready` → `picked_up` (admin action)
- `ready` → `no_show` (admin action)
- `paid` → `cancelled` (full refund before cut‑off) → sends “refund” SMS
- `unpaid` → `cancelled` (admin action before cut‑off)
- `paid` → `cancelled` (full refund before cut‑off) → sends "refund" SMS
- Forbidden: reverse transitions except manual admin correction via console (out of UI flow)

# 7. Refund (before cut‑off)
Expand Down