2023-01-03 18:37:10 +11:00
|
|
|
{# DrCr: Web-based double-entry bookkeeping framework
|
2024-04-04 17:28:28 +11:00
|
|
|
Copyright (C) 2022–2024 Lee Yingtong Li (RunasSudo)
|
2023-01-03 18:37:10 +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' %}
|
2023-01-03 18:37:10 +11:00
|
|
|
{% block title %}Chart of accounts{% endblock %}
|
|
|
|
|
|
|
|
{% block content %}
|
2024-04-04 21:02:29 +11:00
|
|
|
<h1 class="page-heading">
|
2024-04-04 17:28:28 +11:00
|
|
|
Chart of accounts
|
|
|
|
</h1>
|
2023-01-03 18:37:10 +11:00
|
|
|
|
|
|
|
<form method="POST">
|
2024-04-04 17:28:28 +11:00
|
|
|
<div class="my-2 py-2 flex gap-x-2 items-baseline bg-white sticky top-0">
|
2024-04-06 03:01:15 +11:00
|
|
|
<div class="relative dropdownbox w-[450px]"> {# FIXME: Width hardcoded #}
|
|
|
|
<button type="button" class="relative w-full cursor-default bg-white bordered-field pl-3 pr-10 text-left">
|
|
|
|
<span class="dropdownbox-text block truncate">Asset</span> {# FIXME: Hardcoded default #}
|
|
|
|
<span class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
|
|
|
|
<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>
|
|
|
|
</span>
|
|
|
|
</button>
|
|
|
|
<input type="hidden" name="kind" value="drcr.asset"> {# FIXME: Hardcoded default #}
|
|
|
|
<ul class="hidden absolute z-20 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">
|
2023-01-07 01:09:17 +11:00
|
|
|
{% for plugin_name, plugin_account_kinds in account_kinds_by_plugin.items() %}
|
2024-04-06 03:01:15 +11:00
|
|
|
{% for account_kind in plugin_account_kinds %}
|
|
|
|
<li class="group relative cursor-default select-none py-1 pl-3 pr-9 text-gray-900 hover:text-white hover:bg-emerald-600" data-value="{{ account_kind[0] }}"{% if account_kind[0] == 'drcr.asset' %} data-selected="selected"{% endif %}>
|
|
|
|
<span class="combobox-text block truncate group-data-[selected=selected]:font-semibold">{{ account_kind[1] }}</span>
|
|
|
|
<span class="hidden group-data-[selected=selected]:flex absolute inset-y-0 right-0 items-center pr-4 text-emerald-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 %}
|
2023-01-04 18:01:59 +11:00
|
|
|
{% endfor %}
|
2024-04-06 03:01:15 +11:00
|
|
|
</ul>
|
2023-01-03 18:37:10 +11:00
|
|
|
</div>
|
|
|
|
<div>
|
2024-04-04 21:02:29 +11:00
|
|
|
<button formaction="{{ url_for('account_add_kind') }}" class="btn-primary" type="submit">Add type</button>
|
2023-01-03 18:37:10 +11:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2024-04-04 17:28:28 +11:00
|
|
|
<table class="min-w-full">
|
2023-01-03 18:37:10 +11:00
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th></th>
|
2024-04-06 02:28:52 +11:00
|
|
|
<th class="py-0.5 px-1 text-gray-900 font-semibold text-start">Account</th>
|
|
|
|
<th class="py-0.5 pl-1 text-gray-900 font-semibold text-start">Associated types</th>
|
2023-01-03 18:37:10 +11:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for account in accounts %}
|
2024-04-04 17:28:28 +11:00
|
|
|
<tr class="border-t border-gray-300">
|
2024-04-06 02:28:52 +11:00
|
|
|
<td class="py-0.5 pr-1 text-gray-900 align-baseline"><input class="checkbox-primary" type="checkbox" name="sel-account" value="{{ account }}"></td>
|
|
|
|
<td class="py-0.5 px-1 text-gray-900 align-baseline">{{ account }}</td>
|
|
|
|
<td class="py-0.5 pl-1 text-gray-900 align-baseline">
|
2023-01-03 18:37:10 +11:00
|
|
|
{% if account in account_configurations %}
|
2024-04-04 17:28:28 +11:00
|
|
|
<ul class="list-disc ml-5">
|
2023-01-03 18:37:10 +11:00
|
|
|
{% for account_configuration in account_configurations[account] %}
|
2023-01-07 01:09:17 +11:00
|
|
|
<li>{{ account_kinds_map[account_configuration.kind] }}</li>
|
2023-01-03 18:37:10 +11:00
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
{% endif %}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
{% endblock %}
|
2024-04-06 03:01:15 +11:00
|
|
|
|
|
|
|
{% block scripts %}
|
|
|
|
<script>
|
|
|
|
document.querySelectorAll('.dropdownbox').forEach((elDropdownbox) => {
|
|
|
|
const elButton = elDropdownbox.querySelector('button');
|
|
|
|
const elInput = elDropdownbox.querySelector('input');
|
|
|
|
const elUl = elDropdownbox.querySelector('ul');
|
|
|
|
|
|
|
|
// Open and close dropdown box
|
|
|
|
elButton.addEventListener('click', (evt) => {
|
|
|
|
if (elUl.classList.contains('hidden')) {
|
|
|
|
elUl.classList.remove('hidden');
|
|
|
|
elUl.classList.add('block');
|
|
|
|
} else {
|
|
|
|
elUl.classList.remove('block');
|
|
|
|
elUl.classList.add('hidden');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Update value on select
|
|
|
|
elUl.querySelectorAll('li').forEach((elLi) => {
|
|
|
|
elLi.addEventListener('click', (evt) => {
|
|
|
|
const liText = elLi.querySelector('.combobox-text').innerText;
|
|
|
|
const liValue = elLi.dataset.value;
|
|
|
|
|
|
|
|
elButton.innerText = liText;
|
|
|
|
elInput.value = liValue;
|
|
|
|
|
|
|
|
elUl.querySelectorAll('li').forEach((elLi2) => {
|
|
|
|
elLi2.dataset.selected = '';
|
|
|
|
});
|
|
|
|
elLi.dataset.selected = 'selected';
|
|
|
|
|
|
|
|
elUl.classList.remove('block');
|
|
|
|
elUl.classList.add('hidden');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
{% endblock %}
|