Skip to content

Commit 9fe3fc9

Browse files
committed
Merge branch 'dev-elarroba' into develop
2 parents 60238f1 + ddf224d commit 9fe3fc9

File tree

5 files changed

+144
-24
lines changed

5 files changed

+144
-24
lines changed

django_ledger/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
default_app_config = 'django_ledger.apps.DjangoLedgerConfig'
1010

1111
"""Django Ledger"""
12-
__version__ = '0.4.0.4'
12+
__version__ = '0.4.0.5'
1313
__license__ = 'GPLv3 License'
1414

1515
__author__ = 'Miguel Sanda'

django_ledger/templates/django_ledger/bill_detail.html

Lines changed: 65 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,75 @@
2323
</div>
2424
</div>
2525
<div class="column is-8">
26-
<div class="card">
27-
<div class="card-header">
28-
<h2 class="card-header-title has-text-weight-light is-size-3">
29-
<span class="icon is-large">{% icon 'grommet-icons:transaction' 36 %}</span>
30-
{% trans 'Bill Transactions' %}
31-
</h2>
26+
<div class="columns is-multiline">
27+
<div class="column is-12">
28+
<div class="card">
29+
<div class="card-header">
30+
<h2 class="card-header-title has-text-weight-light is-size-3">
31+
<span class="icon is-large">{% icon 'grommet-icons:transaction' 36 %}</span>
32+
{% trans 'Bill Transactions' %}
33+
</h2>
34+
</div>
35+
<div class="card-content">
36+
{% bill_txs_table bill %}
37+
</div>
38+
</div>
39+
3240
</div>
33-
<div class="card-content">
34-
{% bill_txs_table bill %}
41+
<div class="column is-12">
42+
<div class="card">
43+
<div class="card-header">
44+
<h2 class="card-header-title has-text-weight-light is-size-3">
45+
<span class="icon is-large">{% icon 'grommet-icons:transaction' 36 %}</span>
46+
{% trans 'Bill Items' %}
47+
</h2>
48+
</div>
49+
<div class="card-content">
50+
<div class="table-container">
51+
<table class="table is-fullwidth is-narrow">
52+
53+
<thead>
54+
<tr>
55+
<th>{% trans 'Item' %}</th>
56+
<th>{% trans 'Unit Cost' %}</th>
57+
<th>{% trans 'Quantity' %}</th>
58+
<th>{% trans 'Total' %}</th>
59+
</tr>
60+
</thead>
61+
62+
<tbody>
63+
{% for bill_item in bill_items %}
64+
<tr>
65+
<td>{{ bill_item.item_model }}</td>
66+
<td>{% currency_symbol %}{{ bill_item.unit_cost | currency_format }}</td>
67+
<td>{{ bill_item.quantity }}</td>
68+
<td>{% currency_symbol %}{{ bill_item.total_amount | currency_format }}</td>
69+
</tr>
70+
{% endfor %}
71+
</tbody>
72+
73+
<tfoot>
74+
<tr>
75+
<th></th>
76+
<th></th>
77+
<th>{% trans 'Total' %}</th>
78+
<th>
79+
{% currency_symbol %}{{ total_amount_due | currency_format }}</th>
80+
<th></th>
81+
</tr>
82+
</tfoot>
83+
84+
</table>
85+
</div>
86+
</div>
87+
</div>
3588
</div>
89+
90+
3691
</div>
3792
</div>
3893
</div>
3994

95+
96+
4097
{% endblock %}

django_ledger/templates/django_ledger/invoice_detail.html

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
{% block view_content %}
77

88
<div class="columns">
9+
910
<div class="column is-4">
1011
<div class="columns is-multiline">
1112
<div class="column is-12">
@@ -22,17 +23,71 @@
2223
</div>
2324
</div>
2425
</div>
26+
2527
<div class="column is-8">
26-
<div class="card">
27-
<div class="card-header">
28-
<h2 class="card-header-title has-text-weight-light is-size-3">
29-
<span class="icon is-large">{% icon 'grommet-icons:transaction' 36 %}</span>
30-
{% trans 'Invoice Transactions' %}
31-
</h2>
28+
<div class="columns is-multiline">
29+
30+
<div class="column is-12">
31+
<div class="card">
32+
<div class="card-header">
33+
<h2 class="card-header-title has-text-weight-light is-size-3">
34+
<span class="icon is-large">{% icon 'grommet-icons:transaction' 36 %}</span>
35+
{% trans 'Invoice Transactions' %}
36+
</h2>
37+
</div>
38+
<div class="card-content">
39+
{% invoice_txs_table invoice %}
40+
</div>
41+
</div>
3242
</div>
33-
<div class="card-content">
34-
{% invoice_txs_table invoice %}
43+
44+
<div class="column is-12">
45+
<div class="card">
46+
<div class="card-header">
47+
<h2 class="card-header-title has-text-weight-light is-size-3">
48+
<span class="icon is-large">{% icon 'grommet-icons:transaction' 36 %}</span>
49+
{% trans 'Invoice Items' %}
50+
</h2>
51+
</div>
52+
<div class="card-content">
53+
<div class="table-container">
54+
<table class="table is-fullwidth is-narrow">
55+
56+
<thead>
57+
<tr>
58+
<th>{% trans 'Item' %}</th>
59+
<th>{% trans 'Unit Cost' %}</th>
60+
<th>{% trans 'Quantity' %}</th>
61+
<th>{% trans 'Total' %}</th>
62+
</tr>
63+
</thead>
64+
<tbody>
65+
{% for invoice_item in invoice_items %}
66+
<tr>
67+
<td>{{ invoice_item.item_model }}</td>
68+
<td>{% currency_symbol %}{{ invoice_item.unit_cost | currency_format }}</td>
69+
<td>{{ invoice_item.quantity }}</td>
70+
<td>
71+
{% currency_symbol %}{{ invoice_item.total_amount | currency_format }}</td>
72+
</tr>
73+
{% endfor %}
74+
</tbody>
75+
<tfoot>
76+
<tr>
77+
<th></th>
78+
<th></th>
79+
<th>{% trans 'Total' %}</th>
80+
<th>
81+
{% currency_symbol %}{{ total_amount_due | currency_format }}</th>
82+
<th></th>
83+
</tr>
84+
</tfoot>
85+
</table>
86+
</div>
87+
</div>
88+
</div>
3589
</div>
90+
3691
</div>
3792
</div>
3893
</div>

django_ledger/views/bill.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from django_ledger.models.bill import BillModel
2222
from django_ledger.utils import new_bill_protocol, mark_progressible_paid
2323
from django_ledger.views.mixins import LoginRequiredMixIn
24-
from django_ledger.views.transactions import TransactionModel
2524

2625

2726
class BillModelListView(LoginRequiredMixIn, ArchiveIndexView):
@@ -228,11 +227,13 @@ def get_context_data(self, *, object_list=None, **kwargs):
228227
title = f'Bill {bill_model.bill_number}'
229228
context['page_title'] = title
230229
context['header_title'] = title
231-
context['transactions'] = TransactionModel.objects.for_bill(
232-
bill_pk=bill_model.uuid,
233-
user_model=self.request.user,
234-
entity_slug=self.kwargs['entity_slug']
235-
).select_related('journal_entry').order_by('-journal_entry__date')
230+
231+
bill_model: BillModel = self.object
232+
bill_items_qs, item_data = bill_model.get_bill_item_data(
233+
queryset=bill_model.billmodelitemsthroughmodel_set.all()
234+
)
235+
context['bill_items'] = bill_items_qs
236+
context['total_amount_due'] = item_data['amount_due']
236237
return context
237238

238239
def get_queryset(self):

django_ledger/views/invoice.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,20 @@ def get_context_data(self, *, object_list=None, **kwargs):
228228
title = f'Invoice {invoice}'
229229
context['page_title'] = title
230230
context['header_title'] = title
231+
232+
invoice_model: InvoiceModel = self.object
233+
invoice_items_qs, item_data = invoice_model.get_invoice_item_data(
234+
queryset=invoice_model.invoicemodelitemsthroughmodel_set.all()
235+
)
236+
context['invoice_items'] = invoice_items_qs
237+
context['total_amount_due'] = item_data['amount_due']
231238
return context
232239

233240
def get_queryset(self):
234241
return InvoiceModel.objects.for_entity(
235242
entity_slug=self.kwargs['entity_slug'],
236243
user_model=self.request.user
237-
).select_related('ledger', 'customer')
244+
).prefetch_related('invoicemodelitemsthroughmodel_set').select_related('ledger', 'customer')
238245

239246

240247
class InvoiceModelDeleteView(LoginRequiredMixIn, DeleteView):

0 commit comments

Comments
 (0)