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

View file

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