membershipworks: Group tickets by price group for event invoices
This groups tickets by their actual price grouping, instead of always using member/non-member, which is not a useful distinction post 2024-07-01.
This commit is contained in:
parent
fe03146bc6
commit
ad93c361fd
@ -704,11 +704,8 @@ class EventInvoice(models.Model):
|
|||||||
|
|
||||||
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=Q(restrict_to__isnull=False)).annotate(
|
return self.values("price_group").annotate(
|
||||||
label=Case(
|
label=F("price_group"),
|
||||||
When(Q(is_members_ticket=True), Value("Members")),
|
|
||||||
default=Value("Non-Members"),
|
|
||||||
),
|
|
||||||
actual_price=F("actual_price"),
|
actual_price=F("actual_price"),
|
||||||
**{
|
**{
|
||||||
field: Sum(field)
|
field: Sum(field)
|
||||||
@ -732,25 +729,31 @@ class EventTicketTypeManager(models.Manager["EventTicketType"]):
|
|||||||
# restricted ticket, but list price for unrestricted
|
# restricted ticket, but list price for unrestricted
|
||||||
# (Non-Members) ticket. After, use Members ticket price
|
# (Non-Members) ticket. After, use Members ticket price
|
||||||
# for all tickets except where members ticket is free.
|
# for all tickets except where members ticket is free.
|
||||||
actual_price=Case(
|
price_group=Case(
|
||||||
When(
|
When(
|
||||||
# member ticket
|
Q(members_price=0)
|
||||||
Q(restrict_to__has_key=settings.MW_MEMBERS_FOLDER_ID)
|
| Q(
|
||||||
| (
|
event__start__lt=datetime(
|
||||||
# non-member ticket
|
year=2024,
|
||||||
Q(restrict_to__isnull=True)
|
month=7,
|
||||||
& (
|
day=1,
|
||||||
Q(
|
tzinfo=timezone.get_default_timezone(),
|
||||||
event__start__lt=datetime(
|
|
||||||
year=2024,
|
|
||||||
month=7,
|
|
||||||
day=1,
|
|
||||||
tzinfo=timezone.get_default_timezone(),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
| Q(members_price=0)
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
Case(
|
||||||
|
When(Q(restrict_to__isnull=True), Value("Non-Members")),
|
||||||
|
default=Value("Members"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
default=Value("Attendee"),
|
||||||
|
),
|
||||||
|
actual_price=Case(
|
||||||
|
# Price group will be "Non-Members" iff we are using
|
||||||
|
# the list price for that ticket type. In all other
|
||||||
|
# cases (special program discounts or non-members
|
||||||
|
# tickets after 2024-07-01), use the members price
|
||||||
|
When(
|
||||||
|
Q(price_group=Value("Non-Members")),
|
||||||
"list_price",
|
"list_price",
|
||||||
),
|
),
|
||||||
default="members_price",
|
default="members_price",
|
||||||
|
Loading…
Reference in New Issue
Block a user