Skip to content

Commit

Permalink
Prevent expired stock from being added to shipments
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcameron committed Apr 1, 2022
1 parent 23b6214 commit f748a8b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions client/src/modules/shipment/create-shipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ function CreateShipmentController(

vm.existingShipmentUuid = existingShipmentUuid;
vm.isCreateState = $state.params.isCreateState;

vm.stockForm = new StockForm('ShipmentForm');
vm.stockForm.setAllowExpired(false);

const gridFooterTemplate = `
<div style="margin-left: 10px;">
Expand Down
14 changes: 13 additions & 1 deletion client/src/modules/stock/StockExitForm.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function StockExitFormService(
this.cache = AppCache(cacheKey);
this.details = { is_exit : 1 };
this.store = new Store({ identifier : 'uuid', data : [] });
this.allowExpired = true;

// this variable is private and will contain the stock for the current depot.
this._pool = new Pool('lot_uuid', []);
Expand All @@ -58,6 +59,14 @@ function StockExitFormService(
this._messages = new Map();
}

/**
* Set flag to allow or disable expired stock
* @param {boolean} flag
*/
StockExitForm.prototype.setAllowExpired = function setAllowExpired(flag) {
this.allowExpired = flag;
};

StockExitForm.prototype._toggleInfoMessage = function _toggleInfoMessage(
shouldShowMsg, msgType, msgText, msgKeys = {},
) {
Expand Down Expand Up @@ -140,7 +149,10 @@ function StockExitFormService(
return Depots.getStockQuantityForDate(depotUuid, parameters)
.then(stock => {

const available = stock
const rawStock = this.allowExpired ? stock
: stock.filter(lot => !lot.is_asset && !lot.is_expired);

const available = rawStock
.map(item => {
const lot = new Lot(item);

Expand Down

0 comments on commit f748a8b

Please sign in to comment.