mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-24 15:38:18 +02:00
Merge pull request #42 from R0m1k3/1.1
Fix customer order creation for employees by updating the schema
This commit is contained in:
5 files changed
+296
-16
No files matched your search
+204
@@ -0,0 +1,204 @@
|
|||||||
|
nocodb_table_id: 'my7zunxprumahmm',
|
||||||
|
|
||||||
|
nocodb_table_name: 'CommandeH',
|
||||||
|
|
||||||
|
invoice_column_name: 'RefFacture',
|
||||||
|
|
||||||
|
group_created_at: '2025-07-22 11:09:08.977622',
|
||||||
|
|
||||||
|
group_updated_at: '2025-08-12 09:39:32.989'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
✅ Processed 1 groups for user _1753266816257
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: _1753266816257
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: _1753266816257
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: _1753266816257
|
||||||
|
|
||||||
|
🔍 Found 1 group assignments for user _1753266816257
|
||||||
|
|
||||||
|
🔍 Raw query result: [
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
user_id: '_1753266816257',
|
||||||
|
|
||||||
|
group_id: 2,
|
||||||
|
|
||||||
|
group_id_ref: 2,
|
||||||
|
|
||||||
|
group_name: 'Houdemont',
|
||||||
|
|
||||||
|
group_color: '#455A64',
|
||||||
|
|
||||||
|
nocodb_config_id: 1,
|
||||||
|
|
||||||
|
nocodb_table_id: 'my7zunxprumahmm',
|
||||||
|
|
||||||
|
nocodb_table_name: 'CommandeH',
|
||||||
|
|
||||||
|
invoice_column_name: 'RefFacture',
|
||||||
|
|
||||||
|
group_created_at: '2025-07-22 11:09:08.977622',
|
||||||
|
|
||||||
|
group_updated_at: '2025-08-12 09:39:32.989'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
✅ Processed 1 groups for user _1753266816257
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: _1753266816257
|
||||||
|
|
||||||
|
🔍 Found 1 group assignments for user _1753266816257
|
||||||
|
|
||||||
|
🔍 Raw query result: [
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
user_id: '_1753266816257',
|
||||||
|
|
||||||
|
group_id: 2,
|
||||||
|
|
||||||
|
group_id_ref: 2,
|
||||||
|
|
||||||
|
group_name: 'Houdemont',
|
||||||
|
|
||||||
|
group_color: '#455A64',
|
||||||
|
|
||||||
|
nocodb_config_id: 1,
|
||||||
|
|
||||||
|
nocodb_table_id: 'my7zunxprumahmm',
|
||||||
|
|
||||||
|
nocodb_table_name: 'CommandeH',
|
||||||
|
|
||||||
|
invoice_column_name: 'RefFacture',
|
||||||
|
|
||||||
|
group_created_at: '2025-07-22 11:09:08.977622',
|
||||||
|
|
||||||
|
group_updated_at: '2025-08-12 09:39:32.989'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
✅ Processed 1 groups for user _1753266816257
|
||||||
|
|
||||||
|
🔍 getUserWithGroups called for user: _1753266816257
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: _1753266816257
|
||||||
|
|
||||||
|
🔍 Found 1 group assignments for user _1753266816257
|
||||||
|
|
||||||
|
🔍 Raw query result: [
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
user_id: '_1753266816257',
|
||||||
|
|
||||||
|
group_id: 2,
|
||||||
|
|
||||||
|
group_id_ref: 2,
|
||||||
|
|
||||||
|
group_name: 'Houdemont',
|
||||||
|
|
||||||
|
group_color: '#455A64',
|
||||||
|
|
||||||
|
nocodb_config_id: 1,
|
||||||
|
|
||||||
|
nocodb_table_id: 'my7zunxprumahmm',
|
||||||
|
|
||||||
|
nocodb_table_name: 'CommandeH',
|
||||||
|
|
||||||
|
invoice_column_name: 'RefFacture',
|
||||||
|
|
||||||
|
group_created_at: '2025-07-22 11:09:08.977622',
|
||||||
|
|
||||||
|
group_updated_at: '2025-08-12 09:39:32.989'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
✅ Processed 1 groups for user _1753266816257
|
||||||
|
|
||||||
|
🔍 Querying user_groups for user: _1753266816257
|
||||||
|
|
||||||
|
🔍 Found 1 group assignments for user _1753266816257
|
||||||
|
|
||||||
|
🔍 Raw query result: [
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
user_id: '_1753266816257',
|
||||||
|
|
||||||
|
group_id: 2,
|
||||||
|
|
||||||
|
group_id_ref: 2,
|
||||||
|
|
||||||
|
group_name: 'Houdemont',
|
||||||
|
|
||||||
|
group_color: '#455A64',
|
||||||
|
|
||||||
|
nocodb_config_id: 1,
|
||||||
|
|
||||||
|
nocodb_table_id: 'my7zunxprumahmm',
|
||||||
|
|
||||||
|
nocodb_table_name: 'CommandeH',
|
||||||
|
|
||||||
|
invoice_column_name: 'RefFacture',
|
||||||
|
|
||||||
|
group_created_at: '2025-07-22 11:09:08.977622',
|
||||||
|
|
||||||
|
group_updated_at: '2025-08-12 09:39:32.989'
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
✅ Processed 1 groups for user _1753266816257
|
||||||
|
|
||||||
|
🔍 DLC Products API called with: {
|
||||||
|
|
||||||
|
userId: '_1753266816257',
|
||||||
|
|
||||||
|
userRole: 'employee',
|
||||||
|
|
||||||
|
userGroups: [ { groupId: 2, groupName: 'Houdemont' } ],
|
||||||
|
|
||||||
|
groupIds: [ 2 ],
|
||||||
|
|
||||||
|
filters: {},
|
||||||
|
|
||||||
|
queryStoreId: undefined
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GET /api/dlc-products/stats 304 in 18ms
|
||||||
|
|
||||||
|
📋 DLC Products returned: 133 items
|
||||||
|
|
||||||
|
📋 Sample DLC products groupIds: [
|
||||||
|
|
||||||
|
{ id: 178, name: 'Nesta grenier strawberry aloe vera', groupId: 2 },
|
||||||
|
|
||||||
|
{ id: 48, name: 'Gressins sésame', groupId: 2 },
|
||||||
|
|
||||||
|
{ id: 154, name: 'M&m’s crispy 240g', groupId: 2 }
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
GET /api/dlc-products 304 in 26ms
|
||||||
|
|
||||||
|
HEAD /api/health 200 in 1ms
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 319 KiB |
@@ -22,17 +22,13 @@ import {
|
|||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/components/ui/select";
|
} from "@/components/ui/select";
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
import { insertCustomerOrderSchema, type CustomerOrderWithRelations, type Group, type Supplier } from "@shared/schema";
|
import { insertCustomerOrderFrontendSchema, type CustomerOrderWithRelations, type Group, type Supplier } from "@shared/schema";
|
||||||
import { useStore } from "@/components/Layout";
|
import { useStore } from "@/components/Layout";
|
||||||
|
|
||||||
const customerOrderFormSchema = insertCustomerOrderSchema.extend({
|
const customerOrderFormSchema = insertCustomerOrderFrontendSchema.extend({
|
||||||
deposit: z.string().optional(),
|
deposit: z.number().optional().default(0),
|
||||||
gencode: z.string().min(1, "Le gencode est obligatoire"),
|
groupId: z.number().int().positive().optional(),
|
||||||
customerName: z.string().min(1, "Le nom du client est obligatoire"),
|
createdBy: z.string().optional(),
|
||||||
quantity: z.union([z.string(), z.number()]).transform(val => typeof val === 'string' ? parseInt(val) || 1 : val),
|
|
||||||
supplierId: z.union([z.string(), z.number()]).transform(val => typeof val === 'string' ? parseInt(val) : val),
|
|
||||||
groupId: z.union([z.string(), z.number()]).transform(val => typeof val === 'string' ? parseInt(val) : val).optional(),
|
|
||||||
createdBy: z.string().optional(), // Will be set automatically
|
|
||||||
});
|
});
|
||||||
|
|
||||||
type CustomerOrderFormData = z.infer<typeof customerOrderFormSchema>;
|
type CustomerOrderFormData = z.infer<typeof customerOrderFormSchema>;
|
||||||
@@ -120,15 +116,22 @@ export function CustomerOrderForm({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare data with proper types
|
// Prepare data with proper types for frontend schema
|
||||||
const submitData = {
|
const submitData = {
|
||||||
...data,
|
customerName: data.customerName.trim(),
|
||||||
customerName: data.customerName.trim(), // Clean the customer name
|
contactNumber: (data as any).customerPhone || (data as any).contactNumber || '',
|
||||||
deposit: data.deposit || "0.00", // Keep as string for decimal field
|
productName: (data as any).productDesignation || (data as any).productName || '',
|
||||||
|
quantity: data.quantity,
|
||||||
groupId: typeof groupId === 'number' ? groupId : parseInt(groupId.toString()),
|
groupId: typeof groupId === 'number' ? groupId : parseInt(groupId.toString()),
|
||||||
createdBy: user?.id || '', // Add the current user ID
|
isPickup: false,
|
||||||
|
notes: (data as any).notes,
|
||||||
|
deposit: data.deposit || 0,
|
||||||
|
isPromotionalPrice: (data as any).isPromotionalPrice || false,
|
||||||
|
customerEmail: (data as any).customerEmail,
|
||||||
|
gencode: (data as any).gencode || '',
|
||||||
|
supplierId: (data as any).supplierId || 1,
|
||||||
};
|
};
|
||||||
console.log("Processed submit data:", submitData);
|
console.log("🔍 Frontend submit data:", submitData);
|
||||||
onSubmit(submitData);
|
onSubmit(submitData);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,4 +2,4 @@
|
|||||||
# https://curl.se/docs/http-cookies.html
|
# https://curl.se/docs/http-cookies.html
|
||||||
# This file was generated by libcurl! Edit at your own risk.
|
# This file was generated by libcurl! Edit at your own risk.
|
||||||
|
|
||||||
#HttpOnly_localhost FALSE / FALSE 1755094358 connect.sid s%3AGqqa9KVEFyrrc64iEAkqzrmbLaa9QLvf.xQnlef9xv7BPKRjEnDyFjY%2Buao%2BP669Ftp46tQk6ozI
|
#HttpOnly_localhost FALSE / FALSE 1755094677 connect.sid s%3AMRvtKRB7l8aU-cxKVAyRLza4Hz26hGS3.B0p70oONarXt57Foz6nSvGoPBIEpN6YNyr22RwYgJEc
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test final pour la création de commandes client par employé
|
||||||
|
*/
|
||||||
|
|
||||||
|
console.log('🔍 Test Final - Création Commande Client Employé');
|
||||||
|
|
||||||
|
async function testEmployeeCustomerOrder() {
|
||||||
|
try {
|
||||||
|
const fetch = require('node-fetch');
|
||||||
|
|
||||||
|
console.log('\n=== TEST FINAL CRÉATION COMMANDE CLIENT ===');
|
||||||
|
|
||||||
|
// 1. Login admin
|
||||||
|
console.log('1. Test admin...');
|
||||||
|
const adminLogin = await fetch('http://localhost:5000/api/login', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ username: 'admin', password: 'admin' })
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!adminLogin.ok) {
|
||||||
|
console.log('❌ Admin login failed');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const adminCookies = adminLogin.headers.get('set-cookie');
|
||||||
|
|
||||||
|
// 2. Test création avec nouveau format
|
||||||
|
const orderData = {
|
||||||
|
customerName: 'Client Test Final',
|
||||||
|
contactNumber: '0123456789',
|
||||||
|
productName: 'Produit Test Final',
|
||||||
|
quantity: 1,
|
||||||
|
groupId: 1,
|
||||||
|
isPickup: false,
|
||||||
|
notes: 'Test final avec nouveau schema'
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log('2. Envoi données:', orderData);
|
||||||
|
|
||||||
|
const createOrder = await fetch('http://localhost:5000/api/customer-orders', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Cookie': adminCookies,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(orderData)
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('Status:', createOrder.status);
|
||||||
|
const response = await createOrder.text();
|
||||||
|
|
||||||
|
if (createOrder.ok) {
|
||||||
|
console.log('✅ Commande créée avec succès');
|
||||||
|
console.log('Réponse:', JSON.parse(response));
|
||||||
|
} else {
|
||||||
|
console.log('❌ Erreur création:', response);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('\n3. Instructions pour test employé en production:');
|
||||||
|
console.log('- Se connecter avec un compte employé');
|
||||||
|
console.log('- Essayer de créer une commande client');
|
||||||
|
console.log('- Vérifier les logs pour "Frontend submit data" et "Backend data mapped"');
|
||||||
|
console.log('- Si erreur 403, vérifier que l\'employé est assigné au bon groupe');
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.log('❌ Erreur test:', error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
testEmployeeCustomerOrder();
|
||||||
Reference in new issue
Block a user