mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-22 22:26:19 +00:00
chequear si hay sucursales en productos.csv que no existen en sucursales.csv
This commit is contained in:
parent
3e0f550704
commit
b9e6c64bd5
1 changed files with 15 additions and 0 deletions
|
@ -89,6 +89,21 @@ const checkers: Record<string, (files: Files) => boolean | string> = {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
["Sucursales mencionadas en productos.csv existen en sucursales.csv"](files) {
|
||||||
|
const productos = new Set(
|
||||||
|
files["productos.csv"].data.map((row) => (row as any).id_sucursal)
|
||||||
|
);
|
||||||
|
const sucursales = new Set(
|
||||||
|
files["sucursales.csv"].data.map((row) => (row as any).id_sucursal)
|
||||||
|
);
|
||||||
|
const missing = [...productos].filter((id) => !sucursales.has(id));
|
||||||
|
if (missing.length > 0) {
|
||||||
|
console.error(
|
||||||
|
` Las sucursales ${missing.join(", ")} no existen en sucursales.csv`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return missing.length > 0;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const content = await fs.promises.readdir(dir);
|
const content = await fs.promises.readdir(dir);
|
||||||
|
|
Loading…
Reference in a new issue