Skip to content

Commit

Permalink
Merge pull request #621 from fecgov/patch/sprint-34
Browse files Browse the repository at this point in the history
Patch/sprint-34 Refactor summary handling of SA11aI and SA11aII
  • Loading branch information
mjtravers authored Nov 30, 2023
2 parents 3342a43 + 3d00a96 commit 1a41c7c
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions django-backend/fecfiler/web_services/summary/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def calculate_summary(self):
def calculate_summary_column_a(self):
report_transactions = Transaction.objects.filter(report=self.report)
summary = report_transactions.aggregate(
line_11ai=self.get_line("SA11AI", itemized=True),
line_11aii=self.get_line("SA11AI", itemized=False),
line_11ai=self.get_line("SA11AI"),
line_11aii=self.get_line("SA11AII"),
line_11b=self.get_line("SA11B"),
line_11c=self.get_line("SA11C"),
line_12=self.get_line("SA12"),
Expand Down Expand Up @@ -174,8 +174,8 @@ def calculate_summary_column_b(self):

# build summary
summary = ytd_transactions.aggregate(
line_11ai=self.get_line("SA11AI", itemized=True),
line_11aii=self.get_line("SA11AI", itemized=False),
line_11ai=self.get_line("SA11AI"),
line_11aii=self.get_line("SA11AII"),
line_11b=self.get_line("SA11B"),
line_11c=self.get_line("SA11C"),
line_12=self.get_line("SA12"),
Expand Down Expand Up @@ -297,10 +297,6 @@ def calculate_summary_column_b(self):

return summary

def get_line(self, form_type, field="amount", itemized=None):
query = (
Q(~Q(memo_code=True), itemized=itemized, _form_type=form_type)
if itemized is not None
else Q(~Q(memo_code=True), _form_type=form_type)
)
def get_line(self, form_type, field="amount"):
query = Q(~Q(memo_code=True), form_type=form_type)
return Coalesce(Sum(field, filter=query), Decimal(0.0))

0 comments on commit 1a41c7c

Please sign in to comment.