Commit 93e208626e366e0240c9b337048d8a469c627140
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master See merge request !6
Showing
2 changed files
Show diff stats
src/app/comprobantes/comprobantes.component.html
1 | <div class="row panel-informativo"> | 1 | <div class="row panel-informativo"> |
2 | <div class="col-12"> | 2 | <div class="col-12"> |
3 | <div class="row titulares"> | 3 | <div class="row titulares"> |
4 | <div | 4 | <div |
5 | class="col-12 col-sm numero-pedido text-center text-md-left border border-white align-middle ng-binding ng-scope"> | 5 | class="col-12 col-sm numero-pedido text-center text-md-left border border-white align-middle ng-binding ng-scope"> |
6 | Recepción | 6 | Recepción |
7 | <button class="btn btn-xs btn-outline-light float-right" type="button" (click)="busquedaComprobantes()" | 7 | <button class="btn btn-xs btn-outline-light float-right" type="button" (click)="busquedaComprobantes()" |
8 | title="Buscar"> | 8 | title="Buscar"> |
9 | <i class="fa fa-search"></i> | 9 | <i class="fa fa-search"></i> |
10 | </button> | 10 | </button> |
11 | </div> | 11 | </div> |
12 | <div class="col-7 col-sm border border-white align-middle"> | 12 | <div class="col-7 col-sm border border-white align-middle"> |
13 | Fecha: | 13 | Fecha: |
14 | <span ng-click="datepickerAbierto = true"> {{ fecha | date: 'dd/MM/yyyy' }}</span> | 14 | <span ng-click="datepickerAbierto = true"> {{ fecha | date: 'dd/MM/yyyy' }}</span> |
15 | </div> | 15 | </div> |
16 | <div class="col-5 col-sm border border-white border-right-0 align-middle"> | 16 | <div class="col-5 col-sm border border-white border-right-0 align-middle"> |
17 | Hora: | 17 | Hora: |
18 | <span ng-click="datepickerAbierto = true"> {{ fecha | date: 'shortTime'}}</span> | 18 | <span ng-click="datepickerAbierto = true"> {{ fecha | date: 'shortTime'}}</span> |
19 | </div> | 19 | </div> |
20 | </div> | 20 | </div> |
21 | </div> | 21 | </div> |
22 | </div> | 22 | </div> |
23 | <div class="row"> | 23 | <div class="row"> |
24 | <form class="col-12 col-sm-10"> | 24 | <form class="col-12 col-sm-10"> |
25 | <div class="row border" *ngIf="showCabecera"> | 25 | <div class="row border" *ngIf="showCabecera"> |
26 | <div class="col-6 col-sm-3 d-flex"> | 26 | <div class="col-6 col-sm-3 d-flex"> |
27 | <strong>Letra Factura: </strong> | 27 | <strong>Letra Factura: </strong> |
28 | <label>{{cabecera['TIP']}}</label> | 28 | <label>{{cabecera['TIP']}}</label> |
29 | </div> | 29 | </div> |
30 | <div class="col-6 col-sm-3 d-flex"> | 30 | <div class="col-6 col-sm-3 d-flex"> |
31 | <strong>Tipo Factura: </strong> | 31 | <strong>Tipo Factura: </strong> |
32 | <label>{{cabecera['TCO']}}</label> | 32 | <label>{{cabecera['TCO']}}</label> |
33 | </div> | 33 | </div> |
34 | <div class="col-6 col-sm-3 d-flex"> | 34 | <div class="col-6 col-sm-3 d-flex"> |
35 | <strong>Sucursal: </strong> | 35 | <strong>Sucursal: </strong> |
36 | <label>{{cabecera['SUC']}}</label> | 36 | <label>{{cabecera['SUC']}}</label> |
37 | </div> | 37 | </div> |
38 | <div class="col-6 col-sm-3 d-flex"> | 38 | <div class="col-6 col-sm-3 d-flex"> |
39 | <strong>Número: </strong> | 39 | <strong>Número: </strong> |
40 | <label>{{cabecera['NCO']}}</label> | 40 | <label>{{cabecera['NCO']}}</label> |
41 | </div> | 41 | </div> |
42 | <div class="col-6 col-sm-3 d-flex"> | 42 | <div class="col-6 col-sm-3 d-flex"> |
43 | <strong>Cuit: </strong> | 43 | <strong>Cuit: </strong> |
44 | <label>{{cabecera['CUI']}}</label> | 44 | <label>{{cabecera['CUI']}}</label> |
45 | </div> | 45 | </div> |
46 | <div class="col-12 col-sm-6 d-flex"> | 46 | <div class="col-12 col-sm-6 d-flex"> |
47 | <strong>Nombre: </strong> | 47 | <strong>Nombre: </strong> |
48 | <label>{{cabecera['NOM']}}</label> | 48 | <label>{{cabecera['NOM']}}</label> |
49 | </div> | 49 | </div> |
50 | </div> | 50 | </div> |
51 | <div> | 51 | <div> |
52 | <button type="button" class="btn btn-dark form-control" (click)="showCabecera = !showCabecera"> | 52 | <button type="button" class="btn btn-dark form-control" (click)="showCabecera = !showCabecera"> |
53 | <i class="fa" [ngClass]="{'fa-chevron-down': !showCabecera, 'fa-chevron-up': showCabecera }"></i> | 53 | <i class="fa" [ngClass]="{'fa-chevron-down': !showCabecera, 'fa-chevron-up': showCabecera }"></i> |
54 | </button> | 54 | </button> |
55 | </div> | 55 | </div> |
56 | <div class="row border pr-2"> | 56 | <div class="row border pr-2"> |
57 | <div class="col-6"> | 57 | <div class="col-6"> |
58 | <button type="button" class="btn btn-outline-success btn-sm" | 58 | <button type="button" class="btn btn-outline-success btn-sm" |
59 | [ngClass]="{'active': estadoArticulos == 'modificado'}" | 59 | [ngClass]="{'active': estadoArticulos == 'modificado'}" |
60 | (click)="estadoArticulos == 'modificado' ? estadoArticulos = undefined : estadoArticulos = 'modificado'; filter = '';"> | 60 | (click)="estadoArticulos == 'modificado' ? estadoArticulos = undefined : estadoArticulos = 'modificado'; filter = '';"> |
61 | Modificados ({{getCantidadArticulosByEstado('modificado')}}) | 61 | Modificados ({{getCantidadArticulosByEstado('modificado')}}) |
62 | </button> | 62 | </button> |
63 | </div> | 63 | </div> |
64 | <div class="col-6"> | 64 | <div class="col-6"> |
65 | <button type="button" class="btn btn-outline-danger btn-sm" | 65 | <button type="button" class="btn btn-outline-danger btn-sm" |
66 | [ngClass]="{'active': estadoArticulos == 'rechazado'}" | 66 | [ngClass]="{'active': estadoArticulos == 'rechazado'}" |
67 | (click)="estadoArticulos == 'rechazado' ? estadoArticulos = undefined : estadoArticulos = 'rechazado'; filter = '';"> | 67 | (click)="estadoArticulos == 'rechazado' ? estadoArticulos = undefined : estadoArticulos = 'rechazado'; filter = '';"> |
68 | Rechazados ({{getCantidadArticulosByEstado('rechazado')}}) | 68 | Rechazados ({{getCantidadArticulosByEstado('rechazado')}}) |
69 | </button> | 69 | </button> |
70 | </div> | 70 | </div> |
71 | </div> | 71 | </div> |
72 | <div class="row"> | 72 | <div class="row"> |
73 | <input type="text" class="form-control-sm col-12" placeholder="Busque producto por nombre, codigo" | 73 | <input type="text" class="form-control-sm col-12" placeholder="Busque producto por nombre, codigo" |
74 | [(ngModel)]="filter" [ngModelOptions]="{standalone: true}" /> | 74 | [(ngModel)]="filter" [ngModelOptions]="{standalone: true}" /> |
75 | </div> | 75 | </div> |
76 | <div class="row"> | 76 | <div class="row"> |
77 | <table class="table table-dark"> | 77 | <table class="table table-dark"> |
78 | <thead> | 78 | <thead> |
79 | <tr> | 79 | <tr> |
80 | <th>Producto</th> | 80 | <th>Producto</th> |
81 | <th>Cantidad</th> | 81 | <th>Cantidad</th> |
82 | <th></th> | 82 | <th></th> |
83 | </tr> | 83 | </tr> |
84 | </thead> | 84 | </thead> |
85 | <tbody class="scroll-tabla w-100 mb-5"> | 85 | <tbody class="scroll-tabla w-100 mb-5"> |
86 | <tr *ngFor="let articulo of getPaginaFiltro();" class="row mx-0" [ngClass]="{'bg-danger': articulo.estado == 'rechazado'}"> | 86 | <tr *ngFor="let articulo of getPaginaFiltro();" class="row mx-0" [ngClass]="{'bg-danger': articulo.estado == 'rechazado'}"> |
87 | <td class="col-5">{{articulo.TIO.trim() || articulo.LI0}}</td> | 87 | <td class="col-5">{{articulo.TIO.trim() || articulo.LI0}}</td> |
88 | <td | 88 | <td |
89 | class="col-5" | 89 | class="col-5" |
90 | *ngIf="!articulo.input" | 90 | *ngIf="!articulo.input" |
91 | (click)="articulo.estado != 'rechazado' ? articulo.input = true : false" | 91 | (click)="articulo.estado != 'rechazado' ? articulo.input = true : false" |
92 | > | 92 | > |
93 | {{articulo.recibido ? articulo.recibido + '/' : ''}}{{articulo.CAN}} | 93 | {{articulo.recibido ? articulo.recibido + '/' : ''}}{{articulo.CAN}} |
94 | </td> | 94 | </td> |
95 | <td *ngIf="articulo.input" class="col-5"> | 95 | <td *ngIf="articulo.input" class="col-5"> |
96 | <input | 96 | <input |
97 | class="form-control-sm col-10" | 97 | class="form-control-sm col-10" |
98 | type="number" | 98 | type="number" |
99 | (focus)="$event.target.select();" | 99 | (focus)="$event.target.select();" |
100 | (keyup.enter)="articulo.input = false; articulo.recibido = articulo.tempRecibido" | 100 | (keyup.enter)="inputArticulo(articulo)" |
101 | (keyup.esc)="articulo.input = false" | ||
101 | [(ngModel)]="articulo.tempRecibido" | 102 | [(ngModel)]="articulo.tempRecibido" |
102 | [ngModelOptions]="{standalone: true}" autofocus/> | 103 | [ngModelOptions]="{standalone: true}" autofocus/> |
103 | /{{articulo.CAN}} | 104 | /{{articulo.CAN}} |
104 | </td> | 105 | </td> |
105 | <td class="col-2" *ngIf="articulo.estado != 'rechazado'"> | 106 | <td class="col-2" *ngIf="articulo.estado != 'rechazado'"> |
106 | <button type="button" | 107 | <button type="button" |
107 | (click)="articulo.estado = 'rechazado'"> | 108 | (click)="articulo.estado = 'rechazado'"> |
108 | <i class="fa fa-window-close"></i> | 109 | <i class="fa fa-window-close"></i> |
109 | </button> | 110 | </button> |
110 | </td> | 111 | </td> |
111 | <td class="col-2" *ngIf="articulo.estado == 'rechazado'"> | 112 | <td class="col-2" *ngIf="articulo.estado == 'rechazado'"> |
112 | <button type="button" (click)="articulo.estado = undefined"> | 113 | <button type="button" (click)="articulo.estado = undefined"> |
113 | <i class="fa fa-check"></i> | 114 | <i class="fa fa-check"></i> |
114 | </button> | 115 | </button> |
115 | </td> | 116 | </td> |
116 | </tr> | 117 | </tr> |
117 | <tr> | 118 | <tr> |
118 | <th colspan="3" *ngIf="articulosFiltro.length == 0">Por el momento no hay elementos aquí</th> | 119 | <th colspan="3" *ngIf="articulosFiltro.length == 0">Por el momento no hay elementos aquí</th> |
119 | </tr> | 120 | </tr> |
120 | </tbody> | 121 | </tbody> |
121 | <!-- <tfoot> | ||
122 | <nav *ngIf="articulosFiltro.length > 0" class="mr-auto position-absolute mb-5"> | ||
123 | <ul class="pagination pagination-sm justify-content mb-0"> | ||
124 | <li class="page-item" [ngClass]="{'disabled': paginaActiva == 1}"> | ||
125 | <a class="page-link" href="javascript:void();" (click)="paginaActiva = paginaActiva - 1"> | ||
126 | <span aria-hidden="true">«</span> | ||
127 | <span class="sr-only">Anterior</span> | ||
128 | </a> | ||
129 | </li> | ||
130 | <li | ||
131 | class="page-item" | ||
132 | *ngFor="let pagina of paginas; index as i" | ||
133 | [ngClass]="{'active': pagina == paginaActiva}" | ||
134 | > | ||
135 | <a | ||
136 | class="page-link" | ||
137 | href="javascript:void();" | ||
138 | (click)="paginaActiva = pagina" | ||
139 | >{{pagina}}</a> | ||
140 | </li> | ||
141 | <li class="page-item" [ngClass]="{'disabled': paginaActiva == paginas.length}"> | ||
142 | <a class="page-link" href="javascript:void();" (click)="paginaActiva = paginaActiva + 1"> | ||
143 | <span aria-hidden="true">»</span> | ||
144 | <span class="sr-only">Siguiente</span> | ||
145 | </a> | ||
146 | </li> | ||
147 | </ul> | ||
148 | </nav> | ||
149 | </tfoot> --> | ||
150 | </table> | 122 | </table> |
151 | </div> | 123 | </div> |
152 | </form> | 124 | </form> |
153 | <app-acciones (guardar)="guardarComprobante()" [(saveLoading)]="saveLoading"></app-acciones> | 125 | <app-acciones (guardar)="guardarComprobante()" [(saveLoading)]="saveLoading"></app-acciones> |
src/app/comprobantes/comprobantes.component.ts
1 | import { Component, OnInit} from '@angular/core'; | 1 | import { Component, OnInit} from '@angular/core'; |
2 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; | 2 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; |
3 | import { BusquedaComprobanteComponent } from '../busqueda-comprobante/busqueda-comprobante.component'; | 3 | import { BusquedaComprobanteComponent } from '../busqueda-comprobante/busqueda-comprobante.component'; |
4 | import { ComprobanteService } from './comprobantes.service'; | 4 | import { ComprobanteService } from './comprobantes.service'; |
5 | import { Router } from '@angular/router'; | 5 | import { Router } from '@angular/router'; |
6 | 6 | ||
7 | @Component({ | 7 | @Component({ |
8 | templateUrl: './comprobantes.component.html', | 8 | templateUrl: './comprobantes.component.html', |
9 | styleUrls: ['./comprobantes.component.scss'], | 9 | styleUrls: ['./comprobantes.component.scss'], |
10 | providers:[ ComprobanteService ] | 10 | providers:[ ComprobanteService ] |
11 | }) | 11 | }) |
12 | export class ComprobantesComponent implements OnInit { | 12 | export class ComprobantesComponent implements OnInit { |
13 | 13 | ||
14 | constructor( | 14 | constructor( |
15 | private modalService: NgbModal, | 15 | private modalService: NgbModal, |
16 | public comprobanteService: ComprobanteService, | 16 | public comprobanteService: ComprobanteService, |
17 | public router: Router) { } | 17 | public router: Router) { } |
18 | 18 | ||
19 | ngOnInit() { } | 19 | ngOnInit() { } |
20 | 20 | ||
21 | filter = ''; | 21 | filter = ''; |
22 | estadoArticulos : string; | 22 | estadoArticulos : string; |
23 | tempRecibido = []; | 23 | tempRecibido = []; |
24 | cabecera = {}; | 24 | cabecera = {}; |
25 | cuerpo = []; | 25 | cuerpo = []; |
26 | articulosFiltro = []; | 26 | articulosFiltro = []; |
27 | saveLoading = false; | 27 | saveLoading = false; |
28 | showCabecera = true; | 28 | showCabecera = true; |
29 | 29 | ||
30 | fecha = new Date(); | 30 | fecha = new Date(); |
31 | 31 | ||
32 | getPaginaFiltro() { | 32 | getPaginaFiltro() { |
33 | 33 | ||
34 | this.articulosFiltro = this.cuerpo.filter((articulo) => { | 34 | this.articulosFiltro = this.cuerpo.filter((articulo) => { |
35 | 35 | ||
36 | var tio = articulo.TIO.trim().toLocaleUpperCase().includes(this.filter.toLocaleUpperCase()); | 36 | var tio = articulo.TIO.trim().toLocaleUpperCase().includes(this.filter.toLocaleUpperCase()); |
37 | var lio = articulo.LI0.trim().toLocaleUpperCase().includes(this.filter.toLocaleUpperCase()); | 37 | var lio = articulo.LI0.trim().toLocaleUpperCase().includes(this.filter.toLocaleUpperCase()); |
38 | var codigoBarras = articulo.codigoBarras == this.filter; | 38 | var codigoBarras = articulo.codigoBarras == this.filter; |
39 | 39 | ||
40 | articulo.recibido && !articulo.estado ? articulo.estado = 'modificado' : false; | 40 | articulo.recibido && !articulo.estado ? articulo.estado = 'modificado' : false; |
41 | 41 | ||
42 | var estado = articulo.estado == this.estadoArticulos; | 42 | var estado = articulo.estado == this.estadoArticulos; |
43 | 43 | ||
44 | return (tio || lio || codigoBarras) && estado; | 44 | return (tio || lio || codigoBarras) && estado; |
45 | }); | 45 | }); |
46 | 46 | ||
47 | return this.articulosFiltro; | 47 | return this.articulosFiltro; |
48 | } | 48 | } |
49 | 49 | ||
50 | getCantidadArticulosByEstado(estado: String) { | 50 | getCantidadArticulosByEstado(estado: String) { |
51 | return this.cuerpo.filter((articulo) => { | 51 | return this.cuerpo.filter((articulo) => { |
52 | return articulo.estado == estado; | 52 | return articulo.estado == estado; |
53 | }).length; | 53 | }).length; |
54 | } | 54 | } |
55 | 55 | ||
56 | guardarComprobante() { | 56 | guardarComprobante() { |
57 | 57 | ||
58 | if (this.getCantidadArticulosByEstado('pendiente')) { | 58 | if (this.getCantidadArticulosByEstado('pendiente')) { |
59 | alert('No deben quedar articulos pendientes'); | 59 | alert('No deben quedar articulos pendientes'); |
60 | return; | 60 | return; |
61 | } | 61 | } |
62 | 62 | ||
63 | if (!this.cuerpo.length) { | 63 | if (!this.cuerpo.length) { |
64 | alert('Debe seleccionar un comprobante'); | 64 | alert('Debe seleccionar un comprobante'); |
65 | return; | 65 | return; |
66 | } | 66 | } |
67 | 67 | ||
68 | this.saveLoading = true; | 68 | this.saveLoading = true; |
69 | 69 | ||
70 | this.comprobanteService | 70 | this.comprobanteService |
71 | .saveComprobantes({cabecera: this.cabecera, cuerpo: this.cuerpo}) | 71 | .saveComprobantes({cabecera: this.cabecera, cuerpo: this.cuerpo}) |
72 | .subscribe(data => { | 72 | .subscribe(data => { |
73 | 73 | ||
74 | alert('Comprobante guardado con éxito'); | 74 | alert('Comprobante guardado con éxito'); |
75 | this.saveLoading = false; | 75 | this.saveLoading = false; |
76 | this.router.navigateByUrl('/home'); | 76 | this.router.navigateByUrl('/home'); |
77 | 77 | ||
78 | }, err => { | 78 | }, err => { |
79 | 79 | ||
80 | alert('Algo salió mal'); | 80 | alert('Algo salió mal...'); |
81 | this.saveLoading = false; | 81 | this.saveLoading = false; |
82 | console.log(err); | 82 | console.log(err); |
83 | }); | 83 | }); |
84 | } | 84 | } |
85 | 85 | ||
86 | busquedaComprobantes() { | 86 | busquedaComprobantes() { |
87 | this.modalService.open(BusquedaComprobanteComponent).result.then(comprobante => { | 87 | this.modalService.open(BusquedaComprobanteComponent).result.then(comprobante => { |
88 | 88 | ||
89 | this.cabecera = comprobante.cabecera; | 89 | this.cabecera = comprobante.cabecera; |
90 | this.cuerpo = comprobante.cuerpo; | 90 | this.cuerpo = comprobante.cuerpo; |
91 | 91 | ||
92 | this.getPaginaFiltro(); | 92 | this.getPaginaFiltro(); |
93 | }, (reason) => { }); | 93 | }, (reason) => { }); |
94 | } | 94 | } |
95 | 95 | ||
96 | inputArticulo(articulo) { | ||
97 | if (articulo.tempRecibido > 999999) { | ||
98 | alert('Cantidad máxima superada'); | ||
99 | return; | ||
100 | } | ||
101 | articulo.input = false; | ||
102 | articulo.recibido = articulo.tempRecibido; | ||
103 | } | ||
104 | |||
96 | } | 105 | } |
97 | 106 |