mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-11-22 08:32:03 +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
189 lines
13 KiB
Python
189 lines
13 KiB
Python
# Generated by Django 5.2.17 on 2026-11-20 20:26
|
|
|
|
import apps.splits.models
|
|
import apps.transactions.storage
|
|
import django.core.validators
|
|
import django.db.models.deletion
|
|
import django.utils.timezone
|
|
import uuid
|
|
from decimal import Decimal
|
|
from django.conf import settings
|
|
from django.db import migrations, models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
initial = True
|
|
|
|
dependencies = [
|
|
('currencies', '0028_currency_show_exchanged_amounts'),
|
|
('transactions', '0056_filterpreset_is_default'),
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name='SplitEvent',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('name', models.CharField(max_length=255, verbose_name='Name')),
|
|
('description', models.TextField(blank=True, verbose_name='Description')),
|
|
('share_token', models.UUIDField(db_index=True, default=uuid.uuid4, unique=True, verbose_name='Share token')),
|
|
('allow_external_access', models.BooleanField(default=True, help_text='Allow external participants to access this event via the shared link.', verbose_name='Allow external access')),
|
|
('is_archived', models.BooleanField(default=False, verbose_name='Archived')),
|
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
('updated_at', models.DateTimeField(auto_now=True)),
|
|
('creator', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='created_split_events', to=settings.AUTH_USER_MODEL, verbose_name='Creator')),
|
|
('currency', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='split_events', to='currencies.currency', verbose_name='Currency')),
|
|
],
|
|
options={
|
|
'verbose_name': 'Split Event',
|
|
'verbose_name_plural': 'Split Events',
|
|
'db_table': 'split_events',
|
|
'ordering': ['-created_at', 'name'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='SplitExpense',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('description', models.CharField(max_length=255, verbose_name='Description')),
|
|
('amount', models.DecimalField(decimal_places=6, max_digits=20, validators=[django.core.validators.MinValueValidator(Decimal('0.000001'))], verbose_name='Amount')),
|
|
('date', models.DateField(default=django.utils.timezone.localdate, verbose_name='Date')),
|
|
('split_type', models.CharField(choices=[('EQUAL', 'Equal'), ('EXACT', 'Exact amounts'), ('PERCENTAGE', 'Percentages'), ('SHARES', 'Shares')], default='EQUAL', max_length=16, verbose_name='Split type')),
|
|
('notes', models.TextField(blank=True, verbose_name='Notes')),
|
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
('updated_at', models.DateTimeField(auto_now=True)),
|
|
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='expenses', to='splits.splitevent', verbose_name='Event')),
|
|
],
|
|
options={
|
|
'verbose_name': 'Split Expense',
|
|
'verbose_name_plural': 'Split Expenses',
|
|
'db_table': 'split_expenses',
|
|
'ordering': ['-date', '-created_at', '-id'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='SplitParticipant',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('name', models.CharField(max_length=150, verbose_name='Name')),
|
|
('is_external', models.BooleanField(default=False, verbose_name='External')),
|
|
('is_active', models.BooleanField(default=True, verbose_name='Active')),
|
|
('external_username', models.CharField(blank=True, max_length=150, verbose_name='External username')),
|
|
('external_password_hash', models.CharField(blank=True, max_length=255, verbose_name='External password hash')),
|
|
('external_claimed_at', models.DateTimeField(blank=True, null=True, verbose_name='Claimed at')),
|
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='participants', to='splits.splitevent', verbose_name='Event')),
|
|
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='split_participations', to=settings.AUTH_USER_MODEL, verbose_name='WYGIWYH User')),
|
|
],
|
|
options={
|
|
'verbose_name': 'Split Participant',
|
|
'verbose_name_plural': 'Split Participants',
|
|
'db_table': 'split_participants',
|
|
'ordering': ['-is_active', 'name', 'id'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='SplitExpenseShare',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('amount', models.DecimalField(decimal_places=6, max_digits=20, validators=[django.core.validators.MinValueValidator(Decimal('0'))], verbose_name='Amount')),
|
|
('percentage', models.DecimalField(blank=True, decimal_places=4, max_digits=7, null=True, verbose_name='Percentage')),
|
|
('shares', models.DecimalField(blank=True, decimal_places=4, max_digits=12, null=True, verbose_name='Shares')),
|
|
('expense', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='shares', to='splits.splitexpense', verbose_name='Expense')),
|
|
('participant', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='expense_shares', to='splits.splitparticipant', verbose_name='Participant')),
|
|
],
|
|
options={
|
|
'verbose_name': 'Split Expense Share',
|
|
'verbose_name_plural': 'Split Expense Shares',
|
|
'db_table': 'split_expense_shares',
|
|
'ordering': ['participant__name', 'id'],
|
|
},
|
|
),
|
|
migrations.AddField(
|
|
model_name='splitexpense',
|
|
name='created_by_participant',
|
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='expenses_created', to='splits.splitparticipant', verbose_name='Created by'),
|
|
),
|
|
migrations.AddField(
|
|
model_name='splitexpense',
|
|
name='paid_by',
|
|
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='expenses_paid', to='splits.splitparticipant', verbose_name='Paid by'),
|
|
),
|
|
migrations.CreateModel(
|
|
name='SplitPayment',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('amount', models.DecimalField(decimal_places=6, max_digits=20, validators=[django.core.validators.MinValueValidator(Decimal('0.000001'))], verbose_name='Amount')),
|
|
('date', models.DateField(default=django.utils.timezone.localdate, verbose_name='Date')),
|
|
('notes', models.TextField(blank=True, verbose_name='Notes')),
|
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
('updated_at', models.DateTimeField(auto_now=True)),
|
|
('created_by_participant', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='payments_created', to='splits.splitparticipant', verbose_name='Created by')),
|
|
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='payments', to='splits.splitevent', verbose_name='Event')),
|
|
('from_participant', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='payments_sent', to='splits.splitparticipant', verbose_name='From')),
|
|
('to_participant', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='payments_received', to='splits.splitparticipant', verbose_name='To')),
|
|
],
|
|
options={
|
|
'verbose_name': 'Split Payment',
|
|
'verbose_name_plural': 'Split Payments',
|
|
'db_table': 'split_payments',
|
|
'ordering': ['-date', '-created_at', '-id'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='SplitAttachment',
|
|
fields=[
|
|
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
|
('file', models.FileField(storage=apps.transactions.storage.PrivateMediaStorage(), upload_to=apps.splits.models.split_attachment_path, verbose_name='File')),
|
|
('original_name', models.CharField(max_length=255, verbose_name='Original Name')),
|
|
('content_type', models.CharField(blank=True, max_length=255, verbose_name='Content Type')),
|
|
('size', models.PositiveBigIntegerField(default=0, verbose_name='Size')),
|
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='splits.splitevent', verbose_name='Event')),
|
|
('expense', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='splits.splitexpense', verbose_name='Expense')),
|
|
('uploaded_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='uploaded_attachments', to='splits.splitparticipant', verbose_name='Uploaded By')),
|
|
('payment', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='splits.splitpayment', verbose_name='Payment')),
|
|
],
|
|
options={
|
|
'verbose_name': 'Split Attachment',
|
|
'verbose_name_plural': 'Split Attachments',
|
|
'db_table': 'split_attachments',
|
|
'ordering': ['-created_at', 'original_name'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='SplitTransactionLink',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('kind', models.CharField(choices=[('EXPENSE', 'Expense paid'), ('PAYMENT_OUT', 'Payment sent'), ('PAYMENT_IN', 'Payment received'), ('SETTLEMENT_OUT', 'Planned payment to send'), ('SETTLEMENT_IN', 'Planned payment to receive')], max_length=24, verbose_name='Kind')),
|
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
|
('counterparty', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='counterparty_transaction_links', to='splits.splitparticipant', verbose_name='Counterparty')),
|
|
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='transaction_links', to='splits.splitevent', verbose_name='Event')),
|
|
('expense', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='transaction_links', to='splits.splitexpense', verbose_name='Expense')),
|
|
('payment', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='transaction_links', to='splits.splitpayment', verbose_name='Payment')),
|
|
('transaction', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='split_links', to='transactions.transaction', verbose_name='Transaction')),
|
|
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='split_transaction_links', to=settings.AUTH_USER_MODEL, verbose_name='User')),
|
|
],
|
|
options={
|
|
'verbose_name': 'Split Transaction Link',
|
|
'verbose_name_plural': 'Split Transaction Links',
|
|
'db_table': 'split_transaction_links',
|
|
'ordering': ['-created_at'],
|
|
},
|
|
),
|
|
migrations.AddConstraint(
|
|
model_name='splitparticipant',
|
|
constraint=models.UniqueConstraint(condition=models.Q(('user__isnull', False)), fields=('event', 'user'), name='unique_split_participant_user_per_event'),
|
|
),
|
|
migrations.AddConstraint(
|
|
model_name='splitparticipant',
|
|
constraint=models.UniqueConstraint(fields=('event', 'name'), name='unique_split_participant_name_per_event'),
|
|
),
|
|
migrations.AddConstraint(
|
|
model_name='splitexpenseshare',
|
|
constraint=models.UniqueConstraint(fields=('expense', 'participant'), name='unique_share_per_expense_participant'),
|
|
),
|
|
]
|