Skip to content

Commit

Permalink
improvement(Employee payslip and description in journal)
Browse files Browse the repository at this point in the history
- Addition of the employee's name, on the description of the transaction
  in posting journal

- Adding employee reference to payslip

closes #4654
  • Loading branch information
lomamech committed Jan 7, 2021
1 parent 666ad34 commit 6f8fb03
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 6 deletions.
18 changes: 14 additions & 4 deletions server/controllers/payroll/multiplePayroll/commitment.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ function commitments(employees, rubrics, rubricsConfig, account, projectId, user
const datePeriodTo = moment(account[0].dateTo).format('YYYY-MM-DD');
const labelPayroll = account[0].label;
const commitmentUuid = util.uuid();

const descriptionCommitment = `ENGAGEMENT DE PAIE [${periodPayroll}]/ ${labelPayroll}`;
const descriptionWithholding = `RETENUE DU PAIEMENT [${periodPayroll}]/ ${labelPayroll}`;

const voucherCommitmentUuid = db.bid(commitmentUuid);
const withholdingUuid = util.uuid();
const voucherWithholdingUuid = db.bid(withholdingUuid);
Expand All @@ -35,6 +39,8 @@ function commitments(employees, rubrics, rubricsConfig, account, projectId, user
voucherCommitmentUuid,
voucherWithholdingUuid,
voucherChargeRemunerationUuid,
descriptionCommitment,
descriptionWithholding,
};
const enterpriseChargeRemunerations = [];

Expand Down Expand Up @@ -113,7 +119,7 @@ function commitments(employees, rubrics, rubricsConfig, account, projectId, user
currency_id : currencyId,
user_id : userId,
type_id : COMMITMENT_TYPE_ID,
description : `ENGAGEMENT DE PAIE [${periodPayroll}]/ ${labelPayroll}`,
description : descriptionCommitment,
amount : totalCommitments,
};

Expand All @@ -124,6 +130,7 @@ function commitments(employees, rubrics, rubricsConfig, account, projectId, user
0,
voucherCommitmentUuid,
null,
voucherCommitment.description,
]);

if (rubricsBenefits.length) {
Expand All @@ -135,6 +142,7 @@ function commitments(employees, rubrics, rubricsConfig, account, projectId, user
0,
voucherCommitmentUuid,
null,
voucherCommitment.description,
]);
});
}
Expand Down Expand Up @@ -179,7 +187,7 @@ function commitments(employees, rubrics, rubricsConfig, account, projectId, user
currency_id : currencyId,
user_id : userId,
type_id : WITHHOLDING_TYPE_ID,
description : `RETENUE DU PAIEMENT [${periodPayroll}]/ ${labelPayroll}`,
description : descriptionWithholding,
amount : util.roundDecimal(totalWithholdings, 2),
};

Expand All @@ -191,6 +199,7 @@ function commitments(employees, rubrics, rubricsConfig, account, projectId, user
util.roundDecimal(withholding.totals, 2),
voucherWithholdingUuid,
null,
voucherWithholding.description,
]);
});
}
Expand All @@ -200,7 +209,8 @@ function commitments(employees, rubrics, rubricsConfig, account, projectId, user
query : 'INSERT INTO voucher SET ?',
params : [voucherCommitment],
}, {
query : 'INSERT INTO voucher_item (uuid, account_id, debit, credit, voucher_uuid, entity_uuid) VALUES ?',
query : `INSERT INTO voucher_item
(uuid, account_id, debit, credit, voucher_uuid, entity_uuid, description) VALUES ?`,
params : [employeesBenefitsItem],
}, {
query : 'CALL PostVoucher(?);',
Expand All @@ -227,7 +237,7 @@ function commitments(employees, rubrics, rubricsConfig, account, projectId, user
params : [voucherWithholding],
}, {
query : `INSERT INTO voucher_item
(uuid, account_id, debit, credit, voucher_uuid, entity_uuid) VALUES ?`,
(uuid, account_id, debit, credit, voucher_uuid, entity_uuid, description) VALUES ?`,
params : [employeesWithholdingItem],
}, {
query : 'CALL PostVoucher(?);',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ function dataCommitment(employees, exchangeRates, rubrics, identificationCommitm
let totalCommitments = 0;
let totalBasicSalaries = 0;

const { voucherCommitmentUuid, voucherWithholdingUuid } = identificationCommitment;
const {
voucherCommitmentUuid,
voucherWithholdingUuid,
descriptionCommitment,
descriptionWithholding,
} = identificationCommitment;

const employeesBenefitsItem = [];
const employeesWithholdingItem = [];
Expand Down Expand Up @@ -57,6 +62,7 @@ function dataCommitment(employees, exchangeRates, rubrics, identificationCommitm
conversionGrossSalary,
voucherCommitmentUuid,
db.bid(employee.creditor_uuid),
`${descriptionCommitment} (${employee.display_name})`,
]);

rubrics.forEach(rubric => {
Expand All @@ -82,6 +88,7 @@ function dataCommitment(employees, exchangeRates, rubrics, identificationCommitm
0,
voucherWithholdingUuid,
db.bid(employee.creditor_uuid),
`${descriptionWithholding} (${employee.display_name})`,
]);

if (employeeWithholdings.length) {
Expand All @@ -94,6 +101,7 @@ function dataCommitment(employees, exchangeRates, rubrics, identificationCommitm
util.roundDecimal(withholding.value, 2),
voucherWithholdingUuid,
db.bid(employee.creditor_uuid),
`${descriptionWithholding} (${employee.display_name})`,
]);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<div> <b>{{translate "FORM.LABELS.NAME"}} :</b> {{display_name}} </div>
<div> <b>{{translate "FORM.LABELS.GENDER"}} :</b> {{sex}} </div>
<div> <b>{{translate "FORM.LABELS.CODE"}} :</b> {{code}} </div>
<div> <b>{{translate "FORM.LABELS.REFERENCE"}} :</b> {{hrreference}} </div>
<div> <b>{{translate "FORM.LABELS.GRADE"}} :</b> {{text}} </div>
<div> <b>{{translate "FORM.LABELS.DATE_EMBAUCHE"}} :</b> {{date date_embauche}} </div>
<div> <b>{{translate "FORM.LABELS.NB_CHILD"}} :</b> {{nb_enfant}} </div>
Expand Down
62 changes: 62 additions & 0 deletions server/models/migrations/next/migrate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,65 @@ ALTER TABLE `user` ADD COLUMN `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TI

-- reset all last_login information
UPDATE `user` SET `last_login` = NULL;


/*
* @author: lomamech
* @date: 2021-01-07
* @subject : Using the description from the voucher_item table in the alternative where it is provided
*/
DELIMITER $$

DROP PROCEDURE IF EXISTS PostVoucher$$

CREATE PROCEDURE PostVoucher(
IN uuid BINARY(16)
)
BEGIN
DECLARE enterprise_id INT;
DECLARE project_id INT;
DECLARE currency_id INT;
DECLARE date TIMESTAMP;

-- variables to store core set-up results
DECLARE fiscal_year_id MEDIUMINT(8) UNSIGNED;
DECLARE period_id MEDIUMINT(8) UNSIGNED;
DECLARE current_exchange_rate DECIMAL(19, 8) UNSIGNED;
DECLARE enterprise_currency_id TINYINT(3) UNSIGNED;
DECLARE transaction_id VARCHAR(100);
DECLARE gain_account_id INT UNSIGNED;
DECLARE loss_account_id INT UNSIGNED;


DECLARE transIdNumberPart INT;
--
SELECT p.enterprise_id, p.id, v.currency_id, v.date
INTO enterprise_id, project_id, currency_id, date
FROM voucher AS v JOIN project AS p ON v.project_id = p.id
WHERE v.uuid = uuid;

-- populate core setup values
CALL PostingSetupUtil(date, enterprise_id, project_id, currency_id, fiscal_year_id, period_id, current_exchange_rate, enterprise_currency_id, transaction_id, gain_account_id, loss_account_id);

-- make sure the exchange rate is correct
SET current_exchange_rate = GetExchangeRate(enterprise_id, currency_id, date);
SET current_exchange_rate = (SELECT IF(currency_id = enterprise_currency_id, 1, current_exchange_rate));

SET transIdNumberPart = GetTransactionNumberPart(transaction_id, project_id);

-- POST to the posting journal
-- @TODO(sfount) transaction ID number reference should be fetched seperately from full transaction ID to model this relationship better
INSERT INTO posting_journal (uuid, project_id, fiscal_year_id, period_id,
trans_id, trans_id_reference_number, trans_date, record_uuid, description, account_id, debit,
credit, debit_equiv, credit_equiv, currency_id, entity_uuid,
reference_uuid, comment, transaction_type_id, user_id)
SELECT
HUID(UUID()), v.project_id, fiscal_year_id, period_id, transaction_id, transIdNumberPart, v.date,
v.uuid, IF((vi.description IS NULL), v.description, vi.description), vi.account_id, vi.debit, vi.credit,
vi.debit * (1 / current_exchange_rate), vi.credit * (1 / current_exchange_rate), v.currency_id,
vi.entity_uuid, vi.document_uuid, NULL, v.type_id, v.user_id
FROM voucher AS v JOIN voucher_item AS vi ON v.uuid = vi.voucher_uuid
WHERE v.uuid = uuid;

-- NOTE: this does not handle any rounding - it simply converts the currency as needed.
END $$
2 changes: 1 addition & 1 deletion server/models/procedures/voucher.sql
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ BEGIN
reference_uuid, comment, transaction_type_id, user_id)
SELECT
HUID(UUID()), v.project_id, fiscal_year_id, period_id, transaction_id, transIdNumberPart, v.date,
v.uuid, v.description, vi.account_id, vi.debit, vi.credit,
v.uuid, IF((vi.description IS NULL), v.description, vi.description), vi.account_id, vi.debit, vi.credit,
vi.debit * (1 / current_exchange_rate), vi.credit * (1 / current_exchange_rate), v.currency_id,
vi.entity_uuid, vi.document_uuid, NULL, v.type_id, v.user_id
FROM voucher AS v JOIN voucher_item AS vi ON v.uuid = vi.voucher_uuid
Expand Down

0 comments on commit 6f8fb03

Please sign in to comment.