diff --git a/client/src/js/components/bhStockOut/bhStockOut.js b/client/src/js/components/bhStockOut/bhStockOut.js index 8aaafb98a8..5f7dc20932 100644 --- a/client/src/js/components/bhStockOut/bhStockOut.js +++ b/client/src/js/components/bhStockOut/bhStockOut.js @@ -41,8 +41,11 @@ function bhStockOutController(Depots, moment, Notify, $filter, $q) { const dateTo = $ctrl.date || new Date(); $ctrl.loading = true; + // format date + const dateToFormatted = $date(dateTo, 'yyyy-MM-dd'); + $q.all([ - Depots.getStockOutsForDate($ctrl.depotUuid, dateTo), + Depots.getStockOutsForDate($ctrl.depotUuid, dateToFormatted), Depots.read($ctrl.depotUuid), ]) .then(([inventories, depot]) => { diff --git a/client/src/modules/stock/LotItem.service.js b/client/src/modules/stock/LotItem.service.js index e27d708113..91cc721da6 100644 --- a/client/src/modules/stock/LotItem.service.js +++ b/client/src/modules/stock/LotItem.service.js @@ -1,5 +1,4 @@ -angular.module('bhima.services') - .service('LotItemService', LotItemService); +angular.module('bhima.services').service('LotItemService', LotItemService); LotItemService.$inject = ['uuid', '$translate']; @@ -146,7 +145,7 @@ function LotItemService(uuid, $translate) { * @function hasLotInformation * * @description - * Checks if the lot information is availability. + * Checks if the lot information is available. */ Lot.prototype.hasLotInformation = function hasLotInformation() { const hasInfo = isUuid(this.lot_uuid) @@ -176,8 +175,8 @@ function LotItemService(uuid, $translate) { * it is considered valid. * 4) If no comparison date is provided, the same comparison is performed with today's * date (the date of the client computer). Thus, if the expiration date is before - * the current date, the lot is considered expired. If the expiration date is after - * the current date, it is considered not expired. + * the current date, the lot is considered expired. If the expiration date is the + * same or after the current date, it is considered not expired. */ Lot.prototype.isExpired = function isExpired(comparisonDate = new Date()) { @@ -348,7 +347,13 @@ function LotItemService(uuid, $translate) { this.__tracking_consumption = bool; }; - // + /** + * @function formatForExport + * + * @description + * This function formats the lot for export to CSV using the ui-grid's + * internal CSV exporter. + */ Lot.prototype.formatForExport = function formatForExport() { return [ this.code, diff --git a/client/src/modules/stock/StockExitForm.service.js b/client/src/modules/stock/StockExitForm.service.js index 50f286cd4c..ed33176e9d 100644 --- a/client/src/modules/stock/StockExitForm.service.js +++ b/client/src/modules/stock/StockExitForm.service.js @@ -4,7 +4,7 @@ angular.module('bhima.services') StockExitFormService.$inject = [ 'Store', 'AppCache', 'SessionService', '$timeout', 'bhConstants', 'DepotService', 'Pool', 'LotItemService', 'StockExitFormHelperService', 'util', '$translate', - 'StockService', + 'StockService', '$filter', ]; /** @@ -16,7 +16,7 @@ StockExitFormService.$inject = [ function StockExitFormService( Store, AppCache, Session, $timeout, bhConstants, Depots, Pool, Lot, Helpers, util, $translate, - Stock, + Stock, $filter, ) { const { @@ -24,6 +24,7 @@ function StockExitFormService( } = bhConstants.flux; const today = new Date(); + const $date = $filter('date'); const INFO_NO_EXIT_TYPE = 'STOCK.MESSAGES.INFO_NO_EXIT_TYPE'; const INFO_NEEDS_LOTS = 'STOCK.MESSAGES.INFO_NEEDS_LOTS'; @@ -122,14 +123,15 @@ function StockExitFormService( * @function fetchQuantityInStock * * @description - * Loads the quantity in stock for the depot - * + * Loads the quantity in stock for the depot at a given date. * */ StockExitForm.prototype.fetchQuantityInStock = function fetchQuantityInStock(depotUuid, date) { if (!depotUuid || !date) { return {}; } - const parameters = { consumable : 1, inStock : true, date }; + // format date into something that can be cached. + const dateFormatted = $date(date, 'yyyy-MM-dd'); + const parameters = { consumable : 1, inStock : true, date : dateFormatted }; this._queriesInProgress++; @@ -235,7 +237,7 @@ function StockExitFormService( // reset store by releasing all locks on items // and clearing the data - this.store.data.forEach(item => this.pool.release(item.lot_uuid)); + this.store.data.forEach(item => this._pool.release(item.lot_uuid)); this.store.clear(); }; @@ -265,7 +267,12 @@ function StockExitFormService( }); const hasNoConsumableItems = (available.length === 0 && unavailable.length === 0); - this._toggleInfoMessage(hasNoConsumableItems, 'warn', WARN_NOT_CONSUMABLE_INVOICE, { ...this.details, inventories }); + this._toggleInfoMessage( + hasNoConsumableItems, + 'warn', + WARN_NOT_CONSUMABLE_INVOICE, + { ...this.details, inventories }, + ); // if there are no consumable items in the invoice, this will exit early if (hasNoConsumableItems) { diff --git a/client/src/modules/stock/exit/exit.js b/client/src/modules/stock/exit/exit.js index 459f28fbf1..85023353ac 100644 --- a/client/src/modules/stock/exit/exit.js +++ b/client/src/modules/stock/exit/exit.js @@ -165,6 +165,7 @@ function StockExitController( } vm.validate(); + // vm.gridApi.core.notifyDataChange(uiGridConstants.dataChange.ALL); } vm.setDate = function setDate(date) {