parent
f41bd9c65b
commit
e2d027f71b
3 changed files with 44 additions and 2 deletions
|
@ -1,8 +1,16 @@
|
||||||
|
from registrasion.models import conditions
|
||||||
from registrasion.models import inventory
|
from registrasion.models import inventory
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
# Staff-facing forms.
|
# Reporting forms.
|
||||||
|
|
||||||
|
|
||||||
|
class DiscountForm(forms.Form):
|
||||||
|
discount = forms.ModelMultipleChoiceField(
|
||||||
|
queryset=conditions.DiscountBase.objects.all(),
|
||||||
|
required=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ProductAndCategoryForm(forms.Form):
|
class ProductAndCategoryForm(forms.Form):
|
||||||
|
|
|
@ -268,6 +268,40 @@ def product_status(request, form):
|
||||||
return ListReport("Inventory", headings, data)
|
return ListReport("Inventory", headings, data)
|
||||||
|
|
||||||
|
|
||||||
|
@report_view("Product status", form_type=forms.DiscountForm)
|
||||||
|
def discount_status(request, form):
|
||||||
|
''' Summarises the usage of a given discount. '''
|
||||||
|
|
||||||
|
discounts = form.cleaned_data["discount"]
|
||||||
|
|
||||||
|
|
||||||
|
items = commerce.DiscountItem.objects.filter(
|
||||||
|
Q(discount__in=discounts),
|
||||||
|
).select_related("cart", "product", "product__category")
|
||||||
|
|
||||||
|
items = group_by_cart_status(
|
||||||
|
items,
|
||||||
|
["discount",],
|
||||||
|
["discount", "discount__description",],
|
||||||
|
)
|
||||||
|
|
||||||
|
headings = [
|
||||||
|
"Discount", "Paid", "Reserved", "Unreserved", "Refunded",
|
||||||
|
]
|
||||||
|
data = []
|
||||||
|
|
||||||
|
for item in items:
|
||||||
|
data.append([
|
||||||
|
item["discount__description"],
|
||||||
|
item["total_paid"],
|
||||||
|
item["total_reserved"],
|
||||||
|
item["total_unreserved"],
|
||||||
|
item["total_refunded"],
|
||||||
|
])
|
||||||
|
|
||||||
|
return ListReport("Usage by item", headings, data)
|
||||||
|
|
||||||
|
|
||||||
@report_view("Paid invoices by date", form_type=forms.ProductAndCategoryForm)
|
@report_view("Paid invoices by date", form_type=forms.ProductAndCategoryForm)
|
||||||
def paid_invoices_by_date(request, form):
|
def paid_invoices_by_date(request, form):
|
||||||
''' Shows the number of paid invoices containing given products or
|
''' Shows the number of paid invoices containing given products or
|
||||||
|
|
|
@ -45,7 +45,7 @@ reports = [
|
||||||
url(r"^attendee/?$", rv.attendee, name="attendee"),
|
url(r"^attendee/?$", rv.attendee, name="attendee"),
|
||||||
url(r"^attendee/([0-9]*)$", rv.attendee, name="attendee"),
|
url(r"^attendee/([0-9]*)$", rv.attendee, name="attendee"),
|
||||||
url(r"^credit_notes/?$", rv.credit_notes, name="credit_notes"),
|
url(r"^credit_notes/?$", rv.credit_notes, name="credit_notes"),
|
||||||
url(r"^items_sold/?$", rv.items_sold, name="items_sold"),
|
url(r"^discount_status/?$", rv.discount_status, name="discount_status"),
|
||||||
url(
|
url(
|
||||||
r"^paid_invoices_by_date/?$",
|
r"^paid_invoices_by_date/?$",
|
||||||
rv.paid_invoices_by_date,
|
rv.paid_invoices_by_date,
|
||||||
|
|
Loading…
Reference in a new issue