Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(payroll): add service to multiple payroll #7198

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions client/src/modules/multiple_payroll/multiple_payroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ function MultiplePayrollController(
field : 'display_name',
displayName : 'FORM.LABELS.EMPLOYEE_NAME',
headerCellFilter : 'translate',
}, {
field : 'service_name',
displayName : 'FORM.LABELS.SERVICE',
headerCellFilter : 'translate',
}, {
field : 'code',
displayName : 'FORM.LABELS.CODE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ function MultiplePayrollIndiceController(
width : 100,
aggregationType : uiGridConstants.aggregationTypes.count,
aggregationHideLabel : true,
},
{
}, {
field : 'service_name',
displayName : 'FORM.LABELS.SERVICE',
headerCellFilter : 'translate',
}, {
field : 'action',
width : 100,
displayName : '',
Expand Down Expand Up @@ -108,7 +111,7 @@ function MultiplePayrollIndiceController(

function renameGridHeaders(rubrics) {
const actions = angular.copy(columnDefs[columnDefs.length - 1]);
const newColumns = columnDefs.slice(0, 1);
const newColumns = columnDefs.slice(0, 2);

const header = {
type : 'number',
Expand Down Expand Up @@ -136,19 +139,19 @@ function MultiplePayrollIndiceController(
}

function setGridData(employees) {
const data = [];
employees.forEach(employee => {
return employees.map(employee => {
const row = {
employee_uuid : employee.uuid,
display_name : employee.display_name,
service_name : employee.service_name,
};

employee.rubrics.forEach(r => {
row[r.rubric_id] = r.rubric_value;
});
data.push(row);

return row;
});
return data;
}
// remove a filter with from the filter object, save the filters and reload
function onRemoveFilter(key) {
Expand Down
24 changes: 12 additions & 12 deletions server/controllers/payroll/multiplePayrollIndice/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function create(req, res, next) {

rubrics.forEach(r => {
transaction.addQuery(`
DELETE FROM stage_payment_indice
DELETE FROM stage_payment_indice
WHERE employee_uuid = ? AND payroll_configuration_id=? AND rubric_id = ?`, [
db.bid(employeeUuid), payrollConfigurationId, r.id]);

Expand All @@ -73,14 +73,15 @@ async function lookUp(options) {
const employeeUuid = options.employee_uuid;

const employeSql = `
SELECT BUID(emp.uuid) as uuid,UPPER(pt.display_name) AS display_name, pt.sex
SELECT BUID(emp.uuid) as uuid,UPPER(pt.display_name) AS display_name, pt.sex, service.name as service_name
FROM payroll_configuration pc
JOIN config_employee ce ON ce.id = pc.config_employee_id
JOIN config_employee_item cei ON cei.config_employee_id = ce.id
JOIN employee emp ON emp.uuid = cei.employee_uuid
JOIN patient pt ON pt.uuid = emp.patient_uuid
WHERE pc.id = ?
${employeeUuid ? ` AND emp.uuid = ?` : ''}
JOIN config_employee ce ON ce.id = pc.config_employee_id
JOIN config_employee_item cei ON cei.config_employee_id = ce.id
JOIN employee emp ON emp.uuid = cei.employee_uuid
LEFT JOIN service ON emp.service_uuid = service.uuid
JOIN patient pt ON pt.uuid = emp.patient_uuid
WHERE pc.id = ?
${employeeUuid ? ' AND emp.uuid = ?' : ''}
ORDER BY pt.display_name ASC
`;

Expand All @@ -89,19 +90,18 @@ async function lookUp(options) {
FROM stage_payment_indice sti
JOIN employee emp ON emp.uuid = sti.employee_uuid
JOIN rubric_payroll rb ON rb.id = sti.rubric_id
WHERE sti.payroll_configuration_id = ?
${employeeUuid ? ` AND emp.uuid = ?` : ''}
WHERE sti.payroll_configuration_id = ?
${employeeUuid ? ' AND emp.uuid = ?' : ''}
`;

const rubricSql = `
SELECT rb.*
SELECT rb.*
FROM rubric_payroll rb
JOIN config_rubric_item cti ON cti.rubric_payroll_id = rb.id
JOIN config_rubric cr On cr.id = cti.config_rubric_id
WHERE
cr.id IN ( SELECT config_rubric_id FROM payroll_configuration WHERE id = ?)
AND rb.is_indice = 1

ORDER BY rb.position
`;

Expand Down