Configure EOFY date in database

This commit is contained in:
RunasSudo 2023-07-03 22:31:58 +10:00
parent d3c437ce7d
commit 99d3d6d22d
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
3 changed files with 17 additions and 10 deletions

View File

@ -16,24 +16,17 @@
from drcr import AMOUNT_DPS from drcr import AMOUNT_DPS
from drcr.database import db from drcr.database import db
from drcr.models import AccountConfiguration, Amount, Transaction, TrialBalancer from drcr.models import AccountConfiguration, Amount, Metadata, Transaction, TrialBalancer
from drcr.reports import Calculated, Report, Section, Spacer, Subtotal, entries_for_kind from drcr.reports import Calculated, Report, Section, Spacer, Subtotal, entries_for_kind
from .tax_tables import base_tax, repayment_rates, fbt_grossup from .tax_tables import base_tax, repayment_rates, fbt_grossup
from datetime import datetime from datetime import datetime
def eofy_date(dt=None): def eofy_date():
"""Get the datetime for the end of the financial year""" """Get the datetime for the end of the financial year"""
if dt is None: return datetime.strptime(Metadata.get('eofy_date'), '%Y-%m-%d')
dt = datetime.now()
dt_eofy = dt.replace(month=6, day=30)
if dt_eofy < dt:
dt_eofy = dt_eofy.replace(year=dt.year + 1)
return dt_eofy
def base_income_tax(year, taxable_income): def base_income_tax(year, taxable_income):
"""Get the amount of base income tax""" """Get the amount of base income tax"""

View File

@ -237,3 +237,15 @@ class AccountConfiguration(db.Model):
kinds = {k: [vv.kind for vv in v] for k, v in account_configurations.items()} kinds = {k: [vv.kind for vv in v] for k, v in account_configurations.items()}
return kinds return kinds
class Metadata(db.Model):
__tablename__ = 'metadata'
id = db.Column(db.Integer, primary_key=True)
key = db.Column(db.String)
value = db.Column(db.String)
@staticmethod
def get(key):
return Metadata.query.filter_by(key=key).one().value

View File

@ -57,6 +57,8 @@ init_plugins()
def initdb(): def initdb():
db.create_all() db.create_all()
# FIXME: Need to init metadata
if app.debug: if app.debug:
@app.before_request @app.before_request
def before_request(): def before_request():