Added the option management, and moved the configuration of the default currency, the default account for the income and expenses log, and the recurring expenses and incomes to the options.
This commit is contained in:
src/accounting
tests/test_site
@ -1,43 +0,0 @@
|
||||
# The Mia! Accounting Flask Project.
|
||||
# Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/7
|
||||
|
||||
# Copyright (c) 2023 imacat.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""The pseudo account for the income and expenses log.
|
||||
|
||||
"""
|
||||
from flask import current_app
|
||||
|
||||
from accounting.models import Account
|
||||
from accounting.utils.ie_account import IncomeExpensesAccount
|
||||
|
||||
|
||||
def default_ie_account_code() -> str:
|
||||
"""Returns the default account code for the income and expenses log.
|
||||
|
||||
:return: The default account code for the income and expenses log.
|
||||
"""
|
||||
return current_app.config.get("ACCOUNTING_DEFAULT_IE_ACCOUNT",
|
||||
Account.CASH_CODE)
|
||||
|
||||
|
||||
def default_ie_account() -> IncomeExpensesAccount:
|
||||
"""Returns the default account for the income and expenses log.
|
||||
|
||||
:return: The default account for the income and expenses log.
|
||||
"""
|
||||
code: str = default_ie_account_code()
|
||||
if code == IncomeExpensesAccount.CURRENT_AL_CODE:
|
||||
return IncomeExpensesAccount.current_assets_and_liabilities()
|
||||
return IncomeExpensesAccount(Account.find_by_code(code))
|
@ -20,8 +20,8 @@
|
||||
from flask import url_for
|
||||
|
||||
from accounting.models import Currency, Account
|
||||
from accounting.option.options import options
|
||||
from accounting.report.period import Period
|
||||
from accounting.report.utils.ie_account import default_ie_account_code
|
||||
from accounting.template_globals import default_currency_code
|
||||
from accounting.utils.ie_account import IncomeExpensesAccount
|
||||
|
||||
@ -65,7 +65,7 @@ def income_expenses_url(currency: Currency, account: IncomeExpensesAccount,
|
||||
:return: The URL of the income and expenses log.
|
||||
"""
|
||||
if currency.code == default_currency_code() \
|
||||
and account.code == default_ie_account_code() \
|
||||
and account.code == options.default_ie_account_code \
|
||||
and period.is_default:
|
||||
return url_for("accounting.report.default")
|
||||
if period.is_default:
|
||||
|
@ -21,6 +21,7 @@ from flask import Blueprint, request, Response
|
||||
|
||||
from accounting import db
|
||||
from accounting.models import Currency, Account
|
||||
from accounting.option.options import options
|
||||
from accounting.report.period import Period, get_period
|
||||
from accounting.template_globals import default_currency_code
|
||||
from accounting.utils.ie_account import IncomeExpensesAccount
|
||||
@ -28,7 +29,6 @@ from accounting.utils.permission import has_permission, can_view
|
||||
from .reports import Journal, Ledger, IncomeExpenses, TrialBalance, \
|
||||
IncomeStatement, BalanceSheet, Search
|
||||
from .template_filters import format_amount
|
||||
from .utils.ie_account import default_ie_account
|
||||
|
||||
bp: Blueprint = Blueprint("report", __name__)
|
||||
"""The view blueprint for the reports."""
|
||||
@ -44,7 +44,7 @@ def get_default_report() -> str | Response:
|
||||
"""
|
||||
return __get_income_expenses(
|
||||
db.session.get(Currency, default_currency_code()),
|
||||
default_ie_account(),
|
||||
options.default_ie_account,
|
||||
get_period())
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user