diff --git a/client/src/js/services/StockService.js b/client/src/js/services/StockService.js index 28c9947193..57b142df4f 100644 --- a/client/src/js/services/StockService.js +++ b/client/src/js/services/StockService.js @@ -2,10 +2,10 @@ angular.module('bhima.services') .service('StockService', StockService); StockService.$inject = [ - 'PrototypeApiService', 'StockFilterer', 'HttpCacheService', + 'PrototypeApiService', 'StockFilterer', 'HttpCacheService', 'util', 'PeriodService', ]; -function StockService(Api, StockFilterer, HttpCache) { +function StockService(Api, StockFilterer, HttpCache, util, Periods) { // API for stock lots const stocks = new Api('/stock/lots'); @@ -85,8 +85,7 @@ function StockService(Api, StockFilterer, HttpCache) { const StockLotFilters = new StockFilterer('stock-lot-filters'); const StockAssignFilters = new StockFilterer('stock-assign-filters'); const StockRequisitionFilters = new StockFilterer('stock-requisition-filters'); - const StockMovementFilters = new StockFilterer('stock-movement-filters'); - const StockInlineMovementFilters = new StockFilterer('stock-inline-movement-filters'); + const StockMovementFilters = new StockFilterer('stock-inline-movement-filters'); const StockInventoryFilters = new StockFilterer('stock-inventory-filters'); const StockDepotFilters = new StockFilterer('stock-depot-filters'); @@ -94,13 +93,29 @@ function StockService(Api, StockFilterer, HttpCache) { const stockFilter = { lot : StockLotFilters, stockAssign : StockAssignFilters, - movement : StockMovementFilters, - inlineMovement : StockInlineMovementFilters, + movements : StockMovementFilters, inventory : StockInventoryFilters, depot : StockDepotFilters, requisition : StockRequisitionFilters, }; + function assignDefaultPeriodFilters(filterService) { + // get the keys of filters already assigned - on initial load this will be empty + const assignedKeys = Object.keys(filterService._filters.formatHTTP()); + + // assign default period filter + const periodDefined = util.arrayIncludes(assignedKeys, [ + 'period', 'custom_period_start', 'custom_period_end', + ]); + + if (!periodDefined) { + filterService._filters.assignFilters(Periods.defaultFilters()); + } + } + + // assign default period filter to inlineStockMovements + assignDefaultPeriodFilters(stockFilter.movements); + function assignNoEmptyLotsDefaultFilter(service) { // add in the default key for the stock lots filter const assignedKeys = Object.keys(service._filters.formatHTTP()); diff --git a/client/src/modules/stock/movements/registry.js b/client/src/modules/stock/movements/registry.js index b646956285..56f175a4dc 100644 --- a/client/src/modules/stock/movements/registry.js +++ b/client/src/modules/stock/movements/registry.js @@ -20,7 +20,7 @@ function StockMovementsController( ) { const vm = this; const cacheKey = 'movements-grid'; - const stockMovementsFilters = Stock.filter.inlineMovement; + const stockMovementsFilters = Stock.filter.movements; // grid columns const columns = getGridColumns(); diff --git a/client/src/modules/stock/stock.service.js b/client/src/modules/stock/stock.service.js index 629b24d264..f34fe52f14 100644 --- a/client/src/modules/stock/stock.service.js +++ b/client/src/modules/stock/stock.service.js @@ -17,7 +17,6 @@ function StockModalService(Modal) { service.openSearchLots = openSearchLots; service.openSearchStockAssign = openSearchStockAssign; service.openSearchMovements = openSearchMovements; - service.openSearchInlineMovements = openSearchInlineMovements; service.openSearchInventories = openSearchInventories; service.openSearchDepots = openSearchDepots; service.openFindPatient = openFindPatient; @@ -135,19 +134,6 @@ function StockModalService(Modal) { return instance.result; } - /** search stock inline movement */ - function openSearchInlineMovements(request) { - const params = angular.extend(modalParameters, { - templateUrl : 'modules/stock/inline-movements/modals/search.modal.html', - controller : 'SearchInlineMovementsModalController', - controllerAs : '$ctrl', - resolve : { data : () => request }, - }); - - const instance = Modal.open(params); - return instance.result; - } - /** search depots */ function openSearchDepots(request) { const params = angular.extend(modalParameters, {