feat(splits): add split expenses for shared group costs

Track expenses shared with other people (trips, flats, dinners) and settle
up with the fewest payments.

- Events with WYGIWYH users and people without an account, who join through
  a share link and pick a password on first sign-in
- Equal, exact, percentage and share-weight splits that always add up
- Balances, a minimal settle-up plan and an activity feed showing what each
  item means for you
- Link items to your own transactions; recording a payment marks planned
  ones as paid
- Share menu: printable PDF report and PNG images of the summary, settle-up
  and balances (adds modern-screenshot)
- Only the two people involved or the organizer can record a payment;
  members can leave events they don't organize
This commit is contained in:
Herculino Trotta committed 2026-11-20 19:43:23 -03:00
1 parent f558d52ac6
commit 77bf2d7bdb
47 files changed
+5612

No files matched your search

+6
View File
@@ -126,6 +126,12 @@
active="dca_strategy_index||dca_strategy_detail_index"
icon="fa-solid fa-magnifying-glass-chart">
</c-components.sidebar-menu-item>
<c-components.sidebar-menu-item
title="{% translate 'Split Expenses' %}"
url='split_event_index'
active="split_event_index||split_event_detail"
icon="fa-solid fa-people-arrows">
</c-components.sidebar-menu-item>
<c-components.sidebar-menu-item
title="{% translate 'Unit Price Calculator' %}"
url='unit_price_calculator'
@@ -0,0 +1,27 @@
{% load i18n %}
{% load split_urls %}
{% if item and item.attachments.all %}
<div class="flex flex-wrap gap-2 mb-3">
{% for att in item.attachments.all %}
<span class="badge badge-outline gap-1">
<a href="{% split_portal_url urls 'attachment_download_name' attachment_id=att.id %}"
target="_blank" rel="noopener" class="no-underline hover:underline">
<i class="fa-solid fa-paperclip fa-fw"></i>{{ att.original_name }}
</a>
<button type="button"
class="text-error cursor-pointer"
aria-label="{% translate 'Delete' %}"
hx-delete="{% split_portal_url urls 'attachment_delete_name' attachment_id=att.id %}"
hx-trigger="confirmed"
hx-swap="none"
data-title="{% translate 'Are you sure?' %}"
data-text="{% translate "You won't be able to revert this!" %}"
data-confirm-text="{% translate 'Yes, delete it!' %}"
_="install prompt_swal
on htmx:afterRequest[detail.successful] remove closest .badge">
<i class="fa-solid fa-xmark fa-fw"></i>
</button>
</span>
{% endfor %}
</div>
{% endif %}
@@ -0,0 +1 @@
{% load i18n %}{% if item.attachments.all %}<i class="fa-solid fa-paperclip text-xs text-base-content/40 ms-1.5" aria-label="{% translate 'Has attachments' %}"></i>{% endif %}{% if item.user_tx_links %}<i class="fa-solid fa-link text-xs text-base-content/40 ms-1.5" aria-label="{% translate 'Linked to your transactions' %}"></i>{% endif %}
@@ -0,0 +1,114 @@
{% load i18n %}
{% load split_urls %}
<li>
<details name="split-activity" class="group">
<summary class="list-none [&::-webkit-details-marker]:hidden flex items-center gap-3 px-2 py-2.5 rounded-box cursor-pointer
hover:bg-base-content/5 transition-colors duration-150
focus-visible:outline-2 focus-visible:outline-primary">
<div class="w-10 shrink-0 text-center leading-tight {% if item.is_payment %}text-base-content/50{% endif %}">
<div class="text-xs uppercase text-base-content/50">{{ item.date|date:"M" }}</div>
<div class="text-lg font-semibold tabular-nums">{{ item.date|date:"j" }}</div>
</div>
<div class="min-w-0 flex-1">
{% if item.is_payment %}
<div class="line-clamp-2 wrap-anywhere">
<i class="fa-solid fa-hand-holding-dollar text-success me-1"></i>
{% if item.from_participant_id == me_id %}{% blocktranslate with to=item.to_participant.name %}You paid {{ to }}{% endblocktranslate %}
{% elif item.to_participant_id == me_id %}{% blocktranslate with from=item.from_participant.name %}{{ from }} paid you{% endblocktranslate %}
{% else %}{% blocktranslate with from=item.from_participant.name to=item.to_participant.name %}{{ from }} paid {{ to }}{% endblocktranslate %}{% endif %}
{% include 'splits/fragments/event/activity_flags.html' %}
</div>
{% if item.notes %}<div class="text-xs text-base-content/50 truncate">{{ item.notes }}</div>{% endif %}
{% else %}
<div class="truncate font-medium">{{ item.description }}{% include 'splits/fragments/event/activity_flags.html' %}</div>
<div class="text-xs text-base-content/50 truncate tabular-nums">
{% if item.paid_by_id == me_id %}{% translate 'You paid' %}{% else %}{% blocktranslate with name=item.paid_by.name %}{{ name }} paid{% endblocktranslate %}{% endif %}
<c-amount.display :amount="item.amount" :prefix="event.currency.prefix" :suffix="event.currency.suffix" :decimal_places="event.currency.decimal_places" divless></c-amount.display>
</div>
{% endif %}
</div>
<div class="shrink-0 text-end text-sm tabular-nums">
{% if item.is_payment %}
<c-amount.display :amount="item.amount" :prefix="event.currency.prefix" :suffix="event.currency.suffix" :decimal_places="event.currency.decimal_places" divless></c-amount.display>
{% elif item.my_delta is None %}
<div class="text-xs text-base-content/40">{% translate 'not involved' %}</div>
{% elif item.my_delta > 0 %}
<div class="text-xs text-base-content/50">{% translate 'you lent' %}</div>
<c-amount.display :amount="item.my_delta_abs" :prefix="event.currency.prefix" :suffix="event.currency.suffix" :decimal_places="event.currency.decimal_places" color="green" divless></c-amount.display>
{% elif item.my_delta < 0 %}
<div class="text-xs text-base-content/50">{% translate 'you borrowed' %}</div>
<c-amount.display :amount="item.my_delta_abs" :prefix="event.currency.prefix" :suffix="event.currency.suffix" :decimal_places="event.currency.decimal_places" color="red" divless></c-amount.display>
{% else %}
<div class="text-xs text-base-content/40">{% translate 'settled' %}</div>
{% endif %}
</div>
<div class="w-4 shrink-0 text-xs text-base-content/40">
<i class="fa-solid fa-chevron-down transition-[rotate] duration-200 ease-[cubic-bezier(0.23,1,0.32,1)] group-open:rotate-180"></i>
</div>
</summary>
<div class="ms-15 me-2 mb-3 flex flex-col gap-3 text-sm
transition-[opacity,translate] duration-200 ease-[cubic-bezier(0.23,1,0.32,1)]
starting:opacity-0 motion-safe:starting:-translate-y-1">
{% if not item.is_payment %}
<dl class="flex flex-col divide-y divide-base-content/10 tabular-nums">
{% for s in item.shares.all %}
<div class="flex justify-between gap-4 py-1.5">
<dt class="text-base-content/60 min-w-0 truncate">{% if s.participant_id == me_id %}{% translate 'You' %}{% else %}{{ s.participant.name }}{% endif %}</dt>
<dd class="whitespace-nowrap"><c-amount.display :amount="s.amount" :prefix="event.currency.prefix" :suffix="event.currency.suffix" :decimal_places="event.currency.decimal_places" divless></c-amount.display></dd>
</div>
{% endfor %}
</dl>
{% if item.split_type != 'EQUAL' %}
<div class="text-xs text-base-content/50 -mt-2">{% blocktranslate with mode=item.get_split_type_display %}Split by {{ mode }}{% endblocktranslate %}</div>
{% endif %}
{% endif %}
{% if item.notes %}<p class="text-base-content/70 whitespace-pre-line text-pretty">{{ item.notes }}</p>{% endif %}
{% if item.attachments.all or item.user_tx_links %}
<div class="flex flex-wrap gap-1">
{% for att in item.attachments.all %}
<a href="{% split_portal_url urls 'attachment_download_name' attachment_id=att.id %}"
target="_blank" rel="noopener" class="badge badge-sm badge-outline no-underline">
<i class="fa-solid fa-paperclip"></i>{{ att.original_name }}
</a>
{% endfor %}
{% include 'splits/fragments/tx_links.html' with links=item.user_tx_links %}
</div>
{% endif %}
{% if item.can_sync or item.can_edit %}
<div class="flex flex-wrap gap-1 -ms-3">
{% if item.can_sync %}
<button type="button" class="btn btn-ghost btn-sm"
hx-get="{% if item.is_payment %}{% url 'split_sync_payment' event_id=event.id payment_id=item.id %}{% else %}{% url 'split_sync_expense' event_id=event.id expense_id=item.id %}{% endif %}"
hx-target="#generic-offcanvas">
<i class="fa-solid fa-wallet"></i>{% translate 'Add to my transactions' %}
</button>
{% endif %}
{% if item.can_edit %}
<button type="button" class="btn btn-ghost btn-sm"
hx-get="{% if item.is_payment %}{% split_portal_url urls 'payment_edit_name' payment_id=item.id %}{% else %}{% split_portal_url urls 'expense_edit_name' expense_id=item.id %}{% endif %}"
hx-target="#generic-offcanvas">
<i class="fa-solid fa-pencil"></i>{% translate 'Edit' %}
</button>
<button type="button" class="btn btn-ghost btn-sm text-error"
hx-delete="{% if item.is_payment %}{% split_portal_url urls 'payment_delete_name' payment_id=item.id %}{% else %}{% split_portal_url urls 'expense_delete_name' expense_id=item.id %}{% endif %}"
hx-trigger="confirmed"
data-bypass-on-ctrl="true"
data-title="{% translate 'Are you sure?' %}"
data-text="{% translate "You won't be able to revert this!" %}"
data-confirm-text="{% translate 'Yes, delete it!' %}"
_="install prompt_swal">
<i class="fa-solid fa-trash"></i>{% translate 'Delete' %}
</button>
{% endif %}
</div>
{% endif %}
</div>
</details>
</li>
@@ -0,0 +1,11 @@
{% extends 'extends/offcanvas.html' %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block title %}{% translate 'Add event' %}{% endblock %}
{% block body %}
<form hx-post="{% url 'split_event_add' %}" hx-target="#generic-offcanvas" novalidate>
{% crispy form %}
</form>
{% endblock %}
@@ -0,0 +1,188 @@
{% load i18n %}
{% load l10n %}
{% with c=event.currency %}
<c-components.fab>
<c-components.fab_menu_button
color="error" hx_target="#generic-offcanvas" hx_trigger="click"
url="{{ urls.expense_add }}"
icon="fa-solid fa-receipt"
title="{% translate 'Expense' %}"></c-components.fab_menu_button>
<c-components.fab_menu_button
color="success" hx_target="#generic-offcanvas" hx_trigger="click"
url="{{ urls.payment_add }}"
icon="fa-solid fa-hand-holding-dollar"
title="{% translate 'Payment' %}"></c-components.fab_menu_button>
</c-components.fab>
<div class="container pb-20">
<div class="flex items-center gap-2 mb-1">
{% if not actor.is_external_portal %}
<a href="{% url 'split_event_index' %}" hx-boost="true"
class="btn btn-ghost btn-sm btn-square text-base-content/50 hover:text-base-content"
aria-label="{% translate 'Split Expenses' %}"><i class="fa-solid fa-arrow-left"></i></a>
{% endif %}
<h1 class="text-2xl font-bold truncate text-balance">{{ event.name }}</h1>
{% if event.is_archived %}<span class="badge badge-warning badge-sm">{% translate 'Archived' %}</span>{% endif %}
{% if actor.is_creator %}
<button class="btn btn-ghost btn-sm btn-square text-base-content/40 hover:text-base-content"
data-tippy-content="{% translate 'People' %}" aria-label="{% translate 'People' %}"
hx-get="{% url 'split_participants_manage' event_id=event.id %}" hx-target="#generic-offcanvas">
<i class="fa-solid fa-user-group"></i>
</button>
<button class="btn btn-ghost btn-sm btn-square text-base-content/40 hover:text-base-content"
data-tippy-content="{% translate 'Edit event' %}" aria-label="{% translate 'Edit event' %}"
hx-get="{% url 'split_event_edit' event_id=event.id %}" hx-target="#generic-offcanvas">
<i class="fa-solid fa-pencil"></i>
</button>
{% elif actor.is_wygiwyh_user %}
<button class="btn btn-ghost btn-sm btn-square text-base-content/40 hover:text-error"
data-tippy-content="{% translate 'Leave event' %}" aria-label="{% translate 'Leave event' %}"
hx-post="{% url 'split_event_leave' event_id=event.id %}"
hx-trigger="confirmed"
data-title="{% translate 'Leave this event?' %}"
data-text="{% translate 'It disappears from your list. Expenses and payments you were part of stay, so the others still see correct balances.' %}"
data-confirm-text="{% translate 'Leave' %}"
_="install prompt_swal">
<i class="fa-solid fa-right-from-bracket"></i>
</button>
{% endif %}
{% include 'splits/fragments/event/share_menu.html' %}
</div>
<div class="text-sm text-base-content/50 mb-6 {% if not actor.is_external_portal %}ps-10{% endif %}">
{% blocktranslate count counter=active_participants_count %}{{ counter }} person{% plural %}{{ counter }} people{% endblocktranslate %}
{% if event.description %}<div class="text-pretty whitespace-pre-line mt-1">{{ event.description }}</div>{% endif %}
</div>
<div class="hidden" data-export="header">
<div class="text-2xl font-bold text-balance">{{ event.name }}</div>
<div class="text-sm text-base-content/60 tabular-nums">
{% blocktranslate count counter=active_participants_count %}{{ counter }} person{% plural %}{{ counter }} people{% endblocktranslate %}
· {% translate 'Group total' %} <c-amount.display :amount="total_spent" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>
</div>
</div>
{# The one number people open this page for #}
{% if my_balance %}
<div class="card bg-base-100 card-border shadow mb-4">
<div class="card-body p-5 flex-row flex-wrap items-end justify-between gap-4">
<div>
{% if not my_balance.net_balance %}
<div class="text-2xl font-bold"><i class="fa-solid fa-circle-check text-success me-2"></i>{% if transfers %}{% translate 'You are settled up' %}{% else %}{% translate 'Everyone is settled up' %}{% endif %}</div>
{% else %}
<div class="text-sm text-base-content/60">
{% if my_balance.net_balance > 0 %}{% translate 'You are owed' %}{% else %}{% translate 'You owe' %}{% endif %}
</div>
<div class="text-3xl sm:text-4xl font-bold tabular-nums tracking-tight whitespace-nowrap">
{# Show the magnitude; the sentence above carries the direction #}
<c-amount.display :amount="my_balance_abs" :prefix="c.prefix" :suffix="c.suffix"
:decimal_places="c.decimal_places" color="{% if my_balance.net_balance > 0 %}green{% elif my_balance.net_balance < 0 %}red{% endif %}" divless></c-amount.display>
</div>
{% endif %}
</div>
<div class="text-sm sm:text-end tabular-nums">
<div class="text-base-content/60">{% translate 'Group total' %}</div>
<c-amount.display :amount="total_spent" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>
</div>
</div>
</div>
{% endif %}
<div class="grid grid-cols-1 lg:grid-cols-3 gap-4">
<div class="flex flex-col gap-4">
{% if transfers %}
<div class="card bg-base-100 card-border shadow" data-export="settle">
<div class="px-5 pt-4 pb-1 font-semibold">{% translate 'Settle up' %}</div>
<ul class="px-5 pb-3 flex flex-col divide-y divide-base-content/10 text-sm">
{% for item in transfers %}{% with t=item.transfer %}
<li class="py-3 flex flex-col gap-2">
<div class="flex items-baseline justify-between gap-3">
<span class="min-w-0">
<span class="font-medium" data-export-name="{{ t.from_participant.name }}">{% if t.from_participant.id == me_id %}{% translate 'You' %}{% else %}{{ t.from_participant.name }}{% endif %}</span>
<i class="fa-solid fa-arrow-right text-xs text-base-content/40 mx-1"></i>
<span class="font-medium" data-export-name="{{ t.to_participant.name }}">{% if t.to_participant.id == me_id %}{% translate 'You' %}{% else %}{{ t.to_participant.name }}{% endif %}</span>
</span>
<span class="tabular-nums whitespace-nowrap font-semibold">
<c-amount.display :amount="t.amount" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>
</span>
</div>
{% if item.tx_links %}
<div class="flex flex-wrap gap-1" data-export-hide>{% include 'splits/fragments/tx_links.html' with links=item.tx_links %}</div>
{% endif %}
{% if item.can_record or item.user_direction %}
<div class="flex gap-2" data-export-hide>
{% if item.can_record %}
<button type="button" class="btn btn-sm btn-soft btn-success flex-1"
hx-get="{{ urls.payment_add }}?from={{ t.from_participant.id }}&to={{ t.to_participant.id }}&amount={{ t.amount|unlocalize }}"
hx-target="#generic-offcanvas">
<i class="fa-solid fa-check"></i>{% translate 'Record as paid' %}
</button>
{% endif %}
{% if item.user_direction %}
<button type="button" class="btn btn-sm btn-ghost btn-square"
data-tippy-content="{% if item.user_direction == 'out' %}{% translate 'Add as planned expense in my transactions' %}{% else %}{% translate 'Add as expected income in my transactions' %}{% endif %}"
aria-label="{% translate 'Add to my transactions' %}"
hx-get="{% url 'split_sync_settlement' event_id=event.id %}?direction={{ item.user_direction }}&counterparty={{ item.counterparty.id }}&amount={{ t.amount|unlocalize }}"
hx-target="#generic-offcanvas">
<i class="fa-solid fa-wallet"></i>
</button>
{% endif %}
</div>
{% endif %}
</li>
{% endwith %}{% endfor %}
</ul>
</div>
{% endif %}
<div class="card bg-base-100 card-border shadow" data-export="balances">
<div class="px-5 pt-4 pb-1 font-semibold">{% translate 'Balances' %}</div>
<ul class="px-5 pb-3 flex flex-col divide-y divide-base-content/10 text-sm">
{% for row in balance_rows %}{% with b=row.balance %}
<li class="py-2.5 {% if not b.participant.is_active %}opacity-50{% endif %}">
<div class="flex items-baseline justify-between gap-3">
<span class="min-w-0 truncate">
{{ b.participant.name }}
{% if b.participant.id == me_id %}<span class="badge badge-xs badge-primary align-middle" data-export-hide>{% translate 'you' %}</span>{% endif %}
{% if not b.participant.is_active %}<span class="badge badge-xs badge-ghost align-middle">{% translate 'inactive' %}</span>{% endif %}
</span>
<span class="tabular-nums whitespace-nowrap">
<c-amount.display :amount="b.net_balance" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" color="auto" divless></c-amount.display>
</span>
</div>
{# Diverging bar: right of center is owed money, left owes #}
<div class="relative h-1 mt-1.5 rounded-full bg-base-content/10" aria-hidden="true">
<div class="absolute inset-y-0 left-1/2 w-px bg-base-content/20"></div>
{% if row.bar %}
<div class="absolute inset-y-0 rounded-full {% if b.net_balance > 0 %}left-1/2 bg-success{% else %}right-1/2 bg-error{% endif %}"
style="width: {{ row.bar }}%"></div>
{% endif %}
</div>
<div class="text-xs text-base-content/50 tabular-nums mt-1">
{% translate 'paid' %} <c-amount.display :amount="b.total_paid" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>
· {% translate 'share' %} <c-amount.display :amount="b.total_owed" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>
</div>
</li>
{% endwith %}{% endfor %}
</ul>
</div>
</div>
<div class="lg:col-span-2">
<div class="card bg-base-100 card-border shadow">
<div class="px-5 pt-4 pb-1 font-semibold">{% translate 'Activity' %}</div>
{% if activity %}
<ul class="px-3 pb-2 flex flex-col">
{% for item in activity %}
{% include 'splits/fragments/event/activity_item.html' %}
{% endfor %}
</ul>
{% else %}
<c-msg.empty icon="fa-solid fa-receipt"
title="{% translate 'Nothing here yet' %}"
subtitle="{% translate 'Add the first expense with the + button' %}"></c-msg.empty>
{% endif %}
</div>
</div>
</div>
</div>
{% endwith %}
@@ -0,0 +1,23 @@
{% extends 'extends/offcanvas.html' %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block title %}{% translate 'Edit event' %}{% endblock %}
{% block body %}
<form hx-post="{% url 'split_event_edit' event_id=event.id %}" hx-target="#generic-offcanvas" novalidate>
{% crispy form %}
</form>
<div class="divider"></div>
<button type="button"
class="btn btn-error btn-outline w-full"
hx-delete="{% url 'split_event_delete' event_id=event.id %}"
hx-trigger="confirmed"
data-title="{% translate 'Delete this event?' %}"
data-text="{% translate 'All its expenses, payments and attachments are deleted. Transactions you linked in your accounts are kept.' %}"
data-confirm-text="{% translate 'Yes, delete it!' %}"
_="install prompt_swal">
<i class="fa-solid fa-trash fa-fw"></i>{% translate 'Delete event' %}
</button>
{% endblock %}
@@ -0,0 +1,58 @@
{% load i18n %}
<script>
// Renders tagged sections ([data-export]) into one phone-width PNG, then shares (touch devices) or downloads it
async function splitExportImage(button) {
if (button.disabled) return;
button.disabled = true;
document.activeElement?.blur(); // closes the daisyUI dropdown
const card = document.createElement('div');
card.className = 'bg-base-200 text-base-content font-mono p-6 flex flex-col gap-4';
// Off-screen but laid out, so it renders at a fixed phone-friendly width
card.style.cssText = 'position: fixed; left: -10000px; top: 0; width: 480px;';
for (const name of ['header', ...button.dataset.sections.split(',')]) {
const source = document.querySelector(`[data-export="${name}"]`);
if (!source) continue;
const clone = source.cloneNode(true);
clone.classList.remove('hidden', 'shadow');
clone.querySelectorAll('[data-export-hide]').forEach((el) => el.remove());
clone.querySelectorAll('[data-export-name]').forEach((el) => (el.textContent = el.dataset.exportName));
// Font Awesome 7's `content: "…" / ""` alt syntax renders a stray "/" in the capture
clone.querySelectorAll('.fa-arrow-right').forEach((el) => el.replaceWith(' → '));
card.append(clone);
}
const footer = document.createElement('div');
footer.className = 'text-xs text-base-content/40 text-end';
footer.textContent = 'WYGIWYH';
card.append(footer);
document.body.append(card);
try {
const blob = await window.domToBlob(card, {
scale: 2,
backgroundColor: getComputedStyle(card).backgroundColor,
});
const file = new File([blob], button.dataset.filename, {type: 'image/png'});
if (matchMedia('(pointer: coarse)').matches && navigator.canShare?.({files: [file]})) {
try {
await navigator.share({files: [file]});
return;
} catch (e) {
if (e.name === 'AbortError') return;
}
}
const link = document.createElement('a');
link.href = URL.createObjectURL(file);
link.download = file.name;
link.click();
setTimeout(() => URL.revokeObjectURL(link.href), 1000);
} catch (e) {
console.error(e);
Swal.fire({icon: 'error', text: "{% translate "Couldn't create the image." %}"});
} finally {
card.remove();
button.disabled = false;
}
}
</script>
@@ -0,0 +1,71 @@
{% load i18n %}
<c-ui.fab-single-action
url="{% url 'split_event_add' %}"
hx_target="#generic-offcanvas">
</c-ui.fab-single-action>
<div class="container">
<div class="flex flex-wrap justify-between items-center gap-3 mb-3">
<div class="text-3xl font-bold font-mono">{% translate 'Split Expenses' %}</div>
<label class="label cursor-pointer text-sm">
<input type="checkbox" class="toggle toggle-sm"
{% if show_archived %}checked{% endif %}
hx-get="{% url 'split_event_list' %}{% if not show_archived %}?archived=1{% endif %}"
hx-target="closest .show-loading"
hx-trigger="change">
{% translate 'Show archived' %}
</label>
</div>
{% if not event_cards %}
<c-msg.empty
icon="fa-solid fa-people-arrows"
title="{% translate 'No events yet' %}"
subtitle="{% translate 'Create one for a trip, a shared flat or a dinner' %}"></c-msg.empty>
{% else %}
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3">
{% for card in event_cards %}
<a href="{% url 'split_event_detail' event_id=card.event.id %}" hx-boost="true"
class="card bg-base-100 card-border shadow no-underline hover:shadow-lg transition-shadow">
<div class="card-body">
<div class="flex justify-between items-start gap-2">
<div class="card-title text-xl min-w-0"><span class="truncate">{{ card.event.name }}</span></div>
<div class="flex gap-1 shrink-0">
{% if card.event.is_archived %}<span class="badge badge-warning">{% translate 'Archived' %}</span>{% endif %}
<span class="badge badge-secondary rounded-full">{{ card.event.currency.code }}</span>
</div>
</div>
{% if card.event.description %}
<div class="text-base-content/60 line-clamp-2">{{ card.event.description }}</div>
{% endif %}
<div class="grid grid-cols-2 gap-2 mt-2">
<div>
<div class="text-sm text-base-content/60">{% translate 'Total spent' %}</div>
<c-amount.display
:amount="card.total_spent"
:prefix="card.event.currency.prefix"
:suffix="card.event.currency.suffix"
:decimal_places="card.event.currency.decimal_places"></c-amount.display>
</div>
{% if card.my_balance %}
<div class="text-right">
<div class="text-sm text-base-content/60">{% translate 'Your balance' %}</div>
<c-amount.display
:amount="card.my_balance.net_balance"
:prefix="card.event.currency.prefix"
:suffix="card.event.currency.suffix"
:decimal_places="card.event.currency.decimal_places"
color="auto"></c-amount.display>
</div>
{% endif %}
</div>
<div class="text-sm text-base-content/60 mt-2">
<i class="fa-solid fa-users fa-fw"></i>
{% blocktranslate count counter=card.participant_count %}{{ counter }} person{% plural %}{{ counter }} people{% endblocktranslate %}
{% if card.is_creator %}· {% translate 'Organizer' %}{% endif %}
</div>
</div>
</a>
{% endfor %}
</div>
{% endif %}
</div>
@@ -0,0 +1,34 @@
{% load i18n %}
<div class="dropdown dropdown-end ms-auto shrink-0">
<div tabindex="0" role="button" class="btn btn-ghost btn-sm">
<i class="fa-solid fa-arrow-up-from-bracket"></i><span class="hidden sm:inline">{% translate 'Share' %}</span>
</div>
<ul tabindex="-1" class="dropdown-content menu bg-base-100 rounded-box z-10 w-60 p-2 shadow-lg mt-1">
<li>
<a href="{{ urls.report }}" target="_blank" rel="noopener" class="no-underline">
<i class="fa-solid fa-file-pdf fa-fw"></i>{% translate 'Full report (PDF)' %}
</a>
</li>
<li class="menu-title">{% translate 'Image' %}</li>
<li>
<button type="button" onclick="splitExportImage(this)"
data-sections="{% if transfers %}settle,{% endif %}balances" data-filename="{{ event.name|slugify }}-summary.png">
<i class="fa-solid fa-image fa-fw"></i>{% translate 'Summary' %}
</button>
</li>
{% if transfers %}
<li>
<button type="button" onclick="splitExportImage(this)"
data-sections="settle" data-filename="{{ event.name|slugify }}-settle-up.png">
<i class="fa-solid fa-arrow-right-arrow-left fa-fw"></i>{% translate 'Settle up' %}
</button>
</li>
{% endif %}
<li>
<button type="button" onclick="splitExportImage(this)"
data-sections="balances" data-filename="{{ event.name|slugify }}-balances.png">
<i class="fa-solid fa-scale-balanced fa-fw"></i>{% translate 'Balances' %}
</button>
</li>
</ul>
</div>
@@ -0,0 +1,87 @@
{% extends 'extends/offcanvas.html' %}
{% load i18n %}
{% load crispy_forms_filters %}
{% block title %}
{% if expense %}{% translate 'Edit expense' %}{% else %}{% translate 'Add expense' %}{% endif %}
{% endblock %}
{% block body %}
<form hx-post="{{ post_url }}"
hx-target="#generic-offcanvas"
hx-encoding="multipart/form-data"
novalidate>
{% if form.non_field_errors %}
<div class="alert alert-error mb-3">{{ form.non_field_errors }}</div>
{% endif %}
{{ form.description|as_crispy_field }}
<div class="grid grid-cols-1 sm:grid-cols-2 gap-x-3">
{{ form.amount|as_crispy_field }}
{{ form.date|as_crispy_field }}
{{ form.paid_by|as_crispy_field }}
{{ form.split_type|as_crispy_field }}
</div>
<fieldset class="fieldset my-3">
<legend class="fieldset-legend">{% translate 'Split between' %}</legend>
<div class="flex flex-col gap-2">
{% for row in participant_rows %}
<div class="flex items-center justify-between gap-2">
<label class="label cursor-pointer flex-1 text-base-content">
<input type="checkbox"
name="share_participants"
value="{{ row.participant.id }}"
class="checkbox checkbox-sm"
{% if row.selected %}checked{% endif %} />
{{ row.participant.name }}
</label>
<input type="number"
step="any"
min="0"
inputmode="decimal"
name="share_value_{{ row.participant.id }}"
value="{{ row.value }}"
aria-label="{{ row.participant.name }}"
class="input input-sm w-32 split-value-input" />
</div>
{% endfor %}
</div>
<p class="label" id="split-mode-hint"></p>
</fieldset>
{{ form.notes|as_crispy_field }}
{{ form.attachments|as_crispy_field }}
{% include 'splits/fragments/attachments_existing.html' with item=expense %}
<button type="submit" class="btn btn-primary w-full mt-3">
{% if expense %}{% translate 'Update' %}{% else %}{% translate 'Add' %}{% endif %}
</button>
</form>
<script>
(function () {
const modeSelect = document.getElementById('id_split_type');
const hint = document.getElementById('split-mode-hint');
const hints = {
EQUAL: "{% translate 'Divided equally between the people checked' %}",
EXACT: "{% translate 'Amounts must add up to the total' %}",
PERCENTAGE: "{% translate 'Percentages must add up to 100' %}",
SHARES: "{% translate 'Weights, e.g. 2 pays twice as much as 1' %}",
};
const placeholders = {EXACT: "{{ event.currency.code }}", PERCENTAGE: "%", SHARES: "×"};
function update() {
const mode = modeSelect.value;
hint.textContent = hints[mode] || '';
document.querySelectorAll('.split-value-input').forEach((inp) => {
inp.classList.toggle('hidden', mode === 'EQUAL');
inp.placeholder = placeholders[mode] || '';
});
}
modeSelect.addEventListener('change', update);
update();
})();
</script>
{% endblock %}
@@ -0,0 +1,141 @@
{% extends 'extends/offcanvas.html' %}
{% load i18n %}
{% block title %}{% translate 'People' %}{% endblock %}
{% block body %}
<fieldset class="fieldset">
<legend class="fieldset-legend">{% translate 'Share link' %}</legend>
{% if event.allow_external_access %}
<div class="join w-full">
<input type="text" id="split-share-url-input" class="input join-item w-full" value="{{ share_url }}" readonly
aria-label="{% translate 'Share link' %}" />
{# navigator.clipboard needs HTTPS; self-hosted instances often run on plain HTTP #}
<button type="button" class="btn btn-primary join-item"
onclick="const i = document.getElementById('split-share-url-input'), b = this;
const done = () => { b.innerText = '{% translate "Copied!" %}'; setTimeout(() => b.innerText = '{% translate "Copy" %}', 1500); };
if (navigator.clipboard && window.isSecureContext) navigator.clipboard.writeText(i.value).then(done);
else { i.select(); document.execCommand('copy'); done(); }">{% translate 'Copy' %}</button>
</div>
<p class="label whitespace-normal">
{% translate 'People without an account open this link, pick their name and set a password the first time.' %}
</p>
<div>
<button type="button" class="btn btn-ghost btn-sm text-warning"
hx-post="{% url 'split_event_regenerate_link' event_id=event.id %}"
hx-target="#generic-offcanvas"
hx-trigger="confirmed"
data-title="{% translate 'Regenerate share link?' %}"
data-text="{% translate 'The current link stops working and everyone signed in through it is signed out.' %}"
data-confirm-text="{% translate 'Regenerate' %}"
_="install prompt_swal">
<i class="fa-solid fa-rotate fa-fw"></i>{% translate 'Regenerate link' %}
</button>
</div>
{% else %}
<p class="text-sm text-base-content/70">
{% translate 'Link sharing is off. Turn on "Allow external access" in the event settings to share it.' %}
</p>
{% endif %}
</fieldset>
<fieldset class="fieldset">
<legend class="fieldset-legend">{% translate 'Add person without an account' %}</legend>
<form hx-post="{% url 'split_participant_add_external' event_id=event.id %}" hx-target="#generic-offcanvas"
class="join w-full">
<input type="text" name="name" value="{{ external_form.name.value|default:'' }}"
placeholder="{% translate 'Name' %}" aria-label="{% translate 'Name' %}"
class="input join-item w-full {% if external_form.name.errors %}input-error{% endif %}" required />
<button type="submit" class="btn btn-primary join-item">{% translate 'Add' %}</button>
</form>
{% if external_form.name.errors %}<p class="label text-error">{{ external_form.name.errors.0 }}</p>{% endif %}
</fieldset>
{% if wygiwyh_form.fields.user.queryset.exists %}
<fieldset class="fieldset">
<legend class="fieldset-legend">{% translate 'Add user' %}</legend>
<form hx-post="{% url 'split_participant_add_wygiwyh' event_id=event.id %}" hx-target="#generic-offcanvas"
class="flex gap-2 items-start">
<div class="flex-1 min-w-0">{{ wygiwyh_form.user }}</div>
<button type="submit" class="btn btn-primary">{% translate 'Add' %}</button>
</form>
{% if wygiwyh_form.user.errors %}<p class="label text-error">{{ wygiwyh_form.user.errors.0 }}</p>{% endif %}
</fieldset>
{% endif %}
<fieldset class="fieldset">
<legend class="fieldset-legend">{% translate 'Participants' %}</legend>
<ul class="list bg-base-200 rounded-box">
{% for p in participants %}
<li class="list-row items-center {% if not p.is_active %}opacity-60{% endif %}">
<div class="list-col-grow min-w-0">
<div class="truncate">{{ p.display_name }}</div>
<div class="flex flex-wrap gap-1 mt-1">
{% if p.is_creator %}<span class="badge badge-xs badge-primary">{% translate 'Organizer' %}</span>{% endif %}
{% if p.is_external %}
{% if p.is_claimed %}
<span class="badge badge-xs badge-ghost">{% translate 'Password set' %}</span>
{% else %}
<span class="badge badge-xs badge-ghost">{% translate 'Never signed in' %}</span>
{% endif %}
{% endif %}
{% if not p.is_active %}<span class="badge badge-xs badge-warning">{% translate 'Inactive' %}</span>{% endif %}
</div>
</div>
<div class="join">
{% if p.is_external and p.is_claimed %}
<button type="button" class="btn btn-sm btn-secondary join-item"
data-tippy-content="{% translate 'Reset password' %}"
aria-label="{% translate 'Reset password' %}"
hx-post="{% url 'split_participant_reset_password' event_id=event.id participant_id=p.id %}"
hx-target="#generic-offcanvas"
hx-trigger="confirmed"
data-title="{% translate 'Reset password?' %}"
data-text="{% translate 'They will choose a new one the next time they sign in.' %}"
data-confirm-text="{% translate 'Reset' %}"
_="install prompt_swal">
<i class="fa-solid fa-key fa-fw"></i>
</button>
{% endif %}
{% if not p.is_creator %}
{% if p.is_active %}
<button type="button" class="btn btn-sm btn-secondary join-item"
data-tippy-content="{% translate 'Deactivate' %}"
aria-label="{% translate 'Deactivate' %}"
hx-post="{% url 'split_participant_toggle_active' event_id=event.id participant_id=p.id %}"
hx-target="#generic-offcanvas">
<i class="fa-solid fa-user-slash fa-fw"></i>
</button>
{% else %}
<button type="button" class="btn btn-sm btn-secondary join-item"
data-tippy-content="{% translate 'Reactivate' %}"
aria-label="{% translate 'Reactivate' %}"
hx-post="{% url 'split_participant_toggle_active' event_id=event.id participant_id=p.id %}"
hx-target="#generic-offcanvas">
<i class="fa-solid fa-user-check fa-fw"></i>
</button>
{% endif %}
{% if p.deletable %}
<button type="button" class="btn btn-sm btn-error join-item"
data-tippy-content="{% translate 'Remove' %}"
aria-label="{% translate 'Remove' %}"
hx-delete="{% url 'split_participant_delete' event_id=event.id participant_id=p.id %}"
hx-target="#generic-offcanvas"
hx-trigger="confirmed"
data-title="{% translate 'Are you sure?' %}"
data-text="{% translate "You won't be able to revert this!" %}"
data-confirm-text="{% translate 'Yes, delete it!' %}"
_="install prompt_swal">
<i class="fa-solid fa-trash fa-fw"></i>
</button>
{% endif %}
{% endif %}
</div>
</li>
{% endfor %}
</ul>
<p class="label whitespace-normal">
{% translate "People with expenses or payments can't be removed, only deactivated." %}
</p>
</fieldset>
{% endblock %}
@@ -0,0 +1,32 @@
{% extends 'extends/offcanvas.html' %}
{% load i18n %}
{% load crispy_forms_filters %}
{% block title %}
{% if payment %}{% translate 'Edit payment' %}{% else %}{% translate 'Record payment' %}{% endif %}
{% endblock %}
{% block body %}
<form hx-post="{{ post_url }}"
hx-target="#generic-offcanvas"
hx-encoding="multipart/form-data"
novalidate>
{% if form.non_field_errors %}
<div class="alert alert-error mb-3">{{ form.non_field_errors }}</div>
{% endif %}
<div class="grid grid-cols-1 sm:grid-cols-2 gap-x-3">
{{ form.from_participant|as_crispy_field }}
{{ form.to_participant|as_crispy_field }}
{{ form.amount|as_crispy_field }}
{{ form.date|as_crispy_field }}
</div>
{{ form.notes|as_crispy_field }}
{{ form.attachments|as_crispy_field }}
{% include 'splits/fragments/attachments_existing.html' with item=payment %}
<button type="submit" class="btn btn-primary w-full mt-3">
{% if payment %}{% translate 'Update' %}{% else %}{% translate 'Record' %}{% endif %}
</button>
</form>
{% endblock %}
@@ -0,0 +1,66 @@
{% extends 'extends/offcanvas.html' %}
{% load i18n %}
{% load crispy_forms_filters %}
{% block title %}{{ title }}{% endblock %}
{% block body %}
<form hx-post="{{ post_url }}"
hx-target="#generic-offcanvas"
novalidate
id="split-sync-form">
{% if form.non_field_errors %}
<div class="alert alert-error mb-3">{{ form.non_field_errors }}</div>
{% endif %}
<div class="join w-full mb-3">
<input type="radio" name="mode" value="create" aria-label="{% translate 'Create new' %}"
class="join-item btn btn-sm flex-1 sync-mode-radio"
{% if form.mode.value != 'link' %}checked{% endif %} />
<input type="radio" name="mode" value="link" aria-label="{% translate 'Link existing' %}"
class="join-item btn btn-sm flex-1 sync-mode-radio"
{% if form.mode.value == 'link' %}checked{% endif %} />
</div>
<div id="sync-create-fields">
<p class="text-sm text-base-content/70 mb-2">
{% if tx_type == 'IN' %}
{% translate 'Creates an income transaction in one of your accounts.' %}
{% else %}
{% translate 'Creates an expense transaction in one of your accounts.' %}
{% endif %}
{% blocktranslate with code=event.currency.code %}Amounts are in {{ code }}.{% endblocktranslate %}
</p>
{{ form.account|as_crispy_field }}
<div class="grid grid-cols-1 sm:grid-cols-2 gap-x-3">
{{ form.amount|as_crispy_field }}
{{ form.date|as_crispy_field }}
</div>
{{ form.description|as_crispy_field }}
{{ form.is_paid|as_crispy_field }}
{{ form.category|as_crispy_field }}
{{ form.tags|as_crispy_field }}
{{ form.entities|as_crispy_field }}
{{ form.notes|as_crispy_field }}
</div>
<div id="sync-link-fields" class="hidden">
{{ form.existing_transaction|as_crispy_field }}
</div>
<button type="submit" class="btn btn-primary w-full mt-3">{% translate 'Save' %}</button>
</form>
<script>
(function () {
const form = document.getElementById('split-sync-form');
function update() {
const linking = form.querySelector('.sync-mode-radio:checked').value === 'link';
document.getElementById('sync-create-fields').classList.toggle('hidden', linking);
document.getElementById('sync-link-fields').classList.toggle('hidden', !linking);
}
form.querySelectorAll('.sync-mode-radio').forEach((r) => r.addEventListener('change', update));
update();
})();
</script>
{% endblock %}
@@ -0,0 +1,16 @@
{% load i18n %}
{% for link in links %}
<span class="badge badge-sm {% if link.transaction.is_paid %}badge-success{% else %}badge-info{% endif %} gap-1"
data-tippy-content="{% if link.transaction.is_paid %}{% translate 'Linked transaction' %}{% else %}{% translate 'Linked transaction, not paid yet' %}{% endif %}">
<i class="fa-solid fa-link fa-fw"></i>{{ link.transaction.account.name }}
<button type="button" class="cursor-pointer" aria-label="{% translate 'Unlink' %}"
hx-delete="{% url 'split_sync_unlink' event_id=event.id link_id=link.id %}"
hx-trigger="confirmed"
data-title="{% translate 'Unlink this transaction?' %}"
data-text="{% translate 'The transaction itself is kept.' %}"
data-confirm-text="{% translate 'Unlink' %}"
_="install prompt_swal">
<i class="fa-solid fa-xmark fa-fw"></i>
</button>
</span>
{% endfor %}
@@ -0,0 +1,9 @@
{% extends "layouts/base.html" %}
{% load i18n %}
{% block title %}{{ event.name }} :: {% translate 'Split Expenses' %}{% endblock %}
{% block content %}
<div hx-get="{{ urls.event_content }}" hx-trigger="load, updated from:window" class="show-loading"></div>
{% include 'splits/fragments/event/export_script.html' %}
{% endblock %}
@@ -0,0 +1,8 @@
{% extends "layouts/base.html" %}
{% load i18n %}
{% block title %}{% translate 'Split Expenses' %}{% endblock %}
{% block content %}
<div hx-get="{% url 'split_event_list' %}" hx-trigger="load, updated from:window" class="show-loading"></div>
{% endblock %}
@@ -0,0 +1,149 @@
{% load i18n %}
{% load title %}
{% with c=event.currency %}
<!doctype html>
<html lang="en" data-theme="wygiwyh_light" class="bg-base-100">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% filter site_title %}{{ event.name }} :: {% translate 'Report' %}{% endfilter %}</title>
{% include 'includes/head/favicons.html' %}
{% include 'includes/styles.html' %}
<style>
@page { size: A4; margin: 14mm; }
tr, li { break-inside: avoid; }
h2 { break-after: avoid; }
</style>
</head>
<body class="font-mono bg-base-100 text-base-content">
<div class="max-w-3xl mx-auto p-6 print:p-0 flex flex-col gap-8">
<div class="flex justify-end gap-2 print:hidden">
<button type="button" class="btn btn-primary btn-sm" onclick="window.print()">
<i class="fa-solid fa-file-pdf"></i>{% translate 'Save as PDF' %}
</button>
</div>
<header>
<h1 class="text-3xl font-bold text-balance">{{ event.name }}</h1>
{% if event.description %}<p class="text-base-content/70 whitespace-pre-line text-pretty mt-1">{{ event.description }}</p>{% endif %}
<p class="text-sm text-base-content/60 mt-2 tabular-nums">
{% blocktranslate count counter=active_participants_count %}{{ counter }} person{% plural %}{{ counter }} people{% endblocktranslate %}
· {% translate 'Group total' %} <c-amount.display :amount="total_spent" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>
· {% now "SHORT_DATE_FORMAT" %}
</p>
</header>
<section>
<h2 class="text-lg font-semibold mb-2">{% translate 'Settle up' %}</h2>
{% if transfers %}
<table class="table table-sm tabular-nums">
<tbody>
{% for item in transfers %}{% with t=item.transfer %}
<tr>
<td>{{ t.from_participant.name }} <i class="fa-solid fa-arrow-right text-xs text-base-content/40 mx-1"></i> {{ t.to_participant.name }}</td>
<td class="text-end whitespace-nowrap font-semibold"><c-amount.display :amount="t.amount" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></td>
</tr>
{% endwith %}{% endfor %}
</tbody>
</table>
{% else %}
<p class="text-base-content/70">{% translate 'Everyone is settled up.' %}</p>
{% endif %}
</section>
<section>
<h2 class="text-lg font-semibold mb-2">{% translate 'Balances' %}</h2>
<table class="table table-sm tabular-nums">
<thead>
<tr>
<th>{% translate 'Person' %}</th>
<th class="text-end">{% translate 'Paid' %}</th>
<th class="text-end">{% translate 'Share' %}</th>
<th class="text-end">{% translate 'Sent' %}</th>
<th class="text-end">{% translate 'Received' %}</th>
<th class="text-end">{% translate 'Balance' %}</th>
</tr>
</thead>
<tbody>
{% for row in balance_rows %}{% with b=row.balance %}
<tr>
<td>{{ b.participant.name }}{% if not b.participant.is_active %} <span class="text-base-content/50">({% translate 'inactive' %})</span>{% endif %}</td>
<td class="text-end whitespace-nowrap"><c-amount.display :amount="b.total_paid" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></td>
<td class="text-end whitespace-nowrap"><c-amount.display :amount="b.total_owed" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></td>
<td class="text-end whitespace-nowrap"><c-amount.display :amount="b.payments_sent" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></td>
<td class="text-end whitespace-nowrap"><c-amount.display :amount="b.payments_received" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></td>
<td class="text-end whitespace-nowrap font-semibold"><c-amount.display :amount="b.net_balance" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" color="auto" divless></c-amount.display></td>
</tr>
{% endwith %}{% endfor %}
</tbody>
</table>
</section>
<section>
<h2 class="text-lg font-semibold mb-2">{% translate 'Expenses' %}</h2>
<table class="table table-sm tabular-nums">
<thead>
<tr>
<th>{% translate 'Date' %}</th>
<th>{% translate 'Expense' %}</th>
<th class="text-end">{% translate 'Amount' %}</th>
</tr>
</thead>
<tbody>
{% for item in activity %}{% if not item.is_payment %}
<tr>
<td class="whitespace-nowrap align-top">{{ item.date|date:"SHORT_DATE_FORMAT" }}</td>
<td>
<div class="font-medium">{{ item.description }}</div>
<div class="text-xs text-base-content/60">
{% blocktranslate with name=item.paid_by.name %}Paid by {{ name }}{% endblocktranslate %}
{% if item.split_type != 'EQUAL' %}· {{ item.get_split_type_display }}{% endif %}
</div>
<div class="text-xs text-base-content/60">
{% for s in item.shares.all %}{{ s.participant.name }} <c-amount.display :amount="s.amount" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>{% if not forloop.last %} · {% endif %}{% endfor %}
</div>
{% if item.notes %}<div class="text-xs text-base-content/60 italic whitespace-pre-line">{{ item.notes }}</div>{% endif %}
</td>
<td class="text-end whitespace-nowrap align-top"><c-amount.display :amount="item.amount" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></td>
</tr>
{% endif %}{% endfor %}
{% if not expense_count %}<tr><td colspan="3" class="text-base-content/60">{% translate 'No expenses.' %}</td></tr>{% endif %}
</tbody>
</table>
</section>
<section>
<h2 class="text-lg font-semibold mb-2">{% translate 'Payments' %}</h2>
<table class="table table-sm tabular-nums">
<thead>
<tr>
<th>{% translate 'Date' %}</th>
<th>{% translate 'Payment' %}</th>
<th class="text-end">{% translate 'Amount' %}</th>
</tr>
</thead>
<tbody>
{% for item in activity %}{% if item.is_payment %}
<tr>
<td class="whitespace-nowrap align-top">{{ item.date|date:"SHORT_DATE_FORMAT" }}</td>
<td>
{{ item.from_participant.name }} <i class="fa-solid fa-arrow-right text-xs text-base-content/40 mx-1"></i> {{ item.to_participant.name }}
{% if item.notes %}<div class="text-xs text-base-content/60 italic whitespace-pre-line">{{ item.notes }}</div>{% endif %}
</td>
<td class="text-end whitespace-nowrap align-top"><c-amount.display :amount="item.amount" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></td>
</tr>
{% endif %}{% endfor %}
{% if not payment_count %}<tr><td colspan="3" class="text-base-content/60">{% translate 'No payments.' %}</td></tr>{% endif %}
</tbody>
</table>
</section>
</div>
{% include 'includes/scripts.html' %}
<script>
// Opened from "Full report (PDF)": go straight to the print dialog once amounts and fonts are in
window.addEventListener('load', () => setTimeout(() => window.print(), 300));
</script>
</body>
</html>
{% endwith %}
@@ -0,0 +1,66 @@
{% extends "layouts/base_auth.html" %}
{% load i18n %}
{% load crispy_forms_filters %}
{% block title %}{{ event.name }}{% endblock %}
{% block content %}
<div class="min-h-screen flex items-center justify-center p-4">
<div class="w-full max-w-md">
<div class="card bg-base-100 shadow-2xl">
<div class="card-body">
<h1 class="text-2xl card-title text-balance">{{ event.name }}</h1>
{% if event.description %}
<p class="text-sm text-base-content/60 text-pretty whitespace-pre-line">{{ event.description }}</p>
{% endif %}
{% if not external_participants %}
<p class="mt-2 text-base-content/70">
{% translate 'Nobody without an account has been added yet. Ask the organizer to add your name.' %}
</p>
{% else %}
<form method="post" class="mt-2" id="external-auth-form" novalidate>
{% csrf_token %}
{% if form.non_field_errors %}<div class="alert alert-error mb-3">{{ form.non_field_errors }}</div>{% endif %}
{{ form.participant|as_crispy_field }}
<p id="first-time-hint" class="text-sm text-base-content/70 my-2 hidden">
{% translate 'First time here: pick a password so only you can sign in as this person.' %}
</p>
<div id="first-time-fields" class="hidden">
{{ form.username|as_crispy_field }}
</div>
{{ form.password|as_crispy_field }}
<div id="confirm-field" class="hidden">
{{ form.password_confirm|as_crispy_field }}
</div>
<button type="submit" class="btn btn-primary w-full mt-4" id="auth-submit">{% translate 'Continue' %}</button>
</form>
{{ claimed_ids|json_script:"split-claimed-ids" }}
<script>
(function () {
const claimed = new Set(JSON.parse(document.getElementById('split-claimed-ids').textContent).map(String));
const select = document.getElementById('id_participant');
const submit = document.getElementById('auth-submit');
function update() {
const firstTime = !!select.value && !claimed.has(select.value);
['first-time-hint', 'first-time-fields', 'confirm-field'].forEach(
(id) => document.getElementById(id).classList.toggle('hidden', !firstTime)
);
submit.textContent = firstTime ? "{% translate 'Set password and join' %}"
: select.value ? "{% translate 'Sign in' %}" : "{% translate 'Continue' %}";
}
select.addEventListener('change', update);
update();
// base_auth loads scripts after the content, so set up Tom Select once they're in
window.addEventListener('load', () => {
select.classList.remove('select');
if (!select.tomselect) new TomSelect(select);
});
})();
</script>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock %}
@@ -0,0 +1,64 @@
{% load pwa %}
{% load i18n %}
{% load title %}
<!DOCTYPE html>
<html lang="en"
data-theme="{% if request.session.theme == 'wygiwyh_light' %}wygiwyh_light{% else %}wygiwyh_dark{% endif %}">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>
{% filter site_title %}
{% block title %}{% translate 'Split Expenses' %}{% endblock title %}
{% endfilter %}
</title>
{% include 'includes/head/favicons.html' %}
{% progressive_web_app_meta %}
{% block extra_styles %}{% endblock %}
{% include 'includes/scripts.html' %}
{% block extra_js_head %}{% endblock %}
</head>
<body class="font-mono">
<div _="install htmx_error_handler" hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'>
{% if actor %}
<header class="navbar border-b border-base-content/10 px-4">
<div class="flex-1 flex items-center gap-3 min-w-0">
<div class="logo"></div>
<div class="truncate">
<span class="font-bold text-lg">{{ event.name }}</span>
</div>
</div>
<div class="flex-none flex items-center gap-3">
<span class="text-sm text-base-content/70 hidden sm:inline">
<i class="fa-solid fa-user mr-1"></i>{{ actor.participant.display_name }}
</span>
<form method="post" action="{% url 'split_external_logout' share_token=event.share_token %}">
{% csrf_token %}
<button type="submit" class="btn btn-ghost btn-sm">
<i class="fa-solid fa-right-from-bracket"></i>
<span class="hidden sm:inline">{% translate 'Sign out' %}</span>
</button>
</form>
</div>
</header>
{% endif %}
<main class="max-w-6xl mx-auto my-6 px-3">
<div id="content">
{% block content %}{% endblock content %}
</div>
{% include "includes/offcanvas.html" %}
{% if actor %}
<div id="toasts">
<div class="toast toast-top toast-end toast-container z-1050"
hx-trigger="load, updated from:window, toasts from:window"
hx-get="{% url 'split_external_toasts' share_token=event.share_token %}"
hx-swap="beforeend">
</div>
</div>
{% endif %}
</main>
</div>
{% block extra_js_body %}{% endblock extra_js_body %}
</body>
</html>
@@ -0,0 +1,17 @@
{% extends "layouts/base_auth.html" %}
{% load i18n %}
{% block title %}{{ event.name }}{% endblock %}
{% block content %}
<div class="min-h-screen flex items-center justify-center p-4">
<div class="card bg-base-100 shadow-2xl w-full max-w-md">
<div class="card-body">
<h1 class="text-2xl card-title text-balance">{{ event.name }}</h1>
<p class="text-base-content/70">
<i class="fa-solid fa-lock me-1"></i>{% translate 'The organizer turned off link access for this event.' %}
</p>
</div>
</div>
</div>
{% endblock %}
@@ -0,0 +1,9 @@
{% extends "splits/pages/external_base.html" %}
{% load i18n %}
{% block title %}{{ event.name }} :: {% translate 'Split Expenses' %}{% endblock %}
{% block content %}
<div hx-get="{{ urls.event_content }}" hx-trigger="load, updated from:window" class="show-loading"></div>
{% include 'splits/fragments/event/export_script.html' %}
{% endblock %}