feat(clientes-maestro): importar y exportar clientes del archivo maestro
- Tabla ClienteMaestro (27 campos, unique numCliente) - Importador Excel: 1535 clientes del Reporte maestro - API: listar/filtros/exportar/detalle/importar - Frontend: tabla paginada, filtros, exportar Excel - Dark mode completo, 52 tests verdes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Importa el archivo maestro de estatus de venta (Reporte_EstatusVenta.xlsx)
|
||||
* Importa el archivo maestro de estatus de venta (/root/Reporte_EstatusVenta.xlsx)
|
||||
* a la tabla CapturaDepartamento.
|
||||
*
|
||||
* Uso:
|
||||
@@ -152,7 +152,7 @@ function detectarDesarrollo(nombreHoja) {
|
||||
// ── Main ─────────────────────────────────────────────────────────────
|
||||
|
||||
async function main() {
|
||||
const rutaExcel = process.argv[2] || join(__dirname, '..', '..', 'Reporte_EstatusVenta.xlsx')
|
||||
const rutaExcel = process.argv[2] || '/root/Reporte_EstatusVenta.xlsx'
|
||||
const usuarioId = process.argv[3] || 'importacion-maestro'
|
||||
|
||||
console.log(`Leyendo archivo: ${rutaExcel}`)
|
||||
@@ -203,12 +203,19 @@ async function main() {
|
||||
let hojaActualizados = 0
|
||||
|
||||
for (const fila of filasDatos) {
|
||||
// Detectar unidad: primera columna con valor
|
||||
const unidadCodigo = String(fila[0] ?? '').trim()
|
||||
// Detectar unidad: columna 1 (Depto) o combinación UBICACIÓN+MZA+LOTE
|
||||
let unidadCodigo = String(fila[1] ?? '').trim() // columna 1 = Depto
|
||||
if (!unidadCodigo) {
|
||||
// Fallback: combinar UBICACIÓN (col 10) + MZA (col 11) + LOTE (col 12)
|
||||
const ubic = String(fila[10] ?? '').trim()
|
||||
const mza = String(fila[11] ?? '').trim()
|
||||
const lote = String(fila[12] ?? '').trim()
|
||||
if (ubic || mza || lote) unidadCodigo = [ubic, mza, lote].filter(Boolean).join('-')
|
||||
}
|
||||
if (!unidadCodigo) continue
|
||||
|
||||
// Skip rows that are clearly headers/section markers
|
||||
if (normalizeHeader(unidadCodigo).includes('TOTAL')) continue
|
||||
if (normalizeHeader(unidadCodigo).includes('TOTAL') || normalizeHeader(unidadCodigo).includes('DDI')) continue
|
||||
|
||||
for (let col = 0; col < headers.length; col++) {
|
||||
const mapeo = mapaColumnas[col]
|
||||
|
||||
Reference in New Issue
Block a user