Merge branch 'counter' into 'master'

Add CB sums in invoice calls

See merge request !64
This commit is contained in:
Skia 2017-04-05 15:11:46 +02:00
commit cbfaf13536
3 changed files with 203 additions and 189 deletions

View File

@ -15,6 +15,9 @@
</select>
<input type="submit" value="{% trans %}Go{% endtrans %}" />
</form>
<br>
<p>{% trans %}CB Payments{% endtrans %} : {{ sum_cb }} €</p>
<br>
<table>
<thead>
<td>{% trans %}Club{% endtrans %}</td>

View File

@ -1031,6 +1031,10 @@ class InvoiceCallView(CounterAdminTabsMixin, CounterAdminMixin, TemplateView):
start_date = start_date.replace(tzinfo=pytz.UTC)
end_date = (start_date + timedelta(days=32)).replace(day=1, hour=0, minute=0, microsecond=0)
from django.db.models import Sum, Case, When, F, DecimalField
kwargs['sum_cb'] = sum([r.amount for r in Refilling.objects.filter(payment_method='CARD', is_validated=True,
date__gte=start_date, date__lte=end_date)])
kwargs['sum_cb'] += sum([s.quantity*s.unit_price for s in Selling.objects.filter(payment_method='CARD', is_validated=True,
date__gte=start_date, date__lte=end_date)])
kwargs['start_date'] = start_date
kwargs['sums'] = Selling.objects.values('club__name').annotate(selling_sum=Sum(
Case(When(date__gte=start_date,

File diff suppressed because it is too large Load Diff