Skip to content

Commit 677f40f

Browse files
committed
Bill Void WIP
1 parent ca665c5 commit 677f40f

File tree

4 files changed

+61
-47
lines changed

4 files changed

+61
-47
lines changed

django_ledger/templates/django_ledger/bill_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ <h1 class="is-size-1 has-text-weight-thin">{% trans 'Latest Bills' %}</h1>
9090
</div>
9191
</div>
9292

93-
{% bill_table %}
93+
{% bill_table bills %}
9494

9595
{% if year %}
9696
<h5 class="is-size-5">{% trans 'Go to month:' %}</h5>

django_ledger/templates/django_ledger/includes/card_bill.html

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
<p>Is Progressible:
2525
<span class="icon is-small has-text-danger">{% icon 'maki:roadblock-11' 24 %}</span>
2626
{% endif %}
27-
<p class="is-size-5 has-text-danger">You Still Owe: {% currency_symbol %}{{ bill.get_amount_open | currency_format }}</p>
27+
<p class="is-size-5 has-text-danger">You Still Owe:
28+
{% currency_symbol %}{{ bill.get_amount_open | currency_format }}</p>
2829
<p>Amount Paid: {% currency_symbol %}{{ bill.amount_paid | currency_format }}</p>
2930
<p>Progressed: {{ bill.get_progress | percentage }}</p><br>
3031
<progress class="progress is-medium is-success"
@@ -55,7 +56,6 @@ <h2 class="card-header-title has-text-weight-light is-size-3">
5556
{% trans 'Bill Info' %}</h2>
5657
</div>
5758
<div class="card-content">
58-
5959
{% if bill.paid %}
6060
<p class="is-size-3 has-text-dark">Is Paid
6161
<span class="icon is-large has-text-success-dark">
@@ -66,53 +66,56 @@ <h2 class="card-header-title has-text-weight-light is-size-3">
6666
<span class="has-text-weight-bold">{% currency_symbol %}{{ bill.amount_paid | currency_format }}</span>
6767
</p>
6868
{% else %}
69-
<p class="is-size-3 has-text-dark">Bill Amount:
70-
<span class="has-text-weight-bold">{% currency_symbol %}{{ bill.amount_due | currency_format }}</span>
71-
</p>
72-
{% if not bill.is_past_due %}
73-
<p class="is-size-4 has-text-info">Due in: {{ bill.due_date | timeuntil }}</p>
74-
{% else %}
75-
<p class="is-size-4 has-text-info">Due in: {{ bill.due_date | date }}</p>
76-
<p class="has-text-danger has-text-weight-bold is-size-3">Past
77-
Due: {{ bill.due_date | timesince }} ago</p>
78-
{% endif %}
79-
<p class="is-size-5 has-text-danger">You Still Owe: {% currency_symbol %}{{ bill.get_amount_open | currency_format }}</p>
8069

81-
{% if bill.accrue %}
82-
<p>Is Accrued: <span
83-
class="icon has-text-success">{% icon 'ant-design:check-circle-filled' 24 %}</span>
70+
{% if not bill.void %}
71+
<p class="is-size-3 has-text-dark">Bill Amount:
72+
<span class="has-text-weight-bold">{% currency_symbol %}{{ bill.amount_due | currency_format }}</span>
8473
</p>
74+
{% if not bill.is_past_due %}
75+
<p class="is-size-4 has-text-info">Due in: {{ bill.due_date | timeuntil }}</p>
76+
{% else %}
77+
<p class="is-size-4 has-text-info">Due in: {{ bill.due_date | date }}</p>
78+
<p class="has-text-danger has-text-weight-bold is-size-3">Past
79+
Due: {{ bill.due_date | timesince }} ago</p>
80+
{% endif %}
81+
<p class="is-size-5 has-text-danger">You Still Owe:
82+
{% currency_symbol %}{{ bill.get_amount_open | currency_format }}</p>
83+
{% if bill.accrue %}
84+
<p>Is Accrued: <span
85+
class="icon has-text-success">{% icon 'ant-design:check-circle-filled' 24 %}</span>
86+
</p>
87+
{% else %}
88+
<p>Is Accrued:
89+
<span class="icon is-small has-text-danger">{% icon 'maki:roadblock-11' 24 %}</span>
90+
</p>
91+
{% endif %}
92+
<p>Amount Paid: {% currency_symbol %}{{ bill.amount_paid | currency_format }}</p>
93+
<p>Progressed: {{ bill.get_progress | percentage }}</p><br>
94+
<progress class="progress is-medium is-success"
95+
value="{{ bill.get_progress_percent }}"
96+
max="100">
97+
{{ bill.get_progress | percentage }}
98+
</progress>
99+
<footer class="card-footer">
100+
<a href="{% url 'django_ledger:bill-update' entity_slug=entity_slug bill_pk=bill.uuid %}"
101+
class="card-footer-item has-text-primary has-text-centered">{% trans 'Update' %}</a>
102+
<a onclick="djLedger.toggleModal('{{ bill.get_html_id }}')"
103+
class="card-footer-item has-text-info has-text-centered">{% trans 'Mark as Paid' %}</a>
104+
<a href="{% url 'django_ledger:bill-delete' entity_slug=entity_slug bill_pk=bill.uuid %}"
105+
class="card-footer-item has-text-danger has-text-centered">{% trans 'Delete' %}</a>
106+
<a href="{% url 'django_ledger:bill-void' entity_slug=entity_slug bill_pk=bill.uuid %}"
107+
class="card-footer-item has-text-warning has-text-centered">{% trans 'Void' %}</a>
108+
</footer>
109+
{# MARK AS PAID MODAL #}
110+
{% mark_as_paid bill %}
85111
{% else %}
86-
<p>Is Accrued:
87-
<span class="icon is-small has-text-danger">{% icon 'maki:roadblock-11' 24 %}</span>
112+
<p class="is-size-3 has-text-dark">Bill Amount:
113+
<span class="has-text-weight-bold">{% currency_symbol %}{{ bill.amount_due | currency_format }}</span>
88114
</p>
115+
<p class="is-size-3 has-text-warning-dark">VOIDED {{ bill.void_date | date }}</p>
89116
{% endif %}
90-
91-
<p>Amount Paid: {% currency_symbol %}{{ bill.amount_paid | currency_format }}</p>
92-
93-
<p>Progressed: {{ bill.get_progress | percentage }}</p><br>
94-
<progress class="progress is-medium is-success"
95-
value="{{ bill.get_progress_percent }}"
96-
max="100">
97-
{{ bill.get_progress | percentage }}
98-
</progress>
99-
100117
{% endif %}
101-
102-
{# MARK AS PAID MODAL #}
103-
{% mark_as_paid bill %}
104-
105118
</div>
106-
<footer class="card-footer">
107-
<a href="{% url 'django_ledger:bill-update' entity_slug=entity_slug bill_pk=bill.uuid %}"
108-
class="card-footer-item has-text-primary has-text-centered">{% trans 'Update' %}</a>
109-
<a onclick="djLedger.toggleModal('{{ bill.get_html_id }}')"
110-
class="card-footer-item has-text-info has-text-centered">{% trans 'Mark as Paid' %}</a>
111-
<a href="{% url 'django_ledger:bill-delete' entity_slug=entity_slug bill_pk=bill.uuid %}"
112-
class="card-footer-item has-text-danger has-text-centered">{% trans 'Delete' %}</a>
113-
<a href="{% url 'django_ledger:bill-void' entity_slug=entity_slug bill_pk=bill.uuid %}"
114-
class="card-footer-item has-text-warning has-text-centered">{% trans 'Void' %}</a>
115-
</footer>
116119
</div>
117120
{% endif %}
118121
{% else %}

django_ledger/templatetags/django_ledger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ def invoice_table(context):
227227

228228

229229
@register.inclusion_tag('django_ledger/tags/bill_table.html', takes_context=True)
230-
def bill_table(context):
230+
def bill_table(context, bill_qs):
231231
return {
232-
'bills': context['bills'],
232+
'bills': bill_qs,
233233
'entity_slug': context['view'].kwargs['entity_slug']
234234
}
235235

django_ledger/views/bill.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,19 @@ def delete(self, request, *args, **kwargs):
444444
# forcing QS evaluation
445445
len(bill_items_qs)
446446
if self.void:
447-
# if bill_model.void:
448-
# return HttpResponseNotFound()
447+
448+
if bill_model.void:
449+
messages.add_message(
450+
self.request,
451+
message=f'Bill {bill_model.bill_number} already voided...',
452+
level=messages.ERROR,
453+
extra_tags='is-danger')
454+
url_redirect = reverse('django_ledger:bill-detail',
455+
kwargs={
456+
'entity_slug': self.kwargs['entity_slug'],
457+
'bill_pk': bill_model.uuid
458+
})
459+
return HttpResponseRedirect(redirect_to=url_redirect)
449460

450461
bill_model.void = True
451462
ld = localdate()

0 commit comments

Comments
 (0)