Fix #302 -- Change column layout in order overview (#336)

* Change column layout in order overview. Closes #302

* Include expired orders explicitly in order overview
This commit is contained in:
Tobias Kunze
2016-11-27 14:36:53 +01:00
committed by Raphael Michel
parent 026d8dcd41
commit 8648e9c04d
3 changed files with 46 additions and 22 deletions

View File

@@ -93,7 +93,7 @@ def order_overview(event: Event) -> Tuple[List[Tuple[ItemCategory, List[Item]]],
(p['item'], p['variation']): (p['cnt'], p['price'], p['price'] - p['tax_value']) (p['item'], p['variation']): (p['cnt'], p['price'], p['price'] - p['tax_value'])
for p in counters if p['order__status'] == Order.STATUS_PAID for p in counters if p['order__status'] == Order.STATUS_PAID
} }
num_s_pending = { num_pending = {
(p['item'], p['variation']): (p['cnt'], p['price'], p['price'] - p['tax_value']) (p['item'], p['variation']): (p['cnt'], p['price'], p['price'] - p['tax_value'])
for p in counters if p['order__status'] == Order.STATUS_PENDING for p in counters if p['order__status'] == Order.STATUS_PENDING
} }
@@ -101,7 +101,6 @@ def order_overview(event: Event) -> Tuple[List[Tuple[ItemCategory, List[Item]]],
(p['item'], p['variation']): (p['cnt'], p['price'], p['price'] - p['tax_value']) (p['item'], p['variation']): (p['cnt'], p['price'], p['price'] - p['tax_value'])
for p in counters if p['order__status'] == Order.STATUS_EXPIRED for p in counters if p['order__status'] == Order.STATUS_EXPIRED
} }
num_pending = dictsum(num_s_pending, num_expired)
num_total = dictsum(num_pending, num_paid) num_total = dictsum(num_pending, num_paid)
for item in items: for item in items:
@@ -112,17 +111,20 @@ def order_overview(event: Event) -> Tuple[List[Tuple[ItemCategory, List[Item]]],
variid = var.id variid = var.id
var.num_total = num_total.get((item.id, variid), (0, 0, 0)) var.num_total = num_total.get((item.id, variid), (0, 0, 0))
var.num_pending = num_pending.get((item.id, variid), (0, 0, 0)) var.num_pending = num_pending.get((item.id, variid), (0, 0, 0))
var.num_expired = num_expired.get((item.id, variid), (0, 0, 0))
var.num_canceled = num_canceled.get((item.id, variid), (0, 0, 0)) var.num_canceled = num_canceled.get((item.id, variid), (0, 0, 0))
var.num_refunded = num_refunded.get((item.id, variid), (0, 0, 0)) var.num_refunded = num_refunded.get((item.id, variid), (0, 0, 0))
var.num_paid = num_paid.get((item.id, variid), (0, 0, 0)) var.num_paid = num_paid.get((item.id, variid), (0, 0, 0))
item.num_total = tuplesum(var.num_total for var in item.all_variations) item.num_total = tuplesum(var.num_total for var in item.all_variations)
item.num_pending = tuplesum(var.num_pending for var in item.all_variations) item.num_pending = tuplesum(var.num_pending for var in item.all_variations)
item.num_expired = tuplesum(var.num_expired for var in item.all_variations)
item.num_canceled = tuplesum(var.num_canceled for var in item.all_variations) item.num_canceled = tuplesum(var.num_canceled for var in item.all_variations)
item.num_refunded = tuplesum(var.num_refunded for var in item.all_variations) item.num_refunded = tuplesum(var.num_refunded for var in item.all_variations)
item.num_paid = tuplesum(var.num_paid for var in item.all_variations) item.num_paid = tuplesum(var.num_paid for var in item.all_variations)
else: else:
item.num_total = num_total.get((item.id, None), (0, 0, 0)) item.num_total = num_total.get((item.id, None), (0, 0, 0))
item.num_pending = num_pending.get((item.id, None), (0, 0, 0)) item.num_pending = num_pending.get((item.id, None), (0, 0, 0))
item.num_expired = num_expired.get((item.id, None), (0, 0, 0))
item.num_canceled = num_canceled.get((item.id, None), (0, 0, 0)) item.num_canceled = num_canceled.get((item.id, None), (0, 0, 0))
item.num_refunded = num_refunded.get((item.id, None), (0, 0, 0)) item.num_refunded = num_refunded.get((item.id, None), (0, 0, 0))
item.num_paid = num_paid.get((item.id, None), (0, 0, 0)) item.num_paid = num_paid.get((item.id, None), (0, 0, 0))
@@ -144,6 +146,7 @@ def order_overview(event: Event) -> Tuple[List[Tuple[ItemCategory, List[Item]]],
for c in items_by_category: for c in items_by_category:
c[0].num_total = tuplesum(item.num_total for item in c[1]) c[0].num_total = tuplesum(item.num_total for item in c[1])
c[0].num_pending = tuplesum(item.num_pending for item in c[1]) c[0].num_pending = tuplesum(item.num_pending for item in c[1])
c[0].num_expired = tuplesum(item.num_expired for item in c[1])
c[0].num_canceled = tuplesum(item.num_canceled for item in c[1]) c[0].num_canceled = tuplesum(item.num_canceled for item in c[1])
c[0].num_refunded = tuplesum(item.num_refunded for item in c[1]) c[0].num_refunded = tuplesum(item.num_refunded for item in c[1])
c[0].num_paid = tuplesum(item.num_paid for item in c[1]) c[0].num_paid = tuplesum(item.num_paid for item in c[1])
@@ -165,7 +168,7 @@ def order_overview(event: Event) -> Tuple[List[Tuple[ItemCategory, List[Item]]],
o['payment_provider']: (o['cnt'], o['payment_fee'], o['payment_fee'] - o['tax_value']) o['payment_provider']: (o['cnt'], o['payment_fee'], o['payment_fee'] - o['tax_value'])
for o in counters if o['status'] == Order.STATUS_REFUNDED for o in counters if o['status'] == Order.STATUS_REFUNDED
} }
num_s_pending = { num_pending = {
o['payment_provider']: (o['cnt'], o['payment_fee'], o['payment_fee'] - o['tax_value']) o['payment_provider']: (o['cnt'], o['payment_fee'], o['payment_fee'] - o['tax_value'])
for o in counters if o['status'] == Order.STATUS_PENDING for o in counters if o['status'] == Order.STATUS_PENDING
} }
@@ -177,7 +180,6 @@ def order_overview(event: Event) -> Tuple[List[Tuple[ItemCategory, List[Item]]],
o['payment_provider']: (o['cnt'], o['payment_fee'], o['payment_fee'] - o['tax_value']) o['payment_provider']: (o['cnt'], o['payment_fee'], o['payment_fee'] - o['tax_value'])
for o in counters if o['status'] == Order.STATUS_PAID for o in counters if o['status'] == Order.STATUS_PAID
} }
num_pending = dictsum(num_s_pending, num_expired)
num_total = dictsum(num_pending, num_paid) num_total = dictsum(num_pending, num_paid)
provider_names = {} provider_names = {}
@@ -194,6 +196,7 @@ def order_overview(event: Event) -> Tuple[List[Tuple[ItemCategory, List[Item]]],
ppobj.num_total = total ppobj.num_total = total
ppobj.num_canceled = num_canceled.get(pprov, (0, 0, 0)) ppobj.num_canceled = num_canceled.get(pprov, (0, 0, 0))
ppobj.num_refunded = num_refunded.get(pprov, (0, 0, 0)) ppobj.num_refunded = num_refunded.get(pprov, (0, 0, 0))
ppobj.num_expired = num_expired.get(pprov, (0, 0, 0))
ppobj.num_pending = num_pending.get(pprov, (0, 0, 0)) ppobj.num_pending = num_pending.get(pprov, (0, 0, 0))
ppobj.num_paid = num_paid.get(pprov, (0, 0, 0)) ppobj.num_paid = num_paid.get(pprov, (0, 0, 0))
payment_items.append(ppobj) payment_items.append(ppobj)
@@ -207,6 +210,9 @@ def order_overview(event: Event) -> Tuple[List[Tuple[ItemCategory, List[Item]]],
payment_cat_obj.num_refunded = ( payment_cat_obj.num_refunded = (
Dontsum(''), sum(i.num_refunded[1] for i in payment_items), sum(i.num_refunded[2] for i in payment_items) Dontsum(''), sum(i.num_refunded[1] for i in payment_items), sum(i.num_refunded[2] for i in payment_items)
) )
payment_cat_obj.num_expired = (
Dontsum(''), sum(i.num_expired[1] for i in payment_items), sum(i.num_expired[2] for i in payment_items)
)
payment_cat_obj.num_pending = ( payment_cat_obj.num_pending = (
Dontsum(''), sum(i.num_pending[1] for i in payment_items), sum(i.num_pending[2] for i in payment_items) Dontsum(''), sum(i.num_pending[1] for i in payment_items), sum(i.num_pending[2] for i in payment_items)
) )
@@ -220,6 +226,7 @@ def order_overview(event: Event) -> Tuple[List[Tuple[ItemCategory, List[Item]]],
total = { total = {
'num_total': tuplesum(c.num_total for c, i in items_by_category), 'num_total': tuplesum(c.num_total for c, i in items_by_category),
'num_pending': tuplesum(c.num_pending for c, i in items_by_category), 'num_pending': tuplesum(c.num_pending for c, i in items_by_category),
'num_expired': tuplesum(c.num_expired for c, i in items_by_category),
'num_canceled': tuplesum(c.num_canceled for c, i in items_by_category), 'num_canceled': tuplesum(c.num_canceled for c, i in items_by_category),
'num_refunded': tuplesum(c.num_refunded for c, i in items_by_category), 'num_refunded': tuplesum(c.num_refunded for c, i in items_by_category),
'num_paid': tuplesum(c.num_paid for c, i in items_by_category) 'num_paid': tuplesum(c.num_paid for c, i in items_by_category)

View File

@@ -17,11 +17,19 @@
<thead> <thead>
<tr> <tr>
<th>{% trans "Product" %}</th> <th>{% trans "Product" %}</th>
<th>{% trans "Total (pending or paid)" %}</th>
<th>{% trans "Payment pending" %}</th>
<th>{% trans "Canceled" %}</th> <th>{% trans "Canceled" %}</th>
<th>{% trans "Refunded" %}</th> <th>{% trans "Refunded" %}</th>
<th>{% trans "Expired" %}</th>
<th colspan="3">{% trans "Purchased" %}</th>
</tr>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th>{% trans "Pending" %}</th>
<th>{% trans "Paid" %}</th> <th>{% trans "Paid" %}</th>
<th>{% trans "Total" %}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -29,26 +37,17 @@
{% if tup.0 %} {% if tup.0 %}
<tr class="category"> <tr class="category">
<th>{{ tup.0.name }}</th> <th>{{ tup.0.name }}</th>
<th>{{ tup.0.num_total|togglesum }}</th>
<th>{{ tup.0.num_pending|togglesum }}</th>
<th>{{ tup.0.num_canceled|togglesum }}</th> <th>{{ tup.0.num_canceled|togglesum }}</th>
<th>{{ tup.0.num_refunded|togglesum }}</th> <th>{{ tup.0.num_refunded|togglesum }}</th>
<th>{{ tup.0.num_expired|togglesum }}</th>
<th>{{ tup.0.num_pending|togglesum }}</th>
<th>{{ tup.0.num_paid|togglesum }}</th> <th>{{ tup.0.num_paid|togglesum }}</th>
<th>{{ tup.0.num_total|togglesum }}</th>
</tr> </tr>
{% endif %} {% endif %}
{% for item in tup.1 %} {% for item in tup.1 %}
<tr class="item {% if tup.0 %}categorized{% endif %}"> <tr class="item {% if tup.0 %}categorized{% endif %}">
<td>{{ item.name }}</td> <td>{{ item.name }}</td>
<td>
<a href="{{ listurl }}?item={{ item.id }}&amp;provider={{ item.provider }}">
{{ item.num_total|togglesum }}
</a>
</td>
<td>
<a href="{{ listurl }}?item={{ item.id }}&amp;status=ne&amp;provider={{ item.provider }}">
{{ item.num_pending|togglesum }}
</a>
</td>
<td> <td>
<a href="{{ listurl }}?item={{ item.id }}&amp;status=c&amp;provider={{ item.provider }}"> <a href="{{ listurl }}?item={{ item.id }}&amp;status=c&amp;provider={{ item.provider }}">
{{ item.num_canceled|togglesum }} {{ item.num_canceled|togglesum }}
@@ -59,21 +58,35 @@
{{ item.num_refunded|togglesum }} {{ item.num_refunded|togglesum }}
</a> </a>
</td> </td>
<td>
<a href="{{ listurl }}?item={{ item.id }}&amp;status=e&amp;provider={{ item.provider }}">
{{ item.num_expired|togglesum }}
</a>
</td>
<td>
<a href="{{ listurl }}?item={{ item.id }}&amp;status=n&amp;provider={{ item.provider }}">
{{ item.num_pending|togglesum }}
</a>
</td>
<td> <td>
<a href="{{ listurl }}?item={{ item.id }}&amp;status=p&amp;provider={{ item.provider }}"> <a href="{{ listurl }}?item={{ item.id }}&amp;status=p&amp;provider={{ item.provider }}">
{{ item.num_paid|togglesum }} {{ item.num_paid|togglesum }}
</a> </a>
</td> </td>
<td>
{{ item.num_total|togglesum }}
</td>
</tr> </tr>
{% if item.has_variations %} {% if item.has_variations %}
{% for var in item.all_variations %} {% for var in item.all_variations %}
<tr class="variation {% if tup.0 %}categorized{% endif %}"> <tr class="variation {% if tup.0 %}categorized{% endif %}">
<td>{{ var }}</td> <td>{{ var }}</td>
<td>{{ var.num_total|togglesum }}</td>
<td>{{ var.num_pending|togglesum }}</td>
<td>{{ var.num_canceled|togglesum }}</td> <td>{{ var.num_canceled|togglesum }}</td>
<td>{{ var.num_refunded|togglesum }}</td> <td>{{ var.num_refunded|togglesum }}</td>
<td>{{ var.num_expired|togglesum }}</td>
<td>{{ var.num_pending|togglesum }}</td>
<td>{{ var.num_paid|togglesum }}</td> <td>{{ var.num_paid|togglesum }}</td>
<td>{{ var.num_total|togglesum }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
@@ -83,11 +96,12 @@
<tfoot> <tfoot>
<tr class="total"> <tr class="total">
<th>{% trans "Total" %}</th> <th>{% trans "Total" %}</th>
<th>{{ total.num_total|togglesum }}</th>
<th>{{ total.num_pending|togglesum }}</th>
<th>{{ total.num_canceled|togglesum }}</th> <th>{{ total.num_canceled|togglesum }}</th>
<th>{{ total.num_refunded|togglesum }}</th> <th>{{ total.num_refunded|togglesum }}</th>
<th>{{ total.num_expired|togglesum }}</th>
<th>{{ total.num_paid|togglesum }}</th> <th>{{ total.num_paid|togglesum }}</th>
<th>{{ total.num_pending|togglesum }}</th>
<th>{{ total.num_total|togglesum }}</th>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>

View File

@@ -15,6 +15,9 @@
span.sum-net, span.sum-gross { span.sum-net, span.sum-gross {
display: none; display: none;
} }
tfoot {
border-top: 2px solid #ddd;
}
} }
#sumtoggle { #sumtoggle {