2022-12-24 17:39:18 +11:00
{# DrCr: Web-based double-entry bookkeeping framework
2024-04-04 18:09:42 +11:00
Copyright (C) 2022–2024 Lee Yingtong Li (RunasSudo)
2022-12-24 17:39:18 +11:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see < https: / / www . gnu . org / licenses / > .
#}
2024-04-04 19:38:59 +11:00
{% extends 'base.html' %}
2022-12-24 17:39:18 +11:00
{% block title %}{{ 'Edit' if assertion else 'New' }} balance assertion{% endblock %}
{% block content %}
2024-04-04 18:09:42 +11:00
< div class = "max-w-lg mx-auto px-4" >
2024-04-04 21:02:29 +11:00
< h1 class = "page-heading mb-4" >
2024-04-04 18:09:42 +11:00
{{ 'Edit' if assertion else 'New' }} balance assertion
< / h1 >
< form method = "POST" >
< div class = "grid grid-cols-[max-content_1fr] space-y-2 mb-4 items-baseline" >
< label for = "dt" class = "block text-gray-900 pr-4" > Date< / label >
< div >
2024-04-04 21:02:29 +11:00
< input type = "date" class = "bordered-field" name = "dt" id = "dt" value = "{{ assertion.dt.strftime('%Y-%m-%d') if assertion else '' }}" >
2024-04-04 18:09:42 +11:00
< / div >
< label for = "description" class = "block text-gray-900 pr-4" > Description< / label >
< div >
2024-04-04 21:02:29 +11:00
< input type = "text" class = "bordered-field" name = "description" id = "description" value = "{{ assertion.description if assertion else '' }}" >
2024-04-04 18:09:42 +11:00
< / div >
< label for = "account" class = "block text-gray-900 pr-4" > Account< / label >
2024-04-06 01:31:31 +11:00
< div class = "relative combobox" >
< input type = "text" class = "bordered-field peer" name = "account" id = "account" value = "{{ assertion.account if assertion else '' }}" autocomplete = "off" >
2024-04-06 01:42:34 +11:00
{% include 'components/accounts_combobox_inner.html' %}
2024-04-04 18:09:42 +11:00
< / div >
< label for = "amount" class = "block text-gray-900 pr-4" > Balance< / label >
< div class = "relative shadow-sm" >
< div class = "pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3" >
< span class = "text-gray-500" > $< / span >
< / div >
{# TODO: Display existing credit assertion as credit, not as negative debit #}
2024-04-04 21:02:29 +11:00
< input type = "number" class = "bordered-field pl-7 pr-16" name = "amount" step = "0.01" value = "{{ assertion.balance().quantity_string() if assertion else '' }}" placeholder = "0.00" >
2024-04-04 18:09:42 +11:00
< div class = "absolute inset-y-0 right-0 flex items-center" >
< select class = "h-full border-0 bg-transparent py-0 pl-2 pr-8 text-gray-900 focus:ring-2 focus:ring-inset focus:ring-indigo-600" name = "sign" >
< option value = "dr" > Dr< / option >
< option value = "cr" > Cr< / option >
< / select >
< / div >
2022-12-24 17:39:18 +11:00
< / div >
< / div >
2024-04-04 18:09:42 +11:00
2024-04-06 00:39:36 +11:00
< div class = "flex justify-end mt-4 space-x-2" >
{% if assertion and assertion.id %}
2024-08-16 22:21:10 +10:00
< button type = "submit" name = "action" value = "delete" class = "btn-secondary text-red-600 ring-red-500" onclick = "return confirm('Are you sure you want to delete this balance assertion? This operation is irreversible.');" > Delete< / button >
2024-04-06 00:39:36 +11:00
{% endif %}
2024-04-04 21:02:29 +11:00
< button type = "submit" class = "btn-primary" > Save< / button >
2024-04-04 18:09:42 +11:00
< / div >
< / form >
< / div >
2022-12-24 17:39:18 +11:00
{% endblock %}
2024-04-06 01:31:31 +11:00
{% block scripts %}
< script src = "{{ url_for('static', filename='js/combobox.js') }}" > < / script >
{% endblock %}