diff --git a/backlog/features.json b/backlog/features.json index 85316c5..84bca50 100644 --- a/backlog/features.json +++ b/backlog/features.json @@ -8120,6 +8120,22 @@ }, "phase": "admin", "completed_at": "2026-08-26T18:55:00Z" + }, + { + "id": "ORDER-STATUS-COMPLETED", + "type": "fix", + "title": "Order status COMPLETED in admin dashboard and orders pages", + "description": "POS sales use COMPLETED order state. Show COMPLETED in admin dashboard ordersByState, orders list, and order detail pages with proper Spanish label and color. Include COMPLETED in revenue calculations.", + "priority": "med", + "risk": "low", + "status": "in_progress", + "created_at": "2026-08-26", + "gates": { + "reviewer": false, + "security": false, + "qa": false + }, + "phase": "admin" } ] } diff --git a/project/apps/admin/next-env.d.ts b/project/apps/admin/next-env.d.ts index a419cbe..ce4e94a 100644 --- a/project/apps/admin/next-env.d.ts +++ b/project/apps/admin/next-env.d.ts @@ -1,7 +1,7 @@ /// /// -import "./.next/dev/types/routes.d.ts"; -import "./.next/dev/types/root-params.d.ts"; +import "./.next/types/routes.d.ts"; +import "./.next/types/root-params.d.ts"; // NOTE: This file should not be edited // see https://nextjs.org/docs/app/api-reference/config/typescript for more information. diff --git a/project/apps/admin/src/app/(dashboard)/orders/[id]/page.tsx b/project/apps/admin/src/app/(dashboard)/orders/[id]/page.tsx index 09c9ac4..eae45f1 100644 --- a/project/apps/admin/src/app/(dashboard)/orders/[id]/page.tsx +++ b/project/apps/admin/src/app/(dashboard)/orders/[id]/page.tsx @@ -12,6 +12,7 @@ const STATE_LABELS: Record = { PROCESSING: 'En preparación', SHIPPED: 'Enviado', DELIVERED: 'Entregado', + COMPLETED: 'completado', CANCELLED: 'Cancelado', REFUNDED: 'Reembolsado', PARTIALLY_REFUNDED: 'Reembolso parcial', @@ -24,6 +25,7 @@ const STATE_COLORS: Record = { PROCESSING: 'bg-indigo-100 text-indigo-800', SHIPPED: 'bg-purple-100 text-purple-800', DELIVERED: 'bg-green-100 text-green-800', + COMPLETED: 'bg-emerald-100 text-emerald-800', CANCELLED: 'bg-red-100 text-red-800', REFUNDED: 'bg-purple-100 text-purple-800', PARTIALLY_REFUNDED: 'bg-pink-100 text-pink-800', @@ -32,10 +34,11 @@ const STATE_COLORS: Record = { const ALLOWED_TRANSITIONS: Record = { PENDING: ['AWAITING_PAYMENT', 'CANCELLED'], AWAITING_PAYMENT: ['PAID', 'CANCELLED'], - PAID: ['PROCESSING', 'CANCELLED', 'REFUNDED'], - PROCESSING: ['PAID', 'SHIPPED', 'CANCELLED', 'REFUNDED'], + PAID: ['PROCESSING', 'COMPLETED', 'CANCELLED', 'REFUNDED'], + PROCESSING: ['PAID', 'SHIPPED', 'COMPLETED', 'CANCELLED', 'REFUNDED'], SHIPPED: ['PROCESSING', 'DELIVERED', 'PARTIALLY_REFUNDED'], DELIVERED: ['SHIPPED', 'PARTIALLY_REFUNDED'], + COMPLETED: ['REFUNDED', 'PARTIALLY_REFUNDED'], CANCELLED: [], REFUNDED: [], PARTIALLY_REFUNDED: [], @@ -49,10 +52,12 @@ const ACTION_LABELS_BY_TRANSITION: Record = { 'AWAITING_PAYMENT>PAID': 'Marcar como Pagado', 'AWAITING_PAYMENT>CANCELLED': 'Cancelar pedido', 'PAID>PROCESSING': 'Preparar pedido', + 'PAID>COMPLETED': 'Marcar como completado', 'PAID>CANCELLED': 'Cancelar pedido', 'PAID>REFUNDED': 'Reembolsar', 'PROCESSING>PAID': 'Revertir a Pagado', 'PROCESSING>SHIPPED': 'Marcar como Enviado', + 'PROCESSING>COMPLETED': 'Marcar como completado', 'PROCESSING>CANCELLED': 'Cancelar pedido', 'PROCESSING>REFUNDED': 'Reembolsar', 'SHIPPED>PROCESSING': 'Revertir a En preparación', @@ -60,6 +65,8 @@ const ACTION_LABELS_BY_TRANSITION: Record = { 'SHIPPED>PARTIALLY_REFUNDED': 'Reembolso parcial', 'DELIVERED>SHIPPED': 'Revertir a Enviado', 'DELIVERED>PARTIALLY_REFUNDED': 'Reembolso parcial', + 'COMPLETED>REFUNDED': 'Reembolsar', + 'COMPLETED>PARTIALLY_REFUNDED': 'Reembolso parcial', }; function actionLabel(from: OrderState, to: OrderState): string { diff --git a/project/apps/admin/src/app/(dashboard)/orders/page.tsx b/project/apps/admin/src/app/(dashboard)/orders/page.tsx index 33f64cd..9a90c2c 100644 --- a/project/apps/admin/src/app/(dashboard)/orders/page.tsx +++ b/project/apps/admin/src/app/(dashboard)/orders/page.tsx @@ -11,6 +11,7 @@ const ORDER_STATES: OrderState[] = [ 'PROCESSING', 'SHIPPED', 'DELIVERED', + 'COMPLETED', 'CANCELLED', 'REFUNDED', 'PARTIALLY_REFUNDED', @@ -23,6 +24,7 @@ const STATE_LABELS: Record = { PROCESSING: 'En preparación', SHIPPED: 'Enviado', DELIVERED: 'Entregado', + COMPLETED: 'completado', CANCELLED: 'Cancelado', REFUNDED: 'Reembolsado', PARTIALLY_REFUNDED: 'Reembolso parcial', @@ -35,6 +37,7 @@ const STATE_COLORS: Record = { PROCESSING: 'bg-indigo-100 text-indigo-800', SHIPPED: 'bg-purple-100 text-purple-800', DELIVERED: 'bg-green-100 text-green-800', + COMPLETED: 'bg-emerald-100 text-emerald-800', CANCELLED: 'bg-red-100 text-red-800', REFUNDED: 'bg-purple-100 text-purple-800', PARTIALLY_REFUNDED: 'bg-pink-100 text-pink-800', diff --git a/project/apps/admin/src/app/(dashboard)/page.tsx b/project/apps/admin/src/app/(dashboard)/page.tsx index 2505771..1b63480 100644 --- a/project/apps/admin/src/app/(dashboard)/page.tsx +++ b/project/apps/admin/src/app/(dashboard)/page.tsx @@ -25,6 +25,7 @@ const STATE_LABELS: Record = { PROCESSING: 'Procesando', SHIPPED: 'Enviados', DELIVERED: 'Entregados', + COMPLETED: 'completados', CANCELLED: 'Cancelados', REFUNDED: 'Reembolsados', PARTIALLY_REFUNDED: 'Reembolso parcial', @@ -37,6 +38,7 @@ const STATE_COLORS: Record = { PROCESSING: 'bg-blue-100 text-blue-700', SHIPPED: 'bg-indigo-100 text-indigo-700', DELIVERED: 'bg-emerald-100 text-emerald-700', + COMPLETED: 'bg-emerald-100 text-emerald-700', CANCELLED: 'bg-gray-100 text-gray-600', REFUNDED: 'bg-red-100 text-red-700', PARTIALLY_REFUNDED: 'bg-pink-100 text-pink-700', diff --git a/project/apps/admin/src/types/index.ts b/project/apps/admin/src/types/index.ts index 6b5804d..bf75ff9 100644 --- a/project/apps/admin/src/types/index.ts +++ b/project/apps/admin/src/types/index.ts @@ -100,6 +100,7 @@ export type OrderState = | 'PROCESSING' | 'SHIPPED' | 'DELIVERED' + | 'COMPLETED' | 'CANCELLED' | 'REFUNDED' | 'PARTIALLY_REFUNDED'; diff --git a/project/src/modules/admin-stats/api/stats.routes.ts b/project/src/modules/admin-stats/api/stats.routes.ts index afd5800..bc8d3f8 100644 --- a/project/src/modules/admin-stats/api/stats.routes.ts +++ b/project/src/modules/admin-stats/api/stats.routes.ts @@ -43,12 +43,12 @@ export async function registerAdminStatsRoutes( ) .then((r) => parseInt(r.rows[0]?.count ?? '0', 10)), - // Revenue today (sum of PAID, PROCESSING, SHIPPED, DELIVERED orders) + // Revenue today (sum of PAID, PROCESSING, SHIPPED, DELIVERED, COMPLETED orders) pool .query<{ total: string }>( `SELECT COALESCE(SUM(total_cents), 0)::text AS total FROM orders_orders WHERE created_at >= CURRENT_DATE - AND state IN ('PAID','PROCESSING','SHIPPED','DELIVERED')`, + AND state IN ('PAID','PROCESSING','SHIPPED','DELIVERED','COMPLETED')`, ) .then((r) => parseInt(r.rows[0]?.total ?? '0', 10)),