Applied the form to existing transactions in the accounting application.

This commit is contained in:
依瑪貓 2020-07-28 03:07:37 +08:00
parent 95ffeff8cb
commit b11348b276
5 changed files with 8 additions and 6 deletions

View File

@ -52,7 +52,7 @@ First written: 2020/7/23
<label for="txn-date">{% trans "Date:" context "Accounting|" as text %}{{ text|force_escape }}</label> <label for="txn-date">{% trans "Date:" context "Accounting|" as text %}{{ text|force_escape }}</label>
</div> </div>
<div class="col-sm-10"> <div class="col-sm-10">
<input id="txn-date" class="form-control {% if errors.date %} is-invalid {% endif %}" type="date" name="date" value="{{ item.date }}" required="required" /> <input id="txn-date" class="form-control {% if errors.date %} is-invalid {% endif %}" type="date" name="date" value="{{ item.date|date:"Y-m-d" }}" required="required" />
<div id="txn-date-error" class="invalid-feedback">{{ errors.date|default:"" }}</div> <div id="txn-date-error" class="invalid-feedback">{{ errors.date|default:"" }}</div>
</div> </div>
</div> </div>

View File

@ -52,7 +52,7 @@ First written: 2020/7/23
<label for="txn-date">{% trans "Date:" context "Accounting|" as text %}{{ text|force_escape }}</label> <label for="txn-date">{% trans "Date:" context "Accounting|" as text %}{{ text|force_escape }}</label>
</div> </div>
<div class="col-sm-10"> <div class="col-sm-10">
<input id="txn-date" class="form-control {% if errors.date %} is-invalid {% endif %}" type="date" name="date" value="{{ item.date }}" required="required" /> <input id="txn-date" class="form-control {% if errors.date %} is-invalid {% endif %}" type="date" name="date" value="{{ item.date|date:"Y-m-d" }}" required="required" />
<div id="txn-date-error" class="invalid-feedback">{{ errors.date|default:"" }}</div> <div id="txn-date-error" class="invalid-feedback">{{ errors.date|default:"" }}</div>
</div> </div>
</div> </div>

View File

@ -55,7 +55,7 @@ First written: 2020/7/23
<label for="txn-date">{% trans "Date:" context "Accounting|" as text %}{{ text|force_escape }}</label> <label for="txn-date">{% trans "Date:" context "Accounting|" as text %}{{ text|force_escape }}</label>
</div> </div>
<div class="col-sm-10"> <div class="col-sm-10">
<input id="txn-date" class="form-control {% if errors.date %} is-invalid {% endif %}" type="date" name="date" value="{{ item.date }}" required="required" /> <input id="txn-date" class="form-control {% if errors.date %} is-invalid {% endif %}" type="date" name="date" value="{{ item.date|date:"Y-m-d" }}" required="required" />
<div id="txn-date-error" class="invalid-feedback">{{ errors.date|default:"" }}</div> <div id="txn-date-error" class="invalid-feedback">{{ errors.date|default:"" }}</div>
</div> </div>
</div> </div>

View File

@ -74,7 +74,7 @@ urlpatterns = [
path("transactions/<txn-type:type>/<txn:transaction>", path("transactions/<txn-type:type>/<txn:transaction>",
views.transaction_show, name="transactions.show"), views.transaction_show, name="transactions.show"),
path("transactions/<txn-type:type>/<txn:transaction>/edit", path("transactions/<txn-type:type>/<txn:transaction>/edit",
mia_core_views.todo, name="transactions.edit"), views.transaction_create, name="transactions.edit"),
path("transactions/<txn-type:type>/<txn:transaction>/update", path("transactions/<txn-type:type>/<txn:transaction>/update",
mia_core_views.todo, name="transactions.update"), mia_core_views.todo, name="transactions.update"),
path("transactions/<txn:transaction>/delete", path("transactions/<txn:transaction>/delete",

View File

@ -862,16 +862,18 @@ def transaction_show(request, type, transaction):
@require_GET @require_GET
@digest_login_required @digest_login_required
def transaction_create(request, type): def transaction_create(request, type, transaction=None):
"""The view to create an accounting transaction. """The view to create an accounting transaction.
Args: Args:
request (HttpRequest): The request. request (HttpRequest): The request.
type (str): The transaction type. type (str): The transaction type.
transaction (Transaction: The transaction.
Returns: Returns:
HttpResponse: The response. HttpResponse: The response.
""" """
if transaction is None:
transaction = Transaction() transaction = Transaction()
if len(transaction.debit_records) == 0: if len(transaction.debit_records) == 0:
transaction.records.append(Record(ord=1, is_credit=False)) transaction.records.append(Record(ord=1, is_credit=False))