Skip to content

Commit

Permalink
I removed all namespaces and fix extractor structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaralan committed Aug 30, 2021
1 parent db9062f commit 9546e6d
Show file tree
Hide file tree
Showing 22 changed files with 379 additions and 672 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist
*cache
*log
*.DS_Store
test.js
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules
*log
*.DS_Store
src
test.js
20 changes: 9 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cfdi-to-json",
"version": "1.2.5",
"version": "1.3.1",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand All @@ -19,8 +19,8 @@
"homepage": "https://github.com/onefacture/cfdi-to-json#readme",
"dependencies": {
"he": "1.2.0",
"xmldom": "0.1.27",
"xpath": "0.0.27"
"xmldom": "0.6.0",
"xpath": "0.0.32"
},
"devDependencies": {
"@types/he": "1.1.0",
Expand Down
44 changes: 35 additions & 9 deletions src/CfdiExtractData/__test__/index-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ describe('CfdiExtractData', () => {
Version="3.3"
xmlns:cfdi="http://www.sat.gob.mx/cfd/3">
<cfdi:Emisor Rfc="RFC_EMISOR" Nombre="NOMBRE_DEL_EMISOR" RegimenFiscal="612"></cfdi:Emisor>
<cfdi:Receptor Rfc="RFC_RECEPTOR" Nombre="NOMBRE_DEL_RECEPTOR" UsoCFDI="G03"></cfdi:Receptor>
<Receptor Rfc="RFC_RECEPTOR" Nombre="NOMBRE_DEL_RECEPTOR" UsoCFDI="G03"></Receptor>
<cfdi:Conceptos>
<cfdi:Concepto ClaveProdServ="43231601" Cantidad="1" ClaveUnidad="E48" Unidad="Unidad de servicio" Descripcion="Licencia anual onefacture cfdi" ValorUnitario="430.17" Importe="430.17">
<cfdi:Impuestos>
<Impuestos>
<cfdi:Traslados>
<cfdi:Traslado Base="430.17" Impuesto="002" TipoFactor="Tasa" TasaOCuota="0.160000" Importe="68.83"></cfdi:Traslado>
</cfdi:Traslados>
</cfdi:Impuestos>
</Impuestos>
</cfdi:Concepto>
</cfdi:Conceptos>
<cfdi:Impuestos TotalImpuestosTrasladados="68.83">
Expand Down Expand Up @@ -92,9 +92,9 @@ describe('CfdiExtractData', () => {
"fecha": "2019-04-02T10:41:20",
"formaPago": "04",
"impuestos": {
"totalImpuestosTrasladados": "68.83",
"totalImpuestosTrasladados": 68.83,
"traslados": [{
"importe": "68.83",
"importe": 68.83,
"impuesto": "002",
"tasaOCuota": "0.160000",
"tipoFactor": "Tasa",
Expand Down Expand Up @@ -207,9 +207,9 @@ describe('CfdiExtractData', () => {
"fecha": "2019-04-02T10:41:20",
"formaPago": "04",
"impuestos": {
"totalImpuestosTrasladados": "68.83",
"totalImpuestosTrasladados": 68.83,
"traslados": [{
"importe": "68.83",
"importe": 68.83,
"impuesto": "002",
"tasaOCuota": "0.160000",
"tipoFactor": "Tasa",
Expand Down Expand Up @@ -258,6 +258,32 @@ describe('CfdiExtractData', () => {
});
});

it('Basic data without namespace cfdi in root tag', () => {
expect(CfdiExtractData.extractGeneralData({
contentXML: `
<?xml version="1.0" encoding="utf-8"?>
<Comprobante
xmlns:cfdi="http://www.sat.gob.mx/cfd/3"
Version="3.3"
>
<cfdi:Emisor
Rfc="RFC_EMISOR"
Nombre="NOMBRE_DEL_EMISOR"
RegimenFiscal="612"
></cfdi:Emisor>
</Comprobante>
`
}))
.toEqual({
"version": "3.3",
"emisor": {
"nombre": "NOMBRE_DEL_EMISOR",
"regimenFiscal": "612",
"rfc": "RFC_EMISOR"
}
});
});

it('Receptor', () => {
expect(CfdiExtractData.extractGeneralData({
contentXML: `
Expand Down Expand Up @@ -361,9 +387,9 @@ describe('CfdiExtractData', () => {
.toEqual({
"version": "3.3",
"impuestos": {
"totalImpuestosTrasladados": "68.83",
"totalImpuestosTrasladados": 68.83,
"traslados": [{
"importe": "68.83",
"importe": 68.83,
"impuesto": "002",
"tasaOCuota": "0.160000",
"tipoFactor": "Tasa"
Expand Down
4 changes: 0 additions & 4 deletions src/CfdiExtractData/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,3 @@ export interface tImpuesto {
export interface tMinimalData {
minimalData: Boolean;
}

export interface tNamespace {
namespace?: any;
}
Loading

0 comments on commit 9546e6d

Please sign in to comment.