Skip to content

Commit

Permalink
Adds print button to factura-venta-actions-bar component.
Browse files Browse the repository at this point in the history
  • Loading branch information
facundososalopez committed May 9, 2023
1 parent fb65372 commit fcecfae
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
<fa-icon [icon]="['far', 'eye']"></fa-icon>
</button>
</li>
<li class="list-inline-item" *ngIf="!hiddenButtonsValues['print']">
<button class="btn btn-primary fake-cursor" (click)="downloadFacturaPdf()"
ngbPopover="Imprimir" placement="left" triggers="mouseenter:mouseleave">
<fa-icon [icon]="['fas', 'print']"></fa-icon>
</button>
</li>
<li class="list-inline-item" *ngIf="hasRoleToEnviarPorEmail && !hiddenButtonsValues['email']">
<button class="btn btn-primary fake-cursor" (click)="enviarPorEmail()"
ngbPopover="Enviar por Email" placement="left" triggers="mouseenter:mouseleave">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class FacturaVentaActionsBarComponent implements OnInit {

hiddenButtonsValues = {
'show': false,
'print': false,
'email': false,
'show-remito': false,
'new-remito': false,
Expand Down Expand Up @@ -84,6 +85,21 @@ export class FacturaVentaActionsBarComponent implements OnInit {
this.router.navigate(['/facturas-venta/ver', this.facturaVenta.idFactura]);
}

downloadFacturaPdf() {
this.loadingOverlayService.activate();
this.facturasVentaService.getFacturaPdf(this.facturaVenta.idFactura)
.pipe(finalize(() => this.loadingOverlayService.deactivate()))
.subscribe({
next: (res) => {
const file = new Blob([res], {type: 'application/pdf'});
const fileURL = URL.createObjectURL(file);
window.open(fileURL, '_blank');
},
error: () => this.mensajeService.msg('Error al generar el reporte', MensajeModalType.ERROR),
})
;
}

enviarPorEmail() {
if (!this.hasRoleToEnviarPorEmail) {
this.mensajeService.msg('No posee permiso para enviar la factura por email.', MensajeModalType.ERROR);
Expand Down
4 changes: 0 additions & 4 deletions src/app/components/ver-factura/ver-factura.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ <h1 class="h3 m-0 flex-fill">
Factura {{ factura.type === 'FacturaVenta' ? 'Venta' : 'Compra' }}
</h1>
<div class="align-self-end">
<button class="btn btn-primary" (click)="downloadFacturaPdf()" placement="left" ngbPopover="Imprimir" triggers="mouseenter:mouseleave"
*ngIf="factura.type === 'FacturaVenta'">
<fa-icon [icon]="['fas', 'print']"></fa-icon>
</button>
<app-factura-venta-actions-bar *ngIf="factura && factura.type === 'FacturaVenta'" class="ms-2 text-nowrap"
[facturaVenta]="factura"
[hiddenButtons]="['show']"
Expand Down
16 changes: 0 additions & 16 deletions src/app/components/ver-factura/ver-factura.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,6 @@ export class VerFacturaComponent implements OnInit {
this.location.back();
}

downloadFacturaPdf() {
if (this.factura.type === 'FacturaCompra') { return; }
this.loadingOverlayService.activate();
this.facturasVentaService.getFacturaPdf(this.factura.idFactura)
.pipe(finalize(() => this.loadingOverlayService.deactivate()))
.subscribe(
(res) => {
const file = new Blob([res], {type: 'application/pdf'});
const fileURL = URL.createObjectURL(file);
window.open(fileURL, '_blank');
},
() => this.mensajeService.msg('Error al generar el reporte', MensajeModalType.ERROR),
)
;
}

getNumeroDeComprobante() {
if (this.factura) {
return this.factura.cae
Expand Down

0 comments on commit fcecfae

Please sign in to comment.