mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-12 01:37:40 +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
|
||||
form.setValue("productName", article.libelle1, { shouldValidate: true });
|
||||
|
||||
// Matcher le fournisseur par nom
|
||||
if (article.nom_fou_principal) {
|
||||
const apiName = article.nom_fou_principal.toLowerCase().trim();
|
||||
// Matcher le fournisseur par codefou en priorité, sinon par nom
|
||||
if (article.codefou_principal) {
|
||||
const matched = (suppliers as any[]).find((s: any) =>
|
||||
s.name.toLowerCase().trim().includes(apiName) ||
|
||||
apiName.includes(s.name.toLowerCase().trim())
|
||||
s.codefou && s.codefou.trim().toLowerCase() === article.codefou_principal.trim().toLowerCase()
|
||||
) || (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) {
|
||||
form.setValue("supplierId", matched.id, { shouldValidate: true });
|
||||
|
||||
@@ -43,6 +43,7 @@ export default function Suppliers() {
|
||||
name: "",
|
||||
contact: "",
|
||||
phone: "",
|
||||
codefou: "",
|
||||
hasDlc: false,
|
||||
automaticReconciliation: false,
|
||||
requiresControl: false,
|
||||
@@ -198,6 +199,7 @@ export default function Suppliers() {
|
||||
name: "",
|
||||
contact: "",
|
||||
phone: "",
|
||||
codefou: "",
|
||||
hasDlc: false,
|
||||
automaticReconciliation: false,
|
||||
requiresControl: false,
|
||||
@@ -236,6 +238,7 @@ export default function Suppliers() {
|
||||
name: supplier.name || "",
|
||||
contact: supplier.contact || "",
|
||||
phone: supplier.phone || "",
|
||||
codefou: (supplier as any).codefou || "",
|
||||
hasDlc: supplier.hasDlc || false,
|
||||
automaticReconciliation: supplier.automaticReconciliation || false,
|
||||
requiresControl: supplier.requiresControl || false,
|
||||
@@ -528,6 +531,16 @@ export default function Suppliers() {
|
||||
/>
|
||||
</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>
|
||||
<Label htmlFor="paymentMethod">Mode de paiement</Label>
|
||||
<Select
|
||||
|
||||
@@ -161,11 +161,12 @@ export default function MobileDlcPage() {
|
||||
|
||||
form.setValue("productName", article.libelle1, { shouldValidate: true });
|
||||
|
||||
if (article.nom_fou_principal) {
|
||||
const apiName = article.nom_fou_principal.toLowerCase().trim();
|
||||
if (article.codefou_principal) {
|
||||
const matched = (suppliers as any[]).find((s: any) =>
|
||||
s.name.toLowerCase().trim().includes(apiName) ||
|
||||
apiName.includes(s.name.toLowerCase().trim())
|
||||
s.codefou && s.codefou.trim().toLowerCase() === article.codefou_principal.trim().toLowerCase()
|
||||
) || (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) {
|
||||
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
|
||||
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',
|
||||
content: `CREATE TABLE IF NOT EXISTS webhook_bap_config (
|
||||
|
||||
@@ -80,6 +80,7 @@ export const suppliers = pgTable("suppliers", {
|
||||
name: varchar("name").notNull(),
|
||||
contact: varchar("contact"),
|
||||
phone: varchar("phone"),
|
||||
codefou: varchar("codefou"), // Code fournisseur dans l'API ffnancy
|
||||
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
|
||||
createdAt: timestamp("created_at").defaultNow(),
|
||||
|
||||
Reference in new issue
Block a user