forked from DGNum/gestioCOF
feat(bda/place): show amount left to pay
This commit is contained in:
parent
4d4b536781
commit
8d7ccccc9b
2 changed files with 20 additions and 0 deletions
|
@ -11,9 +11,19 @@
|
|||
<td>{{place.spectacle.date}}</td>
|
||||
<td>{% if place.double %}deux places{%else%}une place{% endif %}</td>
|
||||
<td>{% if place.spectacle.listing %}sur listing{% else %}place physique{% endif %}</td>
|
||||
<td>
|
||||
{% if place.unpaid == 0 %}
|
||||
Payé
|
||||
{% elif place.unpaid == 1 %}
|
||||
Une place à payer ({{place.unpaid_price|floatformat}}€)
|
||||
{% else %}
|
||||
Deux places à payer ({{place.unpaid_price|floatformat}}€)
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<h4 class="bda-prix">Reste à payer : {{ unpaid|floatformat }}€</h4>
|
||||
<h4 class="bda-prix">Total à payer : {{ total|floatformat }}€</h4>
|
||||
<br/>
|
||||
<p>Ne manque pas un spectacle avec le
|
||||
|
|
10
bda/views.py
10
bda/views.py
|
@ -114,6 +114,7 @@ def places(request, tirage_id):
|
|||
"spectacle__date", "spectacle"
|
||||
).select_related("spectacle", "spectacle__location")
|
||||
total = sum(place.spectacle.price for place in places)
|
||||
unpaid = 0
|
||||
filtered_places = []
|
||||
places_dict = {}
|
||||
spectacles = []
|
||||
|
@ -124,6 +125,8 @@ def places(request, tirage_id):
|
|||
places_dict[place.spectacle].double = True
|
||||
else:
|
||||
place.double = False
|
||||
place.unpaid = 0
|
||||
place.unpaid_price = 0
|
||||
places_dict[place.spectacle] = place
|
||||
spectacles.append(place.spectacle)
|
||||
filtered_places.append(place)
|
||||
|
@ -132,6 +135,12 @@ def places(request, tirage_id):
|
|||
warning = True
|
||||
else:
|
||||
dates.append(date)
|
||||
|
||||
if not place.paid:
|
||||
unpaid += place.spectacle.price
|
||||
places_dict[place.spectacle].unpaid += 1
|
||||
places_dict[place.spectacle].unpaid_price += place.spectacle.price
|
||||
|
||||
# On prévient l'utilisateur s'il a deux places à la même date
|
||||
if warning:
|
||||
messages.warning(
|
||||
|
@ -147,6 +156,7 @@ def places(request, tirage_id):
|
|||
"places": filtered_places,
|
||||
"tirage": tirage,
|
||||
"total": total,
|
||||
"unpaid": unpaid,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue