membershipworks: Use monospace font for invoice header math
This commit is contained in:
parent
1ac1470d29
commit
0318a610e7
@ -8,6 +8,8 @@ from django.db.models import OuterRef, Q, Subquery
|
||||
from django.db.models.functions import TruncMonth, TruncYear
|
||||
from django.shortcuts import render
|
||||
from django.template.defaultfilters import floatformat
|
||||
from django.utils.html import format_html
|
||||
from django.utils.safestring import SafeString
|
||||
from django.views.generic import DetailView, ListView
|
||||
from django.views.generic.dates import (
|
||||
ArchiveIndexView,
|
||||
@ -299,17 +301,34 @@ class InvoiceTable(tables.Table):
|
||||
self.event = kwargs.pop("event")
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
@staticmethod
|
||||
def _math_header(name: str, formula: str) -> SafeString:
|
||||
return format_html(
|
||||
'{} <div class="text-nowrap font-monospace fw-light">[{}]</div>',
|
||||
name,
|
||||
formula,
|
||||
)
|
||||
|
||||
label = tables.Column("Ticket Type", footer="Subtotals")
|
||||
list_price = InvoiceMoneyColumn("Ticket Price")
|
||||
actual_price = InvoiceMoneyColumn("Actual Price [P]")
|
||||
quantity = tables.Column("Quantity [Q]", footer=lambda table: table.event.quantity)
|
||||
amount = InvoiceMoneyFooterColumn("Amount [A = P * Q]")
|
||||
materials = InvoiceMoneyFooterColumn("CMS Collected Materials Fee [M = m * Q]")
|
||||
amount_without_materials = InvoiceMoneyFooterColumn(
|
||||
"Event Revenue Base [B = A - M]"
|
||||
actual_price = InvoiceMoneyColumn(_math_header("Actual Price", "P"))
|
||||
quantity = tables.Column(
|
||||
_math_header("Quantity", "Q"),
|
||||
footer=lambda table: table.event.quantity,
|
||||
)
|
||||
amount = InvoiceMoneyFooterColumn(_math_header("Amount", "A=P*Q"))
|
||||
materials = InvoiceMoneyFooterColumn(
|
||||
_math_header("CMS Collected Materials Fee", "M=m*Q")
|
||||
)
|
||||
amount_without_materials = InvoiceMoneyFooterColumn(
|
||||
_math_header("Event Revenue Base", "B=A-M")
|
||||
)
|
||||
instructor_revenue = InvoiceMoneyFooterColumn(
|
||||
_math_header("Instructor Percentage Revenue", "R=B*I")
|
||||
)
|
||||
instructor_amount = InvoiceMoneyFooterColumn(
|
||||
_math_header("Amount Due to Instructor", "R+M")
|
||||
)
|
||||
instructor_revenue = InvoiceMoneyFooterColumn("Instructor Revenue [R = B * I]")
|
||||
instructor_amount = InvoiceMoneyFooterColumn("Amount Due to Instructor [R + M]")
|
||||
|
||||
class Meta:
|
||||
attrs = {
|
||||
|
Loading…
Reference in New Issue
Block a user