Last active
January 21, 2023 06:25
-
-
Save wmakeev/09aad933ef9bcb1a8804e3449ec5ff74 to your computer and use it in GitHub Desktop.
[МойСклад - остатки] #moysklad #stock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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