initial commit

This commit is contained in:
Herculino Trotta
2024-09-26 11:00:40 -03:00
parent 830e821a17
commit 50b0c6ce01
138 changed files with 13566 additions and 46 deletions

View File

@@ -0,0 +1,21 @@
{% load toast_bg %}
{% if messages %}
<div class="toast-container position-fixed top-0 start-50 translate-middle-x p-3">
{% for message in messages %}
<div class="toast align-items-center text-bg-{{ message.tags | toast_bg }} border-0"
role="alert"
aria-live="assertive"
aria-atomic="true">
<div class="toast-header">
<i class="{{ message.tags | toast_icon }} fa-fw me-1"></i>
<strong class="me-auto">{{ message.tags | toast_title }}</strong>
<button type="button"
class="btn-close"
data-bs-dismiss="toast"
aria-label="Fechar"></button>
</div>
<div class="toast-body">{{ message }}</div>
</div>
{% endfor %}
</div>
{% endif %}

View File

@@ -0,0 +1,9 @@
{% load webpack_loader %}
<div class="offcanvas-header">
<h5 class="offcanvas-title">{% block title %}{% endblock %}</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div id="generic-offcanvas-body" class="offcanvas-body">
{% block body %}{% endblock %}
</div>
{% javascript_pack 'select' %}

View File

@@ -0,0 +1,5 @@
<div id="generic-offcanvas" class="offcanvas offcanvas-end offcanvas-size-xl"
_="on htmx:afterSettle call bootstrap.Offcanvas.getOrCreateInstance(me).show() end
on hide_offcanvas call bootstrap.Offcanvas.getOrCreateInstance(me).hide() end
on hidden.bs.offcanvas set my innerHTML to '' end">
</div>

View File

@@ -0,0 +1,7 @@
{% load webpack_loader %}
{% javascript_pack 'bootstrap' %}
{% javascript_pack 'sweetalert2' %}
{% javascript_pack 'htmx' %}
{% javascript_pack 'jquery' %}
{#{% javascript_pack 'select' %}#}

View File

@@ -0,0 +1,4 @@
{% load webpack_loader %}
{% stylesheet_pack 'style' %}
{#{% stylesheet_pack 'select' %}#}

View File

@@ -0,0 +1,3 @@
<div id="toasts" hx-get="{% url 'toasts' %}"
hx-trigger="load, toast from:window">
</div>

View File

@@ -0,0 +1,26 @@
{% load webpack_loader %}
{% load tz_detect %}
<!doctype html>
<html lang="en" data-bs-theme="dark">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}WYGIWYH{% endblock %}</title>
{% include 'includes/styles.html' %}
{% block extra_styles %}{% endblock %}
{% tz_detect %}
</head>
<body>
<div id="content">
{% block content %}{% endblock %}
</div>
{% include 'includes/offcanvas.html' %}
{% include 'includes/toasts.html' %}
{% include 'includes/scripts.html' %}
{% block extra_js %}{% endblock %}
</body>
</html>

View File

@@ -0,0 +1,12 @@
{% extends 'extends/offcanvas.html' %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block title %}{% translate 'Adding transaction' %}{% endblock %}
{% block body %}
<form hx-post="{% url 'transaction_add' %}" hx-target="#generic-offcanvas" novalidate>
{% csrf_token %}
{% crispy form %}
</form>
{% endblock %}

View File

@@ -0,0 +1,12 @@
{% extends 'extends/offcanvas.html' %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block title %}{% translate 'Editing transaction' %}{% endblock %}
{% block body %}
<form hx-post="{% url 'transaction_edit' transaction_id=transaction.id %}" hx-target="#generic-offcanvas" novalidate>
{% csrf_token %}
{% crispy form %}
</form>
{% endblock %}

View File

@@ -1,38 +1,123 @@
<div class="row border-bottom border-top p-1 hover:tw-bg-zinc-900 font-monospace tw-text-sm transaction
{% if transaction.account.is_asset %}tw-opacity-70{% endif %}">
<div class="col-lg-auto col-6">
<input class="form-check-input" type="checkbox" id="checkboxNoLabel" value="" aria-label="...">
{% 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
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"
_="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">
<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">
<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">
{% 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">
<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>
{% endif %}
</div>
<a class="text-decoration-none"
role="button"
hx-get="{% url 'transaction_pay' transaction_id=transaction.id %}"
hx-target="closest .transaction"
hx-swap="outerHTML">
{% 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>
<a class="text-decoration-none text-secondary"
role="button"
hx-get="{% url 'transaction_edit' transaction_id=transaction.id %}"
hx-target="#generic-offcanvas"
data-bs-toggle="offcanvas"
data-bs-target="#generic-offcanvas">
<i class="fa-solid fa-pencil"></i>
</a>
</div>
<div class="col-lg-auto col-md-2 col-12 text-truncate">
{{ transaction.date|date:"SHORT_DATE_FORMAT" }}
</div>
<div class="col-lg-5 col-12 text-truncate" title="{{ transaction.description }}">
{{ transaction.description }}
</div>
<div class="col-lg-2 col-12 text-truncate">
{{ transaction.account.name }}
</div>
<div class="col-lg-auto col-md-2 col-12 {% if transaction.type == "EX" %}tw-text-red-400{% else %}tw-text-green-400{% endif %}
text-truncate">
{{ transaction.account.currency.prefix }}
{{ transaction.amount | floatformat:transaction.account.currency.decimal_places }}
{{ transaction.account.currency.suffix }}
</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>
<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">
<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 click
call Swal.fire({title: '{% translate 'Are you sure?' %}',
text: '{% blocktranslate %}You won\'t be able to revert this!{% endblocktranslate %}',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
cancelButtonText: '{% blocktranslate %}Cancel{% endblocktranslate %}',
confirmButtonText: '{% blocktranslate %}Yes, delete it!{% endblocktranslate %}',
customClass: {
confirmButton: 'btn btn-primary me-3',
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">
<i class="fa-solid fa-pencil fa-fw"></i></a>
</div>
<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"
aria-expanded="false">
<i class="fa-solid fa-ellipsis fa-fw"></i>
</a>
<ul class="dropdown-menu tw-text-base">
<li><a class="dropdown-item"
role="button"
hx-get="{% url 'transaction_edit' transaction_id=transaction.id %}"
hx-target="#generic-offcanvas">
<i class="fa-solid fa-pencil me-3"></i>{% translate "Edit" %}
</a></li>
<li><a class="dropdown-item"
role="button"
hx-get="{% url 'transaction_delete' transaction_id=transaction.id %}"
hx-trigger='confirmed'
_="on click
call Swal.fire({title: '{% translate 'Are you sure?' %}',
text: '{% blocktranslate %}You won\'t be able to revert this!{% endblocktranslate %}',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
cancelButtonText: '{% blocktranslate %}Cancel{% endblocktranslate %}',
confirmButtonText: '{% blocktranslate %}Yes, delete it!{% endblocktranslate %}',
customClass: {
confirmButton: 'btn btn-primary me-3',
cancelButton: 'btn btn-danger'
},
buttonsStyling: false})
if result.isConfirmed trigger confirmed">
<i class="fa-solid fa-trash me-3"></i>{% translate "Delete" %}
</a></li>
</ul>
</div>
</div>
</div>
</div>

View File

@@ -1,3 +1,5 @@
{% for trans in transactions %}
{% include 'transactions/fragments/item.html' with transaction=trans %}
{% endfor %}
<div class="">
{% for trans in transactions %}
{% include 'transactions/fragments/item.html' with transaction=trans %}
{% endfor %}
</div>

View File

@@ -0,0 +1,27 @@
{% extends 'extends/offcanvas.html' %}
{% load month_name %}
{% load i18n %}
{% block title %}{% translate 'Pick one' %}{% endblock %}
{% block body %}
<div class="form-floating mb-3">
<input type="search" class="form-control" id="floatingInput" placeholder="{% translate 'Search' %}"
_="on change or input
if the event's key is 'Escape'
set my value to ''
trigger keyup
else
show <li/> in #month-year-list when its textContent.toLowerCase() contains my value.toLowerCase()">
<label for="floatingInput">{% translate 'Search' %}</label>
</div>
<ul class="list-group list-group-flush" id="month-year-list">
{% for date in available_dates %}
<li class="list-group-item hover:tw-bg-zinc-900">
<a class="text-decoration-none stretched-link" href="{% url "transactions_overview" month=date.month year=date.year %}">
{{ date.month|month_name }} / {{ date.year }}
</a>
</li>
{% endfor %}
</ul>
{% endblock %}

View File

@@ -0,0 +1,123 @@
{% 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 "Presente" %}</p>
<div class="row">
<div class="col-6">
<div class="font-monospace text-primary text-start align-self-end fw-bold m-0">{% translate "Earned 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 "Projected" %}</p>
<div class="row">
<div class="col-6">
<div class="font-monospace text-primary text-start align-self-end fw-bold m-0">{% translate "Total Expenses" %}</div>
</div>
<div class="col-6 text-end font-monospace">
{% for entry in totals.paid_expense %}
<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_expense %}
<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 "Total" %}</p>
<div class="row">
<div class="col-6">
<div class="font-monospace text-primary text-start align-self-end fw-bold m-0">{% translate "Total Expenses" %}</div>
</div>
<div class="col-6 text-end font-monospace">
{% for entry in totals.paid_expense %}
<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_expense %}
<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 "Total Expenses" %}</div>
</div>
<div class="col-6 text-end font-monospace">
{% for entry in totals.paid_expense %}
<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 "Daily Spending Allowance" %}</div>
</div>
<div class="col-6 text-end font-monospace">
{% for entry in totals.projected_expense %}
<div>{% entry_amount entry %}</div>
{% empty %}
<div>-</div>
{% endfor %}
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,63 @@
{% 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">
<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" hx-get="{% url 'available_dates' %}" hx-target="#generic-offcanvas">
{{ 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>
</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 %}

View File

@@ -0,0 +1,16 @@
{% 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>