PriceList
This commit is contained in:
parent
b5ba132517
commit
220b094b8b
4 changed files with 61 additions and 0 deletions
|
@ -11,6 +11,7 @@ import {
|
|||
Producto,
|
||||
Precio,
|
||||
getPublications,
|
||||
getPriceLists,
|
||||
} from "../index.js";
|
||||
|
||||
// TODO: hacerlo input
|
||||
|
@ -94,6 +95,11 @@ setupForm("#price-by-customer", (event) =>
|
|||
filter: (event.target! as any).filter.value,
|
||||
})
|
||||
);
|
||||
setupForm("#price-list", (event) =>
|
||||
getPriceLists(HOST, token(), {
|
||||
filter: (event.target! as any).filter.value,
|
||||
})
|
||||
);
|
||||
setupForm("#customers", () => getCustomers(HOST, token(), {}));
|
||||
|
||||
let customer: Customer | null = null;
|
||||
|
|
|
@ -59,6 +59,12 @@
|
|||
<p class="status"></p>
|
||||
</form>
|
||||
|
||||
<form id="price-list">
|
||||
<button>Conseguir listas de precios</button>
|
||||
<input name="filter" type="text" placeholder="Filtro por ID (opcional)" />
|
||||
<p class="status"></p>
|
||||
</form>
|
||||
|
||||
<form id="customers">
|
||||
<p class="status"></p>
|
||||
<button>Conseguir clientes</button>
|
||||
|
|
1
index.ts
1
index.ts
|
@ -4,6 +4,7 @@ export * from "./dummy.js";
|
|||
export * from "./product.js";
|
||||
export * from "./price.js";
|
||||
export * from "./priceByCustomer.js";
|
||||
export * from "./priceList.js";
|
||||
export * from "./customer.js";
|
||||
export * from "./order.js";
|
||||
export * from "./publications.js";
|
||||
|
|
48
priceList.ts
Normal file
48
priceList.ts
Normal file
|
@ -0,0 +1,48 @@
|
|||
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,
|
||||
token: string,
|
||||
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()}`,
|
||||
{
|
||||
headers: {
|
||||
accesstoken: token,
|
||||
},
|
||||
}
|
||||
);
|
||||
const json = await res.json();
|
||||
console.debug(json);
|
||||
if (json.Message) {
|
||||
throw new Error(`Tango: ${json.Message}`);
|
||||
}
|
||||
return json;
|
||||
}
|
Loading…
Reference in a new issue