12 Commits

Author SHA1 Message Date
0b1dd4f4fc Advanced to version 1.5.3. 2023-04-30 15:07:46 +08:00
46bd27e126 Revised the saveOriginalLineItem method of the JavaScript JournalEntryLineItemEditor class not to override the existing amount when the existing amount is less than the net balance. This make it easier when updating the existing journal entries. 2023-04-30 15:03:59 +08:00
b718d19450 Resolved an issue where, in cases where there was no existing localized title and the default title was submitted, the submitted account title or currency name would be erroneously saved as the localized title. 2023-04-30 15:03:58 +08:00
2969e83afe Advanced to version 1.5.2. 2023-04-30 06:43:18 +08:00
a732656746 Revised the coding style in the "__get_line_items" method of the OffsetMatcher class. 2023-04-30 06:38:43 +08:00
1daed940b6 Corrected the definition of the "is_offset" property in the "__get_line_items" method of the OffsetMatcher class. 2023-04-30 06:38:01 +08:00
f29cb00aec Advanced to version 1.5.1. 2023-04-30 05:53:37 +08:00
693f07a49c Removed the "timestamp" and
"user_pk" type aliases for the columns in the data models.  They do not work with the current version of Flask-SQLAlchemy when creating Sphinx documentation.
2023-04-30 05:51:31 +08:00
8c899776f2 Corrected the filename in the csv method of the AccountsWithUnmatchedOffsets report class. 2023-04-30 05:35:13 +08:00
f9aa226bf9 Removed an unnecessary f-string from the csv method of the AccountsWithUnappliedOriginalLineItems report class. 2023-04-30 05:34:34 +08:00
c9bb4197be Fixed the error calling the old "setEnableDescriptionAccount" method in the saveOriginalLineItem method of the JavaScript JournalEntryLineItemEditor class. 2023-04-30 05:27:09 +08:00
9ae8d587d8 Removed the unused "random_pk" annotated type alias. 2023-04-29 04:16:11 +08:00
7 changed files with 83 additions and 39 deletions

View File

@ -2,6 +2,35 @@ Change Log
==========
Version 1.5.3
-------------
Released 2023/4/30
* Fixed the error of the net balance in the unmatched offset list.
* Revised the original line item editor not to override the existing
amount when the existing amount is less or equal to the net
balance.
Version 1.5.2
-------------
Released 2023/4/30
* Fixed the error of the net balance in the unmatched offset list.
Version 1.5.1
-------------
Released 2023/4/30
* Fixed the error calling the old ``setEnableDescriptionAccount``
method in the ``saveOriginalLineItem`` method of the JavaScript
``JournalEntryLineItemEditor`` class.
Version 1.5.0
-------------

View File

@ -24,7 +24,7 @@ from flask_sqlalchemy import SQLAlchemy
from accounting.utils.user import UserUtilityInterface
VERSION: str = "1.5.0"
VERSION: str = "1.5.3"
"""The package version."""
db: SQLAlchemy = SQLAlchemy()
"""The database instance."""

View File

@ -22,7 +22,7 @@ from __future__ import annotations
import datetime as dt
import re
from decimal import Decimal
from typing import Type, Annotated, Self
from typing import Type, Self
import sqlalchemy as sa
from babel import Locale
@ -34,18 +34,6 @@ from accounting import db
from accounting.locale import gettext
from accounting.utils.user import user_cls, user_pk_column
timestamp: Type[dt.datetime] \
= Annotated[dt.datetime, mapped_column(db.DateTime(timezone=True),
server_default=db.func.now())]
"""The timestamp."""
user_pk: Type[int] \
= Annotated[int, mapped_column(db.ForeignKey(user_pk_column,
onupdate="CASCADE"))]
"""The user primary key."""
random_pk: Type[int] \
= Annotated[int, mapped_column(primary_key=True, autoincrement=False)]
"""The random primary key."""
class BaseAccount(db.Model):
"""A base account."""
@ -126,15 +114,21 @@ class Account(db.Model):
"""The title."""
is_need_offset: Mapped[bool] = mapped_column(default=False)
"""Whether the journal entry line items of this account need offset."""
created_at: Mapped[timestamp]
created_at: Mapped[dt.datetime] \
= mapped_column(db.DateTime(timezone=True),
server_default=db.func.now())
"""The date and time when this record was created."""
created_by_id: Mapped[user_pk] = mapped_column()
created_by_id: Mapped[int] \
= mapped_column(db.ForeignKey(user_pk_column, onupdate="CASCADE"))
"""The ID of the user who created the record."""
created_by: Mapped[user_cls] = db.relationship(foreign_keys=created_by_id)
"""The user who created the record."""
updated_at: Mapped[timestamp]
updated_at: Mapped[dt.datetime] \
= mapped_column(db.DateTime(timezone=True),
server_default=db.func.now())
"""The date and time when this record was last updated."""
updated_by_id: Mapped[user_pk] = mapped_column()
updated_by_id: Mapped[int] \
= mapped_column(db.ForeignKey(user_pk_column, onupdate="CASCADE"))
"""The ID of the last user who updated the record."""
updated_by: Mapped[user_cls] = db.relationship(foreign_keys=updated_by_id)
"""The last user who updated the record."""
@ -188,6 +182,8 @@ class Account(db.Model):
:param value: The new title.
:return: None.
"""
if self.title == value:
return
if self.title_l10n is None:
self.title_l10n = value
return
@ -376,15 +372,21 @@ class Currency(db.Model):
"""The code."""
name_l10n: Mapped[str] = mapped_column("name")
"""The name."""
created_at: Mapped[timestamp]
created_at: Mapped[dt.datetime] \
= mapped_column(db.DateTime(timezone=True),
server_default=db.func.now())
"""The date and time when this record was created."""
created_by_id: Mapped[user_pk] = mapped_column()
created_by_id: Mapped[int] \
= mapped_column(db.ForeignKey(user_pk_column, onupdate="CASCADE"))
"""The ID of the user who created the record."""
created_by: Mapped[user_cls] = db.relationship(foreign_keys=created_by_id)
"""The user who created the record."""
updated_at: Mapped[timestamp]
updated_at: Mapped[dt.datetime] \
= mapped_column(db.DateTime(timezone=True),
server_default=db.func.now())
"""The date and time when this record was last updated."""
updated_by_id: Mapped[user_pk] = mapped_column()
updated_by_id: Mapped[int] \
= mapped_column(db.ForeignKey(user_pk_column, onupdate="CASCADE"))
"""The ID of the last user who updated the record."""
updated_by: Mapped[user_cls] \
= db.relationship(foreign_keys=updated_by_id)
@ -424,6 +426,8 @@ class Currency(db.Model):
:param value: The new name.
:return: None.
"""
if self.name == value:
return
if self.name_l10n is None:
self.name_l10n = value
return
@ -543,15 +547,21 @@ class JournalEntry(db.Model):
"""The account number under the date."""
note: Mapped[str | None]
"""The note."""
created_at: Mapped[timestamp]
created_at: Mapped[dt.datetime] \
= mapped_column(db.DateTime(timezone=True),
server_default=db.func.now())
"""The date and time when this record was created."""
created_by_id: Mapped[user_pk] = mapped_column()
created_by_id: Mapped[int] \
= mapped_column(db.ForeignKey(user_pk_column, onupdate="CASCADE"))
"""The ID of the user who created the record."""
created_by: Mapped[user_cls] = db.relationship(foreign_keys=created_by_id)
"""The user who created the record."""
updated_at: Mapped[timestamp]
updated_at: Mapped[dt.datetime] \
= mapped_column(db.DateTime(timezone=True),
server_default=db.func.now())
"""The date and time when this record was last updated."""
updated_by_id: Mapped[user_pk] = mapped_column()
updated_by_id: Mapped[int] \
= mapped_column(db.ForeignKey(user_pk_column, onupdate="CASCADE"))
"""The ID of the last user who updated the record."""
updated_by: Mapped[user_cls] = db.relationship(foreign_keys=updated_by_id)
"""The last user who updated the record."""
@ -876,15 +886,21 @@ class Option(db.Model):
"""The name."""
value: Mapped[str] = mapped_column(db.Text)
"""The option value."""
created_at: Mapped[timestamp]
created_at: Mapped[dt.datetime] \
= mapped_column(db.DateTime(timezone=True),
server_default=db.func.now())
"""The date and time when this record was created."""
created_by_id: Mapped[user_pk] = mapped_column()
created_by_id: Mapped[int] \
= mapped_column(db.ForeignKey(user_pk_column, onupdate="CASCADE"))
"""The ID of the user who created the record."""
created_by: Mapped[user_cls] = db.relationship(foreign_keys=created_by_id)
"""The user who created the record."""
updated_at: Mapped[timestamp]
updated_at: Mapped[dt.datetime] \
= mapped_column(db.DateTime(timezone=True),
server_default=db.func.now())
"""The date and time when this record was last updated."""
updated_by_id: Mapped[user_pk] = mapped_column()
updated_by_id: Mapped[int] \
= mapped_column(db.ForeignKey(user_pk_column, onupdate="CASCADE"))
"""The ID of the last user who updated the record."""
updated_by: Mapped[user_cls] = db.relationship(foreign_keys=updated_by_id)
"""The last user who updated the record."""

View File

@ -143,7 +143,7 @@ class AccountsWithUnappliedOriginalLineItems(BaseReport):
:return: The response of the report for download.
"""
filename: str = f"unapplied-accounts.csv"
filename: str = "unapplied-accounts.csv"
return csv_download(filename, get_csv_rows(self.__accounts))
def html(self) -> str:

View File

@ -144,7 +144,7 @@ class AccountsWithUnmatchedOffsets(BaseReport):
:return: The response of the report for download.
"""
filename: str = f"unapplied-accounts.csv"
filename: str = "unmatched-accounts.csv"
return csv_download(filename, get_csv_rows(self.__accounts))
def html(self) -> str:

View File

@ -123,15 +123,13 @@ class OffsetMatcher:
.options(selectinload(JournalEntryLineItem.currency),
selectinload(JournalEntryLineItem.journal_entry)).all()
for line_item in self.line_items:
line_item.is_offset = line_item.id in net_balances
self.unapplied = [x for x in self.line_items
if x.is_offset]
line_item.is_offset = line_item.id not in net_balances
self.unapplied = [x for x in self.line_items if not x.is_offset]
for line_item in self.unapplied:
line_item.net_balance = line_item.amount \
if net_balances[line_item.id] is None \
else net_balances[line_item.id]
self.unmatched = [x for x in self.line_items
if not x.is_offset]
self.unmatched = [x for x in self.line_items if x.is_offset]
self.__populate_accumulated_balances()
def __populate_accumulated_balances(self) -> None:

View File

@ -276,7 +276,6 @@ class JournalEntryLineItemEditor {
this.originalLineItemDate = originalLineItem.date;
this.originalLineItemText = originalLineItem.text;
this.#originalLineItemText.innerText = originalLineItem.text;
this.#setEnableDescriptionAccount(false);
if (this.description === null) {
if (originalLineItem.description === "") {
this.#descriptionControl.classList.remove("accounting-not-empty");
@ -291,7 +290,9 @@ class JournalEntryLineItemEditor {
this.account = originalLineItem.account.copy();
this.isAccountConfirmed = false;
this.#accountText.innerText = this.account.text;
this.#amountInput.value = String(originalLineItem.netBalance);
if (this.#amountInput.value === "" || new Decimal(this.#amountInput.value).greaterThan(originalLineItem.netBalance)) {
this.#amountInput.value = String(originalLineItem.netBalance);
}
this.#amountInput.max = String(originalLineItem.netBalance);
this.#amountInput.min = "0";
this.#validate();