Skip to content

Commit

Permalink
ANGOLASUP-909: fixed problem with unit swithing
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikNoga committed Sep 4, 2024
1 parent 68417e6 commit 5378af0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/shipment-view/shipment-view.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@
unitOfOrderableService) {
return unitOfOrderableService.getAll().then(function(response) {
var unitsOfOrderable = response.content ? response.content : response;
var index = 0;
if (shipment.lineItems && shipment.lineItems.length > 0) {
stockCardSummaries.forEach(function(summary) {
summary.canFulfillForMe.forEach(function(canFulfill) {
var index = findLineItemIndexByLotId(canFulfill.lot.id, shipment.lineItems);
if (index === -1) {
return;
}
var unitId = canFulfill.unitOfOrderable.id;
var currentItem = angular.copy(shipment.lineItems[index]);
currentItem.unitOfOrderableId = unitId;
Expand All @@ -76,7 +79,6 @@
Math.floor(currentItem.quantityShipped / currentItem.unit.factor);

shipment.lineItems[index] = currentItem;
index++;
});
});
}
Expand All @@ -91,3 +93,11 @@
});
}
})();

function findLineItemIndexByLotId(lotId, lineItems) {
var item = lineItems.find(function(lineItem) {
return lineItem.lot.id === lotId;
});

return lineItems.indexOf(item);
}

0 comments on commit 5378af0

Please sign in to comment.