mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-21 14:08:08 +02:00
chore: inspect fouident table for correct supplier names
This commit is contained in:
1 parent
67b0c8c74f
commit
f0a360115f
1 file changed
+16
-23
@@ -4,39 +4,32 @@ import { sql } from "drizzle-orm";
|
|||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
try {
|
try {
|
||||||
// 1. Colonnes de v_ca_fournisseur
|
// 1. Colonnes de fouident
|
||||||
const vCols = await db.execute(sql`
|
const cols = await db.execute(sql`
|
||||||
SELECT column_name, data_type
|
SELECT column_name, data_type
|
||||||
FROM information_schema.columns
|
FROM information_schema.columns
|
||||||
WHERE table_name = 'v_ca_fournisseur'
|
WHERE table_name = 'fouident'
|
||||||
ORDER BY ordinal_position
|
ORDER BY ordinal_position
|
||||||
`);
|
`);
|
||||||
|
|
||||||
// 2. Sample de v_ca_fournisseur
|
// 2. Sample fouident
|
||||||
const vSample = await db.execute(sql`
|
const sample = await db.execute(sql`SELECT * FROM fouident LIMIT 10`);
|
||||||
SELECT * FROM v_ca_fournisseur LIMIT 10
|
|
||||||
`);
|
|
||||||
|
|
||||||
// 3. D005 dans v_ca_fournisseur
|
// 3. D005 dans fouident
|
||||||
const vD005 = await db.execute(sql`
|
const d005 = await db.execute(sql`SELECT * FROM fouident WHERE code = 'D005' LIMIT 5`);
|
||||||
SELECT * FROM v_ca_fournisseur
|
|
||||||
WHERE code = 'D005' OR codefou = 'D005'
|
|
||||||
OR raisonsociale ILIKE '%depot%' OR raisonsociale ILIKE '%bazar%'
|
|
||||||
LIMIT 10
|
|
||||||
`);
|
|
||||||
|
|
||||||
// 4. Définition SQL de la vue
|
// 4. Nos fournisseurs clés pour comparer les noms
|
||||||
const vDef = await db.execute(sql`
|
const known = await db.execute(sql`
|
||||||
SELECT definition
|
SELECT * FROM fouident
|
||||||
FROM pg_views
|
WHERE code IN ('D005','J009','M0341','L0091','S053','B0071','T015','C024','S025','C023')
|
||||||
WHERE viewname = 'v_ca_fournisseur'
|
ORDER BY code
|
||||||
`);
|
`);
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
v_ca_fournisseur_columns: vCols.rows,
|
fouident_columns: cols.rows,
|
||||||
v_ca_fournisseur_sample: vSample.rows,
|
fouident_sample: sample.rows,
|
||||||
v_ca_fournisseur_d005: vD005.rows,
|
fouident_d005: d005.rows,
|
||||||
view_definition: vDef.rows,
|
fouident_known: known.rows,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return NextResponse.json({ error: String(e) }, { status: 500 });
|
return NextResponse.json({ error: String(e) }, { status: 500 });
|
||||||
|
|||||||
Reference in new issue
Block a user