Added the view and the templates for the forms of the transactions in the accounting application.

This commit is contained in:
2020-07-27 22:36:28 +08:00
parent cc18dbd5f1
commit 99fb99b160
7 changed files with 577 additions and 6 deletions

View File

@ -859,3 +859,26 @@ def transaction_show(request, type, transaction):
"transaction_type": type,
"item": transaction,
})
@require_GET
@digest_login_required
def transaction_create(request, type):
"""The view to create an accounting transaction.
Args:
request (HttpRequest): The request.
type (str): The transaction type.
Returns:
HttpResponse: The response.
"""
transaction = Transaction()
if len(transaction.debit_records) == 0:
transaction.records.append(Record(ord=1, is_credit=False))
if len(transaction.credit_records) == 0:
transaction.records.append(Record(ord=1, is_credit=True))
return render(request, F"accounting/transactions/{type}/edit.html", {
"transaction_type": type,
"item": transaction,
})