Skip to content

Commit

Permalink
feature(Payroll Message error)
Browse files Browse the repository at this point in the history
- Prevent entry into the database of items whose values are not defined
- Display of the name of the employee for whom the Payroll data configuration was incorrect

closes #7455
  • Loading branch information
lomamech committed Mar 4, 2024
1 parent efd0b84 commit 920299a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions client/src/i18n/en/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"ER_DUP_KEY" : "A key collided in a unique database field. Please retry your action. If the problem persists, contact the developers.",
"ER_DUP_ENTRY" : "You have duplicated a value in a unique field! Please make sure that the necessary values are unique.",
"ER_DUP_PURCHASE_ORDER_ITEM" : "You have duplicate items for an inventory item (shown in red). Please delete it and update the previous item with that inventory item.",
"ER_EMPLOYEE_IS_NOT_CONFIGURED_CORRECTLY" : "The employee: \"%EMPLOYEE%\" is not configured correctly",
"ER_EXPIRED_STOCK_LOTS" : "Some stock lots are expired",
"ER_STOCK_LOT_IS_EXPIRED" : "Stock lot '{{label}}' cannot be selected because it is expired",
"ER_BAD_FIELD_ERROR" : "Column does not exist in database.",
Expand Down
1 change: 1 addition & 0 deletions client/src/i18n/fr/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"ER_DUP_KEY" : "Il ya déjà un enregistrement avec cette clé. Veuillez réessayer votre action. Si le problème persiste, contactez les développeurs.",
"ER_DUP_ENTRY" : "Vous avez dupliqué une valeur dans un champ unique! Assurez-vous que les valeurs nécessaires sont uniques.",
"ER_DUP_PURCHASE_ORDER_ITEM" : "Vous avez des éléments en double pour un article d'inventaire (indiqué en rouge). Veuillez le supprimer et mettre à jour l'élément précédent avec cet élément d'inventaire.",
"ER_EMPLOYEE_IS_NOT_CONFIGURED_CORRECTLY" : "L'employé: \"%EMPLOYEE%\" n'est pas configuré correctement",
"ER_EXPIRED_STOCK_LOTS" : "Certains lots de stock sont expirés",
"ER_STOCK_LOT_IS_EXPIRED" : "Le lot de stock '{{label}}' ne peut être sélectionné car il est expiré",
"ER_BAD_FIELD_ERROR" : "Vous avez entré un champ qui ne peut pas être stocké dans la base de données.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ angular.module('bhima.controllers')

MultiPayrollIndiceParamModalController.$inject = [
'NotifyService', 'MultipleIndicesPayrollService', '$uibModalInstance',
'SessionService',
'SessionService', 'LanguageService',
];

function MultiPayrollIndiceParamModalController(Notify, MultiplePayroll, Instance, Session) {
function MultiPayrollIndiceParamModalController(Notify, MultiplePayroll, Instance, Session, Languages) {
const vm = this;
vm.close = Instance.close;
vm.param = {};
Expand All @@ -24,6 +24,7 @@ function MultiPayrollIndiceParamModalController(Notify, MultiplePayroll, Instanc

vm.submit = (form) => {
if (form.$invalid) { return 0; }
vm.param.lang = Languages.key;
return MultiplePayroll.parameters.create(vm.param).then(() => {
Notify.success('FORM.INFO.OPERATION_SUCCESS');
return vm.close(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
*/
const moment = require('moment');
const debug = require('debug')('payroll:indice');
const { BadRequest } = require('../../../lib/errors');
const db = require('../../../lib/db');
const util = require('../../../lib/util');
const translate = require('../../../lib/helpers/translate');

// get staffing indice parameters
function detail(req, res, next) {
Expand All @@ -29,6 +31,8 @@ function detail(req, res, next) {
// settup staffing indice parameters
async function create(req, res, next) {
const data = req.body;
const { lang } = data;
delete data.lang;

data.uuid = db.uuid();
const id = req.body.payroll_configuration_id;
Expand Down Expand Up @@ -321,6 +325,15 @@ async function create(req, res, next) {

// Set Day index
if (rubricDayIndexId) {
if (!emp.dayIndex) {
const messageError = translate(lang)('ERRORS.ER_EMPLOYEE_IS_NOT_CONFIGURED_CORRECTLY');
const messageErrorFormated = messageError.replace('%EMPLOYEE%', emp.display_name);
next(new BadRequest('The employee: is not configured correctly',
messageErrorFormated),
);
return;
}

transaction.addQuery(
updateStaffingIndice,
[emp.dayIndex, id, emp.employee_buid, rubricDayIndexId],
Expand Down

0 comments on commit 920299a

Please sign in to comment.