Changed the unmatched offsets from a module to a report, and to show both the unapplied original line items and the unmatched offsets instead of only the unmatched offsets, and added the accumulated balance, in order for ease of use. Removed the match information from the unapplied original line item report. Added the currency and period filters to both the unapplied original line item report and unmatched offset reports.

This commit is contained in:
2023-04-18 01:12:04 +08:00
parent f8895e3bff
commit e2f854b5cc
26 changed files with 1436 additions and 619 deletions

View File

@ -23,7 +23,8 @@ from decimal import Decimal
from flask import render_template, Response
from accounting.locale import gettext
from accounting.models import Account
from accounting.models import Currency, Account
from accounting.report.period import Period, PeriodChooser
from accounting.report.utils.base_page_params import BasePageParams
from accounting.report.utils.base_report import BaseReport
from accounting.report.utils.csv_export import BaseCSVRow, csv_download
@ -60,13 +61,24 @@ class CSVRow(BaseCSVRow):
class PageParams(BasePageParams):
"""The HTML page parameters."""
def __init__(self, accounts: list[Account]):
def __init__(self, currency: Currency,
period: Period,
accounts: list[Account]):
"""Constructs the HTML page parameters.
:param currency: The currency.
:param period: The period.
:param accounts: The accounts.
"""
self.currency: Currency = currency
"""The currency."""
self.period: Period = period
"""The period."""
self.accounts: list[Account] = accounts
"""The accounts."""
self.period_chooser: PeriodChooser = PeriodChooser(
lambda x: unapplied_url(currency, None, x))
"""The period chooser."""
@property
def has_data(self) -> bool:
@ -82,7 +94,18 @@ class PageParams(BasePageParams):
:return: The report chooser.
"""
return ReportChooser(ReportType.UNAPPLIED)
return ReportChooser(ReportType.UNAPPLIED, currency=self.currency,
account=None, period=self.period)
@property
def currency_options(self) -> list[OptionLink]:
"""Returns the currency options.
:return: The currency options.
"""
return self._get_currency_options(
lambda x: unapplied_url(x, None, self.period),
self.currency)
@property
def account_options(self) -> list[OptionLink]:
@ -90,13 +113,15 @@ class PageParams(BasePageParams):
:return: The account options.
"""
options: list[OptionLink] = [OptionLink(gettext("Accounts"),
unapplied_url(None),
True)]
options.extend([OptionLink(str(x),
unapplied_url(x),
False)
for x in self.accounts])
options: list[OptionLink] \
= [OptionLink(gettext("Accounts"),
unapplied_url(self.currency, None, self.period),
True)]
options.extend(
[OptionLink(str(x),
unapplied_url(self.currency, x, self.period),
False)
for x in self.accounts])
return options
@ -115,9 +140,18 @@ def get_csv_rows(accounts: list[Account]) -> list[CSVRow]:
class AccountsWithUnappliedOriginalLineItems(BaseReport):
"""The accounts with unapplied original line items."""
def __init__(self):
"""Constructs the outstanding balances."""
self.__accounts: list[Account] = get_accounts_with_unapplied()
def __init__(self, currency: Currency, period: Period):
"""Constructs the outstanding balances.
:param currency: The currency.
:param period: The period.
"""
self.__currency: Currency = currency
"""The currency."""
self.__period: Period = period
"""The period."""
self.__accounts: list[Account] \
= get_accounts_with_unapplied(currency, period)
"""The accounts."""
def csv(self) -> Response:
@ -134,4 +168,6 @@ class AccountsWithUnappliedOriginalLineItems(BaseReport):
:return: The report as HTML.
"""
return render_template("accounting/report/unapplied-accounts.html",
report=PageParams(accounts=self.__accounts))
report=PageParams(currency=self.__currency,
period=self.__period,
accounts=self.__accounts))