mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-25 19:16:19 +00:00
detectar provincias mal escritas
This commit is contained in:
parent
aada90bbe8
commit
6d63511a05
2 changed files with 36 additions and 0 deletions
26
sepa/sepa-dataset-validator/consts.ts
Normal file
26
sepa/sepa-dataset-validator/consts.ts
Normal 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",
|
||||
];
|
|
@ -3,6 +3,7 @@ import { join } from "path";
|
|||
import jschardet from "jschardet";
|
||||
import Papa from "papaparse";
|
||||
import { Comerico, ProductoSegúnSpec } from "./schemas";
|
||||
import { ISO_PROVINCIAS } from "./consts";
|
||||
|
||||
const dir = process.argv[2];
|
||||
|
||||
|
@ -114,6 +115,15 @@ const checkers: Record<string, (files: Files) => boolean | string> = {
|
|||
if (productosEnSucursales.length !== eansUnicos.size) return true;
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue