+
Movimientos
@@ -65,7 +61,7 @@
-
+
@@ -78,7 +74,7 @@
Nº {{ r.serie }}-{{ r.numero }}
- Suc: {{ r.nombreSucursal }}
+ Sucursal: {{ r.nombreSucursal }}
Detalle: {{ r.descripcion }}
|
@@ -100,7 +96,7 @@
-
Sin Movimientos.
+
Sin Movimientos.
1" class="d-flex justify-content-center my-2">
diff --git a/src/app/feature-modules/cuentas-corrientes-proveedor/components/cuenta-corriente-proveedor/cuenta-corriente-proveedor.component.ts b/src/app/feature-modules/cuentas-corrientes-proveedor/components/cuenta-corriente-proveedor/cuenta-corriente-proveedor.component.ts
index c919c8b7..300df4ef 100755
--- a/src/app/feature-modules/cuentas-corrientes-proveedor/components/cuenta-corriente-proveedor/cuenta-corriente-proveedor.component.ts
+++ b/src/app/feature-modules/cuentas-corrientes-proveedor/components/cuenta-corriente-proveedor/cuenta-corriente-proveedor.component.ts
@@ -2,12 +2,12 @@ import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {LoadingOverlayService} from '../../../../services/loading-overlay.service';
import {MensajeService} from '../../../../services/mensaje.service';
-import {DatePipe, Location} from '@angular/common';
+import {DatePipe} from '@angular/common';
import {CuentasCorrientesService} from '../../../../services/cuentas-corrientes.service';
import {finalize} from 'rxjs/operators';
import {CuentaCorrienteProveedor} from '../../../../models/cuenta-corriente';
import {MensajeModalType} from '../../../../components/mensaje-modal/mensaje-modal.component';
-import {combineLatest, Observable} from 'rxjs';
+import {Observable} from 'rxjs';
import {Pagination} from '../../../../models/pagination';
import {RenglonCuentaCorriente} from '../../../../models/renglon-cuenta-corriente';
import {HelperService} from '../../../../services/helper.service';
@@ -33,6 +33,11 @@ import {NuevaNotaDebitoDeRecibo} from '../../../../models/nueva-nota-debito-de-r
import {NotaDebitoCompraDetalleReciboModalComponent} from '../nota-debito-compra-detalle-recibo-modal/nota-debito-compra-detalle-recibo-modal.component';
import {ReciboProveedorModalComponent} from '../../../../components/recibo-proveedor-modal/recibo-proveedor-modal.component';
import {RecibosService} from '../../../../services/recibos.service';
+import { ListadoDirective } from 'src/app/directives/listado.directive';
+import { SucursalesService } from 'src/app/services/sucursales.service';
+import { PreviousRouteService } from 'src/app/services/previous-route.service';
+
+const ssCCPPreviousUrlKey = 'CCP_PREVIOUS_URL';
@Component({
selector: 'app-cuenta-corriente-proveedor',
@@ -40,16 +45,12 @@ import {RecibosService} from '../../../../services/recibos.service';
styleUrls: ['./cuenta-corriente-proveedor.component.scss'],
providers: [DatePipe]
})
-export class CuentaCorrienteProveedorComponent implements OnInit {
+export class CuentaCorrienteProveedorComponent extends ListadoDirective implements OnInit {
ccp: CuentaCorrienteProveedor;
renglones: RenglonCuentaCorriente[] = [];
saldo = 0;
displayPage = 1;
- page = 0;
- totalElements = 0;
- totalPages = 0;
- size = 0;
helper = HelperService;
@@ -86,17 +87,20 @@ export class CuentaCorrienteProveedorComponent implements OnInit {
TipoDeComprobante.RECIBO
];
- constructor(private route: ActivatedRoute,
- private router: Router,
- public loadingOverlayService: LoadingOverlayService,
- private mensajeService: MensajeService,
- private location: Location,
+ constructor(protected route: ActivatedRoute,
+ protected router: Router,
+ protected sucursalesService: SucursalesService,
+ protected loadingOverlayService: LoadingOverlayService,
+ protected mensajeService: MensajeService,
+ private previousRouteService: PreviousRouteService,
private cuentasCorrientesService: CuentasCorrientesService,
private modalService: NgbModal,
private authService: AuthService,
private notasService: NotasService,
private recibosService: RecibosService,
- private datePipe: DatePipe) { }
+ private datePipe: DatePipe) {
+ super(route, router, sucursalesService, loadingOverlayService, mensajeService);
+ }
ngOnInit(): void {
if (this.route.snapshot.paramMap.has('id')) {
@@ -107,7 +111,19 @@ export class CuentaCorrienteProveedorComponent implements OnInit {
.subscribe({
next: (ccp: CuentaCorrienteProveedor) => {
this.ccp = ccp;
- this.getRenglones();
+ super.ngOnInit();
+ this.loadingOverlayService.activate();
+ this.cuentasCorrientesService.getCuentaCorrienteProveedorSaldo(this.ccp.proveedor.idProveedor)
+ .pipe(finalize(() => this.loadingOverlayService.deactivate()))
+ .subscribe({
+ next: saldo => this.saldo = saldo,
+ error: err => {
+ this.mensajeService.msg(err.error, MensajeModalType.ERROR)
+ .then(() => { return; }, () => { return; });
+ this.router.navigate(['/proveedores']);
+ }
+ })
+ ;
},
error: (err) => {
this.mensajeService.msg(err.error, MensajeModalType.ERROR);
@@ -123,42 +139,50 @@ export class CuentaCorrienteProveedorComponent implements OnInit {
this.hasRoleToCrearNota = this.authService.userHasAnyOfTheseRoles(this.allowedRolesToCrearNota);
this.hasRoleToVerDetalle = this.authService.userHasAnyOfTheseRoles(this.allowedRolesToVerDetalle);
this.hasRoleToCrearRecibo = this.authService.userHasAnyOfTheseRoles(this.allowedRolesToCrearRecibo);
+ this.subscription.add(this.previousRouteService.previousRoute$.subscribe(url => {
+ const urlHaveToBeStored = /(^\/proveedores$|^\/proveedores\?[a-zA-Z0-9=&]+$)/.test(url);
+ console.log(urlHaveToBeStored);
+ if (urlHaveToBeStored) {
+ sessionStorage.setItem(ssCCPPreviousUrlKey, url);
+ }
+ }));
}
volverAlListado() {
- this.location.back();
+ const backUrl = sessionStorage.getItem(ssCCPPreviousUrlKey) || '/proveedores';
+ this.router.navigateByUrl(backUrl);
}
- getRenglones() {
- this.loadingOverlayService.activate();
-
- const obvs = [
- this.cuentasCorrientesService.getCuentaCorrienteProveedorSaldo(this.ccp.proveedor.idProveedor),
- this.cuentasCorrientesService.getCuentaCorrienteRenglones(this.ccp.idCuentaCorriente, this.page)
- ];
-
- combineLatest(obvs)
- .pipe(finalize(() => this.loadingOverlayService.deactivate()))
- .subscribe({
- next: (data: [number, Pagination]) => {
- this.saldo = data[0];
- this.renglones = data[1].content;
- this.totalElements = data[1].totalElements;
- this.totalPages = data[1].totalPages;
- this.size = data[1].size;
- },
- error: err => {
- this.mensajeService.msg(err.error, MensajeModalType.ERROR);
- this.router.navigate(['/proveedores']);
- }
- })
- ;
+ getItemsFromQueryParams(params = null) {
+ super.getItemsFromQueryParams(params);
+ this.displayPage = this.page + 1;
}
loadPage(page) {
- this.displayPage = page;
this.page = page - 1;
- this.getRenglones();
+ const qParams = this.getFormValues() as { [key: string]: any };
+ qParams.p = this.page + 1;
+ this.router.navigate([], { relativeTo: this.route, queryParams: qParams });
+ }
+
+ populateFilterForm(params) {
+ /*No hace nada ya que no existe formulario de filtro */
+ }
+
+ getTerminosFromQueryParams(params) {
+ return {
+ pagina: this.page,
+ };
+ }
+
+ createFilterForm() { /* No hace nada ya que no existe formulario de filtro */ }
+ resetFilterForm() { /* No hace nada ya que no existe formulario de filtro */ }
+
+ getAppliedFilters() { this.appliedFilters = []; };
+ getFormValues() { return {} };
+
+ getItemsObservableMethod(terminos): Observable
{
+ return this.cuentasCorrientesService.getCuentaCorrienteRenglones(this.ccp.idCuentaCorriente, terminos.pagina)
}
nuevaNotaCredito() {
@@ -340,7 +364,10 @@ export class CuentaCorrienteProveedorComponent implements OnInit {
.pipe(finalize(() => this.loadingOverlayService.deactivate()))
.subscribe({
next: () => this.loadPage(this.page + 1),
- error: err => this.mensajeService.msg(err.error, MensajeModalType.ERROR),
+ error: err => {
+ this.mensajeService.msg(err.error, MensajeModalType.ERROR)
+ .then(() => { return; }, () => { return; });
+ },
})
;
}
diff --git a/src/app/services/previous-route.service.ts b/src/app/services/previous-route.service.ts
new file mode 100644
index 00000000..bac4cfbd
--- /dev/null
+++ b/src/app/services/previous-route.service.ts
@@ -0,0 +1,27 @@
+import { Router, RoutesRecognized } from '@angular/router';
+import { Injectable } from '@angular/core';
+import { BehaviorSubject, filter, map, pairwise } from 'rxjs';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class PreviousRouteService {
+
+ public previousRoute$ = new BehaviorSubject('');
+
+ constructor(private router: Router) {}
+
+ /**
+ * Debe llamarse una sola vez en el AppComponent
+ */
+ init() {
+ this.router.events.pipe(
+ filter((e) => e instanceof RoutesRecognized),
+ pairwise(),
+ map((e: [RoutesRecognized, RoutesRecognized]) => {
+ const url = e[0].url;
+ if (url !== '') { this.previousRoute$.next(url) };
+ })
+ ).subscribe();
+ }
+}