Merge pull request #129 from R0m1k3/1.1

Ensure order taker information is provided for customer orders
This commit is contained in:
LogiFlow authored and GitHub committed 2025-08-14 13:59:07 +02:00
commit 3a0d9eb5f7
4 files changed
+220 -8

No files matched your search

@@ -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
Binary file not shown.

After

Width:  |  Height:  |  Size: 276 KiB

+11 -8
View File
@@ -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:", {
+5
View File
@@ -1384,6 +1384,11 @@ export async function registerRoutes(app: Express): Promise<Server> {
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,