diff --git a/accounting/models.py b/accounting/models.py index 5ec789d..eec35bd 100644 --- a/accounting/models.py +++ b/accounting/models.py @@ -106,7 +106,7 @@ class Transaction(models.Model): list[Record]: The records. """ if self._records is None: - self._records = self.record_set.all() + self._records = list(self.record_set.all()) return self._records @records.setter @@ -115,23 +115,33 @@ class Transaction(models.Model): @property def debit_records(self): - """The debit records of this transaction.""" + """The debit records of this transaction. + + Returns: + list[Record]: The records. + """ return [x for x in self.records if not x.is_credit] @property def debit_total(self): """The total amount of the debit records.""" - return sum([x.amount for x in self.debit_records]) + return sum([x.amount for x in self.debit_records + if isinstance(x.amount, int)]) @property def credit_records(self): - """The credit records of this transaction.""" + """The credit records of this transaction. + + Returns: + list[Record]: The records. + """ return [x for x in self.records if x.is_credit] @property def credit_total(self): """The total amount of the credit records.""" - return sum([x.amount for x in self.credit_records]) + return sum([x.amount for x in self.credit_records + if isinstance(x.amount, int)]) _is_balanced = None diff --git a/accounting/templates/accounting/transactions/expense/edit.html b/accounting/templates/accounting/transactions/expense/edit.html new file mode 100644 index 0000000..27911a9 --- /dev/null +++ b/accounting/templates/accounting/transactions/expense/edit.html @@ -0,0 +1,151 @@ +{% extends "base.html" %} +{% comment %} +The Mia Accounting Application +edit.html: The template for the form of a cash-expense transaction + + Copyright (c) 2020 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. + +Author: imacat@mail.imacat.idv.tw (imacat) +First written: 2020/7/23 +{% endcomment %} +{% load static %} +{% load i18n %} +{% load mia_core %} +{% load accounting %} + +{% block settings %} + {% trans "Cash Expense Transaction" context "Accounting|" as title %} + {% setvar "title" title %} +{% endblock %} + +{% block content %} + +
+ + + +{% endblock %} diff --git a/accounting/templates/accounting/transactions/income/edit.html b/accounting/templates/accounting/transactions/income/edit.html new file mode 100644 index 0000000..31d09a6 --- /dev/null +++ b/accounting/templates/accounting/transactions/income/edit.html @@ -0,0 +1,151 @@ +{% extends "base.html" %} +{% comment %} +The Mia Accounting Application +edit.html: The template for the form of a cash-income transaction + + Copyright (c) 2020 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. + +Author: imacat@mail.imacat.idv.tw (imacat) +First written: 2020/7/23 +{% endcomment %} +{% load static %} +{% load i18n %} +{% load mia_core %} +{% load accounting %} + +{% block settings %} + {% trans "Cash Income Transaction" context "Accounting|" as title %} + {% setvar "title" title %} +{% endblock %} + +{% block content %} + + + + + +{% endblock %} diff --git a/accounting/templates/accounting/transactions/transfer/edit.html b/accounting/templates/accounting/transactions/transfer/edit.html new file mode 100644 index 0000000..a538721 --- /dev/null +++ b/accounting/templates/accounting/transactions/transfer/edit.html @@ -0,0 +1,213 @@ +{% extends "base.html" %} +{% comment %} +The Mia Accounting Application +edit.html: The template for the form of a transfer transaction + + Copyright (c) 2020 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. + +Author: imacat@mail.imacat.idv.tw (imacat) +First written: 2020/7/23 +{% endcomment %} +{% load static %} +{% load i18n %} +{% load mia_core %} +{% load accounting %} + +{% block settings %} + {% trans "Transfer Transaction" context "Accounting|" as title %} + {% setvar "title" title %} +{% endblock %} + +{% block content %} + + + + + +{% endblock %} diff --git a/accounting/urls.py b/accounting/urls.py index 9d382e5..67b1c82 100644 --- a/accounting/urls.py +++ b/accounting/urls.py @@ -68,7 +68,7 @@ urlpatterns = [ path("search", views.search, name="search"), path("transactions/