diff --git a/client/src/modules/distribution_center/modals/breakDown.modal.js b/client/src/modules/distribution_center/modals/breakDown.modal.js index 6295f4b087..78371c90d4 100644 --- a/client/src/modules/distribution_center/modals/breakDown.modal.js +++ b/client/src/modules/distribution_center/modals/breakDown.modal.js @@ -3,11 +3,11 @@ angular.module('bhima.controllers') BreakDownModalController.$inject = [ '$state', 'NotifyService', 'DistributionCenterService', 'SessionService', 'data', '$uibModalInstance', - 'FeeCenterService', '$translate', + 'FeeCenterService', '$translate', 'util', ]; function BreakDownModalController( - $state, Notify, DistributionCenter, Session, data, ModalInstance, FeeCenters, $translate, + $state, Notify, DistributionCenter, Session, data, ModalInstance, FeeCenters, $translate, util, ) { const vm = this; vm.transaction = data.transactions; @@ -50,6 +50,9 @@ function BreakDownModalController( sumDistributed += vm.percentage.values[key]; }); + // sumDistributed sum must always be 100 for 100% + sumDistributed = util.roundDecimal(sumDistributed, 0); + vm.invalidBreakDown = sumDistributed !== 100; vm.diffPercentage = Math.abs((sumDistributed - 100)); diff --git a/client/src/modules/distribution_center/modals/distribution_key.modal.js b/client/src/modules/distribution_center/modals/distribution_key.modal.js index 4f15fd32bc..374e8a3b8b 100644 --- a/client/src/modules/distribution_center/modals/distribution_key.modal.js +++ b/client/src/modules/distribution_center/modals/distribution_key.modal.js @@ -3,12 +3,12 @@ angular.module('bhima.controllers') DistributionKeyModalController.$inject = [ '$state', 'NotifyService', 'DistributionCenterService', - 'SessionService', '$uibModalInstance', 'FeeCenterService', 'settings', '$translate', + 'SessionService', '$uibModalInstance', 'FeeCenterService', 'settings', '$translate', 'util', ]; function DistributionKeyModalController( $state, Notify, DistributionCenter, Session, ModalInstance, - FeeCenters, settings, $translate, + FeeCenters, settings, $translate, util, ) { const vm = this; @@ -51,6 +51,9 @@ function DistributionKeyModalController( sumDistributed += vm.settings.values[key]; }); + // sumDistributed sum must always be 100 for 100% + sumDistributed = util.roundDecimal(sumDistributed, 0); + vm.invalidBreakDown = sumDistributed !== 100; vm.diffPercentage = Math.abs(sumDistributed - 100);