diff --git a/backend/benefit/applications/admin.py b/backend/benefit/applications/admin.py index 7d74362a1b..9f0274cbb2 100644 --- a/backend/benefit/applications/admin.py +++ b/backend/benefit/applications/admin.py @@ -45,10 +45,11 @@ class ApplicationAdmin(admin.ModelAdmin): AttachmentInline, CalculationInline, ) - list_filter = ("status", "company") + list_filter = ("status", "application_origin", "company") list_display = ( "id", "status", + "application_origin", "application_number", "company_name", "company_contact_person_email", diff --git a/backend/benefit/applications/management/commands/seed.py b/backend/benefit/applications/management/commands/seed.py index 63422a76c3..6542e0f2a0 100755 --- a/backend/benefit/applications/management/commands/seed.py +++ b/backend/benefit/applications/management/commands/seed.py @@ -6,7 +6,11 @@ from django.core.management.base import BaseCommand from django.utils import timezone -from applications.enums import ApplicationBatchStatus, ApplicationStatus +from applications.enums import ( + ApplicationBatchStatus, + ApplicationOrigin, + ApplicationStatus, +) from applications.models import Application, ApplicationBasis, ApplicationBatch from applications.tests.factories import ( AdditionalInformationNeededApplicationFactory, @@ -29,13 +33,13 @@ def add_arguments(self, parser): parser.add_argument( "--number", type=int, - default=10, + default=5, help="Number of applications to create", ) def handle(self, *args, **options): batch_count = 6 - total_created = (len(ApplicationStatus.values) + batch_count) * options[ + total_created = ((len(ApplicationStatus.values) * 2) + batch_count) * options[ "number" ] if not settings.DEBUG: @@ -104,12 +108,13 @@ def _create_batch( for factory in factories: for _ in range(number): - random_datetime = f.past_datetime(tzinfo=pytz.UTC) - application = factory() - application.created_at = random_datetime - application.save() + for application_origin in ApplicationOrigin.values: + random_datetime = f.past_datetime(tzinfo=pytz.UTC) + application = factory(application_origin=application_origin) + application.created_at = random_datetime + application.save() - application.log_entries.all().update(created_at=random_datetime) + application.log_entries.all().update(created_at=random_datetime) _create_batch(ApplicationBatchStatus.DRAFT, ApplicationStatus.ACCEPTED) _create_batch(ApplicationBatchStatus.DRAFT, ApplicationStatus.REJECTED) diff --git a/backend/benefit/applications/tests/test_application_tasks.py b/backend/benefit/applications/tests/test_application_tasks.py index 6f800d7ae7..7b34688a6f 100755 --- a/backend/benefit/applications/tests/test_application_tasks.py +++ b/backend/benefit/applications/tests/test_application_tasks.py @@ -16,7 +16,7 @@ def test_seed_applications_with_arguments(set_debug_to_true): amount = 5 statuses = ApplicationStatus.values batch_count = 6 - total_created = (len(ApplicationStatus.values) + batch_count) * amount + total_created = ((len(ApplicationStatus.values) * 2) + batch_count) * amount out = StringIO() call_command("seed", number=amount, stdout=out) diff --git a/backend/benefit/terms/fixtures/default_terms.json b/backend/benefit/terms/fixtures/default_terms.json index d14162d9d2..b9a89db98a 100644 --- a/backend/benefit/terms/fixtures/default_terms.json +++ b/backend/benefit/terms/fixtures/default_terms.json @@ -88,5 +88,70 @@ "created_at": "2021-01-01T00:00:00+02:00", "modified_at": "2021-01-01T00:00:00+02:00" } + }, + { + "model": "terms.terms", + "pk": "c89bac1e-aa94-4d96-b622-9a86b396b687", + "fields": { + "terms_type": "handler_terms", + "effective_from": "2021-01-01", + "terms_pdf_fi": "/var/media/please_upload_actual_pdf_manually.pdf", + "terms_pdf_sv": "/var/media/please_upload_actual_pdf_manually.pdf", + "terms_pdf_en": "/var/media/please_upload_actual_pdf_manually.pdf", + "created_at": "2021-01-01T00:00:00+02:00", + "modified_at": "2021-01-01T00:00:00+02:00" + } + }, + { + "model": "terms.applicantconsent", + "pk": "50365185-3cd7-4fd4-b11a-1ce43e66b601", + "fields": { + "terms": "c89bac1e-aa94-4d96-b622-9a86b396b687", + "text_fi": "Hakija on hyväksynyt ehdot", + "text_sv": "translation TBD", + "text_en": "translation TBD", + "ordering": 0, + "created_at": "2021-01-01T00:00:00+02:00", + "modified_at": "2021-01-01T00:00:00+02:00" + } + }, + { + "model": "terms.applicantconsent", + "pk": "66fd80cc-e362-4251-9252-90998e07bb76", + "fields": { + "terms": "c89bac1e-aa94-4d96-b622-9a86b396b687", + "text_fi": "Hakija vakuuttaa, että hänen ilmoittamansa pankkitili on organisaation virallinen tili, hänellä on oikeus asioida organisaation puolesta ja organisaatiolla ei ole verovelkoja.", + "text_sv": "translation TBD", + "text_en": "translation TBD", + "ordering": 1, + "created_at": "2021-01-01T00:00:00+02:00", + "modified_at": "2021-01-01T00:00:00+02:00" + } + }, + { + "model": "terms.applicantconsent", + "pk": "7832d5e1-7f85-4d8d-9a66-4df18b626925", + "fields": { + "terms": "c89bac1e-aa94-4d96-b622-9a86b396b687", + "text_fi": "Työnantaja on allekirjoittanut hakemuksen", + "text_sv": "translation TBD", + "text_en": "translation TBD", + "ordering": 2, + "created_at": "2021-01-01T00:00:00+02:00", + "modified_at": "2021-01-01T00:00:00+02:00" + } + }, + { + "model": "terms.applicantconsent", + "pk": "f6fed789-78d8-43bb-a798-652fa0af9287", + "fields": { + "terms": "c89bac1e-aa94-4d96-b622-9a86b396b687", + "text_fi": "Työllistettävä on allekirjoittanut hakemuksen", + "text_sv": "translation TBD", + "text_en": "translation TBD", + "ordering": 3, + "created_at": "2021-01-01T00:00:00+02:00", + "modified_at": "2021-01-01T00:00:00+02:00" + } } ] diff --git a/frontend/benefit/handler/public/locales/en/common.json b/frontend/benefit/handler/public/locales/en/common.json index 7641be440a..b47a8cec5b 100644 --- a/frontend/benefit/handler/public/locales/en/common.json +++ b/frontend/benefit/handler/public/locales/en/common.json @@ -112,6 +112,10 @@ }, "backend": { "Request failed with status code 500": "Virhe taustajärjestelmässä. Kokeile myöhemmin uudestaan." + }, + "terms": { + "label": "Ehdot hyväksymättä", + "text": "Sinun tulee hyväksyä ehdot jatkaaksesi. Palaa takaisin ja hyväksy ehdot." } }, "applications": { diff --git a/frontend/benefit/handler/public/locales/fi/common.json b/frontend/benefit/handler/public/locales/fi/common.json index 331ab517b8..bd6c33c15d 100644 --- a/frontend/benefit/handler/public/locales/fi/common.json +++ b/frontend/benefit/handler/public/locales/fi/common.json @@ -112,6 +112,10 @@ }, "backend": { "Request failed with status code 500": "Virhe taustajärjestelmässä. Kokeile myöhemmin uudestaan." + }, + "terms": { + "label": "Ehdot hyväksymättä", + "text": "Sinun tulee hyväksyä ehdot jatkaaksesi. Palaa takaisin ja hyväksy ehdot." } }, "applications": { diff --git a/frontend/benefit/handler/public/locales/sv/common.json b/frontend/benefit/handler/public/locales/sv/common.json index df42f705fa..e9b9b86d4c 100644 --- a/frontend/benefit/handler/public/locales/sv/common.json +++ b/frontend/benefit/handler/public/locales/sv/common.json @@ -112,6 +112,10 @@ }, "backend": { "Request failed with status code 500": "Virhe taustajärjestelmässä. Kokeile myöhemmin uudestaan." + }, + "terms": { + "label": "Ehdot hyväksymättä", + "text": "Sinun tulee hyväksyä ehdot jatkaaksesi. Palaa takaisin ja hyväksy ehdot." } }, "applications": { diff --git a/frontend/benefit/handler/src/components/newApplication/useApplicationForm.ts b/frontend/benefit/handler/src/components/newApplication/useApplicationForm.ts index 43c8b9cbae..b0d1809c96 100644 --- a/frontend/benefit/handler/src/components/newApplication/useApplicationForm.ts +++ b/frontend/benefit/handler/src/components/newApplication/useApplicationForm.ts @@ -136,7 +136,7 @@ export const useApplicationForm = (): ExtendedComponentProps => { validateOnChange: true, validateOnBlur: true, enableReinitialize: true, - onSubmit: (values) => onNext(values, id, dispatchStep, activeStep), + onSubmit: (values) => onNext(values, dispatchStep, activeStep, id), }); const { values, setFieldValue } = formik; diff --git a/frontend/benefit/handler/src/hooks/useFormActions.tsx b/frontend/benefit/handler/src/hooks/useFormActions.tsx index ac2cbdf467..87d11bd25d 100644 --- a/frontend/benefit/handler/src/hooks/useFormActions.tsx +++ b/frontend/benefit/handler/src/hooks/useFormActions.tsx @@ -21,9 +21,9 @@ import useUpdateApplicationQuery from './useUpdateApplicationQuery'; interface FormActions { onNext: ( values: Application, - applicationId: string | undefined, dispatchStep: React.Dispatch, - activeStep: number + activeStep: number, + applicationId: string | undefined ) => Promise; onSubmit: ( values: Application, @@ -97,6 +97,9 @@ const useFormActions = (application: Partial): FormActions => { ) )[0]; } + if (key === 'approveTerms') { + return

{t('common:error.terms.text')}

; + } return ( {value} @@ -226,9 +229,9 @@ const useFormActions = (application: Partial): FormActions => { const onNext = async ( currentValues: Application, - applicationId: string | undefined, dispatchStep: React.Dispatch, - activeStep: number + activeStep: number, + applicationId: string | undefined ): Promise => { const data = getData(getModifiedValues(currentValues));