Commit cb380bbbed94d2e49a34014916d873942fe578ce
1 parent
a37d3ffa73
Exists in
master
arreglos fechas pmaefact
Showing
8 changed files
with
93 additions
and
61 deletions
Show diff stats
debo/cabeceraDebo.js
1 | module.exports = function(comprobante, afipTablas, entities) { | 1 | module.exports = function(comprobante, afipTablas, entities) { |
2 | 2 | ||
3 | return { | 3 | return { |
4 | TIP: afipTablas(comprobante.identificaxComprobante.tipo).letraComprobante, // [char](1) NOT NULL, LETRA DEL COMPROBANTE (A,B,C,M,E) | 4 | TIP: afipTablas(comprobante.identificaxComprobante.tipo).letraComprobante, // [char](1) NOT NULL, LETRA DEL COMPROBANTE (A,B,C,M,E) |
5 | TCO: afipTablas(comprobante.identificaxComprobante.tipo).tipoComprobante, // [char](2) NOT NULL, TIPO DE COMPROBANTE (FT,NC,ND,RE,CI,LP) | 5 | TCO: afipTablas(comprobante.identificaxComprobante.tipo).tipoComprobante, // [char](2) NOT NULL, TIPO DE COMPROBANTE (FT,NC,ND,RE,CI,LP) |
6 | SUC: parseInt(comprobante.identificaxComprobante.puntoVenta), // [int] NOT NULL, PUNTO DE VENTA | 6 | SUC: parseInt(comprobante.identificaxComprobante.puntoVenta), // [int] NOT NULL, PUNTO DE VENTA |
7 | NCO: parseInt(comprobante.identificaxComprobante.numero), // [bigint] NOT NULL, NUMERO DE COMPROBANTE | 7 | NCO: parseInt(comprobante.identificaxComprobante.numero), // [bigint] NOT NULL, NUMERO DE COMPROBANTE |
8 | COD: entities.proveedores.COD, // [int] NOT NULL, CODIGO DEL PROVEEDOR NECESITAS RELACION -- BUSCAR SI ENVIAN EL CUIT DEL PROVEEDOR SELECT COD FROM PROVEED WHERE CUIT= '30-54775125-2' | 8 | COD: entities.proveedores.COD, // [int] NOT NULL, CODIGO DEL PROVEEDOR NECESITAS RELACION -- BUSCAR SI ENVIAN EL CUIT DEL PROVEEDOR SELECT COD FROM PROVEED WHERE CUIT= '30-54775125-2' |
9 | FEC: comprobante.identificaxComprobante.fechaComprobante, // [smalldatetime] NULL, FECHA DEL COMPROBANTE | 9 | FEC: comprobante.identificaxComprobante.fechaComprobante, // [smalldatetime] NULL, FECHA DEL COMPROBANTE |
10 | NOM: entities.proveedores.NOM, // [varchar](40) NOT NULL, NOMBRE DEL PROVEEDOR TABLA PROVEED CAMPO NOM | 10 | NOM: entities.proveedores.NOM, // [varchar](40) NOT NULL, NOMBRE DEL PROVEEDOR TABLA PROVEED CAMPO NOM |
11 | TIV: entities.proveedores.IVA, // [tinyint] NOT NULL, TIPO DE IVA CAMPO IVA TABLA PROVEED | 11 | TIV: entities.proveedores.IVA, // [tinyint] NOT NULL, TIPO DE IVA CAMPO IVA TABLA PROVEED |
12 | CUI: entities.proveedores.CUIT, // [char](13) NOT NULL, CUIT DEL PROVEEDOR CAMPO CUIT DEL PROVEEDOR O EL QUE VIENE EN LA COMUNICACION | 12 | CUI: entities.proveedores.CUIT, // [char](13) NOT NULL, CUIT DEL PROVEEDOR CAMPO CUIT DEL PROVEEDOR O EL QUE VIENE EN LA COMUNICACION |
13 | FPA: entities.proveedores.FPA, // [tinyint] NOT NULL, FORMA DE PAGO CAMPO FPA TABLA PROVEED | 13 | FPA: entities.proveedores.FPA, // [tinyint] NOT NULL, FORMA DE PAGO CAMPO FPA TABLA PROVEED |
14 | TCA: 1, // [money] NOT NULL, FIJO 1 | 14 | TCA: 1, // [money] NOT NULL, FIJO 1 |
15 | DTO: comprobante.descuentosGlobalesFactura.importe || 0, // [money] NOT NULL, DESCUENTO TOTAL SUMATORIA DE LOS DTO POR ITEM | 15 | DTO: comprobante.descuentosGlobalesFactura.importe || 0, // [money] NOT NULL, DESCUENTO TOTAL SUMATORIA DE LOS DTO POR ITEM |
16 | PDT: 0, // [money] NOT NULL, FIJO 0 | 16 | PDT: 0, // [money] NOT NULL, FIJO 0 |
17 | NET: comprobante.importesTotales.netoGravado, // [money] NOT NULL, SUMATORIA DE LOS NETOS POR ITEM QUE TIENEN IVA <> 0 | 17 | NET: comprobante.importesTotales.netoGravado, // [money] NOT NULL, SUMATORIA DE LOS NETOS POR ITEM QUE TIENEN IVA <> 0 |
18 | NEE: comprobante.importesTotales.importeOperacionesExentas, // [money] NOT NULL, SUMATORIA DE LOS NETOS POR ITEM QUE TIENEN IVA = 0 | 18 | NEE: comprobante.importesTotales.importeOperacionesExentas, // [money] NOT NULL, SUMATORIA DE LOS NETOS POR ITEM QUE TIENEN IVA = 0 |
19 | IRI: comprobante.detallesImportesIVA.importeLiquidado, // [money] NOT NULL, SUMATORIA DE LOS IVA POR ITEM | 19 | IRI: comprobante.detallesImportesIVA.importeLiquidado, // [money] NOT NULL, SUMATORIA DE LOS IVA POR ITEM |
20 | IRS: 0, // [money] NOT NULL, FIJO 0 | 20 | IRS: 0, // [money] NOT NULL, FIJO 0 |
21 | IMI: comprobante.importesTotales.importeImpuestosInternos, // [money] NOT NULL, SUMATORIA DE LOS IMPUESTOS INTERNOS POR ITEM | 21 | IMI: comprobante.importesTotales.importeImpuestosInternos, // [money] NOT NULL, SUMATORIA DE LOS IMPUESTOS INTERNOS POR ITEM |
22 | RGA: 0, // [money] NOT NULL, IMPORTE RETENCION DE GANANCIAS | 22 | RGA: 0, // [money] NOT NULL, IMPORTE RETENCION DE GANANCIAS |
23 | RIB: 0, // [money] NOT NULL, IMPORTE RETENCION DE INGRESOS BRUTOS | 23 | RIB: 0, // [money] NOT NULL, IMPORTE RETENCION DE INGRESOS BRUTOS |
24 | PIV: comprobante.detalleOtrosImpuestosComprobante.percepcionIVA ? comprobante.detalleOtrosImpuestosComprobante.percepcionIVA.importeImpuesto : 0, // [money] NOT NULL, IMPORTE PERCEPCION DE IVA, SECTOR 90 C05 | 24 | PIV: comprobante.detalleOtrosImpuestosComprobante.percepcionIVA ? comprobante.detalleOtrosImpuestosComprobante.percepcionIVA.importeImpuesto : 0, // [money] NOT NULL, IMPORTE PERCEPCION DE IVA, SECTOR 90 C05 |
25 | CNG: comprobante.importesTotales.totalConceptosNoNetoGravado, // [money] NULL, IMPORTE DE CONCEPTOS NO GRAVADOS | 25 | CNG: comprobante.importesTotales.totalConceptosNoNetoGravado, // [money] NULL, IMPORTE DE CONCEPTOS NO GRAVADOS |
26 | TOT: comprobante.importesTotales.totalOperacion, // [money] NOT NULL, IMPORTE TOTAL DE LA FACTURA | 26 | TOT: comprobante.importesTotales.totalOperacion, // [money] NOT NULL, IMPORTE TOTAL DE LA FACTURA |
27 | ZON: entities.empresa.ZON, // [int] NOT NULL, NUMERO DE LA EMPRESA SELECT ZON FROM APAREMP | 27 | ZON: entities.empresa.ZON, // [int] NOT NULL, NUMERO DE LA EMPRESA SELECT ZON FROM APAREMP |
28 | FEV: comprobante.identificaxComprobante.fechaVencimiento, // [datetime] NULL, FECHA DE VENCIMIENTO | 28 | FEV: comprobante.identificaxComprobante.fechaVencimiento, // [datetime] NULL, FECHA DE VENCIMIENTO |
29 | OCP: comprobante.comprobantesReferencia.PC.numeroDocumentoReferencia, // [char](10) NOT NULL, SI VIENE LA ORDEN DE COMPRA FORMATO "0000000000" (DOS PRIMERO PARA PVE Y 8 ULTIMOS EL NUMERO DE LA OC) | 29 | OCP: comprobante.comprobantesReferencia.PC.numeroDocumentoReferencia, // [char](10) NOT NULL, SI VIENE LA ORDEN DE COMPRA FORMATO "0000000000" (DOS PRIMERO PARA PVE Y 8 ULTIMOS EL NUMERO DE LA OC) |
30 | OPE: 0, // [int] NOT NULL, FIJO 0 | 30 | OPE: 0, // [int] NOT NULL, FIJO 0 |
31 | REC: 0, // [bigint] NOT NULL, FIJO 0 | 31 | REC: 0, // [bigint] NOT NULL, FIJO 0 |
32 | FEP: comprobante.identificaxComprobante.fechaComprobante, // [datetime] NULL, ITEM FECHA FACTURA | 32 | FEP: comprobante.identificaxComprobante.fechaComprobante, // [datetime] NULL, ITEM FECHA FACTURA |
33 | NPE: 0, // [bigint] NOT NULL, NOTA DE PEDIDO FIJO 0 | 33 | NPE: 0, // [bigint] NOT NULL, NOTA DE PEDIDO FIJO 0 |
34 | CPA: 0, // [int] NOT NULL, FIJO 0 | 34 | CPA: 0, // [int] NOT NULL, FIJO 0 |
35 | ENV: 0, // [int] NOT NULL, FIJO 0 | 35 | ENV: 0, // [int] NOT NULL, FIJO 0 |
36 | REM: 0, // [bigint] NOT NULL, FIJO 0 | 36 | REM: 0, // [bigint] NOT NULL, FIJO 0 |
37 | PRO: ' ', // [char](1) NOT NULL, FIJO ' ' VACIO NO NULO | 37 | PRO: ' ', // [char](1) NOT NULL, FIJO ' ' VACIO NO NULO |
38 | ANU: ' ', // [char](1) NOT NULL, FIJO ' ' VACIO NO NULO | 38 | ANU: ' ', // [char](1) NOT NULL, FIJO ' ' VACIO NO NULO |
39 | TUR: 0, // [int] NOT NULL, FIJO 0 | 39 | TUR: 0, // [int] NOT NULL, FIJO 0 |
40 | PLA: 0, // [int] NOT NULL, FIJO 0 | 40 | PLA: 0, // [int] NOT NULL, FIJO 0 |
41 | LUG: 0, // [int] NOT NULL, FIJO 0 | 41 | LUG: 0, // [int] NOT NULL, FIJO 0 |
42 | ATO: 0, // [numeric](18, 0) NOT NULL, FIJO 0 | 42 | ATO: 0, // [numeric](18, 0) NOT NULL, FIJO 0 |
43 | CCO: 0, // [bigint] NOT NULL, FIJO 0 | 43 | CCO: 0, // [bigint] NOT NULL, FIJO 0 |
44 | IMA: 0, // [int] NOT NULL, FIJO 0 | 44 | IMA: 0, // [int] NOT NULL, FIJO 0 |
45 | CCA1: 0, // [int] NOT NULL, FIJO 0 | 45 | CCA1: 0, // [int] NOT NULL, FIJO 0 |
46 | CCA2: 0, // [int] NOT NULL, FIJO 0 | 46 | CCA2: 0, // [int] NOT NULL, FIJO 0 |
47 | CCA3: 0, // [int] NOT NULL, FIJO 0 | 47 | CCA3: 0, // [int] NOT NULL, FIJO 0 |
48 | CCA4: 0, // [int] NOT NULL, FIJO 0 | 48 | CCA4: 0, // [int] NOT NULL, FIJO 0 |
49 | CCA5: 0, // [int] NOT NULL, FIJO 0 | 49 | CCA5: 0, // [int] NOT NULL, FIJO 0 |
50 | CCA6: 0, // [int] NOT NULL, FIJO 0 | 50 | CCA6: 0, // [int] NOT NULL, FIJO 0 |
51 | CCA7: 0, // [int] NOT NULL, FIJO 0 | 51 | CCA7: 0, // [int] NOT NULL, FIJO 0 |
52 | CCA8: 0, // [int] NOT NULL, FIJO 0 | 52 | CCA8: 0, // [int] NOT NULL, FIJO 0 |
53 | CCA0: 0, // [int] NOT NULL, FIJO 0 | 53 | CCA0: 0, // [int] NOT NULL, FIJO 0 |
54 | OBS: comprobante.importesTotales.observaciones, // [varchar](60) NOT NULL, SI VIENEN OBSERVACIONES PONER AQUI SINO VACIO NO NULO | 54 | OBS: comprobante.importesTotales.observaciones, // [varchar](60) NOT NULL, SI VIENEN OBSERVACIONES PONER AQUI SINO VACIO NO NULO |
55 | RIV: 0, // [money] NOT NULL, IMPORTE RETENCION DE IVA | 55 | RIV: 0, // [money] NOT NULL, IMPORTE RETENCION DE IVA |
56 | FECCAI: comprobante.identificaxComprobante.fechaVencimientoCai, // [smalldatetime] NOT NULL, FECHA DEL CAI | 56 | FECCAI: comprobante.identificaxComprobante.fechaVencimientoCai, // [smalldatetime] NOT NULL, FECHA DEL CAI |
57 | CAI: comprobante.identificaxComprobante.cai, // [char](16) NOT NULL, NUMERO DE CAI | 57 | CAI: comprobante.identificaxComprobante.cai, // [char](16) NOT NULL, NUMERO DE CAI |
58 | CHO: 0, // [int] NOT NULL, FIJO 0 | 58 | CHO: 0, // [int] NOT NULL, FIJO 0 |
59 | CTR: '', // [char](1) NOT NULL, VACIO NO NULO | 59 | CTR: '', // [char](1) NOT NULL, VACIO NO NULO |
60 | PER: comprobante.importesTotales.importeIB, // [money] NOT NULL, IMPORTE DE PERCEPCIONES | 60 | PER: comprobante.importesTotales.importeIB, // [money] NOT NULL, IMPORTE DE PERCEPCIONES |
61 | CCA9: 0, // [int] NOT NULL, FIJO 0 | 61 | CCA9: 0, // [int] NOT NULL, FIJO 0 |
62 | FECVEN: comprobante.identificaxComprobante.fechaVencimiento, // [smalldatetime] NOT NULL, FECHA DE VENCIMIENTO DE LA FACTURA | 62 | FECVEN: comprobante.identificaxComprobante.fechaVencimiento, // [smalldatetime] NOT NULL, FECHA DE VENCIMIENTO DE LA FACTURA |
63 | CNG2: 0, // [money] NOT NULL, IMPORTE DE CONCEPTOS NO GRAVADOS 2 | 63 | CNG2: 0, // [money] NOT NULL, IMPORTE DE CONCEPTOS NO GRAVADOS 2 |
64 | E_HD: '', // [varchar](8) NOT NULL, VACIO NO NULO | 64 | E_HD: '', // [varchar](8) NOT NULL, VACIO NO NULO |
65 | C_HD: '', // [varchar](1) NOT NULL, VACIO NO NULO | 65 | C_HD: '', // [varchar](1) NOT NULL, VACIO NO NULO |
66 | RSS: 0, // [money] NOT NULL, IMPORTE RETENCIONS SUSS | 66 | RSS: 0, // [money] NOT NULL, IMPORTE RETENCIONS SUSS |
67 | E_HD2: '', // [varchar](12) NOT NULL, VACIO NO NULO | 67 | E_HD2: '', // [varchar](12) NOT NULL, VACIO NO NULO |
68 | C_HD2: '', // [varchar](1) NOT NULL, VACIO NO NULO | 68 | C_HD2: '', // [varchar](1) NOT NULL, VACIO NO NULO |
69 | DTO2: 0, // [money] NOT NULL, IMPORTE DE OTROS DESCUENTOS | 69 | DTO2: 0, // [money] NOT NULL, IMPORTE DE OTROS DESCUENTOS |
70 | ENLP: 0, // [bit] NOT NULL, FIJO 0 | 70 | ENLP: 0, // [bit] NOT NULL, FIJO 0 |
71 | COD_TRANS: comprobante.identificaxComprobante.numeroRegistrado || 0, // [bigint] NOT NULL, VER DE PONER EL NUMERO DE REFERENCIA QUE PUEDA UNIRNOS A LO QUE VIENE DESDE PLANEX | 71 | COD_TRANS: comprobante.identificaxComprobante.numeroRegistrado || 0, // [bigint] NOT NULL, VER DE PONER EL NUMERO DE REFERENCIA QUE PUEDA UNIRNOS A LO QUE VIENE DESDE PLANEX |
72 | RETMUN: comprobante.importesTotales.importeImpuestosMunicipales, // [money] NOT NULL, IMPORTE DE RETENCIONES MUNICIPALES | 72 | RETMUN: comprobante.importesTotales.importeImpuestosMunicipales, // [money] NOT NULL, IMPORTE DE RETENCIONES MUNICIPALES |
73 | TIPO_OPERACION: 0, // [int] NOT NULL, FIJO 0 | 73 | TIPO_OPERACION: 0, // [int] NOT NULL, FIJO 0 |
74 | IRD: 0, // [money] NOT NULL, FIJO 0 | 74 | IRD: 0, // [money] NOT NULL, FIJO 0 |
75 | AUX1: 0, // [money] NOT NULL, FIJO 0 | 75 | AUX1: 0, // [money] NOT NULL, FIJO 0 |
76 | AUX2: 0, // [money] NOT NULL, FIJO 0 | 76 | AUX2: 0, // [money] NOT NULL, FIJO 0 |
77 | AUX3: 0, // [money] NOT NULL, FIJO 0 | 77 | AUX3: 0, // [money] NOT NULL, FIJO 0 |
78 | AUX4: 0, // [money] NOT NULL, FIJO 0 | 78 | AUX4: 0, // [money] NOT NULL, FIJO 0 |
79 | ARBA: 0, // [money] NOT NULL, IMPORTE RETENCION ARBA | 79 | ARBA: 0, // [money] NOT NULL, IMPORTE RETENCION ARBA |
80 | DGR: 0, // [money] NOT NULL, IMPORTE RETENCION DGR | 80 | DGR: 0, // [money] NOT NULL, IMPORTE RETENCION DGR |
81 | DTO_PIE: 0, // [money] NOT NULL, IMPORTE DE DESCUENTO AL PIE, NO POR ITEM | 81 | DTO_PIE: 0, // [money] NOT NULL, IMPORTE DE DESCUENTO AL PIE, NO POR ITEM |
82 | OPERACIONES_3711: 1, // [int] NOT NULL, FIJO 1 (PORQUE SON BIENES) | 82 | OPERACIONES_3711: 1, // [int] NOT NULL, FIJO 1 (PORQUE SON BIENES) |
83 | ORC: comprobante.comprobantesReferencia.PC.numeroDocumentoReferencia, // [bigint] NOT NULL, NUMERO DE ORDEN DE COMPRA | 83 | ORC: comprobante.comprobantesReferencia.PC.numeroDocumentoReferencia, // [bigint] NOT NULL, NUMERO DE ORDEN DE COMPRA |
84 | NC_ES_NP: 0, // [bit] NOT NULL, FIJO 0 | 84 | NC_ES_NP: 0, // [bit] NOT NULL, FIJO 0 |
85 | CABA: 0, // [money] NOT NULL, IMPORTE RETENCION CABA | 85 | CABA: 0, // [money] NOT NULL, IMPORTE RETENCION CABA |
86 | ARBA_PER: 0, // [money] NOT NULL, IMPORTE PERCEPCION ARBA | 86 | ARBA_PER: 0, // [money] NOT NULL, IMPORTE PERCEPCION ARBA |
87 | CABA_PER: 0, // [money] NOT NULL, IMPORTE PERCEPCION CABA | 87 | CABA_PER: 0, // [money] NOT NULL, IMPORTE PERCEPCION CABA |
88 | PERMUN: comprobante.importesTotales.importeImpuestosMunicipales, // [money] NOT NULL, IMPORTE PERCEPCIONES MUNICIPALES | 88 | PERMUN: comprobante.importesTotales.importeImpuestosMunicipales, // [money] NOT NULL, IMPORTE PERCEPCIONES MUNICIPALES |
89 | IMI2: 0, // [money] NOT NULL, FIJO 0 | 89 | IMI2: 0, // [money] NOT NULL, FIJO 0 |
90 | gln: comprobante.identificaxSucursalReceptorFactura.glnSucursal | ||
90 | }; | 91 | }; |
91 | } | 92 | } |
92 | 93 |
debo/cuerpoDebo.js
1 | module.exports = function(comprobante, afipTablas, entities, item) { | 1 | module.exports = function(comprobante, afipTablas, entities, item) { |
2 | 2 | ||
3 | return { | 3 | return { |
4 | TIP: afipTablas(comprobante.identificaxComprobante.tipo).letraComprobante, // [char](1) NOT NULL, LETRA DEL COMPROBANTE (A,B,C,M) | 4 | TIP: afipTablas(comprobante.identificaxComprobante.tipo).letraComprobante, // [char](1) NOT NULL, LETRA DEL COMPROBANTE (A,B,C,M) |
5 | TCO: afipTablas(comprobante.identificaxComprobante.tipo).tipoComprobante, // [char](2) NOT NULL, TIPO DE COMPROBANTE (FT,NC,ND) | 5 | TCO: afipTablas(comprobante.identificaxComprobante.tipo).tipoComprobante, // [char](2) NOT NULL, TIPO DE COMPROBANTE (FT,NC,ND) |
6 | SUC: parseInt(comprobante.identificaxComprobante.puntoVenta), // [int] NOT NULL, PUNTO DE VENTA DE LA FACTURA | 6 | SUC: parseInt(comprobante.identificaxComprobante.puntoVenta), // [int] NOT NULL, PUNTO DE VENTA DE LA FACTURA |
7 | NCO: parseInt(comprobante.identificaxComprobante.numero), // [bigint] NOT NULL, NUMERO DE COMPROBANTE | 7 | NCO: parseInt(comprobante.identificaxComprobante.numero), // [bigint] NOT NULL, NUMERO DE COMPROBANTE |
8 | PRO: entities.proveedores.COD, // [int] NOT NULL, CODIGO DEL PROVEEDOR NECESITAS RELACION -- BUSCAR SI ENVIAN EL CUIT DEL PROVEEDOR SELECT COD FROM PROVEED WHERE CUIT= '30-54775125-2' | 8 | PRO: entities.proveedores.COD, // [int] NOT NULL, CODIGO DEL PROVEEDOR NECESITAS RELACION -- BUSCAR SI ENVIAN EL CUIT DEL PROVEEDOR SELECT COD FROM PROVEED WHERE CUIT= '30-54775125-2' |
9 | ORD: parseInt(item.numeroLinea), // [int] NOT NULL, ORDEN DEL ITEM, EMPIEZA EN 1 Y SUMA DE A 1 POR CADA REGISTRO DE MOVIMIENTO | 9 | ORD: parseInt(item.numeroLinea), // [int] NOT NULL, ORDEN DEL ITEM, EMPIEZA EN 1 Y SUMA DE A 1 POR CADA REGISTRO DE MOVIMIENTO |
10 | COD: item.CodSec, // [int] NOT NULL, SECTOR DEBO DEL PRODUCTO | 10 | COD: item.CodSec, // [int] NOT NULL, SECTOR DEBO DEL PRODUCTO |
11 | ART: item.CodArt, // [int] NOT NULL, ARTICULO DEBO DEL PRODUCTO ESTOS 2 SE OBTIENEN A PARTIR DEL CODIGO DE BARRAS: SELECT CodSec AS SECTOR,CodArt AS ARTICULO FROM CODBAR WHERE CODBAR='03239210540' | 11 | ART: item.CodArt, // [int] NOT NULL, ARTICULO DEBO DEL PRODUCTO ESTOS 2 SE OBTIENEN A PARTIR DEL CODIGO DE BARRAS: SELECT CodSec AS SECTOR,CodArt AS ARTICULO FROM CODBAR WHERE CODBAR='03239210540' |
12 | RUB: item.CodRub, // [int] NOT NULL, CODIGO DE RUBRO SE OBTIENE DE LA TABLA ARTICULOS SELECT DET_LAR,CODRUB FROM ARTICULOS WHERE CODSEC=SECTOR AND CODART=ARTICULO (DATOS OBTENIDOS EN NOTA ANTERIOR | 12 | RUB: item.CodRub, // [int] NOT NULL, CODIGO DE RUBRO SE OBTIENE DE LA TABLA ARTICULOS SELECT DET_LAR,CODRUB FROM ARTICULOS WHERE CODSEC=SECTOR AND CODART=ARTICULO (DATOS OBTENIDOS EN NOTA ANTERIOR |
13 | TIO: item.DET_LAR, // [varchar](60) NOT NULL DESCRIPCION DEL PRODUCTO DEL PUNTO ANTERIOR DET_LAR | 13 | TIO: item.DET_LAR, // [varchar](60) NOT NULL DESCRIPCION DEL PRODUCTO DEL PUNTO ANTERIOR DET_LAR |
14 | LI0: item.descripcion, // [varchar](60) NOT NULL, DESCRIPCION ENVIADA POR EL PROVEEDOR | 14 | LI0: item.descripcion, // [varchar](60) NOT NULL, DESCRIPCION ENVIADA POR EL PROVEEDOR |
15 | CAN: item.cantidad, // [money] NOT NULL, CANTIDAD DEL ITEM | 15 | CAN: item.cantidad, // [money] NOT NULL, CANTIDAD DEL ITEM |
16 | PUN: item.precioUnitario, // [decimal](20, 8) NOT NULL PRECIO UNITARIO DEL PRODUCTO ITEM | 16 | PUN: item.precioUnitario, // [decimal](20, 8) NOT NULL PRECIO UNITARIO DEL PRODUCTO ITEM |
17 | IMI: item.impuestoInterno ? item.impuestoInterno.importeImpuesto : 0, // [money] NOT NULL, IMPORTE IMPUESTOS INTERNOS DEL ITEM | 17 | IMI: item.impuestoInterno ? item.impuestoInterno.importeImpuesto : 0, // [money] NOT NULL, IMPORTE IMPUESTOS INTERNOS DEL ITEM |
18 | IVA: item.importeIVA, // [money] NOT NULL, IMPORTE IVA DEL ITEM | 18 | IVA: item.importeIVA, // [money] NOT NULL, IMPORTE IVA DEL ITEM |
19 | PUT: item.precioUnitario, // [money] NOT NULL, IGUAL AL PUN | 19 | PUT: item.precioUnitario, // [money] NOT NULL, IGUAL AL PUN |
20 | LEG: 0, // [int] NOT NULL, FIJO 0 | 20 | LEG: 0, // [int] NOT NULL, FIJO 0 |
21 | CMF: 0, // [int] NOT NULL, FIJO 0 | 21 | CMF: 0, // [int] NOT NULL, FIJO 0 |
22 | TUR: 0, // [int] NOT NULL, FIJO 0 | 22 | TUR: 0, // [int] NOT NULL, FIJO 0 |
23 | PLA: 0, // [int] NOT NULL, FIJO 0 | 23 | PLA: 0, // [int] NOT NULL, FIJO 0 |
24 | LUG: 0, // [int] NOT NULL, FIJO 0 | 24 | LUG: 0, // [int] NOT NULL, FIJO 0 |
25 | ESC: 0, // [bit] NOT NULL, FIJO 0 | 25 | ESC: 0, // [bit] NOT NULL, FIJO 0 |
26 | TAN: 0, // [int] NOT NULL, FIJO 0 | 26 | TAN: 0, // [int] NOT NULL, FIJO 0 |
27 | CCO: 0, // [bigint] NOT NULL, FIJO 0 | 27 | CCO: 0, // [bigint] NOT NULL, FIJO 0 |
28 | E_HD: '', // [varchar](8) NOT NULL, FIJO '' VACIO NO NULO | 28 | E_HD: '', // [varchar](8) NOT NULL, FIJO '' VACIO NO NULO |
29 | C_HD: '', // [varchar](1) NOT NULL, FIJO '' VACIO NO NULO | 29 | C_HD: '', // [varchar](1) NOT NULL, FIJO '' VACIO NO NULO |
30 | DTO: 0, // Comprobante.detalleDescuentosItemFactura.importeDescuento; [money] NOT NULL, IMPORTE DESCUENTO DE LA FACTURA | 30 | DTO: 0, // Comprobante.detalleDescuentosItemFactura.importeDescuento; [money] NOT NULL, IMPORTE DESCUENTO DE LA FACTURA |
31 | PTA: 0, // [int] NOT NULL, FIJO 0 | 31 | PTA: 0, // [int] NOT NULL, FIJO 0 |
32 | SUBM: 0, // [int] NOT NULL, FIJO 0 | 32 | SUBM: 0, // [int] NOT NULL, FIJO 0 |
33 | E_HD2: '', // [varchar](12) NOT NULL, FIJO '' VACIO NO NULO | 33 | E_HD2: '', // [varchar](12) NOT NULL, FIJO '' VACIO NO NULO |
34 | C_HD2: '', // [varchar](1) NOT NULL, FIJO '' VACIO NO NULO | 34 | C_HD2: '', // [varchar](1) NOT NULL, FIJO '' VACIO NO NULO |
35 | COMISION: 0, // [money] NOT NULL, FIJO 0 | 35 | COMISION: 0, // [money] NOT NULL, FIJO 0 |
36 | LIQ_VTA: '', // [varchar](20) NOT NULL, FIJO '' VACIO NO NULO | 36 | LIQ_VTA: '', // [varchar](20) NOT NULL, FIJO '' VACIO NO NULO |
37 | COSTO_PMOV: comprobante.itemsFactura.precioUnitario, // [money] NOT NULL, IGUAL AL PUN | 37 | COSTO_PMOV: comprobante.itemsFactura.precioUnitario, // [money] NOT NULL, IGUAL AL PUN |
38 | SAL_ITEM: 0, // [money] NOT NULL, fijo 0 es el que se llenara al mostrar en la tablet o telefono para que llene operador | 38 | SAL_ITEM: 0, // [money] NOT NULL, fijo 0 es el que se llenara al mostrar en la tablet o telefono para que llene operador |
39 | TASIVA: comprobante.itemsFactura.alicuotaIVAAplicable, // [money] NOT NULL, TASA DE IVA DEL ITEM = 21.00 / 10.50 / ETC. | 39 | TASIVA: comprobante.itemsFactura.alicuotaIVAAplicable, // [money] NOT NULL, TASA DE IVA DEL ITEM = 21.00 / 10.50 / ETC. |
40 | gln: comprobante.identificaxSucursalReceptorFactura.glnSucursal, //gln sucursal | ||
41 | codigoBarras: item.codigoUPCEAN13 | ||
40 | }; | 42 | }; |
41 | } | 43 | } |
42 | 44 |
debo/index.js
1 | module.exports = function(comprobante, entities) { | 1 | module.exports = function(comprobante, entities) { |
2 | 2 | ||
3 | var afipTablas = require('../afip/index'); | 3 | var afipTablas = require('../afip/index'); |
4 | 4 | ||
5 | var objReturn = { | 5 | var objReturn = { |
6 | cabecera: require('./cabeceraDebo')(comprobante, afipTablas, entities), | 6 | cabecera: require('./cabeceraDebo')(comprobante, afipTablas, entities), |
7 | cuerpo: [] | 7 | cuerpo: [] |
8 | } | 8 | } |
9 | 9 | ||
10 | comprobante.itemsFactura.forEach((item, index) => { | 10 | comprobante.itemsFactura.forEach((item) => { |
11 | 11 | ||
12 | objReturn.cuerpo.push(require('./cuerpoDebo')(comprobante, afipTablas, entities, item)); | 12 | objReturn.cuerpo.push(require('./cuerpoDebo')(comprobante, afipTablas, entities, item)); |
13 | }); | 13 | }); |
14 | 14 | ||
15 | return objReturn; | 15 | return objReturn; |
16 | } | 16 | } |
17 | 17 |
debo/relaciones.js
1 | module.exports = function(planex, wsServer) { | 1 | module.exports = function(planex, wsServer) { |
2 | 2 | ||
3 | return new Promise(function(resolve, reject) { | 3 | return new Promise(function(resolve, reject) { |
4 | 4 | ||
5 | var promesasArticulo = []; | 5 | var promesasArticulo = []; |
6 | 6 | ||
7 | var tipoCuit = planex.identificaxEmisor.cuit.slice(0, 2); | 7 | var tipoCuit = planex.identificaxEmisor.cuit.slice(0, 2); |
8 | var digitoVerificador = planex.identificaxEmisor.cuit[planex.identificaxEmisor.cuit.length - 1]; | 8 | var digitoVerificador = planex.identificaxEmisor.cuit[planex.identificaxEmisor.cuit.length - 1]; |
9 | var cuitToDebo = tipoCuit + '-' + planex.identificaxEmisor.cuit.slice(2, 10) + '-' + digitoVerificador; | 9 | var cuitToDebo = tipoCuit + '-' + planex.identificaxEmisor.cuit.slice(2, 10) + '-' + digitoVerificador; |
10 | 10 | ||
11 | var promiseProveedores = wsServer.getEntidad(planex.identificaxReceptorFactura.glnReceptor, 'PROVEED', {CUIT: cuitToDebo}); | 11 | var promiseProveedores = wsServer.getEntidad(planex.identificaxReceptorFactura.glnReceptor, 'PROVEED', {CUIT: cuitToDebo}); |
12 | var promiseEmp = wsServer.getEntidad(planex.identificaxReceptorFactura.glnReceptor, 'APAREMP'); | 12 | var promiseEmp = wsServer.getEntidad(planex.identificaxReceptorFactura.glnReceptor, 'APAREMP'); |
13 | 13 | ||
14 | planex.itemsFactura.forEach(item => { | 14 | planex.itemsFactura.forEach(item => { |
15 | 15 | ||
16 | var queryString = 'select cb.*, art.CodRub, art.DET_LAR from CODBAR cb ' + | 16 | var queryString = 'select cb.*, art.CodRub, art.DET_LAR from CODBAR cb ' + |
17 | 'join ARTICULOS art on cb.CodArt = art.CodArt and cb.CodSec = art.CodSec where cb.CodBar = \'' + | 17 | 'join ARTICULOS art on cb.CodArt = art.CodArt and cb.CodSec = art.CodSec where cb.CodBar = \'' + |
18 | item.codigoUPCEAN13 + '\''; | 18 | item.codigoUPCEAN13 + '\''; |
19 | 19 | ||
20 | promesasArticulo.push( | 20 | promesasArticulo.push( |
21 | wsServer.getEntidad(planex.identificaxReceptorFactura.glnReceptor, null, {}, queryString) | 21 | wsServer.getEntidad(planex.identificaxReceptorFactura.glnReceptor, null, {}, queryString) |
22 | ); | 22 | ); |
23 | }); | 23 | }); |
24 | 24 | ||
25 | promesas = promesasArticulo.concat([promiseProveedores, promiseEmp]); | 25 | promesas = promesasArticulo.concat([promiseProveedores, promiseEmp]); |
26 | 26 | ||
27 | Promise.all(promesas).then(function(values) { | 27 | Promise.all(promesas).then(function(values) { |
28 | 28 | ||
29 | planex.itemsFactura.forEach((item, index) => { | 29 | planex.itemsFactura.forEach((item, index) => { |
30 | 30 | ||
31 | if (!values[index]) console.error('No se encontrĂ³ el articulo'); | 31 | if (!values[index]) return; console.error('No se encontrĂ³ el articulo'); |
32 | 32 | ||
33 | item.CodArt = values[index].CodArt; | 33 | item.CodArt = values[index].CodArt; |
34 | item.CodSec = values[index].CodSec; | 34 | item.CodSec = values[index].CodSec; |
35 | item.CodRub = values[index].CodRub; | 35 | item.CodRub = values[index].CodRub; |
36 | item.DET_LAR = values[index].DET_LAR; | 36 | item.DET_LAR = values[index].DET_LAR; |
37 | 37 | ||
38 | delete values[index]; | 38 | delete values[index]; |
39 | }); | 39 | }); |
40 | 40 | ||
41 | values = values.filter(function(p) { | 41 | values = values.filter(function(p) { |
42 | return p; | 42 | return p; |
43 | }); | 43 | }); |
44 | 44 | ||
45 | resolve({planex, values}); | 45 | resolve({planex, values}); |
46 | 46 | ||
47 | }); | 47 | }); |
48 | 48 | ||
49 | }); | 49 | }); |
50 | } | 50 | } |
debo/validacion.js
1 | module.exports = function(debo, wsServer, gln) { | 1 | module.exports = function(debo, wsServer, gln) { |
2 | 2 | ||
3 | return new Promise(function(resolve, reject) { | 3 | return new Promise(function(resolve, reject) { |
4 | 4 | ||
5 | wsServer | 5 | wsServer |
6 | .getEntidad(gln, 'PMAEFACT_TEMP', { | 6 | .getEntidad(gln, 'PMAEFACT_TEMP', { |
7 | TIP: debo.cabecera.TIP, | 7 | TIP: debo.cabecera.TIP, |
8 | TCO: debo.cabecera.TCO, | 8 | TCO: debo.cabecera.TCO, |
9 | SUC: debo.cabecera.SUC, | 9 | SUC: debo.cabecera.SUC, |
10 | NCO: debo.cabecera.NCO, | 10 | NCO: debo.cabecera.NCO, |
11 | COD: debo.cabecera.COD | 11 | COD: debo.cabecera.COD |
12 | }).then(function(values) { | 12 | }).then(function(values) { |
13 | 13 | ||
14 | if (values) { | 14 | if (values) { |
15 | reject('Ya existe el comprobante', values); | 15 | reject('Ya existe el comprobante', values); |
16 | } else { | 16 | } else { |
17 | resolve(); | 17 | resolve(); |
18 | } | 18 | } |
19 | }); | 19 | }); |
20 | }); | 20 | }); |
21 | } | ||
21 | } |
index.js
1 | config = require('./config/config.json'); | 1 | config = require('./config/config.json'); |
2 | module.exports = knex = require('knex')(config.db) | 2 | |
3 | module.exports = | ||
4 | knex = require('knex')(config.db), | ||
5 | express = require('express'); | ||
6 | app = express(); | ||
7 | wsServer = require('./webSocketServer/index')(); | ||
8 | moment = require('moment'); | ||
9 | |||
10 | app.listen(config.portWebService); | ||
11 | app.use(express.json({ limit: '50mb' })); | ||
3 | 12 | ||
4 | require('./watch/index')(config.dir, onGetFile); | 13 | require('./watch/index')(config.dir, onGetFile); |
5 | 14 | ||
6 | const wsServer = require('./webSocketServer/index')(); | 15 | app.use(function(req, res, next) { |
7 | var planexArr = [] | 16 | res.setHeader('Access-Control-Allow-Origin', '*'); |
17 | res.setHeader( | ||
18 | 'Access-Control-Allow-Headers', | ||
19 | 'Origin, X-Requested-With, Content-Type, Accept, X-Terminal-Key, X-Nombre-Usuario, X-Punto-Venta' | ||
20 | ); | ||
21 | res.setHeader('Access-Control-Allow-Methods', 'POST, GET, DELETE, OPTIONS'); | ||
22 | next(); | ||
23 | }); | ||
24 | |||
25 | app.use('/gateway-debo', require('./rutas/comprobantes')); | ||
26 | app.use('/gateway-debo', require('./rutas/login')); | ||
27 | |||
28 | var planexArr = []; | ||
8 | 29 | ||
9 | function onGetFile(fileString) { | 30 | function onGetFile(fileString) { |
10 | 31 | ||
11 | if (!fileString) return; | 32 | if (!fileString) return; |
12 | 33 | ||
13 | var planex = require('./planex/index')(fileString); | 34 | var planex = require('./planex/index')(fileString); |
14 | 35 | ||
15 | planexArr.push(planex); | 36 | planexArr.push(planex); |
16 | 37 | ||
17 | // Traigo proveedor, empresa | 38 | // Traigo proveedor, empresa |
18 | require('./debo/relaciones')(planex, wsServer).then(function(result) { | 39 | require('./debo/relaciones')(planex, wsServer).then(function(result) { |
19 | 40 | ||
20 | var planex = planexArr.filter(function(p) { | 41 | var planex = result.planex; |
21 | return p.identificaxMensaje.idMensaje == result.planex.identificaxMensaje.idMensaje | ||
22 | })[0]; | ||
23 | 42 | ||
24 | var entities = {}; | 43 | var entities = {}; |
25 | 44 | ||
26 | entities.proveedores = result.values[0]; | 45 | entities.proveedores = result.values[0]; |
27 | entities.empresa = result.values[1]; | 46 | entities.empresa = result.values[1]; |
28 | 47 | ||
29 | var debo = require('./debo/index')(planex, entities); | 48 | var debo = require('./debo/index')(planex, entities); |
30 | 49 | ||
31 | require('./debo/validacion')(debo, wsServer, planex.identificaxReceptorFactura.glnReceptor).then(function() { | 50 | require('./debo/validacion')(debo, wsServer, planex.identificaxSucursalReceptorFactura.glnSucursal).then(function() { |
32 | 51 | ||
33 | require('./db/index')(debo); | 52 | require('./db/index')(debo); |
34 | }).catch(function(err) { | 53 | }).catch(function(err) { |
35 | 54 | ||
36 | console.log(err); | 55 | console.log(err); |
37 | }); | 56 | }); |
38 | 57 | ||
39 | |||
40 | }); | 58 | }); |
41 | } | 59 | } |
42 | 60 | ||
43 | console.log('listen websocket port ' + config.port); | 61 | console.log('listen websocket port ' + config.port); |
package.json
1 | { | 1 | { |
2 | "name": "websocketho", | 2 | "name": "websocketho", |
3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
4 | "description": "WebSocket Head Office", | 4 | "description": "WebSocket Head Office", |
5 | "main": "index.js", | 5 | "main": "index.js", |
6 | "dependencies": { | 6 | "dependencies": { |
7 | "chokidar": "^3.0.0", | 7 | "chokidar": "^3.0.1", |
8 | "express": "^4.16.4", | 8 | "express": "^4.17.1", |
9 | "knex": "^0.16.5", | 9 | "knex": "^0.16.5", |
10 | "moment": "^2.24.0", | ||
10 | "mssql": "^5.1.0", | 11 | "mssql": "^5.1.0", |
11 | "ws": "^7.0.0" | 12 | "ws": "^7.0.0" |
12 | }, | 13 | }, |
13 | "devDependencies": {}, | 14 | "devDependencies": { |
15 | "nodemon": "^1.19.1" | ||
16 | }, | ||
14 | "scripts": { | 17 | "scripts": { |
15 | "test": "echo \"Error: no test specified\" && exit 1" | 18 | "test": "echo \"Error: no test specified\" && exit 1", |
19 | "dev": "nodemon index.js" | ||
16 | }, | 20 | }, |
17 | "author": "Foca Software", | 21 | "author": "Foca Software", |
18 | "license": "ISC" | 22 | "license": "ISC" |
19 | } | 23 | } |
20 | 24 |
webSocketServer/index.js
1 | module.exports = function() { | 1 | module.exports = function() { |
2 | 2 | ||
3 | const webSocketServer = require('ws').Server; | 3 | const webSocketServer = require('ws').Server; |
4 | var clients = []; | 4 | var clients = []; |
5 | 5 | ||
6 | const objWs = {}; | 6 | const objWs = {}; |
7 | 7 | ||
8 | objWs.wsServer = new webSocketServer({ | 8 | objWs.wsServer = new webSocketServer({ |
9 | port: config.port | 9 | port: config.port |
10 | }); | 10 | }); |
11 | 11 | ||
12 | objWs.wsServer.on('connection', function connection(ws) { | 12 | objWs.wsServer.on('connection', function connection(ws) { |
13 | 13 | ||
14 | console.log('open socket server'); | 14 | console.log('open socket server'); |
15 | 15 | ||
16 | ws.on('message', function incoming(message) { | 16 | ws.on('message', function incoming(message) { |
17 | 17 | ||
18 | message = JSON.parse(message.toString('utf8')); | 18 | message = JSON.parse(message.toString('utf8')); |
19 | 19 | ||
20 | switch (message.action) { | 20 | switch (message.action) { |
21 | case 'gln': | 21 | case 'gln': |
22 | clients.push({ws: ws, gln: message.gln}); | 22 | clients.push({ws: ws, gln: message.gln}); |
23 | break; | 23 | break; |
24 | default: | 24 | default: |
25 | // console.log(message.action); | 25 | // console.log(message.action); |
26 | } | 26 | } |
27 | }); | ||
27 | }); | 28 | }); |
28 | }); | ||
29 | 29 | ||
30 | objWs.getEntidad = function(gln, tableName, where, queryString) { | 30 | objWs.getEntidad = function(gln, tableName, where, queryString) { |
31 | 31 | ||
32 | return new Promise(function(resolve, reject) { | 32 | return new Promise(function(resolve, reject) { |
33 | 33 | ||
34 | var client = clients.filter(function(client) { | 34 | var client = clients.filter(function(client) { |
35 | return client.gln == gln | 35 | return client.gln == gln |
36 | })[0]; | 36 | })[0]; |
37 | |||
38 | if (!client) { | ||
39 | reject('No se encuentra el webSocket client'); | ||
40 | } | ||
37 | 41 | ||
38 | if (!client) { | 42 | var idSolicitud = Math.round(Math.random() * 1000); |
39 | reject('No se encuentra el webSocket client'); | ||
40 | } | ||
41 | 43 | ||
42 | var idSolicitud = Math.round(Math.random() * 1000); | 44 | var enviar = { |
45 | action: 'getEntity', | ||
46 | idSolicitud: idSolicitud | ||
47 | }; | ||
43 | 48 | ||
44 | var enviar = { | 49 | if (queryString) { |
45 | action: 'getEntity', | ||
46 | idSolicitud: idSolicitud | ||
47 | }; | ||
48 | 50 | ||
49 | if (queryString) { | 51 | enviar.queryString = queryString; |
52 | } else { | ||
53 | enviar.tableName = tableName; | ||
54 | enviar.where = where || {}; | ||
55 | } | ||
50 | 56 | ||
51 | enviar.queryString = queryString; | 57 | client.ws.send(JSON.stringify(enviar)); |
52 | } else { | ||
53 | enviar.tableName = tableName; | ||
54 | enviar.where = where || {}; | ||
55 | } | ||
56 | 58 | ||
57 | client.ws.send(JSON.stringify(enviar)); | 59 | client.ws.on('message', function(message) { |
58 | 60 | ||
59 | client.ws.on('message', function(message) { | 61 | message = JSON.parse(message); |
60 | 62 | ||
61 | message = JSON.parse(message); | 63 | if (idSolicitud == message.idSolicitud) { |
62 | 64 | ||
63 | if (idSolicitud == message.idSolicitud) { | 65 | resolve(message.data); |
66 | } | ||
64 | 67 | ||
65 | resolve(message.data); | 68 | }); |
66 | } | 69 | }); |
70 | } |