From aa492da5235b84d3d0a679289bdf651374b7b7f8 Mon Sep 17 00:00:00 2001 From: Marcelo Puebla Date: Thu, 9 Jan 2020 10:36:39 -0300 Subject: [PATCH] Agregados primeros servicios --- .gitignore | 1 + src/app/interfaces/IArticulo.ts | 35 +++++ src/app/interfaces/ICliente.ts | 161 +++++++++++++++++++++ src/app/services/articulo/articulo.service.spec.ts | 12 ++ src/app/services/articulo/articulo.service.ts | 116 +++++++++++++++ src/app/services/cliente/cliente.service.spec.ts | 12 ++ src/app/services/cliente/cliente.service.ts | 16 ++ src/etc/AppSettings.ejemplo.ts | 3 + 8 files changed, 356 insertions(+) create mode 100644 src/app/interfaces/IArticulo.ts create mode 100644 src/app/interfaces/ICliente.ts create mode 100644 src/app/services/articulo/articulo.service.spec.ts create mode 100644 src/app/services/articulo/articulo.service.ts create mode 100644 src/app/services/cliente/cliente.service.spec.ts create mode 100644 src/app/services/cliente/cliente.service.ts create mode 100644 src/etc/AppSettings.ejemplo.ts diff --git a/.gitignore b/.gitignore index 5108f25..facaa1f 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ # dependencies /node_modules /dist +/src/etc/appSettings.ts # profiling files chrome-profiler-events*.json diff --git a/src/app/interfaces/IArticulo.ts b/src/app/interfaces/IArticulo.ts new file mode 100644 index 0000000..7472a30 --- /dev/null +++ b/src/app/interfaces/IArticulo.ts @@ -0,0 +1,35 @@ +export interface IArticulo { + cantidad?: number; + cantidadAdicionada?: number; + cantidadVendida?: number; + categoria_selfservice?: number; + CodArt: number; + codigoBarra?: ICodigoBarra[]; + CodSec: number; + DetArt: string; + DET_LAR: string; + ELBPRO: string; + esAdicionable?: boolean; + esSustraible?: boolean; + FPP?: boolean; + id: number; + idSinonimo?: number; + imagenes?: any[]; + ImpInt: number; + ImpInt2: number; + ImpInt3: number; + importeValorExtra?: number; + PreVen: number; + PRO: boolean; + productos?: IArticulo[]; + seleccionado?: boolean; + tieneSinonimo?: boolean; + tipo_articulo?: number; + comentario?: string; +} + +export interface ICodigoBarra { + CodBar: string; + CodArt: number; + CodSec: string; +} diff --git a/src/app/interfaces/ICliente.ts b/src/app/interfaces/ICliente.ts new file mode 100644 index 0000000..4f89930 --- /dev/null +++ b/src/app/interfaces/ICliente.ts @@ -0,0 +1,161 @@ +export interface ICliente { + COD: number; + NOM: string; + DOM: string; + CPO: string; + LOC: string; + PCI: string; + CUIT: string; + TEL: string; + FPA: number; + TIP: string; + ZON: string; + ACT: string; + PDA: boolean; + MCC: number; + MCH: number; + CTA: number; + IDE: string; + TLI: string; + MOD: string; + SUR: boolean; + IVA: number; + SIT: string; + TCO: string; + LOX: number; + PCX: number; + OBS: string; + FUP: string; + DIC: number; + GRP: boolean; + BLO: boolean; + PLP: boolean; + FRE: boolean; + VEN: number; + FEA: string; + ICP: boolean; + PER: boolean; + RANT: boolean; + D_EN: string; + D_Y: string; + REC: number; + NHA: boolean; + EMG: number; + E_HD: string; + C_HD: string; + PDA_A: number; + CAN_KIL: number; + PER_MAY: boolean; + ES_MAY: boolean; + SEG_MAY: number; + INC_MAY: number; + ZON_MAY: number; + PER_IVA_MAY: number; + LPCC: boolean; + EREPL: boolean; + IMP_ABONO: number; + ID_LEY: number; + NRO_PER_MAY: string; + JUR_MAY_PER: string; + NARIB: string; + DIC_1: number; + REC_1: number; + TASA_DIC: number; + TASA_DIC_1: number; + IMP_CANJE: boolean; + USOINT: boolean; + PERC: number; + CTRL_LIT: boolean; + CTRL_SEC: boolean; + CLI_CON: number; + ITC_SUR: boolean; + PIDVEN: boolean; + MAIL: string; + HAB_NOTIF: boolean; + TIPO_NOTIFICACION: boolean; + VEH_CHF: boolean; + ICIVAL: boolean; + LEY_ABO1: string; + LEY_ABO2: string; + LEY_ABO3: string; + LEY_ABO4: string; + SALDO_ABONO: number; + FACT_ABONO: number; + FACT_AUTO: boolean; + MES_VDO: boolean; + FEC_CTRL: string; + SEG_FID: number; + MARCA_SALDO: boolean; + CTRL_SEC_FPA: boolean; + TIPO_RET: number; + COD_EXT: string; + RIESGO_FISCAL: boolean; + POR_RED: number; + DESTINO_VENTA: number; + FT_ANT: boolean; + FID_PART: boolean; + PER_SL: number; + EN_COBRO: number; + BLO_CTA_PROPIA: boolean; + TIENE_CERTIFICADO_IIBB: boolean; + NOTIF_FT_RE: boolean; + IMP_DET_VAL: boolean; + EX_PER_HASTA: string; + REVENDEDOR: boolean; + CONVMULTILATERAL: boolean; + PERCPORC?: any; + MAIL_COBRANZA: string; + MAIL_COMPRAS: string; + MAIL_OTROS: string; + IMP_OBS_CLI: boolean; + PASSWEB: string; + COD_REG_CANJ: number; + CERTIF_JURIS: boolean; + PER_IVARG17: number; + PER_ATER: number; + OpJurMis: boolean; + TIPO_RES_60: number; + FEB: string; + idPreciosConcidiones: number; + idprecioscondiciones: number; + ES_PROS?: any; + idCobrador: string; + ECI: boolean; + MUM: string; + TipoClienteAbonado: number; + EMAIL?: any; + FNAC?: any; + PAIS?: any; + control_saldos_vencidos: boolean; + Ignora_bloqueo_auto: boolean; + iva: IIva; + cuenta: ICuenta; + tipoComprobante: ITipoComprobante; + estadoCuenta: ICuenta; +} + +export interface ICuenta { + autorizado: number; + extracciones: number; + saldo: number; + facturasvencidas: number; +} + +export interface IIva { + ID: number; + NOMBRE: string; + ABR: string; + IFE: string; + IFH: string; + IFO: string; + TIP: string; + COI: number; +} + +export interface ITipoComprobante { + ID: string; + NOMBRE: string; + TIP: number; + CLA: number; + RES_SUM: number; +} diff --git a/src/app/services/articulo/articulo.service.spec.ts b/src/app/services/articulo/articulo.service.spec.ts new file mode 100644 index 0000000..e35555a --- /dev/null +++ b/src/app/services/articulo/articulo.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { ArticuloService } from './articulo.service'; + +describe('ArticuloService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: ArticuloService = TestBed.get(ArticuloService); + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/articulo/articulo.service.ts b/src/app/services/articulo/articulo.service.ts new file mode 100644 index 0000000..e113995 --- /dev/null +++ b/src/app/services/articulo/articulo.service.ts @@ -0,0 +1,116 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { APP_SETTINGS } from '../../../etc/AppSettings'; +import { IArticulo } from '../../interfaces/IArticulo'; +import { ClienteService } from '../cliente/cliente.service'; +import { Observable } from 'rxjs'; + +@Injectable({ + providedIn: 'root' +}) +export class ArticuloService { + articulos: IArticulo[] = []; + articuloAcargar: IArticulo; + promoAcargar: IArticulo; + mostrar: string; + esPromoPersonalizada: boolean = false; + urlArticulos = `${APP_SETTINGS.apiDeboSuite}/articulos`; + urlPromociones = `${APP_SETTINGS.apiDeboSuite}/promociones`; + urlSinonimos = `${APP_SETTINGS.apiDeboSuite}/sinonimos`; + urlCategorias = `${APP_SETTINGS.apiDeboSuite}/categorias`; + urlComprobante = `${APP_SETTINGS.apiDeboSuite}/comprobante`; + + constructor(private http: HttpClient, private clienteService: ClienteService) { } + + getById(id) { + return this.http.get(`${this.urlArticulos}/${id}`); + } + + getAll() { + return this.http.get(`${this.urlArticulos}`); + } + + getAllWithPaginator(page: number = 1) { + return this.http.get(`${this.urlArticulos}/${page}`); + } + + setArticulos(articulo: IArticulo) { + for (let i = 0; i < this.articulos.length; i++) { + if (this.articulos[i].id === articulo.id) { + if (articulo.PRO) break; + this.articulos[i].cantidad++; + return; + } + } + this.articulos.unshift(articulo); + } + + getPromocionByCodigos(sector, codigo) { + return this.http.get(`${this.urlPromociones}/by-codigos/${sector}/${codigo}`); + } + + getPromociones(sector, codigo) { + return this.http.get(`${this.urlPromociones}/in-articulo/${sector}/${codigo}`); + } + + getPromocionSinonimos(sector, codigo) { + return this.http.get(`${this.urlSinonimos}/promo/${sector}/${codigo}`); + } + + getCategorias() { + return this.http.get(`${this.urlCategorias}`); + } + + getComponentes(sector, codigo) { + return this.http.get(`${this.urlPromociones}/articulos/${sector}/${codigo}`); + } + + pay(dataPago: any) { + return new Observable((observer) => { + this.clienteService.getById(-1) + .subscribe(cliente => { + let puntoVenta = parseInt(localStorage.getItem('impresoraPVE')); + this.markArticuloInPromoAsRemoved(); + this.http.post(`${this.urlComprobante}/guardar/${dataPago.medioPago}`, { + productos: this.articulos, + cliente: cliente, + origen: 'autoservicio', + codigoVendedor: 5, + puntoVenta: dataPago.medioPago === 9 ? -1 * puntoVenta : puntoVenta, + pedidoAnombreDe: dataPago.pedidoAnombreDe, + numeroPlanilla: '11111', + }) + .subscribe((data) => { + observer.next(data); + observer.complete(); + }); + }); + }); + } + + cleanShoppingCar() { + this.articuloAcargar = undefined; + this.promoAcargar = undefined; + this.articulos = []; + } + + setArticulosSinImagen(articulos: IArticulo[]) { + articulos.forEach((articulo: IArticulo) => { + articulo.imagenes = !articulo.imagenes ? [{ imagen: 'noImage.jpg' }] : + !articulo.imagenes.length ? [{ imagen: 'noImage.jpg' }] : articulo.imagenes; + }); + } + + markArticuloInPromoAsRemoved() { + this.articulos.forEach((articulo: IArticulo) => { + if (articulo.PRO) { + articulo.productos.forEach((articulo: IArticulo) => { + if (articulo.cantidadAdicionada === 0) { + articulo.cantidad = 0; + articulo.importeValorExtra = 0; + } + }); + } + }); + } +} diff --git a/src/app/services/cliente/cliente.service.spec.ts b/src/app/services/cliente/cliente.service.spec.ts new file mode 100644 index 0000000..d79a0d3 --- /dev/null +++ b/src/app/services/cliente/cliente.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { ClienteService } from './cliente.service'; + +describe('ClienteService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: ClienteService = TestBed.get(ClienteService); + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/cliente/cliente.service.ts b/src/app/services/cliente/cliente.service.ts new file mode 100644 index 0000000..b99954e --- /dev/null +++ b/src/app/services/cliente/cliente.service.ts @@ -0,0 +1,16 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { APP_SETTINGS } from "src/etc/AppSettings"; + +@Injectable({ + providedIn: 'root' +}) +export class ClienteService { + urlClientes = `${APP_SETTINGS.apiDeboSuite}/clientes`; + + constructor(private http: HttpClient) { } + + getById(id: number) { + return this.http.get(`${this.urlClientes}/get/${id}`); + } +} diff --git a/src/etc/AppSettings.ejemplo.ts b/src/etc/AppSettings.ejemplo.ts new file mode 100644 index 0000000..437d505 --- /dev/null +++ b/src/etc/AppSettings.ejemplo.ts @@ -0,0 +1,3 @@ +// export const APP_SETTINGS = { +// apiDeboSuite: 'http://localhost:9900' +// } -- 1.9.1