2021-11-18 15:07:35 +00:00
|
|
|
import { Paginacion, paginacionToSearchParams, Paging } from "./common.js";
|
|
|
|
|
|
|
|
export interface PriceListQuery {
|
|
|
|
paginacion?: Paginacion;
|
|
|
|
filter?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface PriceList {
|
|
|
|
PriceListNumber: number;
|
|
|
|
Description: string;
|
|
|
|
CommonCurrency: boolean;
|
|
|
|
IvaIncluded: boolean;
|
|
|
|
InternalTaxIncluded: boolean;
|
|
|
|
ValidityDateSince: string;
|
|
|
|
ValidityDateUntil: string;
|
|
|
|
Disabled: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface PriceListResponse {
|
|
|
|
Paging: Paging;
|
|
|
|
Data: PriceList[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function getPriceLists(
|
|
|
|
host: string,
|
2022-11-01 17:21:52 +00:00
|
|
|
headers: HeadersInit,
|
2021-11-18 15:07:35 +00:00
|
|
|
options: PriceListQuery
|
|
|
|
): Promise<PriceListResponse> {
|
|
|
|
let searchParams = new URLSearchParams();
|
|
|
|
paginacionToSearchParams(options.paginacion, searchParams);
|
|
|
|
if (options.filter) {
|
|
|
|
searchParams.set("filter", options.filter);
|
|
|
|
}
|
|
|
|
const res = await fetch(
|
|
|
|
`${host}/api/Aperture/PriceList?${searchParams.toString()}`,
|
2022-11-01 17:21:52 +00:00
|
|
|
{ headers }
|
2021-11-18 15:07:35 +00:00
|
|
|
);
|
|
|
|
const json = await res.json();
|
|
|
|
console.debug(json);
|
|
|
|
if (json.Message) {
|
|
|
|
throw new Error(`Tango: ${json.Message}`);
|
|
|
|
}
|
|
|
|
return json;
|
|
|
|
}
|