feat: implement automated procurement synchronization and API endpoints for supply chain management

This commit is contained in:
Michael committed 2026-04-09 08:18:10 +02:00
1 parent 6e5bc3bc07
commit d74cdeb7b3
2 files changed
+7 -2

No files matched your search

+4
View File
@@ -24,6 +24,10 @@ let pgPool = null;
async function getMssql() {
if (!mssqlPool) {
mssqlPool = await sql.connect(mssqlConfig);
mssqlPool.on('error', (err) => {
console.error('[mssql] Pool error, reconnexion au prochain appel:', err.message);
mssqlPool = null;
});
}
return mssqlPool;
}
+3 -2
View File
@@ -29,11 +29,11 @@ const PLAN_REAPPRO_COLS = [
];
async function syncAppro(force) {
const ms = await getMssql();
const pg = getPg();
const pg = getPg();
// === COMMANDE_FOU (upsert delta) ===
try {
const ms = await getMssql();
const lastSync = force ? null : await getLastSync(pg, 'commande_fou');
const where = lastSync ? `WHERE SUIVIDATEMODIF > '${lastSync.toISOString()}'` : '';
@@ -72,6 +72,7 @@ async function syncAppro(force) {
// === CDEFOU_LIGNE (upsert delta) ===
try {
const ms = await getMssql();
const lastSync = force ? null : await getLastSync(pg, 'cdefou_ligne');
const where = lastSync ? `WHERE SUIVIDATEMODIF > '${lastSync.toISOString()}'` : '';