Skip to content

Commit

Permalink
fix: total amount as int (#2975)
Browse files Browse the repository at this point in the history
  • Loading branch information
rikuke authored May 8, 2024
1 parent c74c659 commit d3a346d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion backend/benefit/applications/services/ahjo_xml_builder.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import copy
from dataclasses import dataclass
from datetime import date
from typing import List, Tuple
Expand Down Expand Up @@ -75,12 +76,15 @@ def _get_period_rows_for_xml(
row_type=RowType.HELSINKI_BENEFIT_TOTAL_EUR
).first()

total_amount_row_with_int = copy.copy(total_amount_row)
total_amount_row_with_int.amount = int(total_amount_row_with_int.amount)

row_types_to_list = [
RowType.HELSINKI_BENEFIT_MONTHLY_EUR,
RowType.HELSINKI_BENEFIT_SUB_TOTAL_EUR,
]
calculation_rows = calculation.rows.filter(row_type__in=row_types_to_list)
return total_amount_row, calculation_rows
return total_amount_row_with_int, calculation_rows

def _prepare_multiple_period_rows(
self,
Expand Down
10 changes: 9 additions & 1 deletion backend/benefit/applications/tests/test_ahjo_xml_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,16 @@ def test_get_context_for_secret_xml_with_single_period(
assert context["language"] == decided_application.applicant_language
assert isinstance(context["total_amount_row"], CalculationRow)
assert context["total_amount_row"] == total_eur_row
assert context["total_amount_row"].amount == int(total_eur_row.amount)


def test_get_context_for_secret_xml_with_multiple_periods(
calculation, decided_application, monthly_row_1, sub_total_row_1, secret_xml_builder
calculation,
decided_application,
monthly_row_1,
sub_total_row_1,
secret_xml_builder,
total_eur_row,
):
monthly_row_2 = CalculationRowFactory(
calculation=calculation,
Expand Down Expand Up @@ -254,3 +260,5 @@ def test_get_context_for_secret_xml_with_multiple_periods(
monthly_row_2.amount
)
assert context["calculation_periods"][1].total_amount == int(sub_total_row_2.amount)
assert context["total_amount_row"] == total_eur_row
assert context["total_amount_row"].amount == int(total_eur_row.amount)

0 comments on commit d3a346d

Please sign in to comment.