Index: src/stock-physical-inventory-draft/messages_en.json =================================================================== diff -u -N -rc2059329b3912d0be7862056032e7f1e85bdf261 -rb4e10952cc208eb13abcedc3f62eb2ad3167db72 --- src/stock-physical-inventory-draft/messages_en.json (.../messages_en.json) (revision c2059329b3912d0be7862056032e7f1e85bdf261) +++ src/stock-physical-inventory-draft/messages_en.json (.../messages_en.json) (revision b4e10952cc208eb13abcedc3f62eb2ad3167db72) @@ -26,7 +26,7 @@ "stockPhysicalInventoryDraft.submitInvalidActive": "Physical inventory has invalid line items on active page. \n Change filter to active and fill items quantity", "stockPhysicalInventoryDraft.VVMStatus": "VVM Status", "stockPhysicalInventoryDraft.selectStatus": "Select Status", - "stockPhysicalInventoryDraft.status": "Status of item", + "stockPhysicalInventoryDraft.includeInactiveItems": "Include inactive items", "stockPhysicalInventoryDraft.statusActive": "Active", "stockPhysicalInventoryDraft.statusInactive": "Inactive", "stockPhysicalInventoryDraft.reasons": "Reasons", Index: src/stock-physical-inventory-draft/physical-inventory-draft-cache.service.js =================================================================== diff -u -N -r6d08166ef49583a646a70ab0b38761b8b7d6f2b3 -rb4e10952cc208eb13abcedc3f62eb2ad3167db72 --- src/stock-physical-inventory-draft/physical-inventory-draft-cache.service.js (.../physical-inventory-draft-cache.service.js) (revision 6d08166ef49583a646a70ab0b38761b8b7d6f2b3) +++ src/stock-physical-inventory-draft/physical-inventory-draft-cache.service.js (.../physical-inventory-draft-cache.service.js) (revision b4e10952cc208eb13abcedc3f62eb2ad3167db72) @@ -67,9 +67,8 @@ * @description * Retrieves given physical inventory draft from the local storage. * - * @param {String} programId program UUID - * @param {String} facilityId facility UUID - * + * @param {String} draftId + * */ function getDraft(draftId) { var cachedDraft, @@ -127,7 +126,7 @@ * @description * Remove a physical inventory draft with the given ID. * - * @param {string} draft the ID of the draft to delete + * @param {String} draftId the ID of the draft to delete */ function removeById(draftId) { offlinePhysicalInventoryDrafts.removeBy('id', draftId); Index: src/stock-physical-inventory-draft/physical-inventory-draft.controller.js =================================================================== diff -u -N -re6a463bc793f42da61dd34330569b82d46590da9 -rb4e10952cc208eb13abcedc3f62eb2ad3167db72 --- src/stock-physical-inventory-draft/physical-inventory-draft.controller.js (.../physical-inventory-draft.controller.js) (revision e6a463bc793f42da61dd34330569b82d46590da9) +++ src/stock-physical-inventory-draft/physical-inventory-draft.controller.js (.../physical-inventory-draft.controller.js) (revision b4e10952cc208eb13abcedc3f62eb2ad3167db72) @@ -34,17 +34,15 @@ 'displayLineItemsGroup', 'confirmService', 'physicalInventoryService', 'MAX_INTEGER_VALUE', 'VVM_STATUS', 'reasons', 'stockReasonsCalculations', 'loadingModalService', '$window', 'stockmanagementUrlFactory', 'accessTokenFactory', 'orderableGroupService', '$filter', '$q', - 'offlineService', 'localStorageFactory', 'physicalInventoryDraftCacheService', 'STOCKCARD_STATUS', - 'stockCardService']; + 'offlineService', 'physicalInventoryDraftCacheService', 'stockCardService']; function controller($scope, $state, $stateParams, addProductsModalService, messageService, physicalInventoryFactory, notificationService, alertService, chooseDateModalService, program, facility, draft, displayLineItemsGroup, confirmService, physicalInventoryService, MAX_INTEGER_VALUE, VVM_STATUS, reasons, stockReasonsCalculations, loadingModalService, $window, stockmanagementUrlFactory, accessTokenFactory, orderableGroupService, $filter, $q, - offlineService, localStorageFactory, - physicalInventoryDraftCacheService, STOCKCARD_STATUS, stockCardService) { + offlineService, physicalInventoryDraftCacheService, stockCardService) { var vm = this; vm.$onInit = onInit; @@ -107,28 +105,17 @@ /** * @ngdoc property * @propertyOf stock-physical-inventory-draft.controller:PhysicalInventoryDraftController - * @name stockCardStatus - * @type {String} + * @name includeInactive + * @type {Boolean} * * @description * Holds stack cards status. */ - vm.stockCardStatus = $stateParams.active; + vm.includeInactive = $stateParams.includeInactive; /** * @ngdoc property * @propertyOf stock-physical-inventory-draft.controller:PhysicalInventoryDraftController - * @name stockCardStatuses - * @type {Object} - * - * @description - * Holds list of Stock Card statuses. - */ - vm.stockCardStatuses = STOCKCARD_STATUS; - - /** - * @ngdoc property - * @propertyOf stock-physical-inventory-draft.controller:PhysicalInventoryDraftController * @name vvmStatuses * @type {Object} * @@ -219,21 +206,6 @@ }; /** - * @ngdoc method - * @methodOf stock-physical-inventory-draft.controller:PhysicalInventoryDraftController - * @name getStockCardStatusDisplay - * - * @description - * Returns Stock Card status display. - * - * @param {String} status Stock Card status - * @return {String} Stock Card status display name - */ - vm.getStockCardStatusDisplay = function(status) { - return messageService.get(STOCKCARD_STATUS.$getDisplayName(status)); - }; - - /** * @ngdoc method * @methodOf stock-physical-inventory-draft.controller:PhysicalInventoryDraftController * @name addProducts @@ -335,13 +307,13 @@ * @name search * * @description - * It searches from the total line items with given keyword and/or stockCardStatus. - * If keyword and stockCardStatus are empty then all line items will be shown. + * It searches from the total line items with given keyword and/or includeInactive. + * If keyword and includeInactive are empty then all line items will be shown. */ vm.search = function() { $stateParams.page = 0; $stateParams.keyword = vm.keyword; - $stateParams.active = vm.stockCardStatus, + $stateParams.includeInactive = vm.includeInactive; $stateParams.program = vm.program; $stateParams.facility = vm.facility; $stateParams.noReload = true; @@ -458,7 +430,7 @@ $state.go('openlmis.stockmanagement.stockCardSummaries', { program: program.id, facility: facility.id, - active: STOCKCARD_STATUS.ACTIVE + includeInactive: false }); }); } Index: src/stock-physical-inventory-draft/physical-inventory-draft.controller.spec.js =================================================================== diff -u -N -re596d0f1e69ae1ef9911aa7c65e1c030cbd9d6ec -rb4e10952cc208eb13abcedc3f62eb2ad3167db72 --- src/stock-physical-inventory-draft/physical-inventory-draft.controller.spec.js (.../physical-inventory-draft.controller.spec.js) (revision e596d0f1e69ae1ef9911aa7c65e1c030cbd9d6ec) +++ src/stock-physical-inventory-draft/physical-inventory-draft.controller.spec.js (.../physical-inventory-draft.controller.spec.js) (revision b4e10952cc208eb13abcedc3f62eb2ad3167db72) @@ -360,7 +360,7 @@ { program: this.program.id, facility: this.facility.id, - active: 'ACTIVE' + includeInactive: false }); }); @@ -379,7 +379,7 @@ { program: this.program.id, facility: this.facility.id, - active: 'ACTIVE' + includeInactive: false }); }); Index: src/stock-physical-inventory-draft/physical-inventory-draft.html =================================================================== diff -u -N -re86e5025c057bd310d31f00ef2c7f2e3dc959b23 -rb4e10952cc208eb13abcedc3f62eb2ad3167db72 --- src/stock-physical-inventory-draft/physical-inventory-draft.html (.../physical-inventory-draft.html) (revision e86e5025c057bd310d31f00ef2c7f2e3dc959b23) +++ src/stock-physical-inventory-draft/physical-inventory-draft.html (.../physical-inventory-draft.html) (revision b4e10952cc208eb13abcedc3f62eb2ad3167db72) @@ -7,10 +7,16 @@
- - +
Index: src/stock-physical-inventory-draft/physical-inventory-draft.routes.js =================================================================== diff -u -N -rd9b3afa0e7de8d58f012b3e9817dc246fbfefb66 -rb4e10952cc208eb13abcedc3f62eb2ad3167db72 --- src/stock-physical-inventory-draft/physical-inventory-draft.routes.js (.../physical-inventory-draft.routes.js) (revision d9b3afa0e7de8d58f012b3e9817dc246fbfefb66) +++ src/stock-physical-inventory-draft/physical-inventory-draft.routes.js (.../physical-inventory-draft.routes.js) (revision b4e10952cc208eb13abcedc3f62eb2ad3167db72) @@ -25,7 +25,7 @@ function routes($stateProvider, STOCKMANAGEMENT_RIGHTS) { $stateProvider.state('openlmis.stockmanagement.physicalInventory.draft', { - url: '/:id?keyword&active&page&size', + url: '/:id?keyword&includeInactive&page&size', isOffline: true, views: { '@openlmis': { @@ -39,7 +39,8 @@ params: { program: undefined, facility: undefined, - noReload: undefined + noReload: undefined, + includeInactive: 'false' }, resolve: { draft: function($stateParams, physicalInventoryFactory, offlineService, @@ -50,14 +51,14 @@ return physicalInventoryFactory.getPhysicalInventory(getDraftFromParent(drafts, $stateParams)); }, program: function($stateParams, programService, draft) { - if (_.isUndefined($stateParams.program)) { - return programService.get(draft.programId); + if ($stateParams.program === undefined) { + $stateParams.program = programService.get(draft.programId); } return $stateParams.program; }, facility: function($stateParams, facilityFactory) { - if (_.isUndefined($stateParams.facility)) { - return facilityFactory.getUserHomeFacility(); + if ($stateParams.facility === undefined) { + $stateParams.facility = facilityFactory.getUserHomeFacility(); } return $stateParams.facility; }, @@ -75,7 +76,7 @@ return paginationService.registerList(validator, $stateParams, function() { var searchResult = physicalInventoryService.search($stateParams.keyword, - draft.lineItems, $stateParams.active); + draft.lineItems, $stateParams.includeInactive === 'true'); var lineItems = $filter('orderBy')(searchResult, 'orderable.productCode'); var groups = _.chain(lineItems).filter(function(item) { Index: src/stock-physical-inventory-list/physical-inventory-list.controller.js =================================================================== diff -u -N -rd9b01385ffc54a55321f685e6b163da565e4c67f -rb4e10952cc208eb13abcedc3f62eb2ad3167db72 --- src/stock-physical-inventory-list/physical-inventory-list.controller.js (.../physical-inventory-list.controller.js) (revision d9b01385ffc54a55321f685e6b163da565e4c67f) +++ src/stock-physical-inventory-list/physical-inventory-list.controller.js (.../physical-inventory-list.controller.js) (revision b4e10952cc208eb13abcedc3f62eb2ad3167db72) @@ -124,7 +124,7 @@ id: draft.id, program: program, facility: facility, - active: 'ACTIVE' + includeInactive: false }); return $q.resolve(); } @@ -134,7 +134,7 @@ id: draft.id, program: program, facility: facility, - active: 'ACTIVE' + includeInactive: false }); }); } Index: src/stock-physical-inventory-list/physical-inventory-list.controller.spec.js =================================================================== diff -u -N -rd9b01385ffc54a55321f685e6b163da565e4c67f -rb4e10952cc208eb13abcedc3f62eb2ad3167db72 --- src/stock-physical-inventory-list/physical-inventory-list.controller.spec.js (.../physical-inventory-list.controller.spec.js) (revision d9b01385ffc54a55321f685e6b163da565e4c67f) +++ src/stock-physical-inventory-list/physical-inventory-list.controller.spec.js (.../physical-inventory-list.controller.spec.js) (revision b4e10952cc208eb13abcedc3f62eb2ad3167db72) @@ -148,7 +148,7 @@ id: draft.id, program: this.programs[0], facility: this.facility, - active: 'ACTIVE' + includeInactive: false }); }); @@ -184,7 +184,7 @@ id: id, program: this.programs[0], facility: this.facility, - active: 'ACTIVE' + includeInactive: false }); }); @@ -193,7 +193,7 @@ id: 123, programId: this.programs[0].id, facilityId: this.facility.id, - active: 'ACTIVE', + includeInactive: false, starter: false }; spyOn(this.offlineService, 'isOffline').andReturn(true); @@ -205,7 +205,7 @@ id: draft.id, program: this.programs[0], facility: this.facility, - active: 'ACTIVE' + includeInactive: false }); }); }); Index: src/stock-physical-inventory/physical-inventory.service.js =================================================================== diff -u -N -re596d0f1e69ae1ef9911aa7c65e1c030cbd9d6ec -rb4e10952cc208eb13abcedc3f62eb2ad3167db72 --- src/stock-physical-inventory/physical-inventory.service.js (.../physical-inventory.service.js) (revision e596d0f1e69ae1ef9911aa7c65e1c030cbd9d6ec) +++ src/stock-physical-inventory/physical-inventory.service.js (.../physical-inventory.service.js) (revision b4e10952cc208eb13abcedc3f62eb2ad3167db72) @@ -30,13 +30,11 @@ service.$inject = [ '$resource', 'stockmanagementUrlFactory', '$filter', 'messageService', 'openlmisDateFilter', - 'productNameFilter', 'stockEventFactory', 'physicalInventoryDraftCacheService', 'offlineService', - 'STOCKCARD_STATUS' + 'productNameFilter', 'stockEventFactory', 'physicalInventoryDraftCacheService', 'offlineService' ]; function service($resource, stockmanagementUrlFactory, $filter, messageService, openlmisDateFilter, - productNameFilter, stockEventFactory, physicalInventoryDraftCacheService, offlineService, - STOCKCARD_STATUS) { + productNameFilter, stockEventFactory, physicalInventoryDraftCacheService, offlineService) { var resource = $resource(stockmanagementUrlFactory('/api/physicalInventories'), {}, { get: { @@ -98,7 +96,7 @@ * @description * Retrieves physical inventory by id from server. * - * @param {String} id physical inventory UUID + * @param {Object} draft Physical inventory draft * @return {Promise} physical inventory promise */ function getPhysicalInventory(draft) { @@ -139,10 +137,13 @@ * * @param {String} keyword keyword * @param {Array} lineItems all line items - * @param {String} active is active stock card + * @param {Boolean} includeInactive is active stock card * @return {Array} search result */ - function search(keyword, lineItems, active) { + function search(keyword, lineItems, includeInactive) { + // Workaround for eslint unexpected token on default param + includeInactive = typeof includeInactive === 'boolean' ? includeInactive : false; + var result = lineItems; var hasLot = _.any(lineItems, function(item) { return item.lot; @@ -168,9 +169,9 @@ }); } - if (typeof active === 'string') { + if (!includeInactive) { result = _.filter(result, function(item) { - return getBooleanValueFromStockCardStatus(active) === item.active; + return item.active; }); } @@ -237,15 +238,6 @@ }); } - function getBooleanValueFromStockCardStatus(stockCardStatus) { - if (stockCardStatus === STOCKCARD_STATUS.ACTIVE) { - return true; - } else if (stockCardStatus === STOCKCARD_STATUS.INACTIVE) { - return false; - } - return undefined; - } - function getLot(item, hasLot) { return item.lot ? item.lot.lotCode : Index: src/stock-physical-inventory/physical-inventory.service.spec.js =================================================================== diff -u -N -re596d0f1e69ae1ef9911aa7c65e1c030cbd9d6ec -rb4e10952cc208eb13abcedc3f62eb2ad3167db72 --- src/stock-physical-inventory/physical-inventory.service.spec.js (.../physical-inventory.service.spec.js) (revision e596d0f1e69ae1ef9911aa7c65e1c030cbd9d6ec) +++ src/stock-physical-inventory/physical-inventory.service.spec.js (.../physical-inventory.service.spec.js) (revision b4e10952cc208eb13abcedc3f62eb2ad3167db72) @@ -58,6 +58,11 @@ .buildAsAdded() ]; + this.physicalInventoryLineItems = _.map(this.physicalInventoryLineItems, function(x) { + x.active = true; + return x; + }); + this.draft = new this.PhysicalInventoryDataBuilder().withLineItems(this.physicalInventoryLineItems) .build(); @@ -163,7 +168,23 @@ }); describe('search', function() { - it('should get all line items when keyword and active is empty', function() { + it('should get all line items when keyword is empty and includeActive is false', function() { + expect(this.physicalInventoryService.search('', this.physicalInventoryLineItems, false)) + .toEqual(this.physicalInventoryLineItems); + }); + + it('should get all active line items when keyword is empty and includeActive is true', function() { + this.physicalInventoryLineItems.push( + { + active: false + } + ); + + expect(this.physicalInventoryService.search('', this.physicalInventoryLineItems, true)) + .toEqual(this.physicalInventoryLineItems); + }); + + it('should get all active line items when keyword is empty and includeActive is not boolean', function() { expect(this.physicalInventoryService.search('', this.physicalInventoryLineItems, null)) .toEqual(this.physicalInventoryLineItems); }); @@ -216,11 +237,11 @@ } ]; - expect(this.physicalInventoryService.search('', lineItems, 'ACTIVE')) + expect(this.physicalInventoryService.search('', lineItems, false)) .toEqual([lineItems[0]]); }); - it('should find only inactive', function() { + it('should find include inactive', function() { var lineItems = [ { active: true @@ -230,20 +251,10 @@ } ]; - expect(this.physicalInventoryService.search('', lineItems, 'INACTIVE')) - .toEqual([lineItems[1]]); + expect(this.physicalInventoryService.search('', lineItems, true)) + .toEqual(lineItems); }); - it('should find nothing when with invalid active param', function() { - var lineItems = [ - { - active: true - } - ]; - - expect(this.physicalInventoryService.search('', lineItems, '')) - .toEqual([]); - }); }); it('should save physical inventory draft', function() {