@@ -3,7 +3,7 @@ import {animate, state, style, transition, trigger} from '@angular/animations';
33import { MatTable } from '@angular/material/table' ;
44import { MatDialog , MAT_DIALOG_DATA } from '@angular/material/dialog' ;
55import { BarcodeScanner } from '@awesome-cordova-plugins/barcode-scanner/ngx' ;
6- import { HttpClient } from '@angular/common/http' ;
6+ import { HttpClient , HttpHeaders } from '@angular/common/http' ;
77
88import { Globals } from '../app.globals' ;
99
@@ -143,18 +143,31 @@ export class AfipComponent implements OnInit {
143143 const decode = decodeURIComponent ( escape ( atob ( encode ) ) ) . replace ( / \' / g, '"' ) ;
144144 const obj = JSON . parse ( decode ) ;
145145 console . log ( obj ) ;
146+ const httpOptions = {
147+ headers : new HttpHeaders ( {
148+ 'Access-Control-Allow-Origin' :'*' ,
149+ } )
150+ } ;
146151
147152 if ( url . host === 'www.afip.gob.ar' || url . host === 'afip.gob.ar' || url . host === 'serviciosweb.afip.gob.ar' ) {
148153 if ( this . invoices . find ( x => x . cae === obj . codAut ) !== undefined ) {
149154 this . openDialog ( '¡Factura ya escaneada!' ) ;
150155 this . loading = false ;
151156 } else {
152157 let newinvoice = await this . processQrFeAr ( obj ) ;
153- this . http . get < any > ( 'https://www.tangofactura.com/Rest/GetContribuyente?cuit=' + obj . cuit , { } ) . subscribe ( dataE => {
158+ this . invoices . push ( newinvoice ) ;
159+ localStorage . setItem ( 'invoices' , JSON . stringify ( this . invoices ) ) ;
160+ setTimeout ( ( ) => {
161+ if ( this . table ) {
162+ this . table ! . renderRows ( ) ;
163+ }
164+ this . loading = false ;
165+ } , 1 ) ;
166+ /*this.http.get<any>('./tango/Rest/GetContribuyente?cuit=' + obj.cuit, httpOptions).subscribe(dataE => {
154167 if (dataE.Contribuyente) {
155168 newinvoice.nameEmi = dataE.Contribuyente.nombre;
156169 if (obj.nroDocRec !== 0 && obj.nroDocRec.toString().length >= 11) {
157- this . http . get < any > ( 'https://www.tangofactura.com/ Rest/GetContribuyente?cuit=' + obj . nroDocRec , { } ) . subscribe ( dataR => {
170+ this.http.get<any>('./tango/ Rest/GetContribuyente?cuit=' + obj.nroDocRec, httpOptions ).subscribe(dataR => {
158171 if (dataR.Contribuyente) {
159172 newinvoice.nameRec = dataR.Contribuyente.nombre;
160173 this.invoices.push(newinvoice);
@@ -168,7 +181,7 @@ export class AfipComponent implements OnInit {
168181 }
169182 }, (err: any) => {
170183 console.log(err);
171- this . openDialog ( err ) ;
184+ this.openDialog(JSON.stringify( err) );
172185 this.loading = false;
173186 });
174187 } else {
@@ -183,9 +196,9 @@ export class AfipComponent implements OnInit {
183196 } else {}
184197 }, (err: any) => {
185198 console.log(err);
186- this . openDialog ( err ) ;
199+ this.openDialog(JSON.stringify( err) );
187200 this.loading = false;
188- } ) ;
201+ });*/
189202 }
190203 } else {
191204 this . openDialog ( 'El QR escaneado no es de AFIP' ) ;
@@ -209,7 +222,15 @@ export class AfipComponent implements OnInit {
209222 this . qrs [ i ] = false ;
210223 } else {
211224 let newinvoice = await this . processQrFeAr ( obj ) ;
212- this . http . get < any > ( 'https://afip.tangofactura.com/Rest/GetContribuyenteFull?cuit=' + obj . cuit , { } ) . subscribe ( dataE => {
225+ this . invoices . push ( newinvoice ) ;
226+ localStorage . setItem ( 'invoices' , JSON . stringify ( this . invoices ) ) ;
227+ setTimeout ( ( ) => {
228+ if ( this . table ) {
229+ this . table ! . renderRows ( ) ;
230+ }
231+ this . qrs [ i ] = false ;
232+ } , 1 ) ;
233+ /*this.http.get<any>('https://afip.tangofactura.com/Rest/GetContribuyenteFull?cuit=' + obj.cuit,{}).subscribe(dataE => {
213234 if (dataE.Contribuyente) {
214235 newinvoice.nameEmi = dataE.Contribuyente.nombre;
215236 if (obj.nroDocRec !== 0) {
@@ -240,7 +261,7 @@ export class AfipComponent implements OnInit {
240261 }, (err: any) => {
241262 this.qrs[i] = false;
242263 this.qrErrors.push(obj.codAut);
243- } ) ;
264+ });*/
244265 }
245266 } else {
246267 this . qrs [ i ] = false ;
0 commit comments