Skip to content

Commit a1b13bf

Browse files
committed
feat: add support for 'Consumidor Final'
1 parent 8567df2 commit a1b13bf

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

src/app/afip/afip.component.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ export class AfipComponent implements OnInit {
6565
// FA-C
6666
// const urlText = "https://www.afip.gob.ar/fe/qr/?p=eyJ2ZXIiOjEsImZlY2hhIjoiMjAyMi0wMS0yNSIsImN1aXQiOjIwMzY3MzYyNDczLCJwdG9WdGEiOjIsInRpcG9DbXAiOjExLCJucm9DbXAiOjg4LCJpbXBvcnRlIjoyMDAwLCJtb25lZGEiOiJQRVMiLCJjdHoiOjEsInRpcG9Eb2NSZWMiOjgwLCJucm9Eb2NSZWMiOjMwNzE2NzQzMjk5LCJ0aXBvQ29kQXV0IjoiRSIsImNvZEF1dCI6NzIwNDMzMjQ5NjcwOTl9";
6767
// FA-A
68-
const urlText = "https://www.afip.gob.ar/fe/qr/?p=eyJ2ZXIiOiAxLCAiZmVjaGEiOiAiMjAyMi0wMi0wMSIsICJjdWl0IjogMzA3MTY3MTg1MjksICJwdG9WdGEiOiAyLCAidGlwb0NtcCI6IDEsICJucm9DbXAiOiAxNjcsICJpbXBvcnRlIjogMTgxNTAuMCwgIm1vbmVkYSI6ICJQRVMiLCAiY3R6IjogMS4wLCAidGlwb0NvZEF1dCI6ICJFIiwgImNvZEF1dCI6IDcyMDU5MDA0NTQ5NTc1LCAibnJvRG9jUmVjIjogMjAzNzAzODYwNTcsICJ0aXBvRG9jUmVjIjogODB9";
68+
// const urlText = "https://www.afip.gob.ar/fe/qr/?p=eyJ2ZXIiOiAxLCAiZmVjaGEiOiAiMjAyMi0wMi0wMSIsICJjdWl0IjogMzA3MTY3MTg1MjksICJwdG9WdGEiOiAyLCAidGlwb0NtcCI6IDEsICJucm9DbXAiOiAxNjcsICJpbXBvcnRlIjogMTgxNTAuMCwgIm1vbmVkYSI6ICJQRVMiLCAiY3R6IjogMS4wLCAidGlwb0NvZEF1dCI6ICJFIiwgImNvZEF1dCI6IDcyMDU5MDA0NTQ5NTc1LCAibnJvRG9jUmVjIjogMjAzNzAzODYwNTcsICJ0aXBvRG9jUmVjIjogODB9";
69+
// FA-B
70+
const urlText = "https://www.afip.gob.ar/fe/qr/?p=eyJjb2RBdXQiOjcyMDQ2MTkwMDUyNDc3LCJjdHoiOjEsImN1aXQiOjMwNzEwMTE0MTc2LCJmZWNoYSI6IjIwMjItMDEtMjMiLCJpbXBvcnRlIjo2Mzk4LjAwLCJtb25lZGEiOiJQRVMiLCJucm9DbXAiOjEwMDk3OTksIm5yb0RvY1JlYyI6MCwicHRvVnRhIjozMSwidGlwb0NtcCI6NiwidGlwb0NvZEF1dCI6IkUiLCJ0aXBvRG9jUmVjIjo5NiwidmVyIjoxfQ=="
6971
this.processQR(urlText);
7072
}
7173

@@ -87,20 +89,30 @@ export class AfipComponent implements OnInit {
8789
this.http.get<any>('https://afip.tangofactura.com/Rest/GetContribuyenteFull?cuit=' + obj.cuit,{}).subscribe(dataE => {
8890
if (dataE.Contribuyente) {
8991
newinvoice.nameEmi = dataE.Contribuyente.nombre;
90-
this.http.get<any>('https://afip.tangofactura.com/Rest/GetContribuyenteFull?cuit=' + obj.nroDocRec,{}).subscribe(dataR => {
91-
if (dataR.Contribuyente) {
92-
newinvoice.nameRec = dataR.Contribuyente.nombre;
92+
if (obj.nroDocRec !== 0) {
93+
this.http.get<any>('https://afip.tangofactura.com/Rest/GetContribuyenteFull?cuit=' + obj.nroDocRec,{}).subscribe(dataR => {
94+
if (dataR.Contribuyente) {
95+
newinvoice.nameRec = dataR.Contribuyente.nombre;
96+
this.invoices.push(newinvoice);
97+
localStorage.setItem('invoices', JSON.stringify(this.invoices));
98+
this.loading = false;
99+
if (this.table) {
100+
this.table!.renderRows();
101+
}
102+
}
103+
}, (err: any) => {
104+
this.loading = false;
105+
this.openDialog(err);
106+
});
107+
} else {
108+
newinvoice.nameRec = 'Consumidor Final';
93109
this.invoices.push(newinvoice);
94110
localStorage.setItem('invoices', JSON.stringify(this.invoices));
95111
this.loading = false;
96112
if (this.table) {
97113
this.table!.renderRows();
98114
}
99115
}
100-
}, (err: any) => {
101-
this.loading = false;
102-
this.openDialog(err);
103-
});
104116
}
105117
}, (err: any) => {
106118
this.loading = false;

0 commit comments

Comments
 (0)