Skip to content

Commit

Permalink
improvement(Payroll process)
Browse files Browse the repository at this point in the history
- Add confirmation modal before employees are put on the payment waiting
  list
- Update E2E test for payroll_process

closes #7459
  • Loading branch information
lomamech committed Feb 22, 2024
1 parent cb29db9 commit c2b40a1
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 13 deletions.
4 changes: 4 additions & 0 deletions client/src/i18n/en/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"DISTRIBUTION_INVALID": "The distribution is invalid. The sum of distributed values must be equal to the amount of the transaction.",
"DISTRIBUTION_PERCENT_INVALID": "The distribution is invalid. The sum of percentage values must be equal to 100%",
"DISTRIBUTION_SUCCESSFULLY": "Distributed successfully",
"DO_WANT_PUT_WAITING_LIST": "Do you actually want to place the selected employees in the payment waiting list?",
"EDITED" : "Edited",
"EMPLOYEE_NOT_FOUND" : "Employee Not Found",
"ENTITY_NOT_FOUND": "Entity (Debtor/Creditor) Not Found",
Expand Down Expand Up @@ -222,6 +223,7 @@
"NO_SOURCE": "No source defined",
"NO_SUPPLIER": "A purchase order must have a supplier before specifying items.",
"NUM_TRANSACTION": "Number of transactions",
"NUMBER_EMPLOYEES_SELECTED": "Number of employees selected",
"NUMBER_PACKAGE_INFO" : "For products or items that come with packaging, you must enter the total number of packages or boxes, this quantity multiplied by the size of the packaging to obtain the global quantity by the smallest unit.",
"OF": "of",
"OPERATION_SUCCESS": "Operation performed successfully",
Expand All @@ -235,6 +237,7 @@
"PATIENT_INVOICE_FOUND": "Invoice found",
"PATIENT_INVOICE_NOT_FOUND": "No invoices found for the patient: {{name}}",
"PAYMENT": "Cash Payment",
"PAYMENT_PERIOD": "Payment period",
"PER": "per",
"PREVIOUS": "Previous",
"RECORD_SAME":"No changes have been made to the form",
Expand Down Expand Up @@ -1156,6 +1159,7 @@
"OVERRUN_DISTRIBUTION": "There is a {{value}} % overrun",
"PAGE_NOT_FOUND": "The page you requested could not be found",
"PERCENTAGE_BREACKDOWN": "Percentage breakdown is not possible when selecting transactions that belong to different expense centers",
"PUTTING_WAITING_LIST": "Putting in the waiting list is an irreversible operation, and the transactions resulting from this operation are recorded in the entry journal on the date of the end of the pay period.",
"REMAINS_DISTRIBUTION": "It remains {{ value }}",
"NO_CHANGES": "You haven't changed any form values. Nothing will be submitted to the server.",
"ONLY_500_TAG_NUMBERS_CAN_BE_GENERATED": "Only a max of 500 labels can be generated at a time"
Expand Down
4 changes: 4 additions & 0 deletions client/src/i18n/fr/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"DELETE_SUCCESS": "Suppression avec succès",
"DISABLED_CURRENCY": "Cette monnaie est inutilisable car il n'y a pas de compte fixée pour elle. Utilisez le module Box Cash Management pour définir un compte pour cette monnaie et caisse.",
"DISPLAY_NAME" : "Le nom complet de l'utilisateur, il est affiché sur tous les documents formels ou reçus traités par le système.",
"DO_WANT_PUT_WAITING_LIST": "Voulez vous effectivement placer les employés sélectionnées dans la liste d'attente de paiement?",
"ENTITY_NOT_FOUND": "Entité (Débiteur/Créditeur) Non Trouvé",
"EMAIL_SUCCESS": "Email envoyé avec succès.",
"EXPORT_SUCCESS": "Exportation avec succes",
Expand Down Expand Up @@ -222,6 +223,7 @@
"NO_SOURCE": "Aucune source définie",
"NO_SUPPLIER": "Un ordre d'achat doit avoir un fournisseur avant de préciser les éléments.",
"NUM_TRANSACTION": "Nombres des transactions",
"NUMBER_EMPLOYEES_SELECTED": "Nombre des employés sélectionnés",
"NUMBER_PACKAGE_INFO" : "Pour les produits ou articles qui se présentent avec un conditionnement, il faut renseigner le nombre total des paquets ou boites, cette quantité multipliée par la taille de l'emballage pour obtenir la quantité global par la plus petite unitée",
"OF": "de",
"OPERATION_SUCCESS": "Opération effectuée avec succès",
Expand All @@ -235,6 +237,7 @@
"PATIENT_INVOICE_FOUND": "La facture a été trouvée",
"PATIENT_INVOICE_NOT_FOUND": "La facture est inexistante pour le patient: {{name}}",
"PAYMENT": "Référence du Paiement",
"PAYMENT_PERIOD": "Période de paiement",
"PER": "par",
"PREVIOUS": "Précédent",
"RECORD_SAME":"Aucun changement n'a été apporté sur le formulaire",
Expand Down Expand Up @@ -1156,6 +1159,7 @@
"OVERRUN_DISTRIBUTION": "Il y a un dépassement de {{value}}",
"PAGE_NOT_FOUND": "La page demandée n'a pas été trouvée",
"PERCENTAGE_BREACKDOWN": "La ventilation par pourcentage n'est pas possible lorsqu'on selectionne des transactions qui appartienent à des centres des frais différents",
"PUTTING_WAITING_LIST": "La mise en attente dans la liste d'attente est une opération irréversible, et les transactions issues de cette opération sont enregistrées dans le journal de saisie à la date de la fin de la période de paie.",
"REMAINS_DISTRIBUTION": "Il reste {{ value }}",
"NO_CHANGES": "Vous n'avez pas changé les données dans le formulaire. Rien a été submis au server.",
"ONLY_500_TAG_NUMBERS_CAN_BE_GENERATED": "Seulement 500 étiquettes maximum peuvent être générées à la fois"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<form name="ModalForm" bh-submit="ModalCtrl.submit(ModalForm)" novalidate>
<div class="modal-header">
<ol class="headercrumb">
<li class="static" translate>FORM.BUTTONS.PUT_ON_WAITING</li>
</ol>
</div>

<div class="modal-body">
<div class="alert alert-warning">
<i class="fa fa-exclamation-triangle"></i>
<span translate translate-values="ModalCtrl.alertI18nValues" translate-sanitize-strategy="'sce'">FORM.WARNINGS.PUTTING_WAITING_LIST</span>
</div>

<div class="alert alert-info">
<i class="fa fa-exclamation-circle"></i>
<span translate translate-values="ModalCtrl.alertI18nValues" translate-sanitize-strategy="'sce'">FORM.INFO.DO_WANT_PUT_WAITING_LIST</span>
</div>

<!--description -->
<dl>
<dt translate>FORM.LABELS.DESCRIPTION</dt>
</dl>

<table class="table table-condensed">
<tbody>
<tr>
<td translate>FORM.INFO.PAYMENT_PERIOD</td>
<td>{{ModalCtrl.employeesNumber}}</td>
</tr>
<tr>
<td translate>FORM.INFO.NUMBER_EMPLOYEES_SELECTED</td>
<td>{{ModalCtrl.paiementPeriodLabel}}</td>
</tr>
<tr>
<td translate>FORM.LABELS.TOTAL</td>
<td>{{ ModalCtrl.totalNetSalary | currency:ModalCtrl.enterprise.currency_id }}</td>
</tr>
</tbody>
</table>
</div>

<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="ModalCtrl.cancel()" translate>
FORM.BUTTONS.CLOSE
</button>

<bh-loading-button loading-state="ModalForm.$loading" disabled="ModalCtrl.hasPaymentsAgainstInvoice">
<span translate>FORM.BUTTONS.CONFIRM</span>
</bh-loading-button>
</div>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
angular.module('bhima.controllers')
.controller('ModalWaitingListConfirmationController', ModalWaitingListConfirmationController);

ModalWaitingListConfirmationController.$inject = [
'data', 'bhConstants', 'SessionService', '$uibModalInstance',
];

function ModalWaitingListConfirmationController(
data, bhConstants, Session, Instance,
) {
const vm = this;
vm.Constants = bhConstants;
vm.submit = submit;
vm.cancel = () => Instance.close(false);

vm.enterprise = Session.enterprise;

vm.employeesNumber = data.employeesNumber;
vm.paiementPeriodLabel = data.paiementPeriodLabel;
vm.totalNetSalary = data.totalNetSalary;

function submit() {
Instance.close(true);
}
}
34 changes: 24 additions & 10 deletions client/src/modules/multiple_payroll/multiple_payroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ angular.module('bhima.controllers')
MultiplePayrollController.$inject = [
'MultiplePayrollService', 'NotifyService',
'GridSortingService', 'GridColumnService', 'GridStateService', '$state',
'ReceiptModal', 'uiGridConstants', 'SessionService',
'ReceiptModal', 'uiGridConstants', 'SessionService', 'ModalService',
];

/**
Expand All @@ -18,7 +18,7 @@ MultiplePayrollController.$inject = [
*/
function MultiplePayrollController(
MultiplePayroll, Notify, Sorting, Columns, GridState, $state,
Receipts, uiGridConstants, Session,
Receipts, uiGridConstants, Session, Modal,
) {
const vm = this;
const cacheKey = 'multiple-payroll-grid';
Expand Down Expand Up @@ -210,17 +210,31 @@ function MultiplePayrollController(
const isNotConfigured = employee => parseInt(employee.status_id, 10) !== 2;
const invalid = employees.some(isNotConfigured);

let totalNetSalary = 0;
employees.forEach(emp => {
totalNetSalary += emp.net_salary;
});

if (invalid) {
Notify.warn('FORM.WARNINGS.ATTENTION_WAITING_LIST');
} else {
vm.activePosting = false;

const idPeriod = vm.latestViewFilters.defaultFilters[0]._value;
MultiplePayroll.paymentCommitment(idPeriod, employeesUuid)
.then(() => {
Notify.success('FORM.INFO.CONFIGURED_SUCCESSFULLY');
vm.activePosting = true;
$state.go('multiple_payroll', null, { reload : true });
const employeesNumber = employeesUuid.length;
const paiementPeriodLabel = vm.latestViewFilters.defaultFilters[0].displayValue;

MultiplePayroll.openModalWaitingListConfirmation(employeesNumber, paiementPeriodLabel, totalNetSalary)
.then(success => {
if (success) {
vm.activePosting = false;

const idPeriod = vm.latestViewFilters.defaultFilters[0]._value;
MultiplePayroll.paymentCommitment(idPeriod, employeesUuid)
.then(() => {
Notify.success('FORM.INFO.CONFIGURED_SUCCESSFULLY');
vm.activePosting = true;
$state.go('multiple_payroll', null, { reload : true });
})
.catch(Notify.handleError);
}
})
.catch(Notify.handleError);
}
Expand Down
20 changes: 17 additions & 3 deletions client/src/modules/multiple_payroll/multiple_payroll.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ angular.module('bhima.services')
.service('MultiplePayrollService', MultiplePayrollService);

MultiplePayrollService.$inject = [
'PrototypeApiService', 'TransactionTypeStoreService', '$uibModal',
'FilterService', 'PeriodService', 'LanguageService', '$httpParamSerializer',
'PrototypeApiService', '$uibModal',
'FilterService', 'LanguageService', '$httpParamSerializer',
'appcache', 'TransactionService',
];

Expand All @@ -16,7 +16,7 @@ MultiplePayrollService.$inject = [
* includes some utilities that are useful for Multiple Payroll pages.
*/
function MultiplePayrollService(
Api, TransactionTypeStore, Modal, Filters, Periods, Languages,
Api, Modal, Filters, Languages,
$httpParamSerializer, AppCache, Transactions,
) {
const service = new Api('/multiple_payroll/');
Expand All @@ -35,6 +35,7 @@ function MultiplePayrollService(
service.setConfiguration = setConfiguration;
service.paymentCommitment = paymentCommitment;
service.configurations = configurations;
service.openModalWaitingListConfirmation = openModalWaitingListConfirmation;

// loads the Payroll Configuration
function getConfiguration(id, params) {
Expand Down Expand Up @@ -125,5 +126,18 @@ function MultiplePayrollService(
}).result;
}

// open a dialog box to put employees in waiting list
function openModalWaitingListConfirmation(employeesNumber, paiementPeriodLabel, totalNetSalary) {
return Modal.open({
templateUrl : 'modules/multiple_payroll/modals/waitingListConfirmation.html',
resolve : { data : { employeesNumber, paiementPeriodLabel, totalNetSalary } },
size : 'md',
animation : true,
keyboard : false,
backdrop : 'static',
controller : 'ModalWaitingListConfirmationController as ModalCtrl',
}, true).result;
}

return service;
}
4 changes: 4 additions & 0 deletions test/end-to-end/payrollProcess/payroll_process.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ test.describe('Payroll Process Management', () => {
await TU.locator('[data-action="open-menu"]').click();
await TU.locator('[data-method="put-waiting"]').click();

// Wait for confirmation dialog
await TU.waitForSelector('.modal-dialog form[name="ModalForm"]');
await TU.modal.submit();

await components.notification.hasSuccess();
});

Expand Down

0 comments on commit c2b40a1

Please sign in to comment.