Skip to content

Commit

Permalink
Merge pull request #907 from fecgov/feature/1977-2
Browse files Browse the repository at this point in the history
feature/1977 - Update transactions to include report_code_label so it can be used by transaction history on the contacts page
  • Loading branch information
mjtravers authored Jun 10, 2024
2 parents fb8c9a4 + 4e4051f commit ac8988b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions django-backend/fecfiler/reports/report_code_label.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db.models import Case, When, Value
from fecfiler.reports.models import Report

report_code_label_mapping = {
"Q1": "APRIL 15 QUARTERLY REPORT (Q1)",
Expand Down Expand Up @@ -36,3 +37,11 @@
When(form_99__isnull=False, then=Value("")),
When(form_1m__isnull=False, then=Value("")),
)


def get_report_code_label(report: Report):
if report.form_3x:
return report_code_label_mapping[report.report_code]
if report.form_24:
return f"{report.form_24.report_type_24_48} HOUR"
return ""
3 changes: 3 additions & 0 deletions django-backend/fecfiler/transactions/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
from fecfiler.transactions.schedule_c2.utils import add_schedule_c2_contact_fields
from fecfiler.transactions.schedule_d.utils import add_schedule_d_contact_fields
from fecfiler.transactions.schedule_e.utils import add_schedule_e_contact_fields

from fecfiler.reports.report_code_label import get_report_code_label
import structlog

logger = structlog.get_logger(__name__)
Expand Down Expand Up @@ -266,6 +268,7 @@ def to_representation(self, instance):
"coverage_through_date": report.coverage_through_date,
"report_code": report.report_code,
"report_type": report.report_type,
"report_code_label": get_report_code_label(report),
}
)

Expand Down

0 comments on commit ac8988b

Please sign in to comment.