Added the period parser to the base report view and the template variables
This commit is contained in:
parent
097e699ccf
commit
db860619f1
@ -70,10 +70,12 @@ class BaseReportView(generic.ListView):
|
|||||||
Attributes:
|
Attributes:
|
||||||
page_no (int): The specified page number
|
page_no (int): The specified page number
|
||||||
page_size (int): The specified page size
|
page_size (int): The specified page size
|
||||||
|
period_parser (PeriodParser): The period parser
|
||||||
"""
|
"""
|
||||||
page_no = None
|
page_no = None
|
||||||
page_size = None
|
page_size = None
|
||||||
pagination = None
|
pagination = None
|
||||||
|
period_parser = None
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
"""Adds object_list to the context.
|
"""Adds object_list to the context.
|
||||||
@ -123,6 +125,7 @@ class BaseReportView(generic.ListView):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
data = super(BaseReportView, self).get_context_data(**kwargs)
|
data = super(BaseReportView, self).get_context_data(**kwargs)
|
||||||
|
data["period_parser"] = self.period_parser
|
||||||
data["pagination_links"] = self.pagination.links
|
data["pagination_links"] = self.pagination.links
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@ -139,7 +142,7 @@ class CashReportView(BaseReportView):
|
|||||||
Returns:
|
Returns:
|
||||||
List[Record]: The accounting records for the cash report
|
List[Record]: The accounting records for the cash report
|
||||||
"""
|
"""
|
||||||
period = PeriodParser(self.kwargs["period_spec"])
|
self.period_parser = PeriodParser(self.kwargs["period_spec"])
|
||||||
if self.kwargs["subject_code"] == "0":
|
if self.kwargs["subject_code"] == "0":
|
||||||
records = Record.objects.raw(
|
records = Record.objects.raw(
|
||||||
"""SELECT r.*
|
"""SELECT r.*
|
||||||
@ -171,7 +174,7 @@ ORDER BY
|
|||||||
t.ord,
|
t.ord,
|
||||||
CASE WHEN is_credit THEN 1 ELSE 2 END,
|
CASE WHEN is_credit THEN 1 ELSE 2 END,
|
||||||
r.ord""",
|
r.ord""",
|
||||||
[period.start, period.end])
|
[self.period_parser.start, self.period_parser.end])
|
||||||
else:
|
else:
|
||||||
records = Record.objects.raw(
|
records = Record.objects.raw(
|
||||||
"""SELECT r.*
|
"""SELECT r.*
|
||||||
@ -197,8 +200,8 @@ ORDER BY
|
|||||||
t.ord,
|
t.ord,
|
||||||
CASE WHEN is_credit THEN 1 ELSE 2 END,
|
CASE WHEN is_credit THEN 1 ELSE 2 END,
|
||||||
r.ord""",
|
r.ord""",
|
||||||
[period.start,
|
[self.period_parser.start,
|
||||||
period.end,
|
self.period_parser.end,
|
||||||
self.kwargs["subject_code"] + "%",
|
self.kwargs["subject_code"] + "%",
|
||||||
self.kwargs["subject_code"] + "%"])
|
self.kwargs["subject_code"] + "%"])
|
||||||
self.pagination = Pagination(
|
self.pagination = Pagination(
|
||||||
|
Loading…
Reference in New Issue
Block a user