This commit is contained in:
Herculino Trotta
2024-10-09 00:31:21 -03:00
parent e78e4cc5e1
commit 3dde44b1cd
139 changed files with 4965 additions and 1004 deletions
@@ -6,7 +6,6 @@
{% block body %}
<form hx-post="{% url 'transaction_add' %}" hx-target="#generic-offcanvas" novalidate>
{% csrf_token %}
{% crispy form %}
</form>
{% endblock %}
@@ -0,0 +1,11 @@
{% extends 'extends/offcanvas.html' %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block title %}{% translate 'Add Installment Plan' %}{% endblock %}
{% block body %}
<form hx-post="{% url 'installments_add' %}" hx-target="#generic-offcanvas" novalidate>
{% crispy form %}
</form>
{% endblock %}
@@ -6,7 +6,6 @@
{% block body %}
<form hx-post="{% url 'transaction_edit' transaction_id=transaction.id %}" hx-target="#generic-offcanvas" novalidate>
{% csrf_token %}
{% crispy form %}
</form>
{% endblock %}
@@ -0,0 +1,11 @@
{% extends 'extends/offcanvas.html' %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block title %}{% translate 'Edit transaction' %}{% endblock %}
{% block body %}
<form hx-post="{% url 'installments_edit' pk=installment_plan.id %}" hx-target="#generic-offcanvas" novalidate>
{% crispy form %}
</form>
{% endblock %}
+77 -53
View File
@@ -1,69 +1,103 @@
{% load i18n %}
{% load currency_display %}
<div class="tw-border-s-2 tw-border-e-0 tw-border-t-0 tw-border-b-0 border-bottom
<div class="tw-border-s-6 tw-border-e-0 tw-border-t-0 tw-border-b-0 border-bottom
hover:tw-bg-zinc-900 p-2 {% if transaction.account.is_asset %}tw-border-dashed{% else %}tw-border-solid{% endif %}
{% if transaction.type == "EX" %}tw-border-red-500{% else %}tw-border-green-500{% endif %} transaction tw-relative"
hx-trigger="dblclick"
hx-get="{% url 'transaction_edit' transaction_id=transaction.id %}"
hx-target="#generic-offcanvas"
_="on mouseover remove .tw-invisible from the first .transaction-actions in me end
on mouseout add .tw-invisible to the first .transaction-actions in me end">
{% if transaction.type == "EX" %}tw-border-red-500{% else %}tw-border-green-500{% endif %} transaction tw-relative
my-3"
_="on mouseenter remove .tw-invisible from the first .transaction-actions in me end
on mouseleave add .tw-invisible to the first .transaction-actions in me end">
<div class="row font-monospace tw-text-sm align-items-center">
<div class="col-lg-1 col-12 d-flex align-items-center tw-text-2xl lg:tw-text-xl text-lg-center">
<div class="col-lg-1 col-12 d-flex align-items-center tw-text-2xl lg:tw-text-xl text-lg-center pay-button">
<a class="text-decoration-none my-2 w-100"
role="button"
hx-get="{% url 'transaction_pay' transaction_id=transaction.id %}"
hx-target="closest .transaction"
hx-swap="outerHTML">
hx-swap="outerHTML"
_="on paid
js
paidSound.pause()
paidSound.currentTime = 0
paidSound.play()
end
end
on unpaid
js
unpaidSound.pause()
unpaidSound.currentTime = 0
unpaidSound.play()
end
end">
{% if transaction.is_paid %}<i class="fa-regular fa-circle-check tw-text-green-400"></i>{% else %}<i
class="fa-regular fa-circle tw-text-red-400"></i>{% endif %}
</a>
</div>
<div class="col-lg-8 col-12">
{# Date#}
<div class="mb-1 tw-text-gray-400">
<i class="fa-solid fa-calendar fa-fw me-1 fa-xs"></i>{{ transaction.date|date:"SHORT_DATE_FORMAT" }}</div>
<div class="mb-1 text-white tw-text-base">{{ transaction.description }}</div>
<div class="text-white-50 mb-2 d-flex align-items-center">
<i class="fa-solid fa-calendar fa-fw me-1 fa-xs"></i>
{{ transaction.date|date:"SHORT_DATE_FORMAT" }}</div>
<div class="text-white-50 mb-1 tw-text-xs">
{% for tag in transaction.tags.all %}
<span><i class="fa-solid fa-hashtag tw-text-gray-400"></i>{{ tag.name }}</span>
{% endfor %}
</div>
<div class="tw-text-sm mb-1 mb-lg-0 tw-text-gray-400 font-normal">
<i class="fa-solid fa-note-sticky me-1"></i>{{ transaction.notes | linebreaksbr }}
</div>
<div class="tw-text-sm mb-1 mb-lg-0">
{% if transaction.category %}
<i class="fa-solid fa-icons text-primary"></i>
<span class="badge rounded-0
{% if transaction.category.mute %}text-bg-secondary{% else %}text-bg-light{% endif %}">
{{ transaction.category.name }}
</span>
<div class="tw-text-gray-400 tw-text-sm">
{# Notes#}
{% if transaction.notes %}
<div class="mb-1 tw-text-gray-400">
<i class="fa-solid fa-align-left fa-fw me-1 fa-xs"></i>{{ transaction.notes | linebreaksbr }}
</div>
{% endif %}
{% if transaction.category %}
<div class="mb-1">
{% spaceless %}
<i class="fa-solid fa-icons fa-fw me-1 fa-xs"></i>
<span class="">{{ transaction.category.name }}</span>
{% endspaceless %}
</div>
{% endif %}
{# Tags#}
{% with transaction.tags.all as tags %}
{% if tags %}
<div class="mb-1">
{% for tag in tags %}
<span><i class="fa-solid fa-hashtag fa-fw fa-xs"></i>{{ tag.name }}</span>
{% endfor %}
</div>
{% endif %}
{% endwith %}
</div>
</div>
<div class="col-lg-3 col-12 text-lg-end align-self-end">
<div class="{% if transaction.type == "EX" %}tw-text-red-400{% else %}tw-text-green-400{% endif %}">
{% transaction_amount transaction %}
<div class="amount" data-original-value="{% transaction_amount transaction %}"></div>
</div>
{# Exchange Rate#}
{% with exchanged=transaction.exchanged_amount %}
{% if exchanged %}
<div class="tw-text-gray-500 amount"
data-original-value="{% currency_display amount=exchanged.amount prefix=exchanged.prefix suffix=exchanged.suffix decimal_places=exchanged.decimal_places %}">
</div>
{% endif %}
{% endwith %}
<div>{{ transaction.account.name }}</div>
</div>
<div>
<div class="transaction-actions !tw-absolute tw-top-0 tw-right-0 tw-invisible tw-text-base d-none
d-xl-flex">
{# Item actions#}
<div class="transaction-actions !tw-absolute tw-left-2/4 tw--top-1/3 tw-invisible d-none
d-xl-flex flex-xl-row tw-text-base card">
<a class="text-decoration-none tw-text-gray-400 p-2 transaction-action"
role="button"
data-bs-toggle="tooltip"
data-bs-title="{% translate "Edit" %}"
hx-get="{% url 'transaction_edit' transaction_id=transaction.id %}"
hx-target="#generic-offcanvas"
_="install toast">
<i class="fa-solid fa-pencil fa-fw"></i></a>
<a class="text-danger text-decoration-none p-2 transaction-action"
role="button"
data-bs-toggle="tooltip"
data-bs-title="{% translate "Delete" %}"
hx-get="{% url 'transaction_delete' transaction_id=transaction.id %}"
hx-trigger='confirmed'
_="on click send transaction_action_clicked to .transaction-action in the closest parent .transaction end
on transaction_action_clicked call bootstrap.Tooltip.getOrCreateInstance(me).dispose() end
on mouseenter call bootstrap.Tooltip.getOrCreateInstance(me) end
on mouseleave call bootstrap.Tooltip.getOrCreateInstance(me).dispose() end
hx-delete="{% url 'transaction_delete' transaction_id=transaction.id %}"
hx-trigger='delete_confirmed'
_="install toast
on click
if event.shiftKey trigger confirmed
if event.ctrlKey trigger delete_confirmed
else
call Swal.fire({title: '{% translate 'Are you sure?' %}',
text: '{% blocktranslate %}You won\'t be able to revert this!{% endblocktranslate %}',
@@ -78,19 +112,9 @@ hover:tw-bg-zinc-900 p-2 {% if transaction.account.is_asset %}tw-border-dashed{%
cancelButton: 'btn btn-danger'
},
buttonsStyling: false})
if result.isConfirmed trigger confirmed"><i class="fa-solid fa-trash fa-fw"></i></a>
<a class="text-decoration-none tw-text-gray-400 p-2 transaction-action"
role="button"
data-bs-toggle="tooltip"
data-bs-title="{% translate "Edit" %}"
hx-get="{% url 'transaction_edit' transaction_id=transaction.id %}"
hx-target="#generic-offcanvas"
_="on click send transaction_action_clicked to .transaction-action in the closest parent .transaction end
on transaction_action_clicked call bootstrap.Tooltip.getOrCreateInstance(me).dispose() end
on mouseenter call bootstrap.Tooltip.getOrCreateInstance(me) end
on mouseleave call bootstrap.Tooltip.getOrCreateInstance(me).dispose() end">
<i class="fa-solid fa-pencil fa-fw"></i></a>
if result.isConfirmed trigger delete_confirmed"><i class="fa-solid fa-trash fa-fw"></i></a>
</div>
{# Item actions dropdown fallback for mobile#}
<div class="dropdown !tw-absolute tw-top-0 tw-right-0 xl:tw-invisible">
<a class="btn tw-text-2xl lg:tw-text-sm lg:tw-border-none text-light" type="button"
data-bs-toggle="dropdown"
@@ -106,8 +130,8 @@ hover:tw-bg-zinc-900 p-2 {% if transaction.account.is_asset %}tw-border-dashed{%
</a></li>
<li><a class="dropdown-item"
role="button"
hx-get="{% url 'transaction_delete' transaction_id=transaction.id %}"
hx-trigger='confirmed'
hx-delete="{% url 'transaction_delete' transaction_id=transaction.id %}"
hx-trigger='delete_confirmed'
_="on click
call Swal.fire({title: '{% translate 'Are you sure?' %}',
text: '{% blocktranslate %}You won\'t be able to revert this!{% endblocktranslate %}',
@@ -122,7 +146,7 @@ hover:tw-bg-zinc-900 p-2 {% if transaction.account.is_asset %}tw-border-dashed{%
cancelButton: 'btn btn-danger'
},
buttonsStyling: false})
if result.isConfirmed trigger confirmed">
if result.isConfirmed trigger delete_confirmed">
<i class="fa-solid fa-trash me-3"></i>{% translate "Delete" %}
</a></li>
</ul>
@@ -1,16 +0,0 @@
{% load i18n %}
<div>
{% for trans in transactions %}
{% include 'transactions/fragments/item.html' with transaction=trans %}
{% empty %}
<div class="row p-5">
<div class="col p-5">
<div class="text-center">
<i class="fa-solid fa-circle-xmark tw-text-6xl"></i>
<p class="lead mt-4 mb-0">{% translate "No transactions this month" %}</p>
<p class="tw-text-gray-500">{% translate "Try adding one" %}</p>
</div>
</div>
</div>
{% endfor %}
</div>
@@ -1,46 +0,0 @@
{% extends 'extends/offcanvas.html' %}
{% load month_name %}
{% load i18n %}
{% block title %}{% translate 'Pick one' %}{% endblock %}
{% block body %}
<ul class="nav nav-pills nav-fill" id="yearTabs" role="tablist">
{% for date in available_years %}
<li class="nav-item" role="presentation">
<button class="nav-link{% if date.year == current_year %} active{% endif %}"
id="{{ date.year }}"
data-bs-toggle="tab"
data-bs-target="#{{ date.year }}-pane"
type="button"
role="tab"
aria-controls="{{ date.year }}-pane"
aria-selected="{% if date.year == current_year %}true{% else %}false{% endif %}">
{{ date.year }}
</button>
</li>
{% endfor %}
</ul>
<div class="tab-content" id="yearTabsContent">
{% for date in available_years %}
<div class="tab-pane fade{% if date.year == current_year %} show active{% endif %} mt-2"
id="{{ date.year }}-pane"
role="tabpanel"
aria-labelledby="{{ date.year }}"
tabindex="0">
<ul class="list-group list-group-flush" id="month-year-list">
{% for month in months %}
<li class="list-group-item hover:tw-bg-zinc-900
{% if month == current_month and date.year == current_year %} disabled bg-primary{% endif %}"
{% if month == current_month and date.year == current_year %}aria-disabled="true"{% endif %}>
<a class="text-decoration-none stretched-link {% if month == current_month and date.year == current_year %} text-black{% endif %}"
href="{% url "transactions_overview" month=month year=date.year %}">
{{ month|month_name }}
</a>
</li>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
{% endblock %}
@@ -1,135 +0,0 @@
{% load i18n %}
{% load currency_display %}
<div class="text-bg-secondary p-2 rounded-2 shadow tw-text-sm">
<p class="font-monospace text-light text-uppercase text-center fw-bold m-0 tw-text-base">{% translate "Summary" %}</p>
<hr class="my-1">
<div>
<p class="font-monospace text-uppercase text-center fw-bold m-0">{% translate "Income" %}</p>
<div class="row">
<div class="col-6">
<div class="font-monospace text-primary text-start align-self-end fw-bold m-0">
{% translate "Current Income" %}</div>
</div>
<div class="col-6 text-end font-monospace">
{% for entry in totals.paid_income %}
<div>{% entry_amount entry %}</div>
{% empty %}
<div>-</div>
{% endfor %}
</div>
</div>
<div class="my-3"></div>
<div class="row">
<div class="col-6">
<div class="font-monospace text-primary text-start align-self-end fw-bold m-0">
{% translate "Projected Income" %}
</div>
</div>
<div class="col-6 text-end font-monospace">
{% for entry in totals.projected_income %}
<div>{% entry_amount entry %}</div>
{% empty %}
<div>-</div>
{% endfor %}
</div>
</div>
</div>
<hr class="my-1">
<div>
<p class="font-monospace text-uppercase text-center fw-bold m-0">{% translate "Expenses" %}</p>
<div class="row">
<div class="col-6">
<div class="font-monospace text-primary text-start align-self-end fw-bold m-0">
{% translate "Current Expenses" %}</div>
</div>
<div class="col-6 text-end font-monospace">
{% for entry in totals.paid_expenses %}
<div>{% entry_amount entry %}</div>
{% empty %}
<div>-</div>
{% endfor %}
</div>
</div>
<div class="my-3"></div>
<div class="row">
<div class="col-6">
<div class="font-monospace text-primary text-start align-self-end fw-bold m-0">
{% translate "Projected Expenses" %}
</div>
</div>
<div class="col-6 text-end font-monospace">
{% for entry in totals.projected_expenses %}
<div>{% entry_amount entry %}</div>
{% empty %}
<div>-</div>
{% endfor %}
</div>
</div>
</div>
<hr class="my-1">
<div>
<p class="font-monospace text-uppercase text-center fw-bold m-0">{% translate "Totals" %}</p>
<div class="row">
<div class="col-6">
<div class="font-monospace text-primary text-start align-self-end fw-bold m-0">
{% translate "Current Total" %}
</div>
</div>
<div class="col-6 text-end font-monospace">
{% for entry in totals.total_current %}
<div>{% entry_amount entry %}</div>
{% empty %}
<div>-</div>
{% endfor %}
</div>
</div>
<div class="my-3"></div>
<div class="row">
<div class="col-6">
<div class="font-monospace text-primary text-start align-self-end fw-bold m-0">
{% translate "Projected Total" %}
</div>
</div>
<div class="col-6 text-end font-monospace">
{% for entry in totals.total_projected %}
<div>{% entry_amount entry %}</div>
{% empty %}
<div>-</div>
{% endfor %}
</div>
</div>
<div class="my-3"></div>
<div class="row">
<div class="col-6">
<div class="font-monospace text-primary text-start align-self-end fw-bold m-0">
{% translate "Final Total" %}
</div>
</div>
<div class="col-6 text-end font-monospace">
{% for entry in totals.total_final %}
<div>{% entry_amount entry %}</div>
{% empty %}
<div>-</div>
{% endfor %}
</div>
</div>
</div>
<hr class="my-1">
<div>
<div class="row">
<div class="col-6">
<div class="font-monospace text-primary text-start align-self-end fw-bold m-0">{% translate "Daily Spending Allowance" %}</div>
</div>
<div class="col-6 text-end font-monospace">
{% for entry in totals.daily_spending_allowance %}
<div>{% entry_amount entry %}</div>
{% empty %}
<div>-</div>
{% endfor %}
</div>
</div>
</div>
</div>
@@ -6,7 +6,6 @@
{% block body %}
<form hx-post="{% url 'transactions_transfer' %}" hx-target="#generic-offcanvas" novalidate>
{% csrf_token %}
{% crispy form %}
</form>
{% endblock %}
-79
View File
@@ -1,79 +0,0 @@
{% extends "layouts/base.html" %}
{% load i18n %}
{% load month_name %}
{% load static %}
{% load webpack_loader %}
{% block content %}
<div class="container-fluid px-md-3 py-5 column-gap-5">
<div class="row mb-3">
<div class="col flex-row align-items-center d-flex">
<div class="tw-text-base mx-2 h-100 align-items-center d-flex">
<a role="button" href="
{% url 'transactions_overview' month=previous_month year=previous_year %}"><i
class="fa-solid fa-chevron-left"></i></a>
</div>
<div class="tw-text-3xl fw-bold font-monospace tw-w-full xl:tw-w-72 text-center"
hx-get="{% url 'available_dates' %}"
hx-target="#generic-offcanvas-left"
hx-vals='{"month": {{ month }}, "year": {{ year }}}' role="button">
{{ month|month_name }} {{ year }}
</div>
<div class="tw-text-base mx-2 h-100 align-items-center d-flex">
<a role="button"
href="{% url 'transactions_overview' month=next_month year=next_year %}">
<i class="fa-solid fa-chevron-right"></i>
</a>
</div>
</div>
</div>
<div class="row gx-xl-4 gy-3">
<div class="col-12 col-xl-3 order-1 order-xl-0">
<div class="row">
<div class="col-6 p-1">
<button class="btn btn-sm btn-outline-success w-100"
hx-get="{% url 'transaction_add' %}"
hx-target="#generic-offcanvas"
hx-vals='{"year": {{ year }}, "month": {{ month }}, "type": "IN"}'>
<i class="fa-solid fa-circle-plus me-3"></i>
{% translate "Income" %}
</button>
</div>
<div class="col-6 p-1">
<button class="btn btn-sm btn-outline-danger w-100"
hx-get="{% url 'transaction_add' %}"
hx-target="#generic-offcanvas"
hx-vals='{"year": {{ year }}, "month": {{ month }}, "type": "EX"}'>
<i class="fa-solid fa-circle-plus me-3"></i>
{% translate "Expense" %}
</button>
</div>
<div class="col-6 p-1">
<button class="btn btn-sm btn-outline-info w-100"
hx-get="{% url 'transactions_transfer' %}"
hx-target="#generic-offcanvas"
hx-vals='{"year": {{ year }}, "month": {{ month }}}'>
<i class="fa-solid fa-money-bill-transfer me-3"></i>
{% translate "Transfer" %}
</button>
</div>
</div>
</div>
<div class="col-12 col-xl-6 order-2 order-xl-1"
id="transactions"
hx-get="{% url 'transactions_list' month=month year=year %}"
hx-trigger="load, transaction_updated from:window">
</div>
<div class="col-12 col-xl-3 order-0 order-xl-2">
<div id="total-expenses" hx-get="{% url 'monthly_summary' month=month year=year %}"
hx-trigger="load, transaction_updated from:window" class="sticky-sidebar">
</div>
{# <div id="total-spent" hx-get="{% url 'monthly_expenses' month=month year=year %}"#}
{# hx-trigger="load, transaction_updated from:window" hx-vals='{"s": "p"}'>#}
{# </div>#}
</div>
</div>
</div>
{% endblock %}
@@ -1,16 +1,28 @@
{% load crispy_forms_field %}
<div class="btn-group w-100 mb-3" role="group" aria-label="{{ field.label }}">
{% for choice in field.field.choices %}
<input type="radio"
class="btn-check"
name="{{ field.html_name }}"
id="{{ field.html_name }}_{{ forloop.counter }}"
value="{{ choice.0 }}"
{% if choice.0 == field.value %}checked{% endif %}>
<label class="btn {% if forloop.first %}btn-outline-success{% elif forloop.last %}btn-outline-danger{% else %}btn-outline-primary{% endif %}"
for="{{ field.html_name }}_{{ forloop.counter }}">
{{ choice.1 }}
</label>
{% endfor %}
<div class="form-group mb-3">
<div class="btn-group w-100" role="group" aria-label="{{ field.label }}">
{% for choice in field.field.choices %}
<input type="radio"
class="btn-check"
name="{{ field.html_name }}"
id="{{ field.html_name }}_{{ forloop.counter }}_tr"
value="{{ choice.0 }}"
{% if choice.0 == field.value %}checked{% endif %}>
<label class="btn {% if forloop.first %}btn-outline-success{% elif forloop.last %}btn-outline-danger{% else %}btn-outline-primary{% endif %} {% if field.errors %}is-invalid{% endif %}"
for="{{ field.html_name }}_{{ forloop.counter }}_tr">
{{ choice.1 }}
</label>
{% endfor %}
</div>
{% if field.errors %}
<div class="invalid-feedback d-block">
{% for error in field.errors %}
{{ error }}
{% endfor %}
</div>
{% endif %}
{% if field.help_text %}
<small class="form-text text-muted">{{ field.help_text }}</small>
{% endif %}
</div>
@@ -0,0 +1,23 @@
{% load crispy_forms_field %}
<div class="btn-group w-100 mb-3"
role="group"
aria-label="{{ field.label }}"
_="on click
if no <input[type='checkbox']:checked/> in me
set nextCheckbox to the next <input[type='checkbox']/> from event.target within me with wrapping
call nextCheckbox.click()
end">
{% for choice in field.field.choices %}
<input type="checkbox"
class="btn-check"
name="{{ field.html_name }}"
id="{{ field.html_name }}_{{ forloop.counter }}"
value="{{ choice.0 }}"
{% if choice.0 in field.value %}checked{% endif %}>
<label class="btn btn-outline-dark"
for="{{ field.html_name }}_{{ forloop.counter }}">
{{ choice.1 }}
</label>
{% endfor %}
</div>