mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-23 06:58:19 +02:00
feat: implement supplier management module with CRUD operations and optimistic updates
This commit is contained in:
1 parent
1488accbdb
commit
44950d2239
5 files changed
+29
-9
No files matched your search
@@ -137,12 +137,13 @@ export default function DlcPage() {
|
|||||||
// Toujours mettre à jour le nom du produit
|
// Toujours mettre à jour le nom du produit
|
||||||
form.setValue("productName", article.libelle1, { shouldValidate: true });
|
form.setValue("productName", article.libelle1, { shouldValidate: true });
|
||||||
|
|
||||||
// Matcher le fournisseur par nom
|
// Matcher le fournisseur par codefou en priorité, sinon par nom
|
||||||
if (article.nom_fou_principal) {
|
if (article.codefou_principal) {
|
||||||
const apiName = article.nom_fou_principal.toLowerCase().trim();
|
|
||||||
const matched = (suppliers as any[]).find((s: any) =>
|
const matched = (suppliers as any[]).find((s: any) =>
|
||||||
s.name.toLowerCase().trim().includes(apiName) ||
|
s.codefou && s.codefou.trim().toLowerCase() === article.codefou_principal.trim().toLowerCase()
|
||||||
apiName.includes(s.name.toLowerCase().trim())
|
) || (suppliers as any[]).find((s: any) =>
|
||||||
|
s.name.toLowerCase().trim().includes(article.nom_fou_principal?.toLowerCase().trim() || '') ||
|
||||||
|
(article.nom_fou_principal?.toLowerCase().trim() || '').includes(s.name.toLowerCase().trim())
|
||||||
);
|
);
|
||||||
if (matched) {
|
if (matched) {
|
||||||
form.setValue("supplierId", matched.id, { shouldValidate: true });
|
form.setValue("supplierId", matched.id, { shouldValidate: true });
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export default function Suppliers() {
|
|||||||
name: "",
|
name: "",
|
||||||
contact: "",
|
contact: "",
|
||||||
phone: "",
|
phone: "",
|
||||||
|
codefou: "",
|
||||||
hasDlc: false,
|
hasDlc: false,
|
||||||
automaticReconciliation: false,
|
automaticReconciliation: false,
|
||||||
requiresControl: false,
|
requiresControl: false,
|
||||||
@@ -198,6 +199,7 @@ export default function Suppliers() {
|
|||||||
name: "",
|
name: "",
|
||||||
contact: "",
|
contact: "",
|
||||||
phone: "",
|
phone: "",
|
||||||
|
codefou: "",
|
||||||
hasDlc: false,
|
hasDlc: false,
|
||||||
automaticReconciliation: false,
|
automaticReconciliation: false,
|
||||||
requiresControl: false,
|
requiresControl: false,
|
||||||
@@ -236,6 +238,7 @@ export default function Suppliers() {
|
|||||||
name: supplier.name || "",
|
name: supplier.name || "",
|
||||||
contact: supplier.contact || "",
|
contact: supplier.contact || "",
|
||||||
phone: supplier.phone || "",
|
phone: supplier.phone || "",
|
||||||
|
codefou: (supplier as any).codefou || "",
|
||||||
hasDlc: supplier.hasDlc || false,
|
hasDlc: supplier.hasDlc || false,
|
||||||
automaticReconciliation: supplier.automaticReconciliation || false,
|
automaticReconciliation: supplier.automaticReconciliation || false,
|
||||||
requiresControl: supplier.requiresControl || false,
|
requiresControl: supplier.requiresControl || false,
|
||||||
@@ -528,6 +531,16 @@ export default function Suppliers() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Label htmlFor="codefou">Code fournisseur API <span className="text-xs text-gray-400 font-normal">(liaison ffnancy)</span></Label>
|
||||||
|
<Input
|
||||||
|
id="codefou"
|
||||||
|
value={formData.codefou}
|
||||||
|
onChange={(e) => handleChange('codefou', e.target.value)}
|
||||||
|
placeholder="ex: FOU01"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="paymentMethod">Mode de paiement</Label>
|
<Label htmlFor="paymentMethod">Mode de paiement</Label>
|
||||||
<Select
|
<Select
|
||||||
|
|||||||
@@ -161,11 +161,12 @@ export default function MobileDlcPage() {
|
|||||||
|
|
||||||
form.setValue("productName", article.libelle1, { shouldValidate: true });
|
form.setValue("productName", article.libelle1, { shouldValidate: true });
|
||||||
|
|
||||||
if (article.nom_fou_principal) {
|
if (article.codefou_principal) {
|
||||||
const apiName = article.nom_fou_principal.toLowerCase().trim();
|
|
||||||
const matched = (suppliers as any[]).find((s: any) =>
|
const matched = (suppliers as any[]).find((s: any) =>
|
||||||
s.name.toLowerCase().trim().includes(apiName) ||
|
s.codefou && s.codefou.trim().toLowerCase() === article.codefou_principal.trim().toLowerCase()
|
||||||
apiName.includes(s.name.toLowerCase().trim())
|
) || (suppliers as any[]).find((s: any) =>
|
||||||
|
s.name.toLowerCase().trim().includes(article.nom_fou_principal?.toLowerCase().trim() || '') ||
|
||||||
|
(article.nom_fou_principal?.toLowerCase().trim() || '').includes(s.name.toLowerCase().trim())
|
||||||
);
|
);
|
||||||
if (matched) {
|
if (matched) {
|
||||||
form.setValue("supplierId", matched.id, { shouldValidate: true });
|
form.setValue("supplierId", matched.id, { shouldValidate: true });
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ export async function runMigrations() {
|
|||||||
|
|
||||||
// Ajouter les migrations hardcodées directement dans le code pour éviter les problèmes de chemins
|
// Ajouter les migrations hardcodées directement dans le code pour éviter les problèmes de chemins
|
||||||
const hardcodedMigrations = [
|
const hardcodedMigrations = [
|
||||||
|
{
|
||||||
|
filename: '20260402000000_add_codefou_to_suppliers.sql',
|
||||||
|
content: `ALTER TABLE suppliers ADD COLUMN IF NOT EXISTS codefou VARCHAR;`
|
||||||
|
},
|
||||||
{
|
{
|
||||||
filename: '20250903141000_create_webhook_bap_config.sql',
|
filename: '20250903141000_create_webhook_bap_config.sql',
|
||||||
content: `CREATE TABLE IF NOT EXISTS webhook_bap_config (
|
content: `CREATE TABLE IF NOT EXISTS webhook_bap_config (
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ export const suppliers = pgTable("suppliers", {
|
|||||||
name: varchar("name").notNull(),
|
name: varchar("name").notNull(),
|
||||||
contact: varchar("contact"),
|
contact: varchar("contact"),
|
||||||
phone: varchar("phone"),
|
phone: varchar("phone"),
|
||||||
|
codefou: varchar("codefou"), // Code fournisseur dans l'API ffnancy
|
||||||
hasDlc: boolean("has_dlc").default(false), // Coche DLC pour la gestion DLC
|
hasDlc: boolean("has_dlc").default(false), // Coche DLC pour la gestion DLC
|
||||||
paymentMethod: varchar("payment_method"), // Mode de paiement: Virement, Traite, Traite Magnétique, Chèque
|
paymentMethod: varchar("payment_method"), // Mode de paiement: Virement, Traite, Traite Magnétique, Chèque
|
||||||
createdAt: timestamp("created_at").defaultNow(),
|
createdAt: timestamp("created_at").defaultNow(),
|
||||||
|
|||||||
Reference in new issue
Block a user