Skip to content

Instantly share code, notes, and snippets.

@wmakeev
Last active January 21, 2023 06:25
Show Gist options
  • Select an option

  • Save wmakeev/09aad933ef9bcb1a8804e3449ec5ff74 to your computer and use it in GitHub Desktop.

Select an option

Save wmakeev/09aad933ef9bcb1a8804e3449ec5ff74 to your computer and use it in GitHub Desktop.
[МойСклад - остатки] #moysklad #stock
// https://gist.githubusercontent.com/wmakeev/09aad933ef9bcb1a8804e3449ec5ff74
import { env } from "../env.js";
/**
* Возвращает остатки МойСклад
*
* @param {import('moysklad').Instance} ms
*/
export async function getMoyskladStock(ms) {
console.time("Загрузка остатков");
/** @type {StockItem[]} */
const stockItems = await ms.GET("report/stock/all/current", {
filter: {
// TODO По хорошему надо по всем складам (нужно обнулять остатки)
storeId: env.MOYSKLAD_STOCKS_STORE_ID,
},
stockType: "stock",
});
console.timeEnd("Загрузка остатков");
console.log(`Получено ${stockItems.length} строк остатков`);
return stockItems;
}
interface StockItem {
assortmentId: string;
storeId: string;
freeStock: number;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment