Permitir filtrar por identificador de cliente en Customer y PriceByCustomer

This commit is contained in:
Cat /dev/Nulo 2021-11-01 17:44:29 -03:00
parent c21e34cc07
commit 0e815bd07b
3 changed files with 37 additions and 1 deletions

View file

@ -40,3 +40,26 @@ export function paginacionToSearchParams(
searchParams.set("pageNumber", "1"); searchParams.set("pageNumber", "1");
} }
} }
export interface QueryCustomer {
type: TipoDeDocumento;
number: string;
}
export function queryCustomerToSearchParams(
cliente: QueryCustomer,
searchParams: URLSearchParams
) {
if (cliente) {
searchParams.set("documentType", cliente.type.toString());
searchParams.set("documentNumber", cliente.number);
}
}
export enum TipoDeDocumento {
CUIT = 80,
CUIL = 86,
CDI = 87,
LE = 89,
LC = 90,
DNI = 96,
}

View file

@ -1,12 +1,16 @@
import { import {
QueryCustomer,
HOST, HOST,
Paginacion, Paginacion,
paginacionToSearchParams, paginacionToSearchParams,
Paging, Paging,
queryCustomerToSearchParams,
TipoDeDocumento,
} from "./common.js"; } from "./common.js";
export interface CustomerQuery { export interface CustomerQuery {
paginacion?: Paginacion; paginacion?: Paginacion;
customer?: QueryCustomer;
} }
export interface Customer { export interface Customer {
@ -23,7 +27,7 @@ export interface Customer {
MobilePhoneNumber: string; MobilePhoneNumber: string;
WebPage: string; WebPage: string;
IvaCategoryCode: string; IvaCategoryCode: string;
DocumentType: string; DocumentType: TipoDeDocumento;
DocumentNumber: string; DocumentNumber: string;
PriceListNumber: number; PriceListNumber: number;
Discount: number; Discount: number;
@ -79,6 +83,9 @@ export async function getCustomers(
): Promise<CustomerResponse> { ): Promise<CustomerResponse> {
let searchParams = new URLSearchParams(); let searchParams = new URLSearchParams();
paginacionToSearchParams(options.paginacion, searchParams); paginacionToSearchParams(options.paginacion, searchParams);
if (options.customer) {
queryCustomerToSearchParams(options.customer, searchParams);
}
const res = await fetch( const res = await fetch(
`${HOST}/api/Aperture/Customer?${searchParams.toString()}`, `${HOST}/api/Aperture/Customer?${searchParams.toString()}`,
{ {

View file

@ -1,4 +1,6 @@
import { import {
QueryCustomer,
queryCustomerToSearchParams,
HOST, HOST,
Paginacion, Paginacion,
paginacionToSearchParams, paginacionToSearchParams,
@ -9,6 +11,7 @@ export interface PriceByCustomerQuery {
paginacion?: Paginacion; paginacion?: Paginacion;
/// Filtro por el código del cliente ("Code" en Customer.) /// Filtro por el código del cliente ("Code" en Customer.)
filter?: string; filter?: string;
customer?: QueryCustomer;
} }
export interface Precio { export interface Precio {
@ -32,6 +35,9 @@ export async function getPricesByCustomer(
if (options.filter) { if (options.filter) {
searchParams.set("filter", options.filter); searchParams.set("filter", options.filter);
} }
if (options.customer) {
queryCustomerToSearchParams(options.customer, searchParams);
}
const res = await fetch( const res = await fetch(
`${HOST}/api/Aperture/PriceByCustomer?${searchParams.toString()}`, `${HOST}/api/Aperture/PriceByCustomer?${searchParams.toString()}`,
{ {