mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-22 22:48:15 +02:00
Improve financial records processing and add production debugging tools
Update schema for financial records to allow optional fields and introduce a SQL script for detailed production debugging of financial data and related entities. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/9fcf4b21-eb0c-4e53-a567-e2ce4a6ad869/2Jd7tYp
This commit is contained in:
1 parent
73b85f2598
commit
c45bda21c5
2 files changed
+79
-2
No files matched your search
@@ -0,0 +1,77 @@
|
|||||||
|
-- 🔍 DIAGNOSTIC PRODUCTION COMPLET - Module Avoirs
|
||||||
|
-- Copiez-collez ce script dans votre utilitaire SQL pour diagnostic précis
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
-- SECTION 1: STRUCTURE DES TABLES
|
||||||
|
SELECT 'VÉRIFICATION STRUCTURE TABLES' AS section_title;
|
||||||
|
|
||||||
|
-- Table avoirs - structure exacte
|
||||||
|
SELECT 'STRUCTURE_AVOIRS' AS check_type, column_name, data_type, is_nullable, column_default
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_name = 'avoirs' AND table_schema = 'public'
|
||||||
|
ORDER BY ordinal_position;
|
||||||
|
|
||||||
|
-- Table suppliers - structure exacte
|
||||||
|
SELECT 'STRUCTURE_SUPPLIERS' AS check_type, column_name, data_type, is_nullable
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_name = 'suppliers' AND table_schema = 'public'
|
||||||
|
ORDER BY ordinal_position;
|
||||||
|
|
||||||
|
-- Table groups - structure exacte
|
||||||
|
SELECT 'STRUCTURE_GROUPS' AS check_type, column_name, data_type, is_nullable
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_name = 'groups' AND table_schema = 'public'
|
||||||
|
ORDER BY ordinal_position;
|
||||||
|
|
||||||
|
-- Table users - structure exacte
|
||||||
|
SELECT 'STRUCTURE_USERS' AS check_type, column_name, data_type, is_nullable
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_name = 'users' AND table_schema = 'public'
|
||||||
|
ORDER BY ordinal_position;
|
||||||
|
|
||||||
|
-- SECTION 2: CONTRAINTES
|
||||||
|
SELECT 'CONTRAINTES_AVOIRS' AS check_type, conname AS constraint_name, contype AS type,
|
||||||
|
confrelid::regclass AS referenced_table
|
||||||
|
FROM pg_constraint
|
||||||
|
WHERE conrelid = 'avoirs'::regclass;
|
||||||
|
|
||||||
|
-- SECTION 3: DONNÉES EXISTANTES
|
||||||
|
SELECT 'COMPTES_TABLES' AS check_type, 'suppliers' AS table_name, COUNT(*) AS count FROM suppliers
|
||||||
|
UNION ALL
|
||||||
|
SELECT 'COMPTES_TABLES', 'groups', COUNT(*) FROM groups
|
||||||
|
UNION ALL
|
||||||
|
SELECT 'COMPTES_TABLES', 'users', COUNT(*) FROM users
|
||||||
|
UNION ALL
|
||||||
|
SELECT 'COMPTES_TABLES', 'avoirs', COUNT(*) FROM avoirs;
|
||||||
|
|
||||||
|
-- SECTION 4: EXEMPLES DE DONNÉES (si elles existent)
|
||||||
|
-- Suppliers
|
||||||
|
SELECT 'EXEMPLES_SUPPLIERS' AS check_type, id, name FROM suppliers LIMIT 3;
|
||||||
|
|
||||||
|
-- Groups
|
||||||
|
SELECT 'EXEMPLES_GROUPS' AS check_type, id, name FROM groups LIMIT 3;
|
||||||
|
|
||||||
|
-- Users
|
||||||
|
SELECT 'EXEMPLES_USERS' AS check_type, id,
|
||||||
|
COALESCE(username, 'no_username') AS username,
|
||||||
|
role
|
||||||
|
FROM users LIMIT 3;
|
||||||
|
|
||||||
|
-- SECTION 5: TEST DE COMPATIBILITÉ
|
||||||
|
-- Test si on peut insérer avec des champs NULL
|
||||||
|
SELECT 'TEST_COMPATIBILITÉ' AS check_type,
|
||||||
|
CASE
|
||||||
|
WHEN (SELECT is_nullable FROM information_schema.columns
|
||||||
|
WHERE table_name = 'avoirs' AND column_name = 'invoice_reference') = 'YES'
|
||||||
|
THEN 'invoice_reference_NULLABLE'
|
||||||
|
ELSE 'invoice_reference_NOT_NULL'
|
||||||
|
END AS invoice_ref_status,
|
||||||
|
CASE
|
||||||
|
WHEN (SELECT is_nullable FROM information_schema.columns
|
||||||
|
WHERE table_name = 'avoirs' AND column_name = 'amount') = 'YES'
|
||||||
|
THEN 'amount_NULLABLE'
|
||||||
|
ELSE 'amount_NOT_NULL'
|
||||||
|
END AS amount_status;
|
||||||
|
|
||||||
|
ROLLBACK; -- Ne pas sauvegarder, c'est juste du diagnostic
|
||||||
+2
-2
@@ -267,8 +267,8 @@ export const avoirs = pgTable("avoirs", {
|
|||||||
id: serial("id").primaryKey(),
|
id: serial("id").primaryKey(),
|
||||||
supplierId: integer("supplier_id").notNull(), // Fournisseur
|
supplierId: integer("supplier_id").notNull(), // Fournisseur
|
||||||
groupId: integer("group_id").notNull(), // Magasin/groupe associé - OBLIGATOIRE pour filtrage
|
groupId: integer("group_id").notNull(), // Magasin/groupe associé - OBLIGATOIRE pour filtrage
|
||||||
invoiceReference: varchar("invoice_reference", { length: 255 }).notNull(), // Référence facture
|
invoiceReference: varchar("invoice_reference", { length: 255 }), // Référence facture (OPTIONNEL)
|
||||||
amount: decimal("amount", { precision: 10, scale: 2 }).notNull(), // Montant
|
amount: decimal("amount", { precision: 10, scale: 2 }), // Montant (OPTIONNEL)
|
||||||
comment: text("comment"), // Commentaire (optionnel)
|
comment: text("comment"), // Commentaire (optionnel)
|
||||||
commercialProcessed: boolean("commercial_processed").default(false), // Avoir fait par commercial
|
commercialProcessed: boolean("commercial_processed").default(false), // Avoir fait par commercial
|
||||||
status: varchar("status", { length: 50 }).notNull().default("En attente de demande"), // En attente de demande, Demandé, Reçu
|
status: varchar("status", { length: 50 }).notNull().default("En attente de demande"), // En attente de demande, Demandé, Reçu
|
||||||
|
|||||||
Reference in new issue
Block a user