diff --git a/client/src/i18n/en/inventory.json b/client/src/i18n/en/inventory.json index eee33c21c5..55ac95a94a 100644 --- a/client/src/i18n/en/inventory.json +++ b/client/src/i18n/en/inventory.json @@ -1,6 +1,7 @@ { "INVENTORY": { "ADD_GROUP": "Add Inventory Group", + "OPEN_AMC_CALCULATION" : "View AMC Calculations", "ADD_METADATA": "Add Inventory Item", "ADD_TYPE": "Add Inventory Type", "ADD_UNIT": "Add Inventory unit form", diff --git a/client/src/i18n/en/stock.json b/client/src/i18n/en/stock.json index 3dc402c3af..e34550a6b0 100644 --- a/client/src/i18n/en/stock.json +++ b/client/src/i18n/en/stock.json @@ -115,6 +115,7 @@ "MONTH_OF_STOCK" : "Stock Months - Months until Stock Out", "MONTHLY_CONSUM" : "Average Monthly Consumption", "MONTHLY_CONSUMPTION" : { + "AVERAGE_MONTHLY_CONSUMPTION" : "Average Monthly Consumption", "ALGO_1" : "Algorithm 1", "ALGO_1_COMMENT" : "The average monthly consumption is obtained by dividing the quantity consumed during the period by the number of days with stock for the period, and by multiplying the result by 30.5.", "ALGO_2" : "Algorithm 2", @@ -122,7 +123,19 @@ "ALGO_3" : "Algorithm 3", "ALGO_3_COMMENT" : "The average consumption is obtained by dividing the quantity consumed during the period by the number of days in the period, and by multiplying the result obtained by 30.5.", "ALGO_4" : "Algorithm 4 (MSH)", - "ALGO_4_COMMENT" : "The average consumption is obtained by dividing the quantity consumed during the period by the difference of the number of months in the period minus the total number of days of stock out in the period. The MSH algorithm is recommended by the Management Sciences for Health organization (https://www.msh.org)." + "ALGO_4_COMMENT" : "The average consumption is obtained by dividing the quantity consumed during the period by the difference of the number of months in the period minus the total number of days of stock out in the period. The MSH algorithm is recommended by the Management Sciences for Health organization (https://www.msh.org).", + "FIRST_INVENTORY_MOVEMENT_DATE" : "First Recorded Movement", + "LAST_INVENTORY_MOVEMENT_DATE" : "Last Recorded Movement", + "DAYS_BEFORE_CONSUMPTION" : "Days before First Consumption", + "NUMBER_OF_MONTHS" : "Number of Months", + "SUM_CONSUMPTION_DAY" : "Stock Consumption", + "SUM_CONSUMED_QUANTITY" :"Quantity Consumed", + "SUM_DAYS" : "Total Days", + "SUM_STOCK_DAY" : "Stock Available in Depot", + "SUM_STOCK_OUT_DAYS" : "Stock Outs", + "TITLE" : "Average Monthly Consumption", + "DAYS" : "Days", + "MONTHS" : "Months" }, "MOTIF" : "Motive", "MOVEMENT" : "Movement", diff --git a/client/src/i18n/fr/inventory.json b/client/src/i18n/fr/inventory.json index 5038eafbc2..edac521540 100644 --- a/client/src/i18n/fr/inventory.json +++ b/client/src/i18n/fr/inventory.json @@ -1,6 +1,7 @@ { "INVENTORY": { "ADD_GROUP": "Ajouter un groupe d'inventaire", + "OPEN_AMC_CALCULATION" : "Voire CMM calcules", "ADD_METADATA": "Ajouter un inventaire", "ADD_TYPE": "Ajouter un type d'inventaire", "ADD_UNIT": "Ajouter une forme d'Inventaire", diff --git a/client/src/js/services/StockService.js b/client/src/js/services/StockService.js index 57b142df4f..df39a709ba 100644 --- a/client/src/js/services/StockService.js +++ b/client/src/js/services/StockService.js @@ -190,6 +190,11 @@ function StockService(Api, StockFilterer, HttpCache, util, Periods) { }); } + inventories.loadAMCForInventory = function loadAMCForInventory(inventoryUuid, depotUuid) { + return inventories.$http.get(`/depots/${depotUuid}/inventories/${inventoryUuid}/cmm`) + .then(util.unwrapHttpResponse); + }; + return { stocks, stockAssign, diff --git a/client/src/modules/stock/inventories/modals/amc.modal.html b/client/src/modules/stock/inventories/modals/amc.modal.html new file mode 100644 index 0000000000..da95bf85cf --- /dev/null +++ b/client/src/modules/stock/inventories/modals/amc.modal.html @@ -0,0 +1,115 @@ + + + + + diff --git a/client/src/modules/stock/inventories/modals/amc.modal.js b/client/src/modules/stock/inventories/modals/amc.modal.js new file mode 100644 index 0000000000..08c7c6794b --- /dev/null +++ b/client/src/modules/stock/inventories/modals/amc.modal.js @@ -0,0 +1,31 @@ +angular.module('bhima.controllers') + .controller('StockAMCModalController', StockAMCModalController); + +StockAMCModalController.$inject = [ + 'StockService', 'NotifyService', '$uibModalInstance', 'data', +]; + +function StockAMCModalController(Stock, Notify, Instance, data) { + const vm = this; + + vm.close = () => Instance.dismiss(); + + Stock.inventories.loadAMCForInventory(data.inventory_uuid, data.depot_uuid) + .then(items => { + vm.data = items; + + vm.settings = vm.data.settings; + vm.inventory = items.inventory; + vm.depot = items.depot; + + vm.data.avg_consumption = vm.data[vm.settings.average_consumption_algo]; + + // nicer aliases to use in the HTML + vm.isAlgo1 = vm.settings.average_consumption_algo === 'algo1'; + vm.isAlgo2 = vm.settings.average_consumption_algo === 'algo2'; + vm.isAlgo3 = vm.settings.average_consumption_algo === 'algo3'; + vm.isAlgo4 = vm.settings.average_consumption_algo === 'algo_msh'; + }) + .catch(Notify.handleError); + +} diff --git a/client/src/modules/stock/inventories/registry.js b/client/src/modules/stock/inventories/registry.js index 245a4c1de8..ec4572f523 100644 --- a/client/src/modules/stock/inventories/registry.js +++ b/client/src/modules/stock/inventories/registry.js @@ -299,6 +299,13 @@ function StockInventoriesController( vm.gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN); }; + vm.viewAMCCalculations = viewAMCCalculations; + + function viewAMCCalculations(item) { + return Modal.openAMCCalculationModal(item) + .catch(angular.noop); + } + /** * @function openBarcodeScanner * diff --git a/client/src/modules/stock/inventories/templates/inventory.action.html b/client/src/modules/stock/inventories/templates/inventory.action.html index 754186738f..14053cb78c 100644 --- a/client/src/modules/stock/inventories/templates/inventory.action.html +++ b/client/src/modules/stock/inventories/templates/inventory.action.html @@ -35,5 +35,13 @@ INVENTORY.VIEW_LOTS_IN_STOCK + +
  • + +
  • + + INVENTORY.OPEN_AMC_CALCULATION + +
  • diff --git a/client/src/modules/stock/lots/modals/edit.modal.html b/client/src/modules/stock/lots/modals/edit.modal.html index f5f72e66a0..8eade8b279 100644 --- a/client/src/modules/stock/lots/modals/edit.modal.html +++ b/client/src/modules/stock/lots/modals/edit.modal.html @@ -1,6 +1,9 @@