mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-05-20 22:57:10 +02:00
feat: first batch of work
This commit is contained in:
@@ -9,60 +9,55 @@
|
||||
<form hx-post="{% url 'account_reconciliation' %}">
|
||||
{% csrf_token %}
|
||||
{{ form.management_form }}
|
||||
<div class="tw:space-y-2" id="balanceAccordionFlush">
|
||||
<div class="space-y-2" id="balanceAccordionFlush">
|
||||
{% for form in form.forms %}
|
||||
<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>
|
||||
<details class="collapse collapse-arrow bg-base-100 border-base-300 border overflow-visible show">
|
||||
<summary class="collapse-title font-medium text-sm">
|
||||
{% if form.account_group %}<span class="badge badge-primary me-2">{{ form.account_group.name }}</span>{% endif %}{{ form.account_name }}
|
||||
</summary>
|
||||
<div class="collapse-content">
|
||||
<div class="fieldset">
|
||||
<span class="fieldset-legend">{% translate 'Current balance' %}</span>
|
||||
<div data-amount="{{ form.current_balance|floatformat:"-40u" }}"
|
||||
data-decimal-places="{{ form.currency_decimal_places }}"
|
||||
id="amount-{{ forloop.counter0 }}">
|
||||
data-decimal-places="{{ form.currency_decimal_places }}"
|
||||
id="amount-{{ forloop.counter0 }}" class="text-base">
|
||||
{% currency_display amount=form.current_balance prefix=form.currency_prefix suffix=form.currency_suffix decimal_places=form.currency_decimal_places %}
|
||||
</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 class="fieldset">
|
||||
<span class="fieldset-legend">{% translate 'Difference' %}</span>
|
||||
<div class="text-base"
|
||||
_="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 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>
|
||||
</details>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="tw:mt-3">
|
||||
<div class="mt-3">
|
||||
<div>
|
||||
<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">
|
||||
<input type="submit" name="submit" value="{% translate 'Reconcile balances' %}" class="btn btn-primary w-full" id="submit-id-submit">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user