Compare commits
3 commits
arreglar-p
...
antifascis
Author | SHA1 | Date | |
---|---|---|---|
|
ddc5f1ae3c | ||
2a68f4f90d | |||
5f78c52db4 |
6 changed files with 69 additions and 1 deletions
|
@ -3,6 +3,7 @@ import {
|
||||||
getProductos,
|
getProductos,
|
||||||
getPrices,
|
getPrices,
|
||||||
getPricesByCustomer,
|
getPricesByCustomer,
|
||||||
|
getStocks,
|
||||||
getCustomers,
|
getCustomers,
|
||||||
order,
|
order,
|
||||||
OrderDto,
|
OrderDto,
|
||||||
|
@ -98,6 +99,12 @@ setupForm("#price", (event) =>
|
||||||
filter: (event.target! as any).filter.value,
|
filter: (event.target! as any).filter.value,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
setupForm("#stock", (event) =>
|
||||||
|
getStocks(HOST, token(), {
|
||||||
|
filter: (event.target! as any).filter.value,
|
||||||
|
warehouseCode: (event.target! as any).warehouseCode.value,
|
||||||
|
})
|
||||||
|
);
|
||||||
setupForm("#price-by-customer", (event) =>
|
setupForm("#price-by-customer", (event) =>
|
||||||
getPricesByCustomer(HOST, token(), {
|
getPricesByCustomer(HOST, token(), {
|
||||||
filter: (event.target! as any).filter.value,
|
filter: (event.target! as any).filter.value,
|
||||||
|
|
|
@ -72,6 +72,13 @@
|
||||||
<p class="status"></p>
|
<p class="status"></p>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<form id="stock">
|
||||||
|
<button>Conseguir stock</button>
|
||||||
|
<input name="filter" type="text" placeholder="Filtro por ID (opcional)" />
|
||||||
|
<input name="warehouseCode" type="text" placeholder="Filtro por código de deposito (opcional)" />
|
||||||
|
<p class="status"></p>
|
||||||
|
</form>
|
||||||
|
|
||||||
<form id="customers">
|
<form id="customers">
|
||||||
<button>Conseguir clientes</button>
|
<button>Conseguir clientes</button>
|
||||||
<p class="status"></p>
|
<p class="status"></p>
|
||||||
|
|
1
index.ts
1
index.ts
|
@ -5,6 +5,7 @@ export * from "./product.js";
|
||||||
export * from "./price.js";
|
export * from "./price.js";
|
||||||
export * from "./priceByCustomer.js";
|
export * from "./priceByCustomer.js";
|
||||||
export * from "./priceList.js";
|
export * from "./priceList.js";
|
||||||
|
export * from "./stock.js";
|
||||||
export * from "./customer.js";
|
export * from "./customer.js";
|
||||||
export * from "./order.js";
|
export * from "./order.js";
|
||||||
export * from "./publications.js";
|
export * from "./publications.js";
|
||||||
|
|
2
order.ts
2
order.ts
|
@ -66,6 +66,8 @@ export interface OrderItemDto {
|
||||||
Quantity: number;
|
Quantity: number;
|
||||||
UnitPrice: number;
|
UnitPrice: number;
|
||||||
DiscountPercentage?: number;
|
DiscountPercentage?: number;
|
||||||
|
SelectMeasureUnit?: string;
|
||||||
|
MeasureCode?: string;
|
||||||
}
|
}
|
||||||
export interface ShippingDto {
|
export interface ShippingDto {
|
||||||
ShippingID: number;
|
ShippingID: number;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@suttyweb/hyperpop",
|
"name": "@suttyweb/hyperpop",
|
||||||
"version": "0.1.1",
|
"version": "0.3.0",
|
||||||
"description": "Un cliente de API de https://github.com/TangoSoftware/ApiTiendas",
|
"description": "Un cliente de API de https://github.com/TangoSoftware/ApiTiendas",
|
||||||
"license": "SEE LICENSE IN LICENSE",
|
"license": "SEE LICENSE IN LICENSE",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
51
stock.ts
Normal file
51
stock.ts
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
import { Paginacion, paginacionToSearchParams, Paging } from "./common.js";
|
||||||
|
|
||||||
|
export interface StockQuery {
|
||||||
|
paginacion?: Paginacion;
|
||||||
|
warehouseCode?: string;
|
||||||
|
filter?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Stock {
|
||||||
|
StoreNumber: number;
|
||||||
|
WarehouseCode: string;
|
||||||
|
SKUCode: string;
|
||||||
|
Quantity: number;
|
||||||
|
EngagedQuantity: number;
|
||||||
|
PendingQuantity: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StockResponse {
|
||||||
|
Paging: Paging;
|
||||||
|
Data: Stock[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://github.com/TangoSoftware/ApiTiendas#saldos-de-stock
|
||||||
|
export async function getStocks(
|
||||||
|
host: string,
|
||||||
|
token: string,
|
||||||
|
options: StockQuery
|
||||||
|
): Promise<StockResponse> {
|
||||||
|
let searchParams = new URLSearchParams();
|
||||||
|
paginacionToSearchParams(options.paginacion, searchParams);
|
||||||
|
if (options.filter) {
|
||||||
|
searchParams.set("filter", options.filter);
|
||||||
|
}
|
||||||
|
if (options.warehouseCode) {
|
||||||
|
searchParams.set("warehouseCode", options.warehouseCode);
|
||||||
|
}
|
||||||
|
const res = await fetch(
|
||||||
|
`${host}/api/Aperture/Stock?${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