feat: first batch of work

This commit is contained in:
Herculino Trotta
2025-11-01 03:15:44 -03:00
parent e600d87968
commit a63367a772
175 changed files with 3433 additions and 2245 deletions
@@ -6,8 +6,8 @@
{% for x in transactions_by_date %}
<div id="{{ x.grouper|slugify }}" class="transactions-divider"
_="on htmx:afterSwap from #transactions if sessionStorage.getItem(my id) is null then sessionStorage.setItem(my id, 'true')">
<div class="tw:mt-3 tw:mb-1 tw:w-full tw:text-base tw:border-b tw:border-b-base-content/30 transactions-divider-title">
<a class="tw:no-underline tw:inline-block tw:w-full"
<div class="mt-3 mb-1 w-full text-base border-b border-b-base-content/30 transactions-divider-title">
<a class="no-underline inline-block w-full"
role="button"
data-bs-toggle="collapse"
data-bs-target="#c-{{ x.grouper|slugify }}-collapse"
@@ -17,7 +17,7 @@
{{ x.grouper }}
</a>
</div>
<div class="collapse transactions-divider-collapse" id="c-{{ x.grouper|slugify }}-collapse"
<div class="collapse transactions-divider-collapse overflow-visible" id="c-{{ x.grouper|slugify }}-collapse"
_="on shown.bs.collapse sessionStorage.setItem(the closest parent @id, 'true')
on hidden.bs.collapse sessionStorage.setItem(the closest parent @id, 'false')
on htmx:afterSettle from #transactions or toggle
@@ -32,7 +32,7 @@
on show
add .show to me
set @aria-expanded of #c-{{ x.grouper|slugify }}-collapsible to true">
<div class="tw:flex tw:flex-col">
<div class="flex flex-col">
{% for transaction in x.list %}
<c-transaction.item
:transaction="transaction"></c-transaction.item>
@@ -2,7 +2,7 @@
{% load i18n %}
{% load currency_display %}
<div class="tw:grid tw:grid-cols-1 tw:gap-4 tw:mt-1 tw:mb-3">
<div class="grid grid-cols-1 gap-4 mt-1 mb-3">
{% for account_id, account in account_data.items %}
<div>
<c-ui.account_card :account="account" :account_id="account_id"
@@ -1,7 +1,7 @@
{% load tools %}
{% load i18n %}
{% load currency_display %}
<div class="tw:grid tw:grid-cols-1 tw:gap-4 tw:mt-1 tw:mb-3">
<div class="grid grid-cols-1 gap-4 mt-1 mb-3">
{% for currency_id, currency in currency_data.items %}
<div>
<c-ui.currency_card :currency="currency" :currency_id="currency_id"
@@ -1,14 +1,14 @@
{% load i18n %}
{% load currency_display %}
<div class="tw:grid tw:grid-cols-1 tw:gap-4 tw:mt-1 tw:mb-3">
<div class="grid grid-cols-1 gap-4 mt-1 mb-3">
{# Daily Spending#}
<div>
<c-ui.info-card color="yellow" icon="fa-solid fa-calendar-day" title="{% trans 'Daily Spending Allowance' %}" help_text={% trans "This is the final total divided by the remaining days in the month" %}>
<div class="tw:flex tw:justify-between tw:mt-3">
<div class="tw:text-right tw:font-mono">
<div class="tw:text-gray-400">{% translate 'today' %}</div>
<div class="flex justify-between mt-3">
<div class="text-right font-mono">
<div class="text-base-content/90">{% translate 'today' %}</div>
</div>
<div class="tw:text-right tw:font-mono">
<div class="text-right font-mono">
{% for currency in daily_spending_allowance.values %}
<div>
<c-amount.display
@@ -37,11 +37,11 @@
{# Income#}
<div>
<c-ui.info-card color="green" icon="fa-solid fa-arrow-right-to-bracket" title="{% trans 'Income' %}">
<div class="tw:flex tw:justify-between tw:mt-3">
<div class="tw:text-right tw:font-mono">
<div class="tw:text-gray-400">{% translate 'current' %}</div>
<div class="flex justify-between mt-3">
<div class="text-right font-mono">
<div class="text-base-content/90">{% translate 'current' %}</div>
</div>
<div class="tw:text-right tw:font-mono">
<div class="text-right font-mono">
{% for currency in income_current.values %}
<div>
<c-amount.display
@@ -66,12 +66,11 @@
{% endfor %}
</div>
</div>
<hr class="tw:my-1">
<div class="tw:flex tw:justify-between">
<div class="tw:text-right tw:font-mono">
<div class="tw:text-gray-400">{% translate 'projected' %}</div>
<div class="flex justify-between">
<div class="text-right font-mono">
<div class="text-base-content/90">{% translate 'projected' %}</div>
</div>
<div class="tw:text-right tw:font-mono">
<div class="text-right font-mono">
{% for currency in income_projected.values %}
<div>
<c-amount.display
@@ -101,11 +100,11 @@
{# Expenses#}
<div>
<c-ui.info-card color="red" icon="fa-solid fa-arrow-right-from-bracket" title="{% trans 'Expenses' %}">
<div class="tw:flex tw:justify-between tw:mt-3">
<div class="tw:text-right tw:font-mono">
<div class="tw:text-gray-400">{% translate 'current' %}</div>
<div class="flex justify-between mt-3">
<div class="text-right font-mono">
<div class="text-base-content/90">{% translate 'current' %}</div>
</div>
<div class="tw:text-right tw:font-mono">
<div class="text-right font-mono">
{% for currency in expense_current.values %}
<div>
<c-amount.display
@@ -130,12 +129,11 @@
{% endfor %}
</div>
</div>
<hr class="tw:my-1">
<div class="tw:flex tw:justify-between">
<div class="tw:text-right tw:font-mono">
<div class="tw:text-gray-400">{% translate 'projected' %}</div>
<div class="flex justify-between">
<div class="text-right font-mono">
<div class="text-base-content/90">{% translate 'projected' %}</div>
</div>
<div class="tw:text-right tw:font-mono">
<div class="text-right font-mono">
{% for currency in expense_projected.values %}
<div>
<c-amount.display
@@ -165,11 +163,11 @@
{# Total#}
<div>
<c-ui.info-card color="blue" icon="fa-solid fa-scale-balanced" title="{% trans 'Total' %}">
<div class="tw:flex tw:justify-between tw:mt-3">
<div class="tw:text-right tw:font-mono">
<div class="tw:text-gray-400">{% translate 'current' %}</div>
<div class="flex justify-between mt-3">
<div class="text-right font-mono">
<div class="text-base-content/90">{% translate 'current' %}</div>
</div>
<div class="tw:text-right tw:font-mono">
<div class="text-right font-mono">
{% for currency in total_current.values %}
<div>
<c-amount.display
@@ -194,11 +192,11 @@
{% endfor %}
</div>
</div>
<div class="tw:flex tw:justify-between tw:mt-3">
<div class="tw:text-right tw:font-mono">
<div class="tw:text-gray-400">{% translate 'projected' %}</div>
<div class="flex justify-between mt-3">
<div class="text-right font-mono">
<div class="text-base-content/90">{% translate 'projected' %}</div>
</div>
<div class="tw:text-right tw:font-mono">
<div class="text-right font-mono">
{% for currency in total_projected.values %}
<div>
<c-amount.display
@@ -223,9 +221,9 @@
{% endfor %}
</div>
</div>
<hr class="tw:my-1">
<div class="tw:flex tw:justify-end">
<div class="tw:text-right tw:font-mono">
<hr class="my-1 hr">
<div class="flex justify-end">
<div class="text-right font-mono">
{% for currency in total_final.values %}
<div>
<c-amount.display
@@ -256,7 +254,7 @@
<div>
<c-ui.info-card color="yellow" icon="fa-solid fa-percent" title="{% trans 'Distribution' %}">
{% for p in percentages.values %}
<p class="tw:text-gray-400 tw:mb-2 {% if not forloop.first %}tw:mt-3{% endif %}">{{ p.currency.name }}</p>
<p class="text-base-content/90 {% if not forloop.first %}mt-3{% endif %}">{{ p.currency.name }}</p>
<c-ui.percentage-distribution :percentage="p"></c-ui.percentage-distribution>
{% endfor %}
</c-ui.info-card>
@@ -12,19 +12,18 @@
{% endblock %}
{% block content %}
<div class="tw:container tw:px-3 tw:md:px-3 tw:py-3 tw:gap-5">
<div class="tw:grid tw:grid-cols-1 tw:xl:grid-cols-12 tw:gap-x-4 tw:gap-y-3 tw:mb-4">
<div class="container px-3 md:px-3 py-3 gap-5">
<div class="grid grid-cols-1 xl:grid-cols-12 gap-x-4 gap-y-3 mb-4">
{# Date picker#}
<div class="tw:col-span-1 tw:xl:col-span-4 tw:flex tw:flex-row tw:items-center">
<div class="tw:text-base tw:h-full tw:flex tw:items-center">
<div class="col-span-1 xl:col-span-4 flex flex-row items-center">
<div class="text-base h-full flex items-center btn btn-ghost">
<a role="button"
class="tw:pe-4 tw:py-2"
hx-boost="true"
hx-trigger="click, previous_month from:window"
href="{% url 'monthly_overview' month=previous_month year=previous_year %}"><i
class="fa-solid fa-chevron-left"></i></a>
</div>
<div class="tw:text-3xl tw:font-bold tw:font-mono tw:w-full tw:text-center"
<div class="text-3xl font-bold btn btn-ghost w-full text-center"
hx-get="{% url 'month_year_picker' %}"
hx-target="#generic-offcanvas-left"
hx-trigger="click, date_picker from:window"
@@ -32,9 +31,8 @@
role="button">
{{ month|month_name }} {{ year }}
</div>
<div class="tw:text-base tw:mx-2 tw:h-full tw:flex tw:items-center">
<div class="text-base h-full flex items-center btn btn-ghost">
<a role="button"
class="tw:ps-3 tw:py-2"
hx-boost="true"
hx-trigger="click, next_month from:window"
href="{% url 'monthly_overview' month=next_month year=next_year %}">
@@ -51,15 +49,15 @@
{# </div>#}
</div>
{# Monthly summary#}
<div class="tw:grid tw:grid-cols-1 tw:xl:grid-cols-12 tw:gap-x-4 tw:gap-y-3">
<div class="tw:col-span-1 tw:xl:col-span-4 tw:order-0 tw:xl:order-2">
<div role="tablist" class="tw:tabs tw:tabs-border">
<input type="radio" name="monthly_summary_tabs" class="tw:tab" aria-label="{% trans 'Summary' %}"
<div class="grid grid-cols-1 xl:grid-cols-12 gap-x-4 gap-y-3">
<div class="col-span-1 xl:col-span-4 lg:order-last! order-first!">
<div role="tablist" class="tabs tabs-border">
<input type="radio" name="monthly_summary_tabs" class="tab" aria-label="{% trans 'Summary' %}"
role="tab"
{% if summary_tab == 'summary' or not summary_tab %}checked="checked"{% endif %}
_="on click fetch {% url 'monthly_summary_select' selected='summary' %}"
aria-controls="summary-tab-pane" />
<div class="tw:tab-content tw:bg-base-100" id="summary-tab-pane" role="tabpanel">
<div class="tab-content" id="summary-tab-pane" role="tabpanel">
<div id="summary"
hx-get="{% url 'monthly_summary' month=month year=year %}"
class="show-loading"
@@ -67,12 +65,12 @@
</div>
</div>
<input type="radio" name="monthly_summary_tabs" class="tw:tab" aria-label="{% trans 'Currencies' %}"
<input type="radio" name="monthly_summary_tabs" class="tab" aria-label="{% trans 'Currencies' %}"
role="tab"
{% if summary_tab == 'currency' %}checked="checked"{% endif %}
_="on click fetch {% url 'monthly_summary_select' selected='currency' %}"
aria-controls="currency-tab-pane" />
<div class="tw:tab-content tw:bg-base-100" id="currency-tab-pane" role="tabpanel">
<div class="tab-content" id="currency-tab-pane" role="tabpanel">
<div id="currency-summary"
hx-get="{% url 'monthly_currency_summary' month=month year=year %}"
class="show-loading"
@@ -80,12 +78,12 @@
</div>
</div>
<input type="radio" name="monthly_summary_tabs" class="tw:tab" aria-label="{% trans 'Accounts' %}"
<input type="radio" name="monthly_summary_tabs" class="tab" aria-label="{% trans 'Accounts' %}"
role="tab"
{% if summary_tab == 'account' %}checked="checked"{% endif %}
_="on click fetch {% url 'monthly_summary_select' selected='account' %}"
aria-controls="account-tab-pane" />
<div class="tw:tab-content tw:bg-base-100" id="account-tab-pane" role="tabpanel">
<div class="tab-content" id="account-tab-pane" role="tabpanel">
<div id="account-summary"
hx-get="{% url 'monthly_account_summary' month=month year=year %}"
class="show-loading"
@@ -95,7 +93,7 @@
</div>
</div>
<div class="tw:col-span-1 tw:xl:col-span-8 tw:order-2 tw:xl:order-1">
<div class="col-span-1 xl:col-span-8 lg:order-first! order-last!">
<div class="my-3">
{# Hidden select to hold the order value and preserve the original update trigger #}
@@ -106,9 +104,9 @@
</select>
{# Main control bar with filter, search, and ordering #}
<div class="tw:join tw:w-full">
<div class="join w-full">
<button class="tw:btn tw:btn-secondary tw:join-item tw:relative" type="button"
<button class="btn btn-secondary join-item relative" type="button"
data-bs-toggle="collapse" data-bs-target="#collapse-filter"
aria-expanded="false" aria-controls="collapse-filter" id="filter-button" hx-preserve
title="{% translate 'Filter transactions' %}">
@@ -116,10 +114,10 @@
</button>
{# Search box #}
<label for="quick-search" class="tw:hidden">
<label for="quick-search" class="hidden">
</label>
<input type="search"
class="tw:input tw:input-bordered tw:join-item tw:flex-1"
class="input input-bordered join-item flex-1"
placeholder="{% translate 'Search' %}"
hx-preserve
id="quick-search"
@@ -134,34 +132,34 @@
when its textContent.toLowerCase() contains my value.toLowerCase()">
{# Order by icon dropdown #}
<div class="tw:dropdown tw:dropdown-end">
<button tabindex="0" class="tw:btn tw:btn-secondary tw:join-item" type="button"
<div class="dropdown dropdown-end">
<button tabindex="0" class="btn btn-secondary join-item" type="button"
title="{% translate 'Order by' %}">
<i class="fa-solid fa-sort fa-fw"></i>
</button>
<ul tabindex="0" class="tw:dropdown-content tw:menu tw:bg-base-200 tw:rounded-box tw:z-[1] tw:w-52 tw:p-2 tw:shadow-md tw:mt-1">
<ul tabindex="0" class="dropdown-content menu bg-base-300 rounded-box z-[1] w-52 p-2 shadow-md mt-1">
<li>
<button class="{% if order == 'default' %}tw:menu-active{% endif %}" type="button"
_="on click remove .tw:menu-active from <li > button/> in the closest <ul/>
then add .tw:menu-active to me
<button class="{% if order == 'default' %}menu-active{% endif %}" type="button"
_="on click remove .menu-active from <li > button/> in the closest <ul/>
then add .menu-active to me
then set the value of #order to 'default'
then trigger change on #order">
{% translate 'Default' %}
</button>
</li>
<li>
<button class="{% if order == 'older' %}tw:menu-active{% endif %}" type="button"
_="on click remove .tw:menu-active from <li > button/> in the closest <ul/>
then add .tw:menu-active to me
<button class="{% if order == 'older' %}menu-active{% endif %}" type="button"
_="on click remove .menu-active from <li > button/> in the closest <ul/>
then add .menu-active to me
then set the value of #order to 'older'
then trigger change on #order">
{% translate 'Oldest first' %}
</button>
</li>
<li>
<button class="{% if order == 'newer' %}tw:menu-active{% endif %}" type="button"
_="on click remove .tw:menu-active from <li > button/> in the closest <ul/>
then add .tw:menu-active to me
<button class="{% if order == 'newer' %}menu-active{% endif %}" type="button"
_="on click remove .menu-active from <li > button/> in the closest <ul/>
then add .menu-active to me
then set the value of #order to 'newer'
then trigger change on #order">
{% translate 'Newest first' %}
@@ -172,22 +170,22 @@
</div>
{# Filter transactions form #}
<div class="collapse" id="collapse-filter" hx-preserve>
<div class="tw:card tw:card-body tw:bg-base-200 tw:mt-2">
<div class="tw:text-right">
<button class="tw:btn tw:btn-outline tw:btn-error tw:btn-sm tw:w-fit"
<div class="collapse overflow-visible" id="collapse-filter" hx-preserve>
<div class="card card-body bg-base-200 mt-2">
<div class="text-right">
<button class="btn btn-outline btn-error btn-sm w-fit"
_="on click call #filter.reset() then trigger change on #filter">{% translate 'Clear' %}</button>
</div>
<form _="on change or submit or search trigger updated on window
install init_tom_select
install init_datepicker"
id="filter" class="tw:mt-3">
id="filter" class="mt-3">
{% crispy filter.form %}
</form>
<div class="tw:text-right">
<button class="tw:btn tw:btn-outline tw:btn-error tw:btn-sm tw:w-fit"
<div class="text-right">
<button class="btn btn-outline btn-error btn-sm w-fit"
_="on click call #filter.reset() then trigger change on #filter">{% translate 'Clear' %}</button>
</div>
</div>