From d848426fe46d1c9ccfe7d605800346674388ff32 Mon Sep 17 00:00:00 2001 From: NG Date: Mon, 25 Nov 2024 11:14:26 -0300 Subject: [PATCH] fix: update StockLevel version and improve ListOfLotStock validation --- package.json | 2 +- src/inventory/internal/stock-level.ts | 7 ++++++- src/inventory/schema/StockLevel.ts | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 0f42060..b87be8d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "quirons-broker", - "version": "0.0.1-alpha.142", + "version": "0.0.1-alpha.143", "description": "A small library to expose the broker types", "typings": "index.d.ts", "types": "index.d.ts", diff --git a/src/inventory/internal/stock-level.ts b/src/inventory/internal/stock-level.ts index 3eab188..aa9c145 100644 --- a/src/inventory/internal/stock-level.ts +++ b/src/inventory/internal/stock-level.ts @@ -49,7 +49,12 @@ export const Converter = { Content.ListOfReturnItem.forEach(item => { const { ListOfWarehouseStock, ListOfLotStock } = item - if (useLotNumber && ListOfLotStock && ListOfLotStock.length > 0) { + if ( + useLotNumber + && ListOfLotStock + && Array.isArray(ListOfLotStock) + && ListOfLotStock.length > 0 + ) { ListOfLotStock.forEach(warehouse => { stockLevel.push({ headerErpCompany: Header.CompanyId, diff --git a/src/inventory/schema/StockLevel.ts b/src/inventory/schema/StockLevel.ts index 786a84e..e2d1bd6 100644 --- a/src/inventory/schema/StockLevel.ts +++ b/src/inventory/schema/StockLevel.ts @@ -95,7 +95,10 @@ const ReturnItem = t.intersection([ UnitItemCost: t.union([t.string, t.number]), WarehouseInternalId: t.string, BranchId: nullable(t.string), - ListOfLotStock: nullable(t.array(ListOfLotStock)) + ListOfLotStock: nullable(t.union([ + t.type({}), + t.array(ListOfLotStock) + ])) }) ])