From 5c69d427a7abeeb6f6b65a2b6ca90cc7261b9a80 Mon Sep 17 00:00:00 2001 From: DominikNoga Date: Fri, 12 Apr 2024 07:58:42 +0200 Subject: [PATCH 1/9] wip --- src/stock-adjustment-creation/adjustment-creation.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stock-adjustment-creation/adjustment-creation.html b/src/stock-adjustment-creation/adjustment-creation.html index a225893..768e5b1 100644 --- a/src/stock-adjustment-creation/adjustment-creation.html +++ b/src/stock-adjustment-creation/adjustment-creation.html @@ -26,9 +26,9 @@

+ + + + + + \ No newline at end of file diff --git a/src/openlmis-unit-add/openlmis-unit-add.module.js b/src/openlmis-unit-add/openlmis-unit-add.module.js new file mode 100644 index 0000000..a740b1a --- /dev/null +++ b/src/openlmis-unit-add/openlmis-unit-add.module.js @@ -0,0 +1,10 @@ +(function() { + 'use strict'; + + angular.module('openlmis-unit-add', [ + 'openlmis-modal', + 'openlmis-templates', + 'openlmis-state-tracker', + 'openlmis-modal-state' + ]); +})(); \ No newline at end of file diff --git a/src/openlmis-unit-add/openlmis-unit-add.routes.js b/src/openlmis-unit-add/openlmis-unit-add.routes.js new file mode 100644 index 0000000..7ff1eaa --- /dev/null +++ b/src/openlmis-unit-add/openlmis-unit-add.routes.js @@ -0,0 +1,42 @@ +/* + * This program is part of the OpenLMIS logistics management information system platform software. + * Copyright © 2017 VillageReach + * + * This program is free software: you can redistribute it and/or modify it under the terms + * of the GNU Affero General Public License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + *   + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  + * See the GNU Affero General Public License for more details. You should have received a copy of + * the GNU Affero General Public License along with this program. If not, see + * http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org.  + */ + +(function() { + + 'use strict'; + + angular + .module('openlmis-unit-add') + .config(routes); + + routes.$inject = ['modalStateProvider']; + + function routes(modalStateProvider) { + + modalStateProvider.state('openlmis.stockmanagement.adjustment.creation.unitAdd', { + controller: 'openlmisUnitAddController', + controllerAs: '$ctrl', + templateUrl: 'openlmis-unit-add/openlmis-unit-add.html', + url: '/addUnit' + }); + + modalStateProvider.state('openlmis.stockmanagement.physicalInventory.draft.unitAdd', { + controller: 'openlmisUnitAddController', + controllerAs: '$ctrl', + templateUrl: 'openlmis-unit-add/openlmis-unit-add.html', + url: '/addUnit' + }); + } +})(); diff --git a/src/openlmis-unit-add/openlmis-unit-add.scss b/src/openlmis-unit-add/openlmis-unit-add.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/openlmis-unit-add/openlmis-unit-add.service.js b/src/openlmis-unit-add/openlmis-unit-add.service.js new file mode 100644 index 0000000..6d1004f --- /dev/null +++ b/src/openlmis-unit-add/openlmis-unit-add.service.js @@ -0,0 +1,19 @@ +(function() { + 'use strict'; + + angular + .module('openlmis-unit-add') + .service('openlmisUnitAddService', openlmisUnitAddService); + + openlmisUnitAddService.$inject = []; + + function openlmisUnitAddService() { + return { + save: save + }; + + function save() { + console.log('Saving form'); + } + } +})(); \ No newline at end of file diff --git a/src/stock-adjustment-creation/adjustment-creation.controller.js b/src/stock-adjustment-creation/adjustment-creation.controller.js index 7b1bbd1..e3c08e2 100644 --- a/src/stock-adjustment-creation/adjustment-creation.controller.js +++ b/src/stock-adjustment-creation/adjustment-creation.controller.js @@ -905,6 +905,10 @@ return vm.hasPermissionToAddNewLot && lineItem.lot && lineItem.$isNewItem; }; + vm.addNewUnit = function() { + $state.go('openlmis.stockmanagement.adjustment.creation.unitAdd'); + }; + /** * @ngdoc method * @methodOf stock-adjustment-creation.controller:StockAdjustmentCreationController diff --git a/src/stock-adjustment-creation/adjustment-creation.html b/src/stock-adjustment-creation/adjustment-creation.html index 768e5b1..e2ff62c 100644 --- a/src/stock-adjustment-creation/adjustment-creation.html +++ b/src/stock-adjustment-creation/adjustment-creation.html @@ -23,7 +23,7 @@

- + - +
+
+ +
@@ -62,6 +67,9 @@

+ @@ -104,6 +112,14 @@

+
{{vm.key('noProducts') | message}}
{{vm.key('srcDstComments') | message}} {{vm.key('reason') | message}} {{vm.key('reasonComments') | message}} + {{ vm.key('unit') | message }} + {{vm.key('quantity') | message}} {{'adjustmentCreation.price' | message}} + + + placeholder + diff --git a/src/stock-adjustment-creation/adjustment-creation.module.js b/src/stock-adjustment-creation/adjustment-creation.module.js index 6b4b7d0..3cc60de 100644 --- a/src/stock-adjustment-creation/adjustment-creation.module.js +++ b/src/stock-adjustment-creation/adjustment-creation.module.js @@ -32,6 +32,7 @@ 'referencedata-lot', 'stock-unpack-kit', 'stock-reasons-modal', - 'stock-edit-lot-modal' + 'stock-edit-lot-modal', + 'openlmis-unit-add' ]); -})(); \ No newline at end of file +})(); diff --git a/src/stock-adjustment-creation/messages_en.json b/src/stock-adjustment-creation/messages_en.json index 05f6c1e..40755e3 100644 --- a/src/stock-adjustment-creation/messages_en.json +++ b/src/stock-adjustment-creation/messages_en.json @@ -3,5 +3,6 @@ "adjustmentCreation.price": "Unit Price", "adjustmentCreation.totalPrice": "Total Price", "adjustmentCreation.numberEqualOrGreaterThan0": "You must input number equal or greater than 0", - "adjustmentCreation.totalCost": "Total Cost" + "adjustmentCreation.totalCost": "Total Cost", + "adjustmentCreation.addNewUnit": "Add New Unit" } \ No newline at end of file diff --git a/src/stock-adjustment-creation/stock-adjustment-creation.scss b/src/stock-adjustment-creation/stock-adjustment-creation.scss new file mode 100644 index 0000000..8617c34 --- /dev/null +++ b/src/stock-adjustment-creation/stock-adjustment-creation.scss @@ -0,0 +1,5 @@ +.is-primary { + display: flex; + font-display: row; + gap: .5rem; +} \ No newline at end of file diff --git a/src/stock-physical-inventory-draft/_physical-inventory-draft.scss b/src/stock-physical-inventory-draft/_physical-inventory-draft.scss new file mode 100644 index 0000000..19e1264 --- /dev/null +++ b/src/stock-physical-inventory-draft/_physical-inventory-draft.scss @@ -0,0 +1,6 @@ +.buttons-section { + display: flex; + flex-direction: row; + gap: .5rem; + align-items: center; +} diff --git a/src/stock-physical-inventory-draft/messages_en.json b/src/stock-physical-inventory-draft/messages_en.json new file mode 100644 index 0000000..044fbb3 --- /dev/null +++ b/src/stock-physical-inventory-draft/messages_en.json @@ -0,0 +1,5 @@ +{ + "stockPhysicalInventoryDraft.addUnit": "Add New Unit", + "stockPhysicalInventoryDraft.quantity": "Quantity", + "stockPhysicalInventoryDraft.unit": "Unit" +} \ No newline at end of file diff --git a/src/stock-physical-inventory-draft/physical-inventory-draft.html b/src/stock-physical-inventory-draft/physical-inventory-draft.html index 2288e83..510ded6 100644 --- a/src/stock-physical-inventory-draft/physical-inventory-draft.html +++ b/src/stock-physical-inventory-draft/physical-inventory-draft.html @@ -1,28 +1,21 @@

- {{'stockPhysicalInventoryDraft.title' | message: {'facilityCode': vm.facility.code, 'facilityName': vm.facility.name, 'program': vm.program.name} }} + {{'stockPhysicalInventoryDraft.title' | message: {'facilityCode': vm.facility.code, 'facilityName': + vm.facility.name, 'program': vm.program.name} }}

-
+
-
@@ -32,31 +25,31 @@

- + - +
- - - - +
+ + + +
- + - + + + - - + + @@ -105,43 +101,52 @@

- - + ng-change="vm.checkUnaccountedStockAdjustments(lineItem); vm.validateUnaccountedQuantity(lineItem)" /> + + + +
@@ -73,14 +66,17 @@

{{'stockPhysicalInventoryDraft.expiryDate' | message}} {{'stockPhysicalInventoryDraft.soh' | message}} {{'stockPhysicalInventoryDraft.currentStock' | message}}{{'stockPhysicalInventoryDraft.VVMStatus' | message}} + {{'stockPhysicalInventoryDraft.VVMStatus' | message}} {{'stockPhysicalInventoryDraft.reasons' | message}} {{'stockPhysicalInventoryDraft.unaccountedQuantity' | message}}{{'stockPhysicalInventoryDraft.actions' | message}}{{:: 'stockPhysicalInventoryDraft.unit' | message}}{{:: 'stockPhysicalInventoryDraft.quantity' | message}}{{'stockPhysicalInventoryDraft.actions' | message}}
{{lineItems[0].orderable.productCode}} {{lineItems[0].orderable | productName}} {{lineItem.lot.expirationDate | openlmisDate}} {{lineItem.stockOnHand}} - + + positive-integer /> - - + - {{lineItem.unaccountedQuantity}} + {{lineItem.unaccountedQuantity}} + + + + unit + + + + + quantity - +
- + \ No newline at end of file From 42b74c69c506ee55fee2a38551125205adfb1129 Mon Sep 17 00:00:00 2001 From: DominikNoga Date: Thu, 23 May 2024 11:24:19 +0200 Subject: [PATCH 3/9] wip --- src/openlmis-unit-add/openlmis-unit-add.module.js | 15 +++++++++++++++ .../openlmis-unit-add.service.js | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/openlmis-unit-add/openlmis-unit-add.module.js b/src/openlmis-unit-add/openlmis-unit-add.module.js index a740b1a..2a9fdf4 100644 --- a/src/openlmis-unit-add/openlmis-unit-add.module.js +++ b/src/openlmis-unit-add/openlmis-unit-add.module.js @@ -1,3 +1,18 @@ +/* + * This program is part of the OpenLMIS logistics management information system platform software. + * Copyright © 2017 VillageReach + * + * This program is free software: you can redistribute it and/or modify it under the terms + * of the GNU Affero General Public License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + *   + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  + * See the GNU Affero General Public License for more details. You should have received a copy of + * the GNU Affero General Public License along with this program. If not, see + * http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org.  + */ + (function() { 'use strict'; diff --git a/src/openlmis-unit-add/openlmis-unit-add.service.js b/src/openlmis-unit-add/openlmis-unit-add.service.js index 6d1004f..279c2e4 100644 --- a/src/openlmis-unit-add/openlmis-unit-add.service.js +++ b/src/openlmis-unit-add/openlmis-unit-add.service.js @@ -1,3 +1,18 @@ +/* + * This program is part of the OpenLMIS logistics management information system platform software. + * Copyright © 2017 VillageReach + * + * This program is free software: you can redistribute it and/or modify it under the terms + * of the GNU Affero General Public License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + *   + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  + * See the GNU Affero General Public License for more details. You should have received a copy of + * the GNU Affero General Public License along with this program. If not, see + * http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org.  + */ + (function() { 'use strict'; From da338232372fe038a988664fcc409a7481e12c6a Mon Sep 17 00:00:00 2001 From: root Date: Mon, 27 May 2024 08:50:37 +0200 Subject: [PATCH 4/9] OAM-27: adjusted FE to the packs and doses --- .../admin-orderable-list.scss | 6 +++ src/admin-orderable-list/messages_en.json | 3 +- .../orderable-list.controller.js | 4 ++ src/admin-orderable-list/orderable-list.html | 26 +++++----- src/messages_en.json | 1 + src/openlmis-unit-add/messages_en.json | 5 +- .../openlmis-unit-add.controller.js | 20 +++++++- src/openlmis-unit-add/openlmis-unit-add.html | 27 ++++++++-- .../openlmis-unit-add.module.js | 3 +- .../openlmis-unit-add.routes.js | 7 +++ .../openlmis-unit-add.service.js | 10 ++-- .../unit-of-orderable.service.js | 49 +++++++++++++++++++ .../adjustment-creation.controller.js | 20 +++++++- .../adjustment-creation.html | 8 ++- .../messages_en.json | 2 +- src/stock-card-summary-list/messages_en.json | 4 +- .../stock-card-summary-list.controller.js | 13 +++++ .../stock-card-summary-list.html | 20 +++++++- .../stock-card-summary-list.scss | 10 ++++ .../messages_en.json | 2 +- 20 files changed, 205 insertions(+), 35 deletions(-) create mode 100644 src/admin-orderable-list/admin-orderable-list.scss create mode 100644 src/openlmis-unit-add/unit-of-orderable.service.js create mode 100644 src/stock-card-summary-list/stock-card-summary-list.scss diff --git a/src/admin-orderable-list/admin-orderable-list.scss b/src/admin-orderable-list/admin-orderable-list.scss new file mode 100644 index 0000000..c86b5ad --- /dev/null +++ b/src/admin-orderable-list/admin-orderable-list.scss @@ -0,0 +1,6 @@ +.buttons-group { + display: flex !important; + flex-direction: row; + gap: 1rem; + float: right !important; +} diff --git a/src/admin-orderable-list/messages_en.json b/src/admin-orderable-list/messages_en.json index 129199d..c3d1ed5 100644 --- a/src/admin-orderable-list/messages_en.json +++ b/src/admin-orderable-list/messages_en.json @@ -1,5 +1,6 @@ { "adminOrderableList.export": "Export", "adminOrderableList.includeQuarantined": "Include Quarantined Products", - "adminOrderableList.isQuarantined": "Quarantined" + "adminOrderableList.isQuarantined": "Quarantined", + "adminOrderableList.createUnit": "Create unit" } diff --git a/src/admin-orderable-list/orderable-list.controller.js b/src/admin-orderable-list/orderable-list.controller.js index a0fdc72..0e6d2e1 100644 --- a/src/admin-orderable-list/orderable-list.controller.js +++ b/src/admin-orderable-list/orderable-list.controller.js @@ -134,6 +134,10 @@ vm.tableConfig = getTableConfig(); } + vm.addNewUnit = function() { + $state.go('openlmis.administration.orderables.unitAdd'); + }; + /** * @ngdoc method * @methodOf admin-orderable-list.controller:OrderableListController diff --git a/src/admin-orderable-list/orderable-list.html b/src/admin-orderable-list/orderable-list.html index d6633d4..91d898c 100644 --- a/src/admin-orderable-list/orderable-list.html +++ b/src/admin-orderable-list/orderable-list.html @@ -1,25 +1,20 @@

{{'adminOrderableList.products' | message}}

- -
- +
- +
-
@@ -28,8 +23,15 @@

{{'adminOrderableList.products' | message}}

{{:: 'adminOrderableList.includeQuarantined' | message}}
- +
+
+ + + +
- -
+ + \ No newline at end of file diff --git a/src/messages_en.json b/src/messages_en.json index 46e202b..43b244e 100644 --- a/src/messages_en.json +++ b/src/messages_en.json @@ -48,6 +48,7 @@ "stockAddProductsModal.newLotCode": "Lot Code", "stockAdjustmentCreation.newNotExpirationDate": "Expiration Date", "stockAdjustmentCreation.newLotCode": "Lot Code", + "stockAdjustmentCreation.unit": "Unit of orderable", "orderableGroupService.addMissingLot": "Add lot", "stockPhysicalInventoryDraft.addLotFailed": "Failed to add lot.", "digestConfiguration.requisition-actionRequired": "Requisition - Action Required", diff --git a/src/openlmis-unit-add/messages_en.json b/src/openlmis-unit-add/messages_en.json index 81f4ac2..1d0c475 100644 --- a/src/openlmis-unit-add/messages_en.json +++ b/src/openlmis-unit-add/messages_en.json @@ -1,6 +1,9 @@ { - "openlmisUnitAdd.form.header": "Add New Unit", + "openlmisUnitAdd.form.header": "Create unit", "openlmisUnitAdd.form.label.name": "Name", + "openlmisUnitAdd.form.label.description": "Description", + "openlmisUnitAdd.form.label.displayOrder": "Display order", + "openlmisUnitAdd.form.label.factor": "Factor", "openlmisUnitAdd.cancel": "Cancel", "openlmisUnitAdd.save": "Save" } diff --git a/src/openlmis-unit-add/openlmis-unit-add.controller.js b/src/openlmis-unit-add/openlmis-unit-add.controller.js index 215043a..9fec5d7 100644 --- a/src/openlmis-unit-add/openlmis-unit-add.controller.js +++ b/src/openlmis-unit-add/openlmis-unit-add.controller.js @@ -32,15 +32,33 @@ function openlmisUnitAddController(openlmisUnitAddService, stateTrackerService) { var $ctrl = this; $ctrl.$onInit = onInit; + $ctrl.newUnit = { + name: undefined, + description: undefined, + displayOrder: undefined, + factor: undefined + }; $ctrl.save = save; $ctrl.goToPreviousState = stateTrackerService.goToPreviousState; + $ctrl.saveDisabled = saveDisabled; function onInit() { } + function saveDisabled() { + return !$ctrl.newUnit.name || + !$ctrl.newUnit.factor || + !$ctrl.newUnit.displayOrder; + } + function save() { - openlmisUnitAddService.save(); + // openlmisUnitAddService.save($ctrl.newUnit) + // .then(function() { + // $ctrl.goToPreviousState(); + // }); + console.log('saving form'); + console.log($ctrl.newUnit); } } })(); diff --git a/src/openlmis-unit-add/openlmis-unit-add.html b/src/openlmis-unit-add/openlmis-unit-add.html index 9db202c..6188513 100644 --- a/src/openlmis-unit-add/openlmis-unit-add.html +++ b/src/openlmis-unit-add/openlmis-unit-add.html @@ -6,13 +6,34 @@

{{:: 'openlmisUnitAdd.form.header' | message}}

diff --git a/src/openlmis-unit-add/openlmis-unit-add.module.js b/src/openlmis-unit-add/openlmis-unit-add.module.js index 2a9fdf4..db8b9e4 100644 --- a/src/openlmis-unit-add/openlmis-unit-add.module.js +++ b/src/openlmis-unit-add/openlmis-unit-add.module.js @@ -20,6 +20,7 @@ 'openlmis-modal', 'openlmis-templates', 'openlmis-state-tracker', - 'openlmis-modal-state' + 'openlmis-modal-state', + 'openlmis-pagination' ]); })(); \ No newline at end of file diff --git a/src/openlmis-unit-add/openlmis-unit-add.routes.js b/src/openlmis-unit-add/openlmis-unit-add.routes.js index 7ff1eaa..99d7e4b 100644 --- a/src/openlmis-unit-add/openlmis-unit-add.routes.js +++ b/src/openlmis-unit-add/openlmis-unit-add.routes.js @@ -38,5 +38,12 @@ templateUrl: 'openlmis-unit-add/openlmis-unit-add.html', url: '/addUnit' }); + + modalStateProvider.state('openlmis.administration.orderables.unitAdd', { + controller: 'openlmisUnitAddController', + controllerAs: '$ctrl', + templateUrl: 'openlmis-unit-add/openlmis-unit-add.html', + url: '/addUnit' + }); } })(); diff --git a/src/openlmis-unit-add/openlmis-unit-add.service.js b/src/openlmis-unit-add/openlmis-unit-add.service.js index 279c2e4..7fc5706 100644 --- a/src/openlmis-unit-add/openlmis-unit-add.service.js +++ b/src/openlmis-unit-add/openlmis-unit-add.service.js @@ -20,15 +20,15 @@ .module('openlmis-unit-add') .service('openlmisUnitAddService', openlmisUnitAddService); - openlmisUnitAddService.$inject = []; + openlmisUnitAddService.$inject = ['unitOfOrderableService']; - function openlmisUnitAddService() { + function openlmisUnitAddService(unitOfOrderableService) { return { save: save }; - function save() { - console.log('Saving form'); + function save(unit) { + return unitOfOrderableService.create(unit); } } -})(); \ No newline at end of file +})(); diff --git a/src/openlmis-unit-add/unit-of-orderable.service.js b/src/openlmis-unit-add/unit-of-orderable.service.js new file mode 100644 index 0000000..57ed779 --- /dev/null +++ b/src/openlmis-unit-add/unit-of-orderable.service.js @@ -0,0 +1,49 @@ +/* + * This program is part of the OpenLMIS logistics management information system platform software. + * Copyright © 2017 VillageReach + * + * This program is free software: you can redistribute it and/or modify it under the terms + * of the GNU Affero General Public License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + *   + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  + * See the GNU Affero General Public License for more details. You should have received a copy of + * the GNU Affero General Public License along with this program. If not, see + * http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org.  + */ + +(function() { + 'use strict'; + + angular + .module('openlmis-unit-add') + .service('unitOfOrderableService', service); + + service.$inject = ['$resource', 'referencedataUrlFactory']; + + function service($resource, referencedataUrlFactory) { + + var resource = $resource(referencedataUrlFactory('/api/unitOfOrderables'), {}, { + getAll: { + method: 'GET' + }, + create: { + method: 'POST' + } + }); + + return { + getAll: getAll, + create: create + }; + + function getAll() { + return resource.getAll().$promise; + } + + function create(unit) { + return resource.create(unit).$promise; + } + } +})(); \ No newline at end of file diff --git a/src/stock-adjustment-creation/adjustment-creation.controller.js b/src/stock-adjustment-creation/adjustment-creation.controller.js index e3c08e2..4a6d510 100644 --- a/src/stock-adjustment-creation/adjustment-creation.controller.js +++ b/src/stock-adjustment-creation/adjustment-creation.controller.js @@ -39,8 +39,9 @@ 'accessTokenFactory', '$window', 'stockmanagementUrlFactory', // ANGOLASUP-717: ends here // AO-805: Allow users with proper rights to edit product prices - 'OrderableResource', 'permissionService', 'ADMINISTRATION_RIGHTS', 'authorizationService' + 'OrderableResource', 'permissionService', 'ADMINISTRATION_RIGHTS', 'authorizationService', // AO-805: Ends here + 'unitOfOrderableService' ]; function controller($scope, $state, $stateParams, $filter, confirmDiscardService, program, @@ -52,7 +53,7 @@ // ANGOLASUP-717: Create New Issue Report // AO-805: Allow users with proper rights to edit product prices accessTokenFactory, $window, stockmanagementUrlFactory, OrderableResource, permissionService, - ADMINISTRATION_RIGHTS, authorizationService) { + ADMINISTRATION_RIGHTS, authorizationService, unitOfOrderableService) { // ANGOLASUP-717: ends here // AO-805: Ends here var vm = this, @@ -138,6 +139,17 @@ */ vm.newLot = undefined; + /** + * @ngdoc property + * @propertyOf stock-adjustment-creation.controller:StockAdjustmentCreationController + * @name unitsOfOrderable + * @type {Object} + * + * @description + * Holds possible units for orderable + */ + vm.unitsOfOrderable = []; + // OAM-5: Lot code filter UI improvements. /** * @ngdoc method @@ -173,6 +185,10 @@ $stateParams.displayItems = vm.displayItems; $stateParams.keyword = vm.keyword; $stateParams.page = getPageNumber(); + unitOfOrderableService.getAll() + .then(function(response) { + vm.unitsOfOrderable = response; + }) $state.go($state.current.name, $stateParams, { reload: true, notify: false diff --git a/src/stock-adjustment-creation/adjustment-creation.html b/src/stock-adjustment-creation/adjustment-creation.html index e2ff62c..3b37605 100644 --- a/src/stock-adjustment-creation/adjustment-creation.html +++ b/src/stock-adjustment-creation/adjustment-creation.html @@ -114,11 +114,9 @@

- - placeholder + {{'stockCardSummaryList.stockOnHand' | m - +
+ +
+ + +
+
- - - - - - + + + + + + + - - + + - + @@ -87,6 +88,7 @@

{{'stockCardSummaryList.stockOnHand' | m

+ @@ -102,7 +104,9 @@

{{'stockCardSummaryList.stockOnHand' | m

- + + + diff --git a/src/stock-card-summary-list/stock-card-summary-list.scss b/src/stock-card-summary-list/stock-card-summary-list.scss index d2501f4..f5979e1 100644 --- a/src/stock-card-summary-list/stock-card-summary-list.scss +++ b/src/stock-card-summary-list/stock-card-summary-list.scss @@ -1,7 +1,7 @@ -.buttons-group { +.stock-card-buttons-group { float: right !important; display: flex !important; - gap: 1rem; + gap: 3rem; flex-direction: row; .units-package-switch { diff --git a/src/stock-physical-inventory-draft/physical-inventory-draft.controller.js b/src/stock-physical-inventory-draft/physical-inventory-draft.controller.js index fb836a5..c67a447 100644 --- a/src/stock-physical-inventory-draft/physical-inventory-draft.controller.js +++ b/src/stock-physical-inventory-draft/physical-inventory-draft.controller.js @@ -35,7 +35,7 @@ 'VVM_STATUS', 'reasons', 'stockReasonsCalculations', 'loadingModalService', '$window', 'stockmanagementUrlFactory', 'accessTokenFactory', 'orderableGroupService', '$filter', '$q', 'offlineService', 'physicalInventoryDraftCacheService', 'stockCardService', 'LotResource', - 'editLotModalService']; + 'editLotModalService', 'unitOfOrderableService']; function controller($scope, $state, $stateParams, addProductsModalService, messageService, physicalInventoryFactory, notificationService, alertService, @@ -44,7 +44,7 @@ reasons, stockReasonsCalculations, loadingModalService, $window, stockmanagementUrlFactory, accessTokenFactory, orderableGroupService, $filter, $q, offlineService, physicalInventoryDraftCacheService, stockCardService, - LotResource, editLotModalService) { + LotResource, editLotModalService, unitOfOrderableService) { var vm = this; vm.$onInit = onInit; @@ -246,6 +246,17 @@ */ vm.dataChanged = false; + /** + * @ngdoc property + * @propertyOf stock-physical-inventory-draft.controller:PhysicalInventoryDraftController + * @name unitsOfOrderable + * @type {boolean} + * + * @description + * Holds possible units for orderable + */ + vm.unitsOfOrderable = undefined; + /** * @ngdoc method * @methodOf stock-physical-inventory-draft.controller:PhysicalInventoryDraftController @@ -427,6 +438,20 @@ }); }; + function multiplyUnitsByFactor(lineItems) { + lineItems.forEach(function(lineItem) { + if (lineItem.unitOfOrderableUUID) { + var assignedUnit = vm.unitsOfOrderable.find(function(unit) { + return unit.id === lineItem.unitOfOrderableUUID; + }); + + if (assignedUnit && lineItem.quantity) { + lineItem.quantity *= assignedUnit.factor; + } + } + }); + } + /** * @ngdoc method * @methodOf stock-physical-inventory-draft.controller:PhysicalInventoryDraftController @@ -436,6 +461,7 @@ * Save physical inventory draft. */ vm.saveDraft = function(withNotification) { + multiplyUnitsByFactor(draft.lineItems); loadingModalService.open(); return physicalInventoryFactory.saveDraft(draft).then(function() { if (!withNotification) { @@ -726,6 +752,11 @@ $stateParams.program = undefined; $stateParams.facility = undefined; + unitOfOrderableService.getAll() + .then(function(response) { + vm.unitsOfOrderable = response.content; + }); + // ANGOLASUP-806: Implement adding default reason in physical inventory if (vm.stateParams.defaultReason !== null) { vm.useDefaultReason = true; diff --git a/src/stock-physical-inventory-draft/physical-inventory-draft.html b/src/stock-physical-inventory-draft/physical-inventory-draft.html index 510ded6..8905a26 100644 --- a/src/stock-physical-inventory-draft/physical-inventory-draft.html +++ b/src/stock-physical-inventory-draft/physical-inventory-draft.html @@ -71,8 +71,7 @@

- - + @@ -83,7 +82,8 @@

- + + @@ -101,39 +101,39 @@

- - - - - - + @@ -114,9 +125,7 @@

ng-model="lineItem.reasonFreeText" rows="1" cols="15">

- + + @@ -125,7 +126,7 @@

ng-model="lineItem.reasonFreeText" rows="1" cols="15">

+ diff --git a/src/stock-physical-inventory/physical-inventory.factory.js b/src/stock-physical-inventory/physical-inventory.factory.js index eef644b..bc81afa 100644 --- a/src/stock-physical-inventory/physical-inventory.factory.js +++ b/src/stock-physical-inventory/physical-inventory.factory.js @@ -202,7 +202,7 @@ angular.forEach(draft.lineItems, function(item) { // ANGOLASUP-825: Fixed inventory saving functionality if (!(item.lot && (item.lot.lotCode && !item.lot.id))) { - if (item.unitOfOrderableUUID) { + if (item.unitOfOrderableId) { console.log(item); } physicalInventory.lineItems.push({ @@ -213,7 +213,7 @@ vvmStatus: item.vvmStatus }, stockAdjustments: item.stockAdjustments, - unitOfOrderableUUID: item.unitOfOrderableUUID + unitOfOrderableId: item.unitOfOrderableId }); } // ANGOLASUP-825: Ends here
{{'stockCardSummaryList.noProducts' | message}} diff --git a/src/stock-card-summary-list/stock-card-summary-list.scss b/src/stock-card-summary-list/stock-card-summary-list.scss new file mode 100644 index 0000000..d2501f4 --- /dev/null +++ b/src/stock-card-summary-list/stock-card-summary-list.scss @@ -0,0 +1,10 @@ +.buttons-group { + float: right !important; + display: flex !important; + gap: 1rem; + flex-direction: row; + + .units-package-switch { + @include flex-layout(row); + } +} diff --git a/src/stock-physical-inventory-draft/messages_en.json b/src/stock-physical-inventory-draft/messages_en.json index 044fbb3..685673d 100644 --- a/src/stock-physical-inventory-draft/messages_en.json +++ b/src/stock-physical-inventory-draft/messages_en.json @@ -1,5 +1,5 @@ { - "stockPhysicalInventoryDraft.addUnit": "Add New Unit", + "stockPhysicalInventoryDraft.addUnit": "Create unit", "stockPhysicalInventoryDraft.quantity": "Quantity", "stockPhysicalInventoryDraft.unit": "Unit" } \ No newline at end of file From 513ba556c8e3418b78f73249c327b058d754fed6 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 31 May 2024 09:28:31 +0200 Subject: [PATCH 5/9] Fixed stock recieve page and adjustment-creation process --- .../admin-orderable-list.scss | 2 +- src/admin-orderable-list/orderable-list.html | 2 +- .../openlmis-unit-add.controller.js | 15 +- .../adjustment-creation.controller.js | 34 ++- .../adjustment-creation.html | 224 +++++++++--------- .../messages_en.json | 4 +- src/stock-card-summary-list/messages_en.json | 3 +- .../stock-card-summary-list.controller.js | 64 ++++- .../stock-card-summary-list.html | 32 +-- .../stock-card-summary-list.scss | 4 +- .../physical-inventory-draft.controller.js | 35 ++- .../physical-inventory-draft.html | 50 ++-- .../physical-inventory.factory.js | 6 +- .../stock-product-price-changes.routes.js | 2 +- 14 files changed, 291 insertions(+), 186 deletions(-) diff --git a/src/admin-orderable-list/admin-orderable-list.scss b/src/admin-orderable-list/admin-orderable-list.scss index c86b5ad..96a2651 100644 --- a/src/admin-orderable-list/admin-orderable-list.scss +++ b/src/admin-orderable-list/admin-orderable-list.scss @@ -1,4 +1,4 @@ -.buttons-group { +.orderable-list-buttons-group { display: flex !important; flex-direction: row; gap: 1rem; diff --git a/src/admin-orderable-list/orderable-list.html b/src/admin-orderable-list/orderable-list.html index 91d898c..012f35f 100644 --- a/src/admin-orderable-list/orderable-list.html +++ b/src/admin-orderable-list/orderable-list.html @@ -25,7 +25,7 @@

{{'adminOrderableList.products' | message}}

-
+
- - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - + + - - + + - - - - - - - - + + + + + + + - - - - - + + + + + - - - + + + + +
{{vm.key('noProducts') | message}}
{{vm.key('productCode') | message}}{{vm.key('product') | message}}{{vm.key('lotCode') | message}}{{vm.key('expiryDate') | message}}{{vm.key('soh') | message}}{{vm.key('srcDstLabel') | message}}{{vm.key('srcDstComments') | message}}{{vm.key('reason') | message}}{{vm.key('reasonComments') | message}} - {{ vm.key('unit') | message }} - {{vm.key('quantity') | message}}{{'adjustmentCreation.price' | message}}{{'adjustmentCreation.totalPrice' | message}}{{vm.key('vvmStatus') | message}}{{vm.key('date') | message}}{{vm.key('actions') | message}}
{{vm.key('productCode') | message}}{{vm.key('product') | message}}{{vm.key('lotCode') | message}}{{vm.key('expiryDate') | message}}{{vm.key('soh') | message}}{{vm.key('srcDstLabel') | message}}{{vm.key('srcDstComments') | message}}{{vm.key('reason') | message}}{{vm.key('reasonComments') | message}} + {{:: 'adjustmentCreation.unit' | message }} + {{vm.key('quantity') | message}}{{:: 'adjustmentCreation.price' | message}}{{:: 'adjustmentCreation.totalPrice' | message}}{{vm.key('vvmStatus') | message}}{{vm.key('date') | message}}{{vm.key('actions') | message}}
{{lineItem.orderable.productCode}}{{lineItem.orderable | productName}} -
{{lineItem.orderable.productCode}}{{lineItem.orderable | productName}} + + {{lineItem.displayLotMessage}} - - - {{lineItem.displayLotMessage}} - {{lineItem.lot.expirationDate | openlmisDate}}{{lineItem.$previewSOH}} - {{lineItem.lot.expirationDate | openlmisDate}}{{lineItem.$previewSOH}} + - - - - + + + + - - - - - - - - - {{lineItem.price | openlmisCurrency}} - - + + + + + + + {{lineItem.price | openlmisCurrency}} + + - - {{lineItem.totalPrice | openlmisCurrency}} - - + {{lineItem.totalPrice | openlmisCurrency}} + + - - - - -
+ + + +
- +
diff --git a/src/stock-adjustment-creation/messages_en.json b/src/stock-adjustment-creation/messages_en.json index a4b66e7..71f66f8 100644 --- a/src/stock-adjustment-creation/messages_en.json +++ b/src/stock-adjustment-creation/messages_en.json @@ -4,5 +4,7 @@ "adjustmentCreation.totalPrice": "Total Price", "adjustmentCreation.numberEqualOrGreaterThan0": "You must input number equal or greater than 0", "adjustmentCreation.totalCost": "Total Cost", - "adjustmentCreation.addNewUnit": "Create unit" + "adjustmentCreation.addNewUnit": "Create unit", + "adjustmentCreation.unit": "Unit", + "adjustmentCreation.unitQuantity": "Unit quantity" } \ No newline at end of file diff --git a/src/stock-card-summary-list/messages_en.json b/src/stock-card-summary-list/messages_en.json index 4a30788..924dcfb 100644 --- a/src/stock-card-summary-list/messages_en.json +++ b/src/stock-card-summary-list/messages_en.json @@ -5,5 +5,6 @@ "stockCardSummaryList.unitPrice": "Unit Price", "stockCardSummaryList.totalPrice": "Total Price", "stockCardSummaryList.packs": "Packs", - "stockCardSummaryList.units": "Units" + "stockCardSummaryList.doses": "Doses", + "stockCardSummaryList.unit": "Unit" } \ No newline at end of file diff --git a/src/stock-card-summary-list/stock-card-summary-list.controller.js b/src/stock-card-summary-list/stock-card-summary-list.controller.js index 5b40eb1..bd0a993 100644 --- a/src/stock-card-summary-list/stock-card-summary-list.controller.js +++ b/src/stock-card-summary-list/stock-card-summary-list.controller.js @@ -30,11 +30,12 @@ controller.$inject = [ 'loadingModalService', '$state', '$stateParams', 'StockCardSummaryRepositoryImpl', 'stockCardSummaries', - 'offlineService', '$scope', 'STOCKCARD_STATUS', 'messageService', 'paginationService' + 'offlineService', '$scope', 'STOCKCARD_STATUS', 'messageService', 'paginationService', 'unitOfOrderableService' ]; function controller(loadingModalService, $state, $stateParams, StockCardSummaryRepositoryImpl, stockCardSummaries, - offlineService, $scope, STOCKCARD_STATUS, messageService, paginationService) { + offlineService, $scope, STOCKCARD_STATUS, messageService, paginationService, + unitOfOrderableService) { var vm = this; vm.$onInit = onInit; @@ -46,8 +47,8 @@ vm.goToPendingOfflineEventsPage = goToPendingOfflineEventsPage; vm.setActiveDisplayType = setActiveDisplayType; vm.PACKS_DISPLAY_TYPE = 'packs'; - vm.UNITS_DISPLAY_TYPE = 'units'; - vm.activeDisplayType = vm.UNITS_DISPLAY_TYPE; + vm.DOSES_DISPLAY_TYPE = 'doses'; + vm.activeDisplayType = vm.DOSES_DISPLAY_TYPE; /** * @ngdoc property @@ -122,6 +123,17 @@ vm.totalCost = 0; // AO-816: Ends here + /** + * @ngdoc property + * @propertyOf stock-card-summary-list.controller:StockCardSummaryListController + * @name allUnitsOfOrderable + * @type {Object[]} + * + * @description + * Holds all available units of orderable + */ + vm.allUnitsOfOrderable = undefined; + /** * @ngdoc method * @methodOf stock-card-summary-list.controller:StockCardSummaryListController @@ -132,11 +144,17 @@ */ function onInit() { // AO-816: Add prices to the Stock On Hand view - stockCardSummaries.forEach(function(stockCardSummary) { - stockCardSummary.orderable.unitPrice = getProductPrice(stockCardSummary); - stockCardSummary.orderable.totalPrice = stockCardSummary.orderable.unitPrice * - stockCardSummary.stockOnHand; + unitOfOrderableService.getAll().then(function(response) { + vm.allUnitsOfOrderable = response.content; + + stockCardSummaries.forEach(function(stockCardSummary) { + stockCardSummary.orderable.unitPrice = getProductPrice(stockCardSummary); + stockCardSummary.orderable.totalPrice = stockCardSummary.orderable.unitPrice * + stockCardSummary.stockOnHand; + stockCardSummary.orderable.unit = getOrderableUnit(stockCardSummary.orderable.unitOfOrderableUUID); + }); }); + calculateTotalCost(stockCardSummaries); // AO-816: Ends here vm.stockCardSummaries = stockCardSummaries; @@ -156,6 +174,31 @@ }, true); } + vm.getSohForPacks = function(fulfills) { + var factor = fulfills.orderable.unit ? fulfills.orderable.unit.factor : 1; + return fulfills.stockOnHand / factor; + }; + + function getOrderableUnit(orderableUnitId) { + var defaultOrderableUnit = { + name: '', + factor: 1 + }; + + if (!orderableUnitId) { + return angular.copy(defaultOrderableUnit); + } + + var unitOfOrderable = vm.allUnitsOfOrderable.find(function(unit) { + return unit.id === orderableUnitId; + }); + + return unitOfOrderable ? { + name: unitOfOrderable.name, + factor: unitOfOrderable.factor + } : angular.copy(defaultOrderableUnit); + } + /** * @ngdoc method * @methodOf stock-card-summary-list.controller:StockCardSummaryListController @@ -278,13 +321,12 @@ vm.totalCost = sum; } - // AO-816: Ends here function setActiveDisplayType(displayType) { - if (displayType === vm.PACKS_DISPLAY_TYPE || displayType === vm.UNITS_DISPLAY_TYPE) { + if (displayType === vm.PACKS_DISPLAY_TYPE || displayType === vm.DOSES_DISPLAY_TYPE) { vm.activeDisplayType = displayType; - console.log(vm.activeDisplayType); } else { + // eslint-disable-next-line no-console console.error('No such display type: ' + displayType); } } diff --git a/src/stock-card-summary-list/stock-card-summary-list.html b/src/stock-card-summary-list/stock-card-summary-list.html index 801a7ad..3a35dca 100644 --- a/src/stock-card-summary-list/stock-card-summary-list.html +++ b/src/stock-card-summary-list/stock-card-summary-list.html @@ -42,15 +42,15 @@

{{'stockCardSummaryList.stockOnHand' | m -
+

{{'stockCardSummaryList.productCode' | message}}{{'stockCardSummaryList.product' | message}}{{'stockCardSummaryList.lotCode' | message}}{{'stockCardSummaryList.expiryDate' | message}}{{'stockCardSummaryList.lastUpdate' | message}}{{'stockCardSummaryList.stockOnHand' | message}}{{:: 'stockCardSummaryList.productCode' | message}}{{:: 'stockCardSummaryList.product' | message}}{{:: 'stockCardSummaryList.lotCode' | message}}{{:: 'stockCardSummaryList.expiryDate' | message}}{{:: 'stockCardSummaryList.lastUpdate' | message}}{{:: 'stockCardSummaryList.unit' | message }}{{:: 'stockCardSummaryList.stockOnHand' | message}} {{'stockCardSummaryList.unitPrice' | message}}{{'stockCardSummaryList.totalPrice' | message}}{{:: 'stockCardSummaryList.unitPrice' | message}}{{:: 'stockCardSummaryList.totalPrice' | message}} {{'stockCardSummaryList.actions' | message}}{{:: 'stockCardSummaryList.actions' | message}}
{{summary.stockOnHand}} {{summary.orderable.unitPrice | openlmisCurrency}}{{fulfills.lot ? fulfills.lot.lotCode : ('stockCardSummaryList.noLotDefined' | message)}} {{fulfills.lot ? (fulfills.lot.expirationDate | openlmisDate) : ''}} {{fulfills.occurredDate | openlmisDate}}{{fulfills.stockOnHand}}{{ fulfills.orderable.unit.name }}{{fulfills.stockOnHand}}{{ vm.getSohForPacks(fulfills) }} {{'stockPhysicalInventoryDraft.reasons' | message}} {{'stockPhysicalInventoryDraft.unaccountedQuantity' | message}} {{:: 'stockPhysicalInventoryDraft.unit' | message}}{{:: 'stockPhysicalInventoryDraft.quantity' | message}}{{'stockPhysicalInventoryDraft.actions' | message}}{{'stockPhysicalInventoryDraft.actions' | message}}
{{vm.calculate(lineItems, 'stockOnHand')}} {{vm.calculate(lineItems, 'quantity')}} {{lineItem.lot.expirationDate | openlmisDate}} {{lineItem.stockOnHand}} - + + positive-integer/> - - + - - {{lineItem.unaccountedQuantity}} - - - - unit + ng-change="vm.checkUnaccountedStockAdjustments(lineItem); vm.validateUnaccountedQuantity(lineItem)" + /> + {{lineItem.unaccountedQuantity}} - - - - quantity + + @@ -62,9 +75,7 @@

{{vm.key('srcDstComments') | message}} {{vm.key('reason') | message}} {{vm.key('reasonComments') | message}} - {{:: 'adjustmentCreation.unit' | message }} - {{:: 'adjustmentCreation.unit' | message}} {{vm.key('quantity') | message}} {{:: 'adjustmentCreation.price' | message}} - + {{ lineItem.unitName }} Date: Mon, 3 Jun 2024 14:14:48 +0200 Subject: [PATCH 7/9] wip --- .../adjustment-creation.controller.js | 27 ++++++++++++++----- .../adjustment-creation.html | 8 ++++-- .../messages_en.json | 3 ++- .../stock-adjustment-creation.scss | 2 +- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/stock-adjustment-creation/adjustment-creation.controller.js b/src/stock-adjustment-creation/adjustment-creation.controller.js index 6d59236..d34ff8a 100644 --- a/src/stock-adjustment-creation/adjustment-creation.controller.js +++ b/src/stock-adjustment-creation/adjustment-creation.controller.js @@ -203,11 +203,11 @@ }); }; - function getUnitNameById(unitId) { + function getUnitOfOrderableById(unitId) { var unit = vm.unitsOfOrderable.find(function(unit) { return unit.id === unitId; }); - return unit.name; + return unit; } /** @@ -248,7 +248,7 @@ $errors: {}, $previewSOH: selectedItem.stockOnHand, unitOfOrderableUUID: vm.newItemUnitUUID, - unitName: getUnitNameById(vm.newItemUnitUUID), + unit: getUnitOfOrderableById(vm.newItemUnitUUID), price: getProductPrice(selectedItem), totalPrice: 0 }, @@ -314,6 +314,20 @@ }); }; + /** + * @ngdoc method + * @methodOf stock-adjustment-creation.controller:StockAdjustmentCreationController + * @name getLineItemTotalQuantity + * + * @description + * Calculates the total quantity of a line item. (mulitiplied by item quantity) + */ + vm.getLineItemTotalQuantity = function(lineItem) { + var itemQuantity = lineItem.quantity ? lineItem.quantity : 0; + var factor = lineItem.unit ? lineItem.unit.factor : 1; + return itemQuantity * factor; + }; + /** * @ngdoc method * @methodOf stock-adjustment-creation.controller:StockAdjustmentCreationController @@ -328,13 +342,14 @@ // AO-804: Display product prices on Stock Issues, Adjustments and Receives Page lineItem.totalPrice = 0; // AO-804: Ends here - if (lineItem.quantity > lineItem.$previewSOH && lineItem.reason + var validatedQuantity = vm.getLineItemTotalQuantity(lineItem); + if (validatedQuantity > lineItem.$previewSOH && lineItem.reason && lineItem.reason.reasonType === REASON_TYPES.DEBIT) { lineItem.$errors.quantityInvalid = messageService .get('stockAdjustmentCreation.quantityGreaterThanStockOnHand'); - } else if (lineItem.quantity > MAX_INTEGER_VALUE) { + } else if (validatedQuantity > MAX_INTEGER_VALUE) { lineItem.$errors.quantityInvalid = messageService.get('stockmanagement.numberTooLarge'); - } else if (lineItem.quantity >= 1) { + } else if (validatedQuantity >= 1) { lineItem.$errors.quantityInvalid = false; // AO-804: Display product prices on Stock Issues, Adjustments and Receives Page lineItem.totalPrice = calculateTotalPrice(lineItem); diff --git a/src/stock-adjustment-creation/adjustment-creation.html b/src/stock-adjustment-creation/adjustment-creation.html index 3740f0c..0722ec4 100644 --- a/src/stock-adjustment-creation/adjustment-creation.html +++ b/src/stock-adjustment-creation/adjustment-creation.html @@ -76,7 +76,8 @@

{{vm.key('reason') | message}} {{vm.key('reasonComments') | message}} {{:: 'adjustmentCreation.unit' | message}}{{vm.key('quantity') | message}}{{:: 'adjustmentCreation.itemQuantity' | message}}{{:: 'adjustmentCreation.totalQuantity' | message}} {{:: 'adjustmentCreation.price' | message}} {{:: 'adjustmentCreation.totalPrice' | message}} - {{ lineItem.unitName }} + {{ lineItem.unit.name}} ng-change="vm.validateQuantity(lineItem)" ng-blur="vm.validateQuantity(lineItem)" positive-integer /> + {{ vm.getLineItemTotalQuantity(lineItem) }} + {{lineItem.price | openlmisCurrency}} diff --git a/src/stock-adjustment-creation/messages_en.json b/src/stock-adjustment-creation/messages_en.json index 43baf57..2d1a964 100644 --- a/src/stock-adjustment-creation/messages_en.json +++ b/src/stock-adjustment-creation/messages_en.json @@ -7,5 +7,6 @@ "adjustmentCreation.addNewUnit": "Create unit", "adjustmentCreation.addProduct": "Add product", "adjustmentCreation.unit": "Unit", - "adjustmentCreation.unitQuantity": "Unit quantity" + "adjustmentCreation.itemQuantity": "Item quantity", + "adjustmentCreation.totalQuantity": "Total quantity" } \ No newline at end of file diff --git a/src/stock-adjustment-creation/stock-adjustment-creation.scss b/src/stock-adjustment-creation/stock-adjustment-creation.scss index e89975a..f94edde 100644 --- a/src/stock-adjustment-creation/stock-adjustment-creation.scss +++ b/src/stock-adjustment-creation/stock-adjustment-creation.scss @@ -1,7 +1,7 @@ .stock-adjustment-creation { .is-primary { @include flex-layout(row, $gap: 0.5rem); - .inline-form{ + .form-inline{ flex-wrap: wrap; } } From 5df30e0234b7da4661ca35ed06f646447ba6ba60 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 3 Jun 2024 16:19:41 +0200 Subject: [PATCH 8/9] merge with master | --- src/messages_en.json | 2 +- .../adjustment-creation.controller.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/messages_en.json b/src/messages_en.json index 43b244e..7f7c565 100644 --- a/src/messages_en.json +++ b/src/messages_en.json @@ -67,7 +67,7 @@ "shipmentView.fillQuantityInPack": "Fill Quantity (in Packs)", "shipmentView.packs": "Packs", "shipmentView.doses": "Doses", - "stockAdjustmentCreation.quantityGreaterThanStockOnHand": "Quantity cannot be greater than stock on hand value.", + "stockAdjustmentCreation.quantityGreaterThanStockOnHand": "Total quantity cannot be greater than stock on hand value.", "adminRoleForm.reportedAndOrderedProducts": "View Reported and Ordered Products Report", "adminRoleForm.submissionOfMonthlyReports": "View Submission of Monthly Reports", "adminRoleForm.aggregateConsumption": "View Aggregate Consumption Report", diff --git a/src/stock-adjustment-creation/adjustment-creation.controller.js b/src/stock-adjustment-creation/adjustment-creation.controller.js index d34ff8a..d30e015 100644 --- a/src/stock-adjustment-creation/adjustment-creation.controller.js +++ b/src/stock-adjustment-creation/adjustment-creation.controller.js @@ -1077,7 +1077,8 @@ // AO-805: Allow users with proper rights to edit product prices function calculateTotalPrice(lineItem) { - return lineItem.price && lineItem.quantity ? lineItem.price * lineItem.quantity : 0; + var lineItemTotalQuantity = vm.getLineItemTotalQuantity(lineItem); + return lineItem.price && lineItem.quantity ? lineItem.price * lineItemTotalQuantity : 0; } function hasPermissionToEditProductPrices() { From e953051f1fe0ff0311950c0736fcfb4e2df6351f Mon Sep 17 00:00:00 2001 From: root Date: Tue, 4 Jun 2024 11:39:42 +0200 Subject: [PATCH 9/9] Partially working. HotFix for a issue view --- .../adjustment-creation.controller.js | 73 +++++++++++++++---- .../adjustment-creation.html | 2 +- .../adjustment-creation.service.js | 3 +- .../stock-card-summary-list.controller.js | 2 +- src/stock-event/stock-event-line-item.js | 6 +- src/stock-event/stock-event.factory.js | 4 +- .../physical-inventory-draft-cache.service.js | 2 +- .../physical-inventory-draft.controller.js | 4 +- .../physical-inventory-draft.html | 2 +- .../physical-inventory.factory.js | 4 +- 10 files changed, 72 insertions(+), 30 deletions(-) diff --git a/src/stock-adjustment-creation/adjustment-creation.controller.js b/src/stock-adjustment-creation/adjustment-creation.controller.js index d30e015..bb9cdae 100644 --- a/src/stock-adjustment-creation/adjustment-creation.controller.js +++ b/src/stock-adjustment-creation/adjustment-creation.controller.js @@ -56,9 +56,9 @@ ADMINISTRATION_RIGHTS, authorizationService, unitOfOrderableService) { // ANGOLASUP-717: ends here // AO-805: Ends here - var vm = this, - previousAdded = {}; + var vm = this; + vm.previousAdded = {}; vm.expirationDateChanged = expirationDateChanged; vm.newLotCodeChanged = newLotCodeChanged; vm.validateExpirationDate = validateExpirationDate; @@ -142,14 +142,14 @@ /** * @ngdoc property * @propertyOf stock-adjustment-creation.controller:StockAdjustmentCreationController - * @name newItemUnitUUID + * @name newItemUnitId * @type {string} * * @description * Holds id of a unit which is added to a new product * */ - vm.newItemUnitUUID = undefined; + vm.newItemUnitId = undefined; /** * @ngdoc property @@ -162,6 +162,18 @@ */ vm.unitsOfOrderable = undefined; + /** + * @ngdoc property + * @propertyOf stock-adjustment-creation.controller:StockAdjustmentCreationController + * @name lotAlreadyAdded + * @type {boolean} + * + * @description + * flag which specifies if the lot from add product form was already added to table + * if yes then unit for new item is fixed + */ + vm.lotAlreadyAdded = false; + // OAM-5: Lot code filter UI improvements. /** * @ngdoc method @@ -203,6 +215,10 @@ }); }; + vm.getAddedUnitName = function() { + return getUnitOfOrderableById(vm.newItemUnitId).name; + }; + function getUnitOfOrderableById(unitId) { var unit = vm.unitsOfOrderable.find(function(unit) { return unit.id === unitId; @@ -247,36 +263,36 @@ vm.addedLineItems.unshift(_.extend({ $errors: {}, $previewSOH: selectedItem.stockOnHand, - unitOfOrderableUUID: vm.newItemUnitUUID, - unit: getUnitOfOrderableById(vm.newItemUnitUUID), + unitOfOrderableId: vm.newItemUnitId, + unit: getUnitOfOrderableById(vm.newItemUnitId), price: getProductPrice(selectedItem), totalPrice: 0 }, selectedItem, copyDefaultValue())); // AO-804: Ends here - previousAdded = vm.addedLineItems[0]; - + vm.previousAdded = vm.addedLineItems[0]; + setLotAlreadyAdded(vm.addedLineItems[0].lot.lotCode); vm.search(); } } function copyDefaultValue() { var defaultDate; - if (previousAdded.occurredDate) { - defaultDate = previousAdded.occurredDate; + if (vm.previousAdded.occurredDate) { + defaultDate = vm.previousAdded.occurredDate; } else { defaultDate = dateUtils.toStringDate(new Date()); } return { - assignment: previousAdded.assignment, - srcDstFreeText: previousAdded.srcDstFreeText, + assignment: vm.previousAdded.assignment, + srcDstFreeText: vm.previousAdded.srcDstFreeText, reason: (adjustmentType.state === ADJUSTMENT_TYPE.KIT_UNPACK.state) ? { id: UNPACK_REASONS.KIT_UNPACK_REASON_ID - } : previousAdded.reason, - reasonFreeText: previousAdded.reasonFreeText, + } : vm.previousAdded.reason, + reasonFreeText: vm.previousAdded.reasonFreeText, occurredDate: defaultDate }; } @@ -343,8 +359,8 @@ lineItem.totalPrice = 0; // AO-804: Ends here var validatedQuantity = vm.getLineItemTotalQuantity(lineItem); - if (validatedQuantity > lineItem.$previewSOH && lineItem.reason - && lineItem.reason.reasonType === REASON_TYPES.DEBIT) { + if (validatedQuantity > lineItem.$previewSOH && ((lineItem.reason + && lineItem.reason.reasonType === REASON_TYPES.DEBIT) || !lineItem.reason)) { lineItem.$errors.quantityInvalid = messageService .get('stockAdjustmentCreation.quantityGreaterThanStockOnHand'); } else if (validatedQuantity > MAX_INTEGER_VALUE) { @@ -421,6 +437,27 @@ return lineItem; }; + function setLotAlreadyAdded(lotCode) { + var matchingLineItem = vm.addedLineItems.find(function(item) { + return item.lot.lotCode === lotCode; + }); + + if (!matchingLineItem) { + vm.lotAlreadyAdded = false; + return; + } + + var matchingUnit = vm.unitsOfOrderable.find(function(unit) { + return unit.id === matchingLineItem.unitOfOrderableId; + }); + + if (matchingUnit) { + vm.newItemUnitId = matchingUnit.id; + } + + vm.lotAlreadyAdded = true; + } + /** * @ngdoc method * @methodOf stock-adjustment-creation.controller:StockAdjustmentCreationController @@ -430,6 +467,8 @@ * Allows inputs to add missing lot to be displayed. */ function lotChanged() { + setLotAlreadyAdded(vm.selectedLot.lotCode); + vm.canAddNewLot = vm.selectedLot && vm.selectedLot.lotCode === messageService.get('orderableGroupService.addMissingLot'); initiateNewLotObject(); @@ -639,6 +678,8 @@ var distinctLots = []; var lotResource = new LotResource(); addedLineItems.forEach(function(lineItem) { + lineItem.quantity = vm.getLineItemTotalQuantity(lineItem); + if (lineItem.lot && lineItem.$isNewItem && _.isUndefined(lineItem.lot.id) && !listContainsTheSameLot(distinctLots, lineItem.lot)) { distinctLots.push(lineItem.lot); diff --git a/src/stock-adjustment-creation/adjustment-creation.html b/src/stock-adjustment-creation/adjustment-creation.html index 0722ec4..0b1620f 100644 --- a/src/stock-adjustment-creation/adjustment-creation.html +++ b/src/stock-adjustment-creation/adjustment-creation.html @@ -51,7 +51,7 @@

{{:: 'adjustmentCreation.unit' | message }} diff --git a/src/stock-adjustment-creation/adjustment-creation.service.js b/src/stock-adjustment-creation/adjustment-creation.service.js index c98242b..dc42a35 100644 --- a/src/stock-adjustment-creation/adjustment-creation.service.js +++ b/src/stock-adjustment-creation/adjustment-creation.service.js @@ -101,7 +101,8 @@ }, occurredDate: item.occurredDate, reasonId: item.reason ? item.reason.id : null, - reasonFreeText: item.reasonFreeText + reasonFreeText: item.reasonFreeText, + unitOfOrderableId: item.unitOfOrderableId }, buildSourceDestinationInfo(item, adjustmentType)); }); // ANGOLASUP-717: Create New Issue Report diff --git a/src/stock-card-summary-list/stock-card-summary-list.controller.js b/src/stock-card-summary-list/stock-card-summary-list.controller.js index bd0a993..c2f9113 100644 --- a/src/stock-card-summary-list/stock-card-summary-list.controller.js +++ b/src/stock-card-summary-list/stock-card-summary-list.controller.js @@ -151,7 +151,7 @@ stockCardSummary.orderable.unitPrice = getProductPrice(stockCardSummary); stockCardSummary.orderable.totalPrice = stockCardSummary.orderable.unitPrice * stockCardSummary.stockOnHand; - stockCardSummary.orderable.unit = getOrderableUnit(stockCardSummary.orderable.unitOfOrderableUUID); + stockCardSummary.orderable.unit = getOrderableUnit(stockCardSummary.orderable.unitOfOrderableId); }); }); diff --git a/src/stock-event/stock-event-line-item.js b/src/stock-event/stock-event-line-item.js index 7ff6181..88e9399 100644 --- a/src/stock-event/stock-event-line-item.js +++ b/src/stock-event/stock-event-line-item.js @@ -46,18 +46,18 @@ * @param {String} occurredDate the occured date * @param {Object} extraData the extra data * @param {Array} stockAdjustments the stock adjustment list - * @param {string} unitOfOrderableUUID id of a unit + * @param {string} unitOfOrderableId id of a unit * @return {StockEventLineItem} the Stock Event Line Item object */ function StockEventLineItem(orderableId, lotId, quantity, occurredDate, extraData, stockAdjustments, - unitOfOrderableUUID) { + unitOfOrderableId) { this.orderableId = orderableId; this.lotId = lotId; this.quantity = quantity; this.occurredDate = occurredDate; this.extraData = extraData; this.stockAdjustments = stockAdjustments; - this.unitOfOrderableUUID = unitOfOrderableUUID; + this.unitOfOrderableId = unitOfOrderableId; } } })(); diff --git a/src/stock-event/stock-event.factory.js b/src/stock-event/stock-event.factory.js index 88b7c70..70faabb 100644 --- a/src/stock-event/stock-event.factory.js +++ b/src/stock-event/stock-event.factory.js @@ -70,7 +70,7 @@ throw 'stockPhysicalInventoryDraft.submitInvalidActive'; } - if (item.unitOfOrderableUUID) { + if (item.unitOfOrderableId) { console.log('this one has unit: ' + item); } @@ -79,7 +79,7 @@ item.quantity, physicalInventory.occurredDate, { vvmStatus: item.vvmStatus - }, stockAdjustments, item.unitOfOrderableUUID + }, stockAdjustments, item.unitOfOrderableId ); }); diff --git a/src/stock-physical-inventory-draft/physical-inventory-draft-cache.service.js b/src/stock-physical-inventory-draft/physical-inventory-draft-cache.service.js index 87488ac..bbc69b7 100644 --- a/src/stock-physical-inventory-draft/physical-inventory-draft-cache.service.js +++ b/src/stock-physical-inventory-draft/physical-inventory-draft-cache.service.js @@ -91,7 +91,7 @@ return lineItem.lot && (lineItem.lot.lotCode && !lineItem.lot.id) && (existingItemsWithNewLots.filter(function(lineItemWithNewLot) { return lineItemWithNewLot.displayLotMessage === lineItem.displayLotMessage && - lineItemWithNewLot.orderable.id === lineItem.orderable.id; + lineItemWithNewLot.orderable.id === lineItem.orderable.id && lineItemWithNewLot.stockCardId; }).length === 0); }); diff --git a/src/stock-physical-inventory-draft/physical-inventory-draft.controller.js b/src/stock-physical-inventory-draft/physical-inventory-draft.controller.js index c67a447..c8694e6 100644 --- a/src/stock-physical-inventory-draft/physical-inventory-draft.controller.js +++ b/src/stock-physical-inventory-draft/physical-inventory-draft.controller.js @@ -440,9 +440,9 @@ function multiplyUnitsByFactor(lineItems) { lineItems.forEach(function(lineItem) { - if (lineItem.unitOfOrderableUUID) { + if (lineItem.unitOfOrderableId) { var assignedUnit = vm.unitsOfOrderable.find(function(unit) { - return unit.id === lineItem.unitOfOrderableUUID; + return unit.id === lineItem.unitOfOrderableId; }); if (assignedUnit && lineItem.quantity) { diff --git a/src/stock-physical-inventory-draft/physical-inventory-draft.html b/src/stock-physical-inventory-draft/physical-inventory-draft.html index 8905a26..b86d42c 100644 --- a/src/stock-physical-inventory-draft/physical-inventory-draft.html +++ b/src/stock-physical-inventory-draft/physical-inventory-draft.html @@ -131,7 +131,7 @@

openlmis-invalid="{{lineItem.unaccountedQuantityInvalid | message}}">{{lineItem.unaccountedQuantity}}

-