Skip to content

Commit

Permalink
chore(payroll): address cosmetic requests
Browse files Browse the repository at this point in the history
Addresses a number of cosmetic requests discussed in #6097.  Notably,
the English syntax for "nontaxable" and "payslip" have been addressed.
Additionally, the currency exchange rate is not rendered on the payslip
if the currency is the enterprise currency.  However, there is a bug with
the currency rendering on the payslip generator that does not allow the
currency to be properly rendered.  This will be addressed in a future
PR.
  • Loading branch information
jniles committed Jan 19, 2025
1 parent 8fcef6e commit edc1702
Show file tree
Hide file tree
Showing 7 changed files with 1,521 additions and 1,518 deletions.
2,376 changes: 1,188 additions & 1,188 deletions client/src/i18n/en/form.json

Large diffs are not rendered by default.

610 changes: 305 additions & 305 deletions client/src/i18n/en/table.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async function config(req, res, next) {
}
});

// Filtering non-taxable Rubrics
// Filtering nontaxable Rubrics
nonTaxables = rubrics.filter(item => item.is_social_care);

// Filtering taxable Rubrics
Expand All @@ -158,7 +158,7 @@ async function config(req, res, next) {
);
}

// Calcul value for non-taxable and automatically calculated Expected Seniority_bonus & Family_allowances
// Calcul value for nontaxable and automatically calculated Expected Seniority_bonus & Family_allowances
if (nonTaxables.length) {
nonTaxables.forEach(nonTaxable => {
if (!nonTaxable.is_seniority_bonus && !nonTaxable.is_family_allowances) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@
<div>
</div>
</section>
</body>
</body>
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@
</strong>
</td>
</tr>
{{!-- only show exhange rate if it is different from 1 --}}
{{#if ../shouldRenderExchangeRate }}
<tr>
<td class="col-xs-12 text-right" colspan="8">
<strong>
Expand All @@ -241,7 +243,8 @@
</strong>
</td>
</tr>
{{/if}}
</table>
</div>
{{/each}}
</body>
</body>
38 changes: 18 additions & 20 deletions server/controllers/payroll/reports/payslipGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ const DEFAULT_OPTS = {
async function build(req, res, next) {
const options = _.clone(req.query);
const paymentIndexSystem = req.session.enterprise.settings.enable_index_payment_system;
// eslint-disable-next-line no-unused-vars
const activatePensionFund = req.session.enterprise.settings.enable_activate_pension_fund;

const templatePayslip = paymentIndexSystem ? templatePayslipIndex : templatePayslipDefault;

Expand All @@ -47,6 +45,7 @@ async function build(req, res, next) {
let template;
_.extend(options, DEFAULT_OPTS);

// TODO(@jniles): what is "socialCharge" in this case?
if (!options.payslip && options.socialCharge) {
template = templateSocialCharge;
options.orientation = 'portrait';
Expand All @@ -58,13 +57,12 @@ async function build(req, res, next) {
template = templatePayslip;
}

const data = {};
let report;

data.enterprise = req.session.enterprise;
data.user = req.session.user;
data.lang = options.lang;
data.conversionRate = options.conversionRate;
const data = {
enterprise : req.session.enterprise,
user : req.session.user,
lang : options.lang,
conversionRate : options.conversionRate,
};

if (options.renderer === 'xls') {
data.optionsRenderer = options.renderer;
Expand All @@ -78,7 +76,7 @@ async function build(req, res, next) {

// set up the report with report manager
try {
report = new ReportManager(template, req.session, options);
const report = new ReportManager(template, req.session, options);

const payrollPeriodData = await PayrollConfig.lookupPayrollConfig(options.idPeriod);
data.payrollPeriod = payrollPeriodData;
Expand All @@ -88,7 +86,8 @@ async function build(req, res, next) {
options.currency,
new Date(data.payrollPeriod.dateTo),
);
// If the convertion rate is not defini, the rate of exchange

// If the convertion rate is not defined, the rate of exchange
// of the period of configuration will be taken into account
exchangeData.rate = data.conversionRate ? data.conversionRate : exchangeData.rate;
data.payrollPeriod.exchangeRate = parseInt(options.currency, 10) === data.enterprise.currency_id
Expand All @@ -98,9 +97,8 @@ async function build(req, res, next) {
new Date(data.payrollPeriod.dateTo),
);

data.exchangeRatesByCurrency = exchangeRatesByCurrencyData;

const dataEmployees = await configurationData.find(params);

// Set Aggregate of Rubrics
let totalNetSalary = 0;
let totalBasicSalary = 0;
Expand All @@ -109,7 +107,7 @@ async function build(req, res, next) {

dataEmployees.forEach(employee => {
const employeeCurrencyId = parseInt(employee.currency_id, 10);
data.exchangeRatesByCurrency.forEach(exchange => {
exchangeRatesByCurrencyData.forEach(exchange => {
const isSameCurrency = exchange.currency_id === employeeCurrencyId;

employee.net_salary_equiv = isSameCurrency
Expand All @@ -126,6 +124,7 @@ async function build(req, res, next) {
? employee.net_salary / exchange.rate : employee.net_salary;
employee.net_salary_equiv = isSameCurrency
? employee.net_salary / exchange.rate : employee.net_salary;

totalNetSalary += employee.net_salary_equiv;
totalBasicSalary += employee.basic_salary_equiv;
totalBaseTaxable += employee.base_taxable_equiv;
Expand All @@ -146,18 +145,16 @@ async function build(req, res, next) {
// Get payment_uuid for Selected Employee
const employeesPaymentUuid = dataEmployees.map(emp => db.bid(emp.payment_uuid));
const [
rubrics,
holidays,
offDays,
rubEmployees, rubEnterprises, rubricsIndexes] = await PayrollConfig.payrollReportElements(
rubrics, holidays, offDays, rubEmployees, rubEnterprises, rubricsIndexes,
] = await PayrollConfig.payrollReportElements(
options.idPeriod,
options.employees,
employeesPaymentUuid,
);

let TotalChargeEnterprise = 0;
rubrics.forEach(item => {
data.exchangeRatesByCurrency.forEach(exchange => {
exchangeRatesByCurrencyData.forEach(exchange => {
item.result_equiv = exchange.currency_id === item.currency_id ? item.result / exchange.rate : item.result;
});
});
Expand Down Expand Up @@ -247,7 +244,7 @@ async function build(req, res, next) {
employee.somRubNonTaxable = somRubNonTaxable;
employee.somChargeEnterprise = somChargeEnterprise;
employee.somChargeEmployee = somChargeEmployee;
data.exchangeRatesByCurrency.forEach(exchange => {
exchangeRatesByCurrencyData.forEach(exchange => {
const isSameCurrency = exchange.currency_id === employeeCurrencyId;

employee.somRubTaxable_equiv = isSameCurrency
Expand Down Expand Up @@ -284,6 +281,7 @@ async function build(req, res, next) {

// Total Of Enterprise Charge
data.TotalChargeEnterprise = TotalChargeEnterprise;
data.shouldRenderExchangeRate = data.payrollPeriod.exchangeRate !== 1;

const result = await report.render(data);
res.set(result.headers).send(result.report);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@
</strong>
</td>
</tr>
{{#if ../shouldRenderExchangeRate }}
<tr>
<td class="col-xs-12 text-right" colspan="8">
<strong>
Expand All @@ -283,6 +284,7 @@
</strong>
</td>
</tr>
{{/if}}
</table>
<h4>
<u>{{translate 'FORM.LABELS.SIGNATURE'}}s</u>
Expand All @@ -303,4 +305,4 @@

</div>
{{/each}}
</body>
</body>

0 comments on commit edc1702

Please sign in to comment.