diff --git a/client/src/i18n/en/form.json b/client/src/i18n/en/form.json index 6cdc40eb9d..3333331de7 100644 --- a/client/src/i18n/en/form.json +++ b/client/src/i18n/en/form.json @@ -388,6 +388,7 @@ "CONVERSION_RATE": "Conversion rate", "CONVERTION_RATE" : "Conversion rate", "COST_CENTER": "Cost Center", + "COST_CENTER_OPTIONAL": "Cost Center (optional)", "COST": "Cost", "COUNTRY": "Country", "CREATE": "Create", @@ -494,6 +495,7 @@ "FORM": "Form", "FROM_ACCOUNT": "From Account", "FROM": "From", + "FUNCTION": "Function", "FUNCTION_BONUS":"Function bonus", "GAIN_ACCOUNT": "Gain on Exchange Rate Account", "GENDER": "Gender", diff --git a/client/src/i18n/fr/form.json b/client/src/i18n/fr/form.json index 0eb790e489..a9d7746af6 100644 --- a/client/src/i18n/fr/form.json +++ b/client/src/i18n/fr/form.json @@ -391,6 +391,7 @@ "CONVERSION_RATE": "Taux de conversion", "CONVERTION_RATE" : "Taux de conversion", "COST_CENTER": "Centre de coûts", + "COST_CENTER_OPTIONAL": "Centre de coûts (optionnel)", "COST": "Coût", "COUNTRY": "Pays", "CREATE": "CRÉATION", diff --git a/client/src/i18n/fr/tree.json b/client/src/i18n/fr/tree.json index d1eb4d9281..d823318ee0 100644 --- a/client/src/i18n/fr/tree.json +++ b/client/src/i18n/fr/tree.json @@ -79,6 +79,7 @@ "FISCAL_YEAR":"Année Fiscale", "FORMS_CONFIGURATION": "Configuration des formulaires", "FORMS_MANAGEMENT": "Gestion des formulaires", + "FUNCTION": "Fonction", "FUNCTION_BONUS_MANAGEMENT":"Gestion des primes sur la responsabilté", "GENERAL_LEDGER":"Grand Livre", "GRADES" : "Gestion des Grades", diff --git a/client/src/js/components/bhCostCenterSelect/bhCostCenterSelect.js b/client/src/js/components/bhCostCenterSelect/bhCostCenterSelect.js index c10fd24927..af3a8969b2 100644 --- a/client/src/js/components/bhCostCenterSelect/bhCostCenterSelect.js +++ b/client/src/js/components/bhCostCenterSelect/bhCostCenterSelect.js @@ -47,7 +47,7 @@ function CostCenterSelectController(CostCenters, Notify, $translate) { $ctrl.$onInit = () => { $ctrl.required = !!($ctrl.required); - $ctrl.label = $ctrl.label || 'COST_CENTER.TITLE'; + $ctrl.label = $ctrl.label || $ctrl.required ? 'FORM.LABELS.COST_CENTER' : 'FORM.LABELS.COST_CENTER_OPTIONAL'; $ctrl.costCenterId = $ctrl.costCenterId ? +$ctrl.costCenterId : null; loadCostCenters(); }; diff --git a/client/src/modules/employees/employee.service.js b/client/src/modules/employees/employee.service.js index 031abeef8c..73d4c0bf01 100644 --- a/client/src/modules/employees/employee.service.js +++ b/client/src/modules/employees/employee.service.js @@ -49,6 +49,7 @@ function EmployeeService(Filters, $uibModal, Api, AppCache, Languages, $httpPara { key : 'reference', label : 'FORM.LABELS.REFERENCE' }, { key : 'fonction_id', label : 'FORM.LABELS.PROFESSION' }, { key : 'service_uuid', label : 'FORM.LABELS.SERVICE' }, + { key : 'cost_center_id', label : 'FORM.LABELS.COST_CENTER' }, { key : 'is_medical', label : 'FORM.LABELS.MEDICAL_STAFF', valueFilter : 'boolean' }, ]); diff --git a/client/src/modules/employees/registry/registry.js b/client/src/modules/employees/registry/registry.js index 0430d23074..a0fa078eae 100644 --- a/client/src/modules/employees/registry/registry.js +++ b/client/src/modules/employees/registry/registry.js @@ -67,7 +67,16 @@ function EmployeeRegistryController( field : 'service_name', displayName : 'TABLE.COLUMNS.SERVICE', headerCellFilter : 'translate', + sort : { direction : uiGridConstants.ASC, priority : 2 }, + visible : false, + cellClass : muteDisabledCells, + }, + { + field : 'cost_center', + displayName : 'TABLE.COLUMNS.COST_CENTER', + headerCellFilter : 'translate', sort : { direction : uiGridConstants.ASC, priority : 1 }, + visible : false, cellClass : muteDisabledCells, }, { @@ -171,13 +180,6 @@ function EmployeeRegistryController( visible : false, cellClass : muteDisabledCells, }, - { - field : 'service_name', - displayName : 'FORM.LABELS.SERVICE', - headerCellFilter : 'translate', - visible : false, - cellClass : muteDisabledCells, - }, { name : 'actions', displayName : '', diff --git a/client/src/modules/employees/registry/search.modal.html b/client/src/modules/employees/registry/search.modal.html index 82a1480025..4b46ae5e77 100644 --- a/client/src/modules/employees/registry/search.modal.html +++ b/client/src/modules/employees/registry/search.modal.html @@ -87,6 +87,13 @@ + + + +
diff --git a/client/src/modules/employees/registry/search.modal.js b/client/src/modules/employees/registry/search.modal.js index 4d4267017f..618cdb04c3 100644 --- a/client/src/modules/employees/registry/search.modal.js +++ b/client/src/modules/employees/registry/search.modal.js @@ -28,8 +28,9 @@ function EmployeeRegistryModalController(ModalInstance, SearchModal, Store, util // these properties will be used to filter employee data form the client const searchQueryOptions = [ - 'display_name', 'sex', 'code', 'dateBirthFrom', 'dateBirthTo', 'dateEmbaucheFrom', - 'dateEmbaucheTo', 'grade_uuid', 'fonction_id', 'service_uuid', 'is_medical', 'reference', + 'display_name', 'sex', 'code', 'dateBirthFrom', 'dateBirthTo', + 'dateEmbaucheFrom', 'dateEmbaucheTo', 'grade_uuid', 'fonction_id', + 'service_uuid', 'cost_center_id', 'is_medical', 'reference', ]; // assign already defined custom filters to searchQueries object @@ -51,6 +52,12 @@ function EmployeeRegistryModalController(ModalInstance, SearchModal, Store, util vm.searchQueries.service_uuid = service.uuid; }; + // custom filter cost_center_id - assign the value to the searchQueries object + vm.onCostCenterSelect = function onCostCenterSelect(center) { + displayValues.cost_center_id = center.label; + vm.searchQueries.cost_center_id = center.id; + }; + // custom filter grade_uuid - assign the value to the searchQueries object vm.onSelectGrade = function onSelectGrade(grade) { displayValues.grade_uuid = grade.text; diff --git a/server/controllers/finance/reports/shared.js b/server/controllers/finance/reports/shared.js index 2bdb78b6cf..461672c0f2 100644 --- a/server/controllers/finance/reports/shared.js +++ b/server/controllers/finance/reports/shared.js @@ -148,6 +148,9 @@ const filters = [{ }, { field : 'code', displayName : 'FORM.LABELS.CODE', +}, { + field : 'cost_center_id', + displayName : 'FORM.LABELS.COST_CENTER', }, { field : 'dateBirthFrom', displayName : 'FORM.LABELS.DOB', diff --git a/server/controllers/payroll/employees/index.js b/server/controllers/payroll/employees/index.js index 9cae983af1..4b955da418 100644 --- a/server/controllers/payroll/employees/index.js +++ b/server/controllers/payroll/employees/index.js @@ -431,7 +431,11 @@ function list(req, res, next) { * @returns {Promise} - the result of the promise query on the database. */ function find(options) { - db.convert(options, ['service_uuid']); + // ensure expected options are parsed appropriately + db.convert(options, ['uuid', 'grade_uuid', 'creditor_uuid', 'patient_uuid', 'service_uuid']); + if (options.cost_center_id) { + options.cost_center_id = Number(options.cost_center_id); + } const sql = ` SELECT @@ -446,7 +450,8 @@ function find(options) { BUID(creditor.uuid) as creditor_uuid, creditor.text AS creditor_text, BUID(creditor.group_uuid) as creditor_group_uuid, creditor_group.account_id, BUID(current_location_id) as current_location_id, BUID(origin_location_id) as origin_location_id, - service.name as service_name, entity_map.text as reference + service.name as service_name, cc.label AS cost_center, cc.id AS cost_center_id, + entity_map.text as reference FROM employee JOIN grade ON employee.grade_uuid = grade.uuid LEFT JOIN fonction ON employee.fonction_id = fonction.id @@ -455,12 +460,11 @@ function find(options) { JOIN creditor ON employee.creditor_uuid = creditor.uuid JOIN creditor_group ON creditor_group.uuid = creditor.group_uuid LEFT JOIN service ON service.uuid = employee.service_uuid + LEFT JOIN service_cost_center AS scc ON scc.service_uuid = service.uuid + LEFT JOIN cost_center AS cc ON cc.id = scc.cost_center_id LEFT JOIN entity_map ON entity_map.uuid = employee.creditor_uuid `; - // ensure epected options are parsed appropriately as binary - db.convert(options, ['uuid', 'grade_uuid', 'creditor_uuid', 'patient_uuid']); - const filters = new FilterParser(options, { tableAlias : 'employee' }); filters.fullText('display_name', 'display_name', 'patient'); @@ -476,12 +480,19 @@ function find(options) { filters.equals('is_medical', 'is_medical', 'employee'); filters.equals('reference', 'text', 'entity_map'); + if (options.cost_center_id) { + if (options.cost_center_id > -1) { + filters.equals('cost_center_id', 'id', 'cc'); + } else { + filters.custom('cost_center_id', 'cc.id IS NULL'); + } + } + // @TODO Support ordering query filters.setOrder('ORDER BY patient.display_name ASC'); // applies filters and limits to defined sql, get parameters in correct order const query = filters.applyQuery(sql); - const parameters = filters.parameters(); return db.exec(query, parameters); diff --git a/server/controllers/payroll/reports/registrations.handlebars b/server/controllers/payroll/reports/registrations.handlebars index 9aec77d62a..dae2878031 100644 --- a/server/controllers/payroll/reports/registrations.handlebars +++ b/server/controllers/payroll/reports/registrations.handlebars @@ -15,6 +15,8 @@ {{translate "TABLE.COLUMNS.AGE" }} ({{translate "TABLE.COLUMNS.DOB"}}) {{translate "FORM.LABELS.GRADE" }} {{translate "FORM.LABELS.FUNCTION" }} + {{translate "FORM.LABELS.SERVICE" }} + {{translate "FORM.LABELS.COST_CENTER" }} {{translate "FORM.LABELS.DATE_EMBAUCHE" }} @@ -27,6 +29,8 @@ {{this.age}} ({{date this.dob}}) {{this.code_grade}} {{this.fonction_txt}} + {{this.service_name}} + {{this.cost_center}} {{date this.date_embauche}} {{else}}