membershipworks: Add model and admin for EventInvoice
This commit is contained in:
parent
132b134dc5
commit
b6b16a17d8
@ -14,6 +14,7 @@ from .models import (
|
|||||||
Event,
|
Event,
|
||||||
EventExt,
|
EventExt,
|
||||||
EventInstructor,
|
EventInstructor,
|
||||||
|
EventInvoice,
|
||||||
EventMeetingTime,
|
EventMeetingTime,
|
||||||
Flag,
|
Flag,
|
||||||
Member,
|
Member,
|
||||||
@ -119,9 +120,13 @@ class EventInstructorAdmin(admin.ModelAdmin):
|
|||||||
search_fields = ["name", "member__account_name"]
|
search_fields = ["name", "member__account_name"]
|
||||||
|
|
||||||
|
|
||||||
|
class EventInvoiceInline(admin.StackedInline):
|
||||||
|
model = EventInvoice
|
||||||
|
|
||||||
|
|
||||||
@admin.register(EventExt)
|
@admin.register(EventExt)
|
||||||
class EventAdmin(DjangoObjectActions, admin.ModelAdmin):
|
class EventAdmin(DjangoObjectActions, admin.ModelAdmin):
|
||||||
inlines = [EventMeetingTimeInline]
|
inlines = [EventInvoiceInline, EventMeetingTimeInline]
|
||||||
list_display = [
|
list_display = [
|
||||||
"unescaped_title",
|
"unescaped_title",
|
||||||
"start",
|
"start",
|
||||||
|
41
membershipworks/migrations/0016_eventinvoice.py
Normal file
41
membershipworks/migrations/0016_eventinvoice.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# Generated by Django 5.0.2 on 2024-03-08 21:30
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("membershipworks", "0015_eventmeetingtime_end_after_start"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="EventInvoice",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"uuid",
|
||||||
|
models.UUIDField(
|
||||||
|
default=uuid.uuid4,
|
||||||
|
editable=False,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("date_submitted", models.DateField()),
|
||||||
|
("date_paid", models.DateField(blank=True, null=True)),
|
||||||
|
("pdf", models.FileField(upload_to="invoices/%Y/%m/%d/")),
|
||||||
|
("amount", models.DecimalField(decimal_places=4, max_digits=13)),
|
||||||
|
(
|
||||||
|
"event",
|
||||||
|
models.OneToOneField(
|
||||||
|
on_delete=django.db.models.deletion.PROTECT,
|
||||||
|
related_name="invoice",
|
||||||
|
to="membershipworks.eventext",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
@ -1,3 +1,4 @@
|
|||||||
|
import uuid
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
@ -576,6 +577,20 @@ class EventMeetingTime(models.Model):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class EventInvoice(models.Model):
|
||||||
|
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||||
|
event = models.OneToOneField(
|
||||||
|
EventExt, on_delete=models.PROTECT, related_name="invoice"
|
||||||
|
)
|
||||||
|
date_submitted = models.DateField()
|
||||||
|
date_paid = models.DateField(blank=True, null=True)
|
||||||
|
pdf = models.FileField(upload_to="protected/invoices/%Y/%m/%d/")
|
||||||
|
amount = models.DecimalField(max_digits=13, decimal_places=4)
|
||||||
|
|
||||||
|
def __str__(self) -> str:
|
||||||
|
return f'"{self.event}" submitted={self.date_submitted} paid:{self.date_paid} ${self.amount}'
|
||||||
|
|
||||||
|
|
||||||
class EventTicketTypeQuerySet(models.QuerySet["EventTicketType"]):
|
class EventTicketTypeQuerySet(models.QuerySet["EventTicketType"]):
|
||||||
def group_by_ticket_type(self):
|
def group_by_ticket_type(self):
|
||||||
return self.values("is_members_ticket").annotate(
|
return self.values("is_members_ticket").annotate(
|
||||||
|
Loading…
Reference in New Issue
Block a user