detectar provincias mal escritas

This commit is contained in:
Cat /dev/Nulo 2024-09-11 22:46:41 -03:00
parent aada90bbe8
commit 6d63511a05
2 changed files with 36 additions and 0 deletions

View file

@ -0,0 +1,26 @@
export const ISO_PROVINCIAS = [
"AR-C",
"AR-B",
"AR-K",
"AR-H",
"AR-U",
"AR-X",
"AR-W",
"AR-E",
"AR-P",
"AR-Y",
"AR-L",
"AR-F",
"AR-M",
"AR-N",
"AR-Q",
"AR-R",
"AR-A",
"AR-J",
"AR-D",
"AR-Z",
"AR-S",
"AR-G",
"AR-V",
"AR-T",
];

View file

@ -3,6 +3,7 @@ import { join } from "path";
import jschardet from "jschardet"; import jschardet from "jschardet";
import Papa from "papaparse"; import Papa from "papaparse";
import { Comerico, ProductoSegúnSpec } from "./schemas"; import { Comerico, ProductoSegúnSpec } from "./schemas";
import { ISO_PROVINCIAS } from "./consts";
const dir = process.argv[2]; const dir = process.argv[2];
@ -114,6 +115,15 @@ const checkers: Record<string, (files: Files) => boolean | string> = {
if (productosEnSucursales.length !== eansUnicos.size) return true; if (productosEnSucursales.length !== eansUnicos.size) return true;
return false; return false;
}, },
["[sucursales.csv] sucursales_provincia no cumple con ISO 3166-2"](files) {
const sucursales = files["sucursales.csv"].data;
for (const sucursal of sucursales) {
if (!(sucursal as any).sucursales_provincia) continue;
if (!ISO_PROVINCIAS.includes((sucursal as any).sucursales_provincia))
return true;
}
return false;
},
}; };
const content = await fs.promises.readdir(dir); const content = await fs.promises.readdir(dir);