Renamed the "accounting.report.reports.utils.get_url" module to "accounting.report.reports.utils.urls", and shortened the names of the utilities, for readability.
This commit is contained in:
parent
140d3c6010
commit
df53f06094
@ -30,12 +30,11 @@ from accounting.report.period import Period
|
||||
from .utils.base_page_params import BasePageParams
|
||||
from .utils.base_report import BaseReport
|
||||
from .utils.csv_export import BaseCSVRow, csv_download, period_spec
|
||||
from .utils.get_url import get_ledger_url, get_balance_sheet_url, \
|
||||
get_income_statement_url
|
||||
from .utils.option_link import OptionLink
|
||||
from .utils.period_choosers import BalanceSheetPeriodChooser
|
||||
from .utils.report_chooser import ReportChooser
|
||||
from .utils.report_type import ReportType
|
||||
from .utils.urls import ledger_url, balance_sheet_url, income_statement_url
|
||||
|
||||
|
||||
class ReportAccount:
|
||||
@ -149,7 +148,7 @@ class AccountCollector:
|
||||
self.accounts: list[ReportAccount] \
|
||||
= [ReportAccount(account=account_by_id[x.id],
|
||||
amount=x.balance,
|
||||
url=get_ledger_url(self.__currency,
|
||||
url=ledger_url(self.__currency,
|
||||
account_by_id[x.id],
|
||||
self.__period))
|
||||
for x in account_balances]
|
||||
@ -169,7 +168,7 @@ class AccountCollector:
|
||||
self.__add_owner_s_equity(
|
||||
Account.ACCUMULATED_CHANGE_CODE,
|
||||
self.__query_accumulated(),
|
||||
get_income_statement_url(self.__currency, self.__period.before))
|
||||
income_statement_url(self.__currency, self.__period.before))
|
||||
|
||||
def __query_accumulated(self) -> Decimal | None:
|
||||
"""Queries and returns the accumulated profit or loss.
|
||||
@ -191,7 +190,7 @@ class AccountCollector:
|
||||
self.__add_owner_s_equity(
|
||||
Account.NET_CHANGE_CODE,
|
||||
self.__query_currency_period(),
|
||||
get_income_statement_url(self.__currency, self.__period))
|
||||
income_statement_url(self.__currency, self.__period))
|
||||
|
||||
def __query_currency_period(self) -> Decimal | None:
|
||||
"""Queries and returns the net income or loss for current period.
|
||||
@ -348,7 +347,7 @@ class PageParams(BasePageParams):
|
||||
:return: The currency options.
|
||||
"""
|
||||
return self._get_currency_options(
|
||||
lambda x: get_balance_sheet_url(x, self.period), self.currency)
|
||||
lambda x: balance_sheet_url(x, self.period), self.currency)
|
||||
|
||||
|
||||
class BalanceSheet(BaseReport):
|
||||
|
@ -33,7 +33,7 @@ from accounting.utils.pagination import Pagination
|
||||
from .utils.base_page_params import BasePageParams
|
||||
from .utils.base_report import BaseReport
|
||||
from .utils.csv_export import BaseCSVRow, csv_download, period_spec
|
||||
from .utils.get_url import get_income_expenses_url
|
||||
from .utils.urls import income_expenses_url
|
||||
from .utils.option_link import OptionLink
|
||||
from .utils.period_choosers import IncomeExpensesPeriodChooser
|
||||
from .utils.report_chooser import ReportChooser
|
||||
@ -324,7 +324,7 @@ class PageParams(BasePageParams):
|
||||
:return: The currency options.
|
||||
"""
|
||||
return self._get_currency_options(
|
||||
lambda x: get_income_expenses_url(x, self.account, self.period),
|
||||
lambda x: income_expenses_url(x, self.account, self.period),
|
||||
self.currency)
|
||||
|
||||
@property
|
||||
@ -337,7 +337,7 @@ class PageParams(BasePageParams):
|
||||
= IncomeExpensesAccount.current_assets_and_liabilities()
|
||||
options: list[OptionLink] \
|
||||
= [OptionLink(str(current_al),
|
||||
get_income_expenses_url(self.currency, current_al,
|
||||
income_expenses_url(self.currency, current_al,
|
||||
self.period),
|
||||
self.account.id == 0)]
|
||||
in_use: sa.Select = sa.Select(JournalEntry.account_id)\
|
||||
@ -349,7 +349,7 @@ class PageParams(BasePageParams):
|
||||
Account.base_code.startswith("22")))\
|
||||
.group_by(JournalEntry.account_id)
|
||||
options.extend([OptionLink(str(x),
|
||||
get_income_expenses_url(
|
||||
income_expenses_url(
|
||||
self.currency,
|
||||
IncomeExpensesAccount(x),
|
||||
self.period),
|
||||
|
@ -30,7 +30,7 @@ from accounting.report.period import Period
|
||||
from .utils.base_page_params import BasePageParams
|
||||
from .utils.base_report import BaseReport
|
||||
from .utils.csv_export import BaseCSVRow, csv_download, period_spec
|
||||
from .utils.get_url import get_ledger_url, get_income_statement_url
|
||||
from .utils.urls import ledger_url, income_statement_url
|
||||
from .utils.option_link import OptionLink
|
||||
from .utils.period_choosers import IncomeStatementPeriodChooser
|
||||
from .utils.report_chooser import ReportChooser
|
||||
@ -188,8 +188,7 @@ class PageParams(BasePageParams):
|
||||
:return: The currency options.
|
||||
"""
|
||||
return self._get_currency_options(
|
||||
lambda x: get_income_statement_url(x, self.period),
|
||||
self.currency)
|
||||
lambda x: income_statement_url(x, self.period), self.currency)
|
||||
|
||||
|
||||
class IncomeStatement(BaseReport):
|
||||
@ -276,7 +275,7 @@ class IncomeStatement(BaseReport):
|
||||
.filter(Account.id.in_([x.id for x in balances])).all()}
|
||||
return [ReportAccount(account=accounts[x.id],
|
||||
amount=x.balance,
|
||||
url=get_ledger_url(self.__currency,
|
||||
url=ledger_url(self.__currency,
|
||||
accounts[x.id],
|
||||
self.__period))
|
||||
for x in balances]
|
||||
|
@ -32,7 +32,7 @@ from accounting.utils.pagination import Pagination
|
||||
from .utils.base_page_params import BasePageParams
|
||||
from .utils.base_report import BaseReport
|
||||
from .utils.csv_export import BaseCSVRow, csv_download, period_spec
|
||||
from .utils.get_url import get_ledger_url
|
||||
from .utils.urls import ledger_url
|
||||
from .utils.option_link import OptionLink
|
||||
from .utils.period_choosers import LedgerPeriodChooser
|
||||
from .utils.report_chooser import ReportChooser
|
||||
@ -292,8 +292,7 @@ class PageParams(BasePageParams):
|
||||
:return: The currency options.
|
||||
"""
|
||||
return self._get_currency_options(
|
||||
lambda x: get_ledger_url(x, self.account, self.period),
|
||||
self.currency)
|
||||
lambda x: ledger_url(x, self.account, self.period), self.currency)
|
||||
|
||||
@property
|
||||
def account_options(self) -> list[OptionLink]:
|
||||
@ -304,8 +303,7 @@ class PageParams(BasePageParams):
|
||||
in_use: sa.Select = sa.Select(JournalEntry.account_id)\
|
||||
.filter(JournalEntry.currency_code == self.currency.code)\
|
||||
.group_by(JournalEntry.account_id)
|
||||
return [OptionLink(str(x), get_ledger_url(self.currency, x,
|
||||
self.period),
|
||||
return [OptionLink(str(x), ledger_url(self.currency, x, self.period),
|
||||
x.id == self.account.id)
|
||||
for x in Account.query.filter(Account.id.in_(in_use))
|
||||
.order_by(Account.base_code, Account.no).all()]
|
||||
|
@ -29,7 +29,7 @@ from accounting.report.period import Period
|
||||
from .utils.base_page_params import BasePageParams
|
||||
from .utils.base_report import BaseReport
|
||||
from .utils.csv_export import BaseCSVRow, csv_download, period_spec
|
||||
from .utils.get_url import get_ledger_url, get_trial_balance_url
|
||||
from .utils.urls import ledger_url, trial_balance_url
|
||||
from .utils.option_link import OptionLink
|
||||
from .utils.period_choosers import TrialBalancePeriodChooser
|
||||
from .utils.report_chooser import ReportChooser
|
||||
@ -150,7 +150,7 @@ class PageParams(BasePageParams):
|
||||
:return: The currency options.
|
||||
"""
|
||||
return self._get_currency_options(
|
||||
lambda x: get_trial_balance_url(x, self.period), self.currency)
|
||||
lambda x: trial_balance_url(x, self.period), self.currency)
|
||||
|
||||
|
||||
class TrialBalance(BaseReport):
|
||||
@ -197,7 +197,7 @@ class TrialBalance(BaseReport):
|
||||
.filter(Account.id.in_([x.id for x in balances])).all()}
|
||||
self.__accounts = [ReportAccount(account=accounts[x.id],
|
||||
amount=x.balance,
|
||||
url=get_ledger_url(self.__currency,
|
||||
url=ledger_url(self.__currency,
|
||||
accounts[x.id],
|
||||
self.__period))
|
||||
for x in balances]
|
||||
|
@ -28,9 +28,8 @@ from accounting.report.income_expense_account import IncomeExpensesAccount
|
||||
from accounting.report.period import YearPeriod, Period, ThisMonth, \
|
||||
LastMonth, SinceLastMonth, ThisYear, LastYear, Today, Yesterday, \
|
||||
TemplatePeriod
|
||||
from .get_url import get_journal_url, get_ledger_url, \
|
||||
get_income_expenses_url, get_trial_balance_url, get_income_statement_url, \
|
||||
get_balance_sheet_url
|
||||
from .urls import journal_url, ledger_url, income_expenses_url, \
|
||||
trial_balance_url, income_statement_url, balance_sheet_url
|
||||
|
||||
|
||||
class PeriodChooser(ABC):
|
||||
@ -113,7 +112,7 @@ class JournalPeriodChooser(PeriodChooser):
|
||||
super().__init__(None if first is None else first.date)
|
||||
|
||||
def _url_for(self, period: Period) -> str:
|
||||
return get_journal_url(period)
|
||||
return journal_url(period)
|
||||
|
||||
|
||||
class LedgerPeriodChooser(PeriodChooser):
|
||||
@ -130,7 +129,7 @@ class LedgerPeriodChooser(PeriodChooser):
|
||||
super().__init__(None if first is None else first.date)
|
||||
|
||||
def _url_for(self, period: Period) -> str:
|
||||
return get_ledger_url(self.currency, self.account, period)
|
||||
return ledger_url(self.currency, self.account, period)
|
||||
|
||||
|
||||
class IncomeExpensesPeriodChooser(PeriodChooser):
|
||||
@ -147,7 +146,7 @@ class IncomeExpensesPeriodChooser(PeriodChooser):
|
||||
super().__init__(None if first is None else first.date)
|
||||
|
||||
def _url_for(self, period: Period) -> str:
|
||||
return get_income_expenses_url(self.currency, self.account, period)
|
||||
return income_expenses_url(self.currency, self.account, period)
|
||||
|
||||
|
||||
class TrialBalancePeriodChooser(PeriodChooser):
|
||||
@ -162,7 +161,7 @@ class TrialBalancePeriodChooser(PeriodChooser):
|
||||
super().__init__(None if first is None else first.date)
|
||||
|
||||
def _url_for(self, period: Period) -> str:
|
||||
return get_trial_balance_url(self.currency, period)
|
||||
return trial_balance_url(self.currency, period)
|
||||
|
||||
|
||||
class IncomeStatementPeriodChooser(PeriodChooser):
|
||||
@ -177,7 +176,7 @@ class IncomeStatementPeriodChooser(PeriodChooser):
|
||||
super().__init__(None if first is None else first.date)
|
||||
|
||||
def _url_for(self, period: Period) -> str:
|
||||
return get_income_statement_url(self.currency, period)
|
||||
return income_statement_url(self.currency, period)
|
||||
|
||||
|
||||
class BalanceSheetPeriodChooser(PeriodChooser):
|
||||
@ -192,4 +191,4 @@ class BalanceSheetPeriodChooser(PeriodChooser):
|
||||
super().__init__(None if first is None else first.date)
|
||||
|
||||
def _url_for(self, period: Period) -> str:
|
||||
return get_balance_sheet_url(self.currency, period)
|
||||
return balance_sheet_url(self.currency, period)
|
||||
|
@ -31,11 +31,10 @@ from accounting.models import Currency, Account
|
||||
from accounting.report.income_expense_account import IncomeExpensesAccount
|
||||
from accounting.report.period import Period
|
||||
from accounting.template_globals import default_currency_code
|
||||
from .get_url import get_journal_url, get_ledger_url, \
|
||||
get_income_expenses_url, get_trial_balance_url, get_income_statement_url, \
|
||||
get_balance_sheet_url
|
||||
from .option_link import OptionLink
|
||||
from .report_type import ReportType
|
||||
from .urls import journal_url, ledger_url, income_expenses_url, \
|
||||
trial_balance_url, income_statement_url, balance_sheet_url
|
||||
|
||||
|
||||
class ReportChooser:
|
||||
@ -88,7 +87,7 @@ class ReportChooser:
|
||||
|
||||
:return: The journal.
|
||||
"""
|
||||
return OptionLink(gettext("Journal"), get_journal_url(self.__period),
|
||||
return OptionLink(gettext("Journal"), journal_url(self.__period),
|
||||
self.__active_report == ReportType.JOURNAL,
|
||||
fa_icon="fa-solid fa-book")
|
||||
|
||||
@ -99,7 +98,7 @@ class ReportChooser:
|
||||
:return: The ledger.
|
||||
"""
|
||||
return OptionLink(gettext("Ledger"),
|
||||
get_ledger_url(self.__currency, self.__account,
|
||||
ledger_url(self.__currency, self.__account,
|
||||
self.__period),
|
||||
self.__active_report == ReportType.LEDGER,
|
||||
fa_icon="fa-solid fa-clipboard")
|
||||
@ -114,8 +113,7 @@ class ReportChooser:
|
||||
if not re.match(r"[12][12]", account.base_code):
|
||||
account: Account = Account.cash()
|
||||
return OptionLink(gettext("Income and Expenses Log"),
|
||||
get_income_expenses_url(
|
||||
self.__currency,
|
||||
income_expenses_url(self.__currency,
|
||||
IncomeExpensesAccount(account),
|
||||
self.__period),
|
||||
self.__active_report == ReportType.INCOME_EXPENSES,
|
||||
@ -128,8 +126,7 @@ class ReportChooser:
|
||||
:return: The trial balance.
|
||||
"""
|
||||
return OptionLink(gettext("Trial Balance"),
|
||||
get_trial_balance_url(self.__currency,
|
||||
self.__period),
|
||||
trial_balance_url(self.__currency, self.__period),
|
||||
self.__active_report == ReportType.TRIAL_BALANCE,
|
||||
fa_icon="fa-solid fa-scale-unbalanced")
|
||||
|
||||
@ -140,8 +137,7 @@ class ReportChooser:
|
||||
:return: The income statement.
|
||||
"""
|
||||
return OptionLink(gettext("Income Statement"),
|
||||
get_income_statement_url(self.__currency,
|
||||
self.__period),
|
||||
income_statement_url(self.__currency, self.__period),
|
||||
self.__active_report == ReportType.INCOME_STATEMENT,
|
||||
fa_icon="fa-solid fa-file-invoice-dollar")
|
||||
|
||||
@ -152,8 +148,7 @@ class ReportChooser:
|
||||
:return: The balance sheet.
|
||||
"""
|
||||
return OptionLink(gettext("Balance Sheet"),
|
||||
get_balance_sheet_url(self.__currency,
|
||||
self.__period),
|
||||
balance_sheet_url(self.__currency, self.__period),
|
||||
self.__active_report == ReportType.BALANCE_SHEET,
|
||||
fa_icon="fa-solid fa-scale-balanced")
|
||||
|
||||
|
@ -24,7 +24,7 @@ from accounting.report.income_expense_account import IncomeExpensesAccount
|
||||
from accounting.report.period import Period
|
||||
|
||||
|
||||
def get_journal_url(period: Period) \
|
||||
def journal_url(period: Period) \
|
||||
-> str:
|
||||
"""Returns the URL of a journal.
|
||||
|
||||
@ -36,7 +36,7 @@ def get_journal_url(period: Period) \
|
||||
return url_for("accounting.report.journal", period=period)
|
||||
|
||||
|
||||
def get_ledger_url(currency: Currency, account: Account, period: Period) \
|
||||
def ledger_url(currency: Currency, account: Account, period: Period) \
|
||||
-> str:
|
||||
"""Returns the URL of a ledger.
|
||||
|
||||
@ -53,7 +53,7 @@ def get_ledger_url(currency: Currency, account: Account, period: Period) \
|
||||
period=period)
|
||||
|
||||
|
||||
def get_income_expenses_url(currency: Currency, account: IncomeExpensesAccount,
|
||||
def income_expenses_url(currency: Currency, account: IncomeExpensesAccount,
|
||||
period: Period) -> str:
|
||||
"""Returns the URL of an income and expenses log.
|
||||
|
||||
@ -70,7 +70,7 @@ def get_income_expenses_url(currency: Currency, account: IncomeExpensesAccount,
|
||||
period=period)
|
||||
|
||||
|
||||
def get_trial_balance_url(currency: Currency, period: Period) -> str:
|
||||
def trial_balance_url(currency: Currency, period: Period) -> str:
|
||||
"""Returns the URL of a trial balance.
|
||||
|
||||
:param currency: The currency.
|
||||
@ -84,7 +84,7 @@ def get_trial_balance_url(currency: Currency, period: Period) -> str:
|
||||
currency=currency, period=period)
|
||||
|
||||
|
||||
def get_income_statement_url(currency: Currency, period: Period) -> str:
|
||||
def income_statement_url(currency: Currency, period: Period) -> str:
|
||||
"""Returns the URL of an income statement.
|
||||
|
||||
:param currency: The currency.
|
||||
@ -98,7 +98,7 @@ def get_income_statement_url(currency: Currency, period: Period) -> str:
|
||||
currency=currency, period=period)
|
||||
|
||||
|
||||
def get_balance_sheet_url(currency: Currency, period: Period) -> str:
|
||||
def balance_sheet_url(currency: Currency, period: Period) -> str:
|
||||
"""Returns the URL of a balance sheet.
|
||||
|
||||
:param currency: The currency.
|
Loading…
Reference in New Issue
Block a user