feat: add stat_dispoperm and phenix_quantite_conseille to sync pipeline
- Add ARTCENTRALE column to articles sync - Add stat_dispoperm table (gamme conseillée, joins via ARTCENTRALE) - Add phenix_quantite_conseille table (journal de commande ERP) - Register both tables in sync/index.js steps Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
c5faddde1f
commit
52c47acc67
5 files changed
+129
-3
No files matched your search
@@ -0,0 +1,37 @@
|
||||
const { getMssql, getPg } = require('../db');
|
||||
const { batchUpsert, logSync } = require('../utils');
|
||||
|
||||
const COLS = ['codesite','code_art','recommand','statut','qtemoyer','qtemoyes','camoyes','nbreclient'];
|
||||
|
||||
async function syncStatDispoperm(force) {
|
||||
const ms = await getMssql();
|
||||
const pg = getPg();
|
||||
|
||||
try {
|
||||
const res = await ms.request().query(`
|
||||
SELECT CodeSite, Code_Art, Recommand, Statut,
|
||||
QteMoyAch, QteMoyRes, CaMoyRes, NbreClient
|
||||
FROM STAT_DISPOPERM
|
||||
`);
|
||||
|
||||
const rows = res.recordset.map(r => ({
|
||||
codesite: r.CodeSite,
|
||||
code_art: r.Code_Art,
|
||||
recommand: r.Recommand ?? null,
|
||||
statut: r.Statut ?? null,
|
||||
qtemoyer: r.QteMoyAch ?? null,
|
||||
qtemoyes: r.QteMoyRes ?? null,
|
||||
camoyes: r.CaMoyRes ?? null,
|
||||
nbreclient: r.NbreClient ?? null,
|
||||
}));
|
||||
|
||||
const count = await batchUpsert(pg, 'stat_dispoperm', rows, ['codesite','code_art'], COLS);
|
||||
await logSync(pg, 'stat_dispoperm', count, 'ok');
|
||||
console.log(`[stat_dispoperm] ${count} lignes upsert`);
|
||||
} catch (err) {
|
||||
await logSync(pg, 'stat_dispoperm', 0, 'error', err.message);
|
||||
console.error(`[stat_dispoperm] ERREUR: ${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { syncStatDispoperm };
|
||||
Reference in new issue
Block a user