Compare commits

..

1 commit

Author SHA1 Message Date
fd8c81f21d Hacer que SKUCode en pedidos sea obligatorio
Fixes #1
2022-05-12 18:48:22 +00:00
6 changed files with 3 additions and 70 deletions

View file

@ -3,7 +3,6 @@ import {
getProductos,
getPrices,
getPricesByCustomer,
getStocks,
getCustomers,
order,
OrderDto,
@ -99,12 +98,6 @@ setupForm("#price", (event) =>
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) =>
getPricesByCustomer(HOST, token(), {
filter: (event.target! as any).filter.value,
@ -204,6 +197,7 @@ setupForm("#pedido", async () => {
UnitPrice: precio.Price,
Quantity: 1,
ProductCode: producto.SKUCode,
SKUCode: producto.SKUCode,
})),
Customer: {
CustomerID: 1,

View file

@ -72,13 +72,6 @@
<p class="status"></p>
</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">
<button>Conseguir clientes</button>
<p class="status"></p>

View file

@ -5,7 +5,6 @@ export * from "./product.js";
export * from "./price.js";
export * from "./priceByCustomer.js";
export * from "./priceList.js";
export * from "./stock.js";
export * from "./customer.js";
export * from "./order.js";
export * from "./publications.js";

View file

@ -59,15 +59,13 @@ export interface CustomerDto {
}
export interface OrderItemDto {
ProductCode: string;
SKUCode?: null | string;
SKUCode: string;
VariantCode?: null | string;
Description: string;
VariantDescription?: null | string;
Quantity: number;
UnitPrice: number;
DiscountPercentage?: number;
SelectMeasureUnit?: string;
MeasureCode?: string;
}
export interface ShippingDto {
ShippingID: number;

View file

@ -1,6 +1,6 @@
{
"name": "@suttyweb/hyperpop",
"version": "0.3.0",
"version": "0.1.1",
"description": "Un cliente de API de https://github.com/TangoSoftware/ApiTiendas",
"license": "SEE LICENSE IN LICENSE",
"scripts": {

View file

@ -1,51 +0,0 @@
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;
}