diff --git a/client/src/modules/shipment/create-shipment.js b/client/src/modules/shipment/create-shipment.js index cb350a3914..81ca67c688 100644 --- a/client/src/modules/shipment/create-shipment.js +++ b/client/src/modules/shipment/create-shipment.js @@ -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 = `
diff --git a/client/src/modules/stock/StockExitForm.service.js b/client/src/modules/stock/StockExitForm.service.js index cab7b8ff79..724e06d295 100644 --- a/client/src/modules/stock/StockExitForm.service.js +++ b/client/src/modules/stock/StockExitForm.service.js @@ -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', []); @@ -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 = {}, ) { @@ -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);