DrCr/drcr/templates/journal/balance_assertions_edit.html

87 lines
4.7 KiB
HTML

{# DrCr: Web-based double-entry bookkeeping framework
Copyright (C) 2022–2024 Lee Yingtong Li (RunasSudo)
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/>.
#}
{% extends 'base.html' %}
{% block title %}{{ 'Edit' if assertion else 'New' }} balance assertion{% endblock %}
{% block content %}
<div class="max-w-lg mx-auto px-4">
<h1 class="page-heading mb-4">
{{ '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>
<input type="date" class="bordered-field" name="dt" id="dt" value="{{ assertion.dt.strftime('%Y-%m-%d') if assertion else '' }}">
</div>
<label for="description" class="block text-gray-900 pr-4">Description</label>
<div>
<input type="text" class="bordered-field" name="description" id="description" value="{{ assertion.description if assertion else '' }}">
</div>
<label for="account" class="block text-gray-900 pr-4">Account</label>
<div class="relative combobox">
<input type="text" class="bordered-field peer" name="account" id="account" value="{{ assertion.account if assertion else '' }}" autocomplete="off">
<button type="button" class="absolute inset-y-0 right-0 flex items-center px-2 focus:outline-none">
<svg class="h-5 w-5 text-gray-400" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 3a.75.75 0 01.55.24l3.25 3.5a.75.75 0 11-1.1 1.02L10 4.852 7.3 7.76a.75.75 0 01-1.1-1.02l3.25-3.5A.75.75 0 0110 3zm-3.76 9.2a.75.75 0 011.06.04l2.7 2.908 2.7-2.908a.75.75 0 111.1 1.02l-3.25 3.5a.75.75 0 01-1.1 0l-3.25-3.5a.75.75 0 01.04-1.06z" clip-rule="evenodd" />
</svg>
</button>
<ul class="hidden peer-focus:block absolute z-10 mt-1 max-h-60 w-full overflow-auto bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm">
{% for account in accounts %}
<li class="group relative cursor-default select-none py-1 pl-3 pr-9 text-gray-900 hover:text-white hover:bg-indigo-600">
<span class="combobox-text block truncate group-data-[selected=selected]:font-semibold">{{ account }}</span>
<span class="hidden group-data-[selected=selected]:flex absolute inset-y-0 right-0 items-center pr-4 text-indigo-600 group-hover:text-white">
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z" clip-rule="evenodd" />
</svg>
</span>
</li>
{% endfor %}
</ul>
</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 #}
<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">
<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>
</div>
</div>
<div class="flex justify-end mt-4 space-x-2">
{% if assertion and assertion.id %}
<button type="submit" name="action" value="delete" class="btn-secondary text-red-600 ring-red-500" onclick="confirm('Are you sure you want to delete this balance assertion? This operation is irreversible.')">Delete</button>
{% endif %}
<button type="submit" class="btn-primary">Save</button>
</div>
</form>
</div>
{% endblock %}
{% block scripts %}
<script src="{{ url_for('static', filename='js/combobox.js') }}"></script>
{% endblock %}