Revised the way to import from the datetime package, to avoid name conflict with the common "date" and "time" names.
This commit is contained in:
src/accounting
journal_entry
report
period
reports
income_expenses.pyjournal.pyledger.pysearch.pyunapplied.pyunapplied_accounts.pyunmatched.pyunmatched_accounts.py
utils
tests
@ -19,9 +19,9 @@
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime as dt
|
||||
import typing as t
|
||||
from abc import ABC, abstractmethod
|
||||
from datetime import date, timedelta
|
||||
from decimal import Decimal
|
||||
from secrets import randbelow
|
||||
|
||||
@ -167,7 +167,8 @@ class JournalEntryData:
|
||||
:param is_update: True for an update operation, or False otherwise
|
||||
:return: The journal entry as a form.
|
||||
"""
|
||||
journal_entry_date: date = date.today() - timedelta(days=self.days)
|
||||
journal_entry_date: dt.date \
|
||||
= dt.date.today() - dt.timedelta(days=self.days)
|
||||
form: dict[str, str] = {"csrf_token": csrf_token,
|
||||
"next": next_uri,
|
||||
"date": journal_entry_date.isoformat()}
|
||||
@ -240,7 +241,8 @@ class BaseTestData(ABC):
|
||||
existing_j_id: set[int] = {x["id"] for x in self.__journal_entries}
|
||||
existing_l_id: set[int] = {x["id"] for x in self.__line_items}
|
||||
journal_entry_data.id = self.__new_id(existing_j_id)
|
||||
j_date: date = date.today() - timedelta(days=journal_entry_data.days)
|
||||
j_date: dt.date \
|
||||
= dt.date.today() - dt.timedelta(days=journal_entry_data.days)
|
||||
self.__journal_entries.append(
|
||||
{"id": journal_entry_data.id,
|
||||
"date": j_date,
|
||||
@ -303,7 +305,7 @@ class BaseTestData(ABC):
|
||||
existing_id.add(obj_id)
|
||||
return obj_id
|
||||
|
||||
def __next_j_no(self, j_date: date) -> int:
|
||||
def __next_j_no(self, j_date: dt.date) -> int:
|
||||
"""Returns the next journal entry number in a day.
|
||||
|
||||
:param j_date: The journal entry date.
|
||||
|
@ -17,7 +17,7 @@
|
||||
"""The data reset for the Mia! Accounting demonstration website.
|
||||
|
||||
"""
|
||||
from datetime import date, timedelta
|
||||
import datetime as dt
|
||||
|
||||
from flask import Flask, Blueprint, url_for, flash, redirect, session, \
|
||||
render_template, current_app
|
||||
@ -116,14 +116,14 @@ class SampleData(BaseTestData):
|
||||
|
||||
:return: None.
|
||||
"""
|
||||
today: date = date.today()
|
||||
today: dt.date = dt.date.today()
|
||||
days: int
|
||||
year: int
|
||||
month: int
|
||||
|
||||
# Recurring in USD
|
||||
j_date: date = date(today.year - 5, today.month, today.day)
|
||||
j_date = j_date + timedelta(days=(4 - j_date.weekday()))
|
||||
j_date: dt.date = dt.date(today.year - 5, today.month, today.day)
|
||||
j_date = j_date + dt.timedelta(days=(4 - j_date.weekday()))
|
||||
days = (today - j_date).days
|
||||
while True:
|
||||
if days < 0:
|
||||
@ -147,7 +147,7 @@ class SampleData(BaseTestData):
|
||||
if month > 12:
|
||||
year = year + 1
|
||||
month = 1
|
||||
days = (today - date(year, month, 1)).days
|
||||
days = (today - dt.date(year, month, 1)).days
|
||||
if days < 0:
|
||||
break
|
||||
self.__add_journal_entry(
|
||||
@ -159,12 +159,12 @@ class SampleData(BaseTestData):
|
||||
|
||||
:return: None.
|
||||
"""
|
||||
today: date = date.today()
|
||||
today: dt.date = dt.date.today()
|
||||
|
||||
year: int = today.year - 5
|
||||
month: int = today.month
|
||||
while True:
|
||||
days: int = (today - date(year, month, 5)).days
|
||||
days: int = (today - dt.date(year, month, 5)).days
|
||||
if days < 0:
|
||||
break
|
||||
self.__add_journal_entry(
|
||||
|
Reference in New Issue
Block a user