Skip to content

Commit 757e9fb

Browse files
committed
fix: error with api tango [remove for now]
1 parent 02ee4c9 commit 757e9fb

5 files changed

Lines changed: 49 additions & 23 deletions

File tree

android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<activity
1515
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
1616
android:name="ar.codize.afip.MainActivity"
17-
android:label="Codize AFIP"
17+
android:label="Codize-AFIP"
1818
android:theme="@style/AppTheme.NoActionBarLaunch"
1919
android:launchMode="singleTask">
2020

angular.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@
7373
},
7474
"serve": {
7575
"builder": "@angular-devkit/build-angular:dev-server",
76+
"options": {
77+
"proxyConfig": "src/proxy.conf.json"
78+
},
7679
"configurations": {
7780
"production": {
7881
"proxyConfig": "src/proxy.conf.json",

src/app/afip/afip.component.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232

3333
<div *ngIf="invoices.length > 0" class="row">
3434
<div class="col-12">
35-
<table mat-table [dataSource]="invoices" class="mat-elevation-z8 w-100" multiTemplateDataRows>
36-
35+
<table mat-table *ngIf="invoices" [dataSource]="invoices" class="mat-elevation-z8 w-100" multiTemplateDataRows>
3736
<ng-container matColumnDef="docName">
3837
<th class="ps-2 pe-2" mat-header-cell *matHeaderCellDef> Tipo </th>
3938
<td class="ps-2 pe-2" mat-cell *matCellDef="let element"> {{element.docName}} </td>
@@ -50,26 +49,26 @@
5049
[@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'">
5150
<div class="p-1 w-50 border-end">
5251
<span class="badge bg-secondary mb-1">{{element.date | date:'dd/MM/yyyy'}}</span><br />
53-
<h3 class="mb-0">{{element.amount | currency:'ARS':'symbol':'':'es-AR'}}</h3>
52+
<h5 class="mb-0"><small>{{element.amount | currency:'ARS':'symbol':'':'es-AR'}}</small></h5>
5453
<small><b>Moneda:</b> {{element.currency}}</small>
5554
</div>
5655
<div class="p-1 w-50">
57-
<h5 class="mb-1">{{element.docName}} {{element.docNumber}}</h5>
58-
<h5 class="mb-1"><b>Emisor:</b> {{element.nameEmi}}</h5>
59-
<h5 class="mb-1"><b>Receptor:</b> {{element.nameRec}}</h5>
56+
<h6 class="mb-1"><small>{{element.docName}} {{element.docNumber}}</small></h6>
57+
<h6 class="mb-1"><small><b>Emisor:</b> {{element.nameEmi}}</small></h6>
58+
<h6 class="mb-1"><small><b>Receptor:</b> {{element.nameRec}}</small></h6>
6059
</div>
6160
</div>
6261
</td>
6362
</ng-container>
6463

65-
<tr class="ps-2 pe-2" mat-header-row *matHeaderRowDef="displayedColumns"></tr>
66-
<tr class="ps-2 pe-2" mat-row *matRowDef="let element; columns: displayedColumns;"
64+
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
65+
<tr mat-row *matRowDef="let element; columns: displayedColumns;"
6766
class="example-element-row"
6867
[class.example-expanded-row]="expandedElement === element"
6968
(click)="expandedElement = expandedElement === element ? null : element">
7069
</tr>
71-
<tr mat-row *matRowDef="let row; columns: ['expandedDetail']" class="example-detail-row ps-2 pe-2"></tr>
72-
70+
<tr mat-row *matRowDef="let row; columns: ['expandedDetail']" class="example-detail-row"></tr>
71+
7372
</table>
7473
</div>
7574
</div>

src/app/afip/afip.component.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {animate, state, style, transition, trigger} from '@angular/animations';
33
import { MatTable } from '@angular/material/table';
44
import { MatDialog, MAT_DIALOG_DATA } from '@angular/material/dialog';
55
import { BarcodeScanner } from '@awesome-cordova-plugins/barcode-scanner/ngx';
6-
import { HttpClient } from '@angular/common/http';
6+
import { HttpClient, HttpHeaders } from '@angular/common/http';
77

88
import { 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;

src/proxy.conf.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
2-
"/api": {
3-
"target": "https://www.tangofactura.com",
4-
"secure": false
2+
"/tango": {
3+
"target": "https://www.tangofactura.com",
4+
"secure": false,
5+
"pathRewrite": {"^/tango": "https://www.tangofactura.com"},
6+
"changeOrigin": true,
7+
"logLevel": "debug"
58
}
6-
}
9+
}

0 commit comments

Comments
 (0)