Skip to content

Commit

Permalink
UHF-7029: UHF-7486: Update labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkkimaagi committed Feb 17, 2023
1 parent 2c62ef1 commit 0be54eb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
13 changes: 9 additions & 4 deletions src/js/calculator/daycare_payment/_translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,18 @@ const translations = {
sv: null,
en: null,
},
receipt_family_estimated_payment_explanation: {
fi: 'Tämä arvio on suuntaa antava. Tarkka asiakasmaksu lasketaan tuloselvityksen perusteella vuosittain. Jos et ilmoita tuloja, lasketaan maksu korkeimman varhaiskasvatusmaksun mukaan.',
receipt_family_estimated_payment_explanation_min: {
fi: 'Alle ${minimum_payment_euro} euron maksuja ei laskuteta. ',
sv: null,
en: null,
},
receipt_family_estimated_payment_explanation_min: {
fi: 'Alle ${minimum_payment_euro} euron maksuja ei laskuteta. ',
receipt_family_empty_income: {
fi: 'Arvio on laskettu korkeimman maksun mukaisesti, koska et täyttänyt laskuriin perheen kuukausituloja. ',
sv: null,
en: null,
},
receipt_family_estimated_payment_explanation: {
fi: 'Tämä arvio on suuntaa antava. Tarkan asiakasmaksun saat asiakasmaksupäätöksessä vuosittain.',
sv: null,
en: null,
},
Expand Down
16 changes: 12 additions & 4 deletions src/js/calculator/daycare_payment/daycare_payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,11 @@ class DaycarePayment {
// Get limits for this household size
const limits = getIncomeLimits(householdSize, tempSettings);
let paymentForYoungest = null;
let totalExplanation = '';

// If gross income per month is below payment limit, no payment.
if (!grossIncomePerMonthRaw && grossIncomePerMonthRaw !== 0) {
totalExplanation = this.t('receipt_family_empty_income');
paymentForYoungest = Number(tempSettings.child_1_max_euro);
} else if (grossIncomePerMonth < limits.min) {
paymentForYoungest = 0;
Expand All @@ -728,9 +730,6 @@ class DaycarePayment {
const subtotals = [];
const additionalDetails = [];

// Check if payment sum is below minimum_payment_euro, set it to 0
let totalExplanation = '';

// Calculate discounted payments for all children
for (let i = 0; i < children.length; i++) {
// Handle sibling discount if any
Expand All @@ -747,9 +746,10 @@ class DaycarePayment {
}
children[i].paymentRounded = Math.round(children[i].payment);

let paymentWasRoundedDown = false;
if (children[i].paymentRounded < tempSettings.minimum_payment_euro) {
children[i].paymentRounded = 0;
totalExplanation = this.t('receipt_family_estimated_payment_explanation_min', { minimum_payment_euro: tempSettings.minimum_payment_euro });
paymentWasRoundedDown = true;
}

const {daycareType} = children[i];
Expand All @@ -766,6 +766,9 @@ class DaycarePayment {
if (freeDays && Number(freeDays) > 0) {
subtotal.details.push(`${this.t('daycare_free_days')}: ${freeDays}`);
}
if (paymentWasRoundedDown) {
subtotal.details.push(this.t('receipt_family_estimated_payment_explanation_min', { minimum_payment_euro: tempSettings.minimum_payment_euro }));
}
subtotals.push(subtotal);

if (daycareType === '2' || daycareType === '3') {
Expand All @@ -779,6 +782,11 @@ class DaycarePayment {
sum += children[i].paymentRounded;
}

// If total sum is below minimum payment limit, round it to 0 and tell user about it.
if (sum < tempSettings.minimum_payment_euro) {
sum = 0;
totalExplanation = this.t('receipt_family_estimated_payment_explanation_min', { minimum_payment_euro: tempSettings.minimum_payment_euro }) + totalExplanation;
}
totalExplanation += this.t('receipt_family_estimated_payment_explanation');

const receiptData = {
Expand Down
2 changes: 1 addition & 1 deletion src/js/calculator/example-calc.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
'#daycare_type_2_2_group_caretime_1_helfi_calc_1025838706': true,
'#daycare_type_2_2_free_days_helfi_calc_1025838706': 10,
'input.hds-button--primary': true
})">family size 3, 5928, 2 full time kids = 140</button>
})">family size 3, 5928, 2 full time kids, second with 10 holidays = 100</button>

<div class="component component--helfi-calculator">
<div class="component__container">
Expand Down

0 comments on commit 0be54eb

Please sign in to comment.