Skip to content

Commit

Permalink
Merge pull request #124 from nginformatica/feature/decode-lot-stock
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksjm authored Oct 18, 2024
2 parents f408f04 + 2a252b8 commit ace6a9f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
71 changes: 49 additions & 22 deletions src/inventory/internal/stock-level.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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
})
})
})
}

})

Expand Down

0 comments on commit ace6a9f

Please sign in to comment.