Skip to content

Commit

Permalink
fix: use company.name instead of app.company_name (#3449)
Browse files Browse the repository at this point in the history
  • Loading branch information
rikuke authored Oct 23, 2024
1 parent 09ff6c0 commit 2b697b3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions backend/benefit/applications/services/ahjo_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ def prepare_case_title(application: Application, company_name: str) -> str:
def prepare_final_case_title(application: Application, limit: int = 150) -> str:
"""Prepare the final case title for Ahjo, if the full title is over 150 characters, \
truncate the company name to fit the limit."""
full_case_title = prepare_case_title(application, application.company_name)
full_case_title = prepare_case_title(application, application.company.name)
length_of_full_title = len(full_case_title)

if length_of_full_title <= limit:
return full_case_title
else:
over_limit = length_of_full_title - limit
truncated_company_name = truncate_string_to_limit(
application.company_name, len(application.company_name) - over_limit
application.company.name, len(application.company.name) - over_limit
)
return prepare_case_title(application, truncated_company_name)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
%}
<tr>
<td>{{ app.ahjo_application_number }}</td>
<td>{{ app.company_name }}</td>
<td>{{ app.company.name }}</td>
<td>{{ app.company.business_id }}</td>
{% if show_employee_names %}
<td>{{ app.employee.first_name }} {{ app.employee.last_name }}</td>
Expand Down Expand Up @@ -58,7 +58,7 @@
{% else %} {% for ahjo_row in app.ahjo_rows %}
<tr>
<td>{{ app.ahjo_application_number }}</td>
<td>{{ app.company_name }}</td>
<td>{{ app.company.name }}</td>
<td>{{ app.company.business_id }}</td>
{% if show_employee_names %}
<td>{{ app.employee.first_name }} {{ app.employee.last_name }}</td>
Expand Down
7 changes: 4 additions & 3 deletions backend/benefit/applications/tests/test_ahjo_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
def test_prepare_case_title(decided_application):
application = decided_application
wanted_title = f"Avustukset työnantajille, työllisyyspalvelut, \
Helsinki-lisä, {application.company_name}, \
Helsinki-lisä, {application.company.name}, \
hakemus {application.application_number}"
got = prepare_case_title(application, decided_application.company_name)
got = prepare_case_title(application, decided_application.company.name)
assert wanted_title == got


Expand Down Expand Up @@ -68,7 +68,8 @@ def test_prepare_final_case_title_truncate(
decided_application, company_name, limit, expected_length
):
application = decided_application
application.company_name = company_name
application.company.name = company_name
application.company.save()
assert len(prepare_final_case_title(application, limit)) <= expected_length


Expand Down

0 comments on commit 2b697b3

Please sign in to comment.