diff --git a/backend/benefit/applications/migrations/0036_alter_employee_working_hours.py b/backend/benefit/applications/migrations/0036_alter_employee_working_hours.py new file mode 100644 index 0000000000..4d16ce4848 --- /dev/null +++ b/backend/benefit/applications/migrations/0036_alter_employee_working_hours.py @@ -0,0 +1,21 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("applications", "0035_alter_applicationbatch_handler"), + ] + + operations = [ + migrations.AlterField( + model_name="employee", + name="working_hours", + field=models.DecimalField( + blank=True, + decimal_places=2, + max_digits=5, + null=True, + verbose_name="working hour", + ), + ), + ] diff --git a/backend/benefit/applications/models.py b/backend/benefit/applications/models.py index 6aa2f676c2..0430168a06 100755 --- a/backend/benefit/applications/models.py +++ b/backend/benefit/applications/models.py @@ -753,8 +753,8 @@ class Employee(UUIDModel, TimeStampedModel): ) working_hours = models.DecimalField( verbose_name=_("working hour"), - decimal_places=1, - max_digits=4, + decimal_places=2, + max_digits=5, blank=True, null=True, ) diff --git a/frontend/benefit/handler/public/locales/en/common.json b/frontend/benefit/handler/public/locales/en/common.json index 186caa8eba..4fbbd11f9f 100644 --- a/frontend/benefit/handler/public/locales/en/common.json +++ b/frontend/benefit/handler/public/locales/en/common.json @@ -827,7 +827,8 @@ "number": { "invalid": "Virheellinen arvo, ilmoita vain numeroita", "max": "Arvon tulee olla enintään {{max}}", - "min": "Arvon tulee olla vähintään {{min}}" + "min": "Arvon tulee olla vähintään {{min}}", + "twoDecimals": "Arvon tulee sisältää enintään kaksi desimaalia" }, "string": { "max": "Tämä kenttä voi olla korkeintaan {{max}} merkkiä pitkä", diff --git a/frontend/benefit/handler/public/locales/fi/common.json b/frontend/benefit/handler/public/locales/fi/common.json index 0f62664773..7671de54d6 100644 --- a/frontend/benefit/handler/public/locales/fi/common.json +++ b/frontend/benefit/handler/public/locales/fi/common.json @@ -827,7 +827,8 @@ "number": { "invalid": "Virheellinen arvo, ilmoita vain numeroita", "max": "Arvon tulee olla enintään {{max}}", - "min": "Arvon tulee olla vähintään {{min}}" + "min": "Arvon tulee olla vähintään {{min}}", + "twoDecimals": "Arvon tulee sisältää enintään kaksi desimaalia" }, "string": { "max": "Tämä kenttä voi olla korkeintaan {{max}} merkkiä pitkä", diff --git a/frontend/benefit/handler/public/locales/sv/common.json b/frontend/benefit/handler/public/locales/sv/common.json index 2368a7cfd1..b5e351409c 100644 --- a/frontend/benefit/handler/public/locales/sv/common.json +++ b/frontend/benefit/handler/public/locales/sv/common.json @@ -833,7 +833,8 @@ "number": { "invalid": "Virheellinen arvo, ilmoita vain numeroita", "max": "Arvon tulee olla enintään {{max}}", - "min": "Arvon tulee olla vähintään {{min}}" + "min": "Arvon tulee olla vähintään {{min}}", + "twoDecimals": "Arvon tulee sisältää enintään kaksi desimaalia" }, "string": { "max": "Tämä kenttä voi olla korkeintaan {{max}} merkkiä pitkä", diff --git a/frontend/benefit/handler/src/components/newApplication/utils/validation.ts b/frontend/benefit/handler/src/components/newApplication/utils/validation.ts index 829cfc6ab3..afff0b3cca 100644 --- a/frontend/benefit/handler/src/components/newApplication/utils/validation.ts +++ b/frontend/benefit/handler/src/components/newApplication/utils/validation.ts @@ -297,6 +297,12 @@ export const getValidationSchema = ( .nullable() .required(t(VALIDATION_MESSAGE_KEYS.REQUIRED)), [EMPLOYEE_KEYS.WORKING_HOURS]: Yup.number() + .test( + 'is-decimal', + t(VALIDATION_MESSAGE_KEYS.NUMBER_TWO_DECIMALS), + (value: number): boolean => + value ? /^\d+.?\d{1,2}$/.test(String(value)) : false + ) .transform((_value, originalValue) => Number(getNumberValue(originalValue)) ) diff --git a/frontend/benefit/shared/src/constants.ts b/frontend/benefit/shared/src/constants.ts index 9bd6c70c2b..5f418bb468 100644 --- a/frontend/benefit/shared/src/constants.ts +++ b/frontend/benefit/shared/src/constants.ts @@ -17,6 +17,7 @@ export enum VALIDATION_MESSAGE_KEYS { NUMBER_INVALID = 'common:form.validation.number.invalid', NUMBER_MIN = 'common:form.validation.number.min', NUMBER_MAX = 'common:form.validation.number.max', + NUMBER_TWO_DECIMALS = 'common:form.validation.number.twoDecimals', PHONE_INVALID = 'common:form.validation.phone.invalid', STRING_POSITIVENUMBER = 'common:form.validation.string.positiveNumber', STRING_MIN = 'common:form.validation.string.min',