Skip to content

Commit

Permalink
Add cost centers to employee registry
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcameron committed Jun 28, 2022
1 parent 765ab4f commit 8627d25
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 16 deletions.
2 changes: 2 additions & 0 deletions client/src/i18n/en/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions client/src/i18n/fr/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions client/src/i18n/fr/tree.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand Down
1 change: 1 addition & 0 deletions client/src/modules/employees/employee.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
]);

Expand Down
16 changes: 9 additions & 7 deletions client/src/modules/employees/registry/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
{
Expand Down Expand Up @@ -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 : '',
Expand Down
7 changes: 7 additions & 0 deletions client/src/modules/employees/registry/search.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@
<bh-clear on-clear="ModalCtrl.clear('service_uuid')"></bh-clear>
</bh-service-select>

<bh-cost-center-select
enable-null="true"
cost-center-id="ModalCtrl.searchQueries.cost_center_id"
on-select-callback="ModalCtrl.onCostCenterSelect(costCenter)">
<bh-clear on-clear="ModalCtrl.clear('cost_center_id')"></bh-clear>
</bh-cost-center-select>

<div class="form-group">
<label class="control-label" translate>FORM.LABELS.MEDICAL_NONMEDICAL_STAFF</label>
<bh-clear on-clear="ModalCtrl.clear('is_medical')"></bh-clear>
Expand Down
11 changes: 9 additions & 2 deletions client/src/modules/employees/registry/search.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions server/controllers/finance/reports/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
23 changes: 17 additions & 6 deletions server/controllers/payroll/employees/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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');
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions server/controllers/payroll/reports/registrations.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<th>{{translate "TABLE.COLUMNS.AGE" }} ({{translate "TABLE.COLUMNS.DOB"}})</th>
<th>{{translate "FORM.LABELS.GRADE" }}</th>
<th>{{translate "FORM.LABELS.FUNCTION" }}</th>
<th>{{translate "FORM.LABELS.SERVICE" }}</th>
<th>{{translate "FORM.LABELS.COST_CENTER" }}</th>
<th>{{translate "FORM.LABELS.DATE_EMBAUCHE" }}</th>
</tr>
</thead>
Expand All @@ -27,6 +29,8 @@
<td>{{this.age}} ({{date this.dob}})</td>
<td>{{this.code_grade}}</td>
<td>{{this.fonction_txt}}</td>
<td>{{this.service_name}}</td>
<td>{{this.cost_center}}</td>
<td>{{date this.date_embauche}}</td>
</tr>
{{else}}
Expand Down

0 comments on commit 8627d25

Please sign in to comment.