diff --git a/package.json b/package.json index 60fd6fc..94d6295 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "quirons-broker", - "version": "0.0.1-alpha.136", + "version": "0.0.1-alpha.137", "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 e1952fc..f0cd413 100644 --- a/src/inventory/internal/stock-level.ts +++ b/src/inventory/internal/stock-level.ts @@ -24,6 +24,7 @@ export const StockLevel = t.intersection([ }), t.partial({ isActive: t.boolean, + lotNumber: nullable(t.string), created_at: nullable(datetime), updated_at: nullable(datetime), operation: t.union([ @@ -46,30 +47,56 @@ export const Converter = { const stockLevel: StockLevel[] = [] Content.ListOfReturnItem.forEach(item => { - const { ListOfWarehouseStock } = item + const { ListOfWarehouseStock, ListOfLotStock } = item - ListOfWarehouseStock.forEach(warehouse => { - stockLevel.push({ - headerErpCompany: Header.CompanyId, - headerErpBranch: Header.BranchId, - erpCompany: item.CompanyId || '', - erpBranch: item.BranchId || '', - version: Header.Version || '1.000', - id: '', - erpId: '', - erpItem: item.ItemInternalId, - erpWarehouse: warehouse.WarehouseInternalId, - amoutBooked: parseInt( - `${warehouse.BookedStockAmount}` - ), - physicalBalance: parseInt( - `${warehouse.CurrentStockAmount}` - ), - operation: Header.Event, - originMessageId: Header.UUID, - sentBy: Header.ProductName + if (ListOfLotStock && ListOfLotStock.length > 0) { + ListOfLotStock.forEach(warehouse => { + stockLevel.push({ + headerErpCompany: Header.CompanyId, + headerErpBranch: Header.BranchId, + erpCompany: item.CompanyId || '', + erpBranch: item.BranchId || '', + version: Header.Version || '1.000', + id: '', + erpId: '', + erpItem: item.ItemInternalId, + erpWarehouse: warehouse.WarehouseInternalId, + amoutBooked: parseInt( + `${warehouse.BookedStockAmount}` + ), + physicalBalance: parseInt( + `${warehouse.CurrentStockAmount}` + ), + lotNumber: warehouse.LotNumber, + operation: Header.Event, + originMessageId: Header.UUID, + sentBy: Header.ProductName + }) + }) + } else { + ListOfWarehouseStock.forEach(warehouse => { + stockLevel.push({ + headerErpCompany: Header.CompanyId, + headerErpBranch: Header.BranchId, + erpCompany: item.CompanyId || '', + erpBranch: item.BranchId || '', + version: Header.Version || '1.000', + id: '', + erpId: '', + erpItem: item.ItemInternalId, + erpWarehouse: warehouse.WarehouseInternalId, + amoutBooked: parseInt( + `${warehouse.BookedStockAmount}` + ), + physicalBalance: parseInt( + `${warehouse.CurrentStockAmount}` + ), + operation: Header.Event, + originMessageId: Header.UUID, + sentBy: Header.ProductName + }) }) - }) + } })