Compare commits
3 Commits
965e78d8ad
...
f6946c1165
Author | SHA1 | Date | |
---|---|---|---|
f6946c1165 | |||
8e219d8006 | |||
53565eb9e6 |
@ -17,8 +17,6 @@
|
|||||||
"""The currency sub-forms for the transaction management.
|
"""The currency sub-forms for the transaction management.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
from flask_babel import LazyString
|
from flask_babel import LazyString
|
||||||
@ -52,13 +50,26 @@ class CurrencyExists:
|
|||||||
class NeedSomeJournalEntries:
|
class NeedSomeJournalEntries:
|
||||||
"""The validator to check if there is any journal entry sub-form."""
|
"""The validator to check if there is any journal entry sub-form."""
|
||||||
|
|
||||||
def __call__(self, form: TransferCurrencyForm, field: FieldList) \
|
def __call__(self, form: FlaskForm, field: FieldList) -> None:
|
||||||
-> None:
|
|
||||||
if len(field) == 0:
|
if len(field) == 0:
|
||||||
raise ValidationError(lazy_gettext(
|
raise ValidationError(lazy_gettext(
|
||||||
"Please add some journal entries."))
|
"Please add some journal entries."))
|
||||||
|
|
||||||
|
|
||||||
|
class IsBalanced:
|
||||||
|
"""The validator to check that the total amount of the debit and credit
|
||||||
|
entries are equal."""
|
||||||
|
|
||||||
|
def __call__(self, form: FlaskForm, field: BooleanField) -> None:
|
||||||
|
if not isinstance(form, TransferCurrencyForm):
|
||||||
|
return
|
||||||
|
if len(form.debit) == 0 or len(form.credit) == 0:
|
||||||
|
return
|
||||||
|
if form.debit_total != form.credit_total:
|
||||||
|
raise ValidationError(lazy_gettext(
|
||||||
|
"The totals of the debit and credit amounts do not match."))
|
||||||
|
|
||||||
|
|
||||||
class CurrencyForm(FlaskForm):
|
class CurrencyForm(FlaskForm):
|
||||||
"""The form to create or edit a currency in a transaction."""
|
"""The form to create or edit a currency in a transaction."""
|
||||||
no = IntegerField()
|
no = IntegerField()
|
||||||
@ -141,19 +152,6 @@ class ExpenseCurrencyForm(CurrencyForm):
|
|||||||
|
|
||||||
class TransferCurrencyForm(CurrencyForm):
|
class TransferCurrencyForm(CurrencyForm):
|
||||||
"""The form to create or edit a currency in a transfer transaction."""
|
"""The form to create or edit a currency in a transfer transaction."""
|
||||||
|
|
||||||
class IsBalanced:
|
|
||||||
"""The validator to check that the total amount of the debit and credit
|
|
||||||
entries are equal."""
|
|
||||||
def __call__(self, form: TransferCurrencyForm, field: BooleanField)\
|
|
||||||
-> None:
|
|
||||||
if len(form.debit) == 0 or len(form.credit) == 0:
|
|
||||||
return
|
|
||||||
if form.debit_total != form.credit_total:
|
|
||||||
raise ValidationError(lazy_gettext(
|
|
||||||
"The totals of the debit and credit amounts do not"
|
|
||||||
" match."))
|
|
||||||
|
|
||||||
no = IntegerField()
|
no = IntegerField()
|
||||||
"""The order in the transaction."""
|
"""The order in the transaction."""
|
||||||
code = StringField(
|
code = StringField(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user