mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-25 10:08:36 +02:00
feat: automated replacement
This commit is contained in:
@@ -9,65 +9,60 @@
|
||||
<form hx-post="{% url 'account_reconciliation' %}">
|
||||
{% csrf_token %}
|
||||
{{ form.management_form }}
|
||||
<div class="accordion accordion-flush" id="balanceAccordionFlush">
|
||||
<div class="tw:space-y-2" id="balanceAccordionFlush">
|
||||
{% for form in form.forms %}
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
|
||||
data-bs-target="#flush-collapse-{{ forloop.counter0 }}" aria-expanded="false"
|
||||
aria-controls="flush-collapseOne">
|
||||
{% if form.account_group %}<span class="badge text-bg-primary me-2">{{ form.account_group.name }}</span>{% endif %}{{ form.account_name }}
|
||||
</button>
|
||||
</h2>
|
||||
<div id="flush-collapse-{{ forloop.counter0 }}" class="accordion-collapse collapse">
|
||||
<div class="accordion-body">
|
||||
<div class="mb-3">
|
||||
<div class="form-label">
|
||||
{% translate 'Current balance' %}
|
||||
</div>
|
||||
<div data-amount="{{ form.current_balance|floatformat:"-40u" }}"
|
||||
data-decimal-places="{{ form.currency_decimal_places }}"
|
||||
id="amount-{{ forloop.counter0 }}">
|
||||
{% currency_display amount=form.current_balance prefix=form.currency_prefix suffix=form.currency_suffix decimal_places=form.currency_decimal_places %}
|
||||
</div>
|
||||
<div class="tw:collapse tw:collapse-arrow tw:bg-base-200">
|
||||
<input type="radio" name="my-accordion-flush" id="accordion-{{ forloop.counter0 }}" />
|
||||
<label for="accordion-{{ forloop.counter0 }}" class="tw:collapse-title tw:text-base tw:font-medium">
|
||||
{% if form.account_group %}<span class="tw:badge tw:badge-primary tw:me-2">{{ form.account_group.name }}</span>{% endif %}{{ form.account_name }}
|
||||
</label>
|
||||
<div class="tw:collapse-content">
|
||||
<div class="tw:mb-3">
|
||||
<div class="tw:label">
|
||||
<span class="tw:label-text">{% translate 'Current balance' %}</span>
|
||||
</div>
|
||||
<div>
|
||||
{% crispy form %}
|
||||
<div data-amount="{{ form.current_balance|floatformat:"-40u" }}"
|
||||
data-decimal-places="{{ form.currency_decimal_places }}"
|
||||
id="amount-{{ forloop.counter0 }}">
|
||||
{% currency_display amount=form.current_balance prefix=form.currency_prefix suffix=form.currency_suffix decimal_places=form.currency_decimal_places %}
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="form-label">
|
||||
{% translate 'Difference' %}
|
||||
</div>
|
||||
<div _="on input from #id_form-{{ forloop.counter0 }}-new_balance
|
||||
set original_amount to parseFloat('{{ form.current_balance|floatformat:"-40u" }}')
|
||||
then set prefix to '{{ form.currency_prefix }}'
|
||||
then set suffix to '{{ form.currency_suffix }}'
|
||||
then set decimal_places to {{ form.currency_decimal_places }}
|
||||
then call parseLocaleNumber(#id_form-{{ forloop.counter0 }}-new_balance.value)
|
||||
then set new_amount to result
|
||||
then set diff to (Math.round((new_amount - original_amount) * Math.pow(10, decimal_places))) / Math.pow(10, decimal_places)
|
||||
then log diff
|
||||
then set format_new_amount to
|
||||
Intl.NumberFormat(
|
||||
undefined,
|
||||
{
|
||||
minimumFractionDigits: decimal_places,
|
||||
maximumFractionDigits: decimal_places,
|
||||
roundingMode: 'trunc'
|
||||
}
|
||||
).format(diff)
|
||||
then set formatted_string to `${prefix}${format_new_amount}${suffix}`
|
||||
then put formatted_string into me if diff else
|
||||
put '-' into me">-</div>
|
||||
</div>
|
||||
<div>
|
||||
{% crispy form %}
|
||||
</div>
|
||||
<div class="tw:mb-3">
|
||||
<div class="tw:label">
|
||||
<span class="tw:label-text">{% translate 'Difference' %}</span>
|
||||
</div>
|
||||
<div _="on input from #id_form-{{ forloop.counter0 }}-new_balance
|
||||
set original_amount to parseFloat('{{ form.current_balance|floatformat:"-40u" }}')
|
||||
then set prefix to '{{ form.currency_prefix }}'
|
||||
then set suffix to '{{ form.currency_suffix }}'
|
||||
then set decimal_places to {{ form.currency_decimal_places }}
|
||||
then call parseLocaleNumber(#id_form-{{ forloop.counter0 }}-new_balance.value)
|
||||
then set new_amount to result
|
||||
then set diff to (Math.round((new_amount - original_amount) * Math.pow(10, decimal_places))) / Math.pow(10, decimal_places)
|
||||
then log diff
|
||||
then set format_new_amount to
|
||||
Intl.NumberFormat(
|
||||
undefined,
|
||||
{
|
||||
minimumFractionDigits: decimal_places,
|
||||
maximumFractionDigits: decimal_places,
|
||||
roundingMode: 'trunc'
|
||||
}
|
||||
).format(diff)
|
||||
then set formatted_string to `${prefix}${format_new_amount}${suffix}`
|
||||
then put formatted_string into me if diff else
|
||||
put '-' into me">-</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
<div class="tw:mt-3">
|
||||
<div>
|
||||
<input type="submit" name="submit" value="{% translate 'Reconcile balances' %}" class="btn btn-outline-primary w-100" id="submit-id-submit">
|
||||
<input type="submit" name="submit" value="{% translate 'Reconcile balances' %}" class="tw:btn tw:btn-outline tw:btn-primary tw:w-full" id="submit-id-submit">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{% load i18n %}
|
||||
<div class="container px-md-3 py-3 column-gap-5">
|
||||
<div class="tw:text-3xl fw-bold font-monospace tw:w-full mb-3">
|
||||
<div class="tw:container tw:px-md-3 tw:py-3 tw:column-gap-5">
|
||||
<div class="tw:text-3xl tw:font-bold tw:font-mono tw:w-full tw:mb-3">
|
||||
{% spaceless %}
|
||||
<div>{% translate 'Accounts' %}<span>
|
||||
<a class="text-decoration-none tw:text-2xl p-1 category-action"
|
||||
<a class="tw:no-underline tw:text-2xl tw:p-1 category-action"
|
||||
role="button"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-title="{% translate "Add" %}"
|
||||
@@ -14,35 +14,35 @@
|
||||
{% endspaceless %}
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body table-responsive">
|
||||
<div class="tw:card tw:bg-base-100 tw:shadow-xl">
|
||||
<div class="tw:card-body tw:overflow-x-auto">
|
||||
{% if accounts %}
|
||||
<c-config.search></c-config.search>
|
||||
<table class="table table-hover text-nowrap">
|
||||
<table class="tw:table tw:table-hover tw:whitespace-nowrap">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="col-auto"></th>
|
||||
<th scope="col" class="col">{% translate 'Name' %}</th>
|
||||
<th scope="col" class="col">{% translate 'Group' %}</th>
|
||||
<th scope="col" class="col">{% translate 'Currency' %}</th>
|
||||
<th scope="col" class="col">{% translate 'Exchange Currency' %}</th>
|
||||
<th scope="col" class="col">{% translate 'Is Asset' %}</th>
|
||||
<th scope="col" class="col">{% translate 'Archived' %}</th>
|
||||
<th scope="col" class="tw:w-auto"></th>
|
||||
<th scope="col">{% translate 'Name' %}</th>
|
||||
<th scope="col">{% translate 'Group' %}</th>
|
||||
<th scope="col">{% translate 'Currency' %}</th>
|
||||
<th scope="col">{% translate 'Exchange Currency' %}</th>
|
||||
<th scope="col">{% translate 'Is Asset' %}</th>
|
||||
<th scope="col">{% translate 'Archived' %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for account in accounts %}
|
||||
<tr class="account">
|
||||
<td class="col-auto">
|
||||
<div class="btn-group" role="group" aria-label="{% translate 'Actions' %}">
|
||||
<a class="btn btn-secondary btn-sm"
|
||||
<td class="tw:w-auto">
|
||||
<div class="tw:join" role="group" aria-label="{% translate 'Actions' %}">
|
||||
<a class="tw:btn tw:btn-secondary tw:btn-sm tw:join-item"
|
||||
role="button"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-title="{% translate "Edit" %}"
|
||||
hx-get="{% url 'account_edit' pk=account.id %}"
|
||||
hx-target="#generic-offcanvas">
|
||||
<i class="fa-solid fa-pencil fa-fw"></i></a>
|
||||
<a class="btn btn-secondary btn-sm text-danger"
|
||||
<a class="tw:btn tw:btn-secondary tw:btn-sm tw:join-item tw:text-error"
|
||||
role="button"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-title="{% translate "Delete" %}"
|
||||
@@ -54,7 +54,7 @@
|
||||
data-confirm-text="{% translate "Yes, delete it!" %}"
|
||||
_="install prompt_swal"><i class="fa-solid fa-trash fa-fw"></i></a>
|
||||
{% if not account.owner %}
|
||||
<a class="btn btn-secondary btn-sm text-primary"
|
||||
<a class="tw:btn tw:btn-secondary tw:btn-sm tw:join-item tw:text-primary"
|
||||
role="button"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-title="{% translate "Take ownership" %}"
|
||||
@@ -62,7 +62,7 @@
|
||||
<i class="fa-solid fa-crown fa-fw"></i></a>
|
||||
{% endif %}
|
||||
{% if user == account.owner %}
|
||||
<a class="btn btn-secondary btn-sm text-primary"
|
||||
<a class="tw:btn tw:btn-secondary tw:btn-sm tw:join-item tw:text-primary"
|
||||
role="button"
|
||||
hx-target="#generic-offcanvas"
|
||||
hx-swap="innerHTML"
|
||||
@@ -71,7 +71,7 @@
|
||||
hx-get="{% url 'account_share_settings' pk=account.id %}">
|
||||
<i class="fa-solid fa-share fa-fw"></i></a>
|
||||
{% endif %}
|
||||
<a class="btn btn-secondary btn-sm"
|
||||
<a class="tw:btn tw:btn-secondary tw:btn-sm tw:join-item"
|
||||
role="button"
|
||||
hx-get="{% url 'account_toggle_untracked' pk=account.id %}"
|
||||
data-bs-toggle="tooltip"
|
||||
@@ -84,12 +84,12 @@
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
<td class="col">{{ account.name }}</td>
|
||||
<td class="col">{{ account.group.name }}</td>
|
||||
<td class="col">{{ account.currency }}</td>
|
||||
<td class="col">{% if account.exchange_currency %}{{ account.exchange_currency }}{% else %}-{% endif %}</td>
|
||||
<td class="col">{% if account.is_asset %}<i class="fa-solid fa-solid fa-check text-success"></i>{% endif %}</td>
|
||||
<td class="col">{% if account.is_archived %}<i class="fa-solid fa-solid fa-check text-success"></i>{% endif %}</td>
|
||||
<td>{{ account.name }}</td>
|
||||
<td>{{ account.group.name }}</td>
|
||||
<td>{{ account.currency }}</td>
|
||||
<td>{% if account.exchange_currency %}{{ account.exchange_currency }}{% else %}-{% endif %}</td>
|
||||
<td>{% if account.is_asset %}<i class="fa-solid fa-solid fa-check tw:text-success"></i>{% endif %}</td>
|
||||
<td>{% if account.is_archived %}<i class="fa-solid fa-solid fa-check tw:text-success"></i>{% endif %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user