mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-11-23 08:54:22 +01:00
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
19 lines
750 B
Python
19 lines
750 B
Python
from django.db import transaction as db_transaction
|
|
|
|
from apps.splits.auth import SplitActor
|
|
from apps.splits.models import SplitTransactionLink
|
|
|
|
|
|
@db_transaction.atomic
|
|
def leave_event(actor: SplitActor):
|
|
"""A non-organizer WYGIWYH user leaves: removed if they have no history, else deactivated."""
|
|
# Their own links only; the linked transactions stay in their accounts
|
|
SplitTransactionLink.objects.filter(event=actor.event, user=actor.user).delete()
|
|
participant = actor.participant
|
|
if participant.can_be_deleted():
|
|
participant.delete()
|
|
else:
|
|
# Keep their expenses and payments so everyone else's balances stay right
|
|
participant.is_active = False
|
|
participant.save(update_fields=["is_active"])
|