diff --git a/attached_assets/Pasted-ctions-GET-api-user-401-in-2ms-GET-api-default-credentials-check-304-in-2ms--1755172560852_1755172560852.txt b/attached_assets/Pasted-ctions-GET-api-user-401-in-2ms-GET-api-default-credentials-check-304-in-2ms--1755172560852_1755172560852.txt new file mode 100644 index 0000000..64611cb --- /dev/null +++ b/attached_assets/Pasted-ctions-GET-api-user-401-in-2ms-GET-api-default-credentials-check-304-in-2ms--1755172560852_1755172560852.txt @@ -0,0 +1,204 @@ +ctions + + + + +GET /api/user 401 in 2ms + +GET /api/default-credentials-check 304 in 2ms + +πŸ” comparePasswords: { + + supplied: 'HIDDEN', + + stored: 'b23ec450a63faf3957a1...', + + hasFormat: true + +} + +πŸ” Password comparison result: true + +POST /api/login 200 in 51ms + +GET /api/user 200 in 5ms + +GET /api/user 304 in 10ms + +πŸ“Š Calcul statistiques mensuelles: { + + year: 2025, + + month: 8, + + startDate: '2025-08-01', + + endDate: '2025-09-01', + + groupIds: [ 2 ] + +} + +Orders API called with: { + + startDate: undefined, + + endDate: undefined, + + storeId: undefined, + + userRole: 'employee' + +} + +Non-admin filtering with groupIds: [ 2 ] + +Deliveries API called with: { + + startDate: undefined, + + endDate: undefined, + + storeId: undefined, + + withBL: undefined, + + userRole: 'employee' + +} + +Non-admin filtering deliveries with groupIds: [ 2 ] + +πŸ“Š Statistiques calculΓ©es: { + + ordersCount: 8, + + deliveriesCount: 21, + + pendingOrdersCount: 4, + + averageDeliveryTime: 0.17647058823529413, + + totalPalettes: 57, + + totalPackages: 17 + +} + +πŸ”— PRODUCTION: getOrders() rΓ©cupΓ©rΓ© 18 commandes avec relations + +Orders returned: 18 items + +Customer Orders API called with: { groupIds: [ 2 ], userRole: 'employee' } + +GET /api/stats/monthly 200 in 76ms + +GET /api/orders 200 in 76ms + +Customer Orders returned: 25 items + +GET /api/customer-orders 200 in 82ms + +πŸ”— PRODUCTION: getDeliveries() rΓ©cupΓ©rΓ© 38 livraisons avec relations + +Deliveries returned: 38 items + +GET /api/deliveries 200 in 91ms + +Tasks API called with: { groupIds: [ 2 ], userRole: 'employee' } + +GET /api/publicities 304 in 92ms + +GET /api/dlc-products/stats 200 in 93ms + +Tasks returned: 9 items + +GET /api/tasks 200 in 92ms + +GET /api/user 304 in 23ms + +GET /api/publicities 304 in 9ms + +GET /api/user 304 in 4ms + +GET /api/groups 200 in 5ms + +GET /api/user 304 in 7ms + +GET /api/suppliers 304 in 10ms + +GET /api/user 304 in 7ms + +πŸ” CUSTOMER ORDER PERMISSION DEBUG: { + + userRole: 'employee', + + userId: '_1753266816257', + + userGroups: [ { userId: '_1753266816257', groupId: 2, group: [Object] } ], + + requestedGroupId: 2, + + requestedGroupIdType: 'number' + +} + +πŸ” CUSTOMER ORDER - User group IDs: [ 2 ] + +πŸ” CUSTOMER ORDER - Requested group ID: 2 + +πŸ” CUSTOMER ORDER - Converted group ID: 2 + +βœ… CUSTOMER ORDER - Permission granted for user role: employee + +Error creating customer order: error: null value in column "order_taker" of relation "customer_orders" violates not-null constraint + + at /app/node_modules/pg-pool/index.js:45:11 + + at process.processTicksAndRejections (node:internal/process/task_queues:95:5) + + at async file:///app/node_modules/drizzle-orm/node-postgres/session.js:83:22 + + at async DatabaseStorage.createCustomerOrder (file:///app/dist/index.js:1823:33) + + at async file:///app/dist/index.js:5278:29 { + + length: 395, + + severity: 'ERROR', + + code: '23502', + + detail: 'Failing row contains (73, null, test, null, null, null, null, 366092323745, 1, 2, En attente de Commande, 0.00, f, f, null, 2, _1753266816257, 2025-08-14 11:55:42.977226, 2025-08-14 11:55:42.977226).', + + hint: undefined, + + position: undefined, + + internalPosition: undefined, + + internalQuery: undefined, + + where: undefined, + + schema: 'public', + + table: 'customer_orders', + + column: 'order_taker', + + dataType: undefined, + + constraint: undefined, + + file: 'execMain.c', + + line: '1972', + + routine: 'ExecConstraints' + +} + +POST /api/customer-orders 500 in 13ms + +HEAD /api/health 200 in 0ms \ No newline at end of file diff --git a/attached_assets/{A0BEA539-9B9A-450F-9538-9F154F5CBCEC}_1755172547592.png b/attached_assets/{A0BEA539-9B9A-450F-9538-9F154F5CBCEC}_1755172547592.png new file mode 100644 index 0000000..deda42e Binary files /dev/null and b/attached_assets/{A0BEA539-9B9A-450F-9538-9F154F5CBCEC}_1755172547592.png differ diff --git a/client/src/components/CustomerOrderForm.tsx b/client/src/components/CustomerOrderForm.tsx index b553761..29461ae 100644 --- a/client/src/components/CustomerOrderForm.tsx +++ b/client/src/components/CustomerOrderForm.tsx @@ -170,18 +170,21 @@ export function CustomerOrderForm({ // Prepare final data with user's assigned group const submitData = { + orderTaker: data.orderTaker || user?.firstName + ' ' + user?.lastName || user?.username || "Inconnu", customerName: data.customerName.trim(), - contactNumber: data.contactNumber || '', - productName: data.productName || '', + customerPhone: data.contactNumber || '', + customerEmail: data.customerEmail || '', + productDesignation: data.productName || '', + productReference: data.productReference || '', + gencode: data.gencode || '', quantity: data.quantity, - groupId: groupId, // Always use the assigned group - isPickup: false, - notes: data.notes, + supplierId: data.supplierId || 1, + status: data.status || "En attente de Commande", deposit: data.deposit || 0, isPromotionalPrice: data.isPromotionalPrice || false, - customerEmail: data.customerEmail, - gencode: data.gencode || '', - supplierId: data.supplierId || 1, + customerNotified: data.customerNotified || false, + notes: data.notes || '', + groupId: groupId, // Always use the assigned group }; console.log("βœ… Customer Order Submit FINAL:", { diff --git a/server/routes.ts b/server/routes.ts index d6eafb2..ba827d7 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -1384,6 +1384,11 @@ export async function registerRoutes(app: Express): Promise { createdBy: user.id, }; + // DEBUG: Log what we received and what we're about to save + console.log('πŸ” CUSTOMER ORDER - Received data from frontend:', req.body); + console.log('πŸ” CUSTOMER ORDER - Final data for DB:', data); + console.log('πŸ” CUSTOMER ORDER - orderTaker value:', data.orderTaker, 'type:', typeof data.orderTaker); + // Check if user has access to the group - PRODUCTION DEBUG console.log('πŸ” CUSTOMER ORDER PERMISSION DEBUG:', { userRole: user.role,