diff --git a/accounting/__pycache__/views.cpython-311.pyc b/accounting/__pycache__/views.cpython-311.pyc index 86bed7d..c4192dc 100644 Binary files a/accounting/__pycache__/views.cpython-311.pyc and b/accounting/__pycache__/views.cpython-311.pyc differ diff --git a/accounting/templates/accounting/journal_entries.html b/accounting/templates/accounting/journal_entries.html index b47711e..82d1e7c 100644 --- a/accounting/templates/accounting/journal_entries.html +++ b/accounting/templates/accounting/journal_entries.html @@ -18,38 +18,80 @@ - {% for entry in entries %} -
-
-
- {% trans "Date" %}: {{ entry.date }} - {% trans "Reference" %}: {{ entry.reference }} -
-
#{{ entry.id }}
-
-
-

{% trans "Description" %}: {{ entry.description }}

+
+
- +
- - - + + + + + + - {% for item in entry.items.all %} + {% for entry in entries %} + - + + + - + + + + + {% empty %} + + {% endfor %} @@ -58,12 +100,5 @@ - {% empty %} -
-
-

{% trans "No journal entries found." %}

-
-
- {% endfor %} {% endblock %} \ No newline at end of file diff --git a/accounting/views.py b/accounting/views.py index 4eee8dd..43f269a 100644 --- a/accounting/views.py +++ b/accounting/views.py @@ -69,7 +69,10 @@ def account_create_update(request, pk=None): @login_required def journal_entries(request): - entries = JournalEntry.objects.all().order_by('-date', '-id') + entries = JournalEntry.objects.annotate( + total_debit=Sum('items__amount', filter=Q(items__type='debit')), + total_credit=Sum('items__amount', filter=Q(items__type='credit')) + ).prefetch_related('items__account').order_by('-date', '-id') return render(request, 'accounting/journal_entries.html', {'entries': entries}) @login_required diff --git a/core/templates/base.html b/core/templates/base.html index e126f04..d566c76 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -320,6 +320,29 @@ {% endif %} + + + {% endwith %} @@ -327,85 +350,15 @@
- - -
+
{% block content %}{% endblock %}
@@ -417,15 +370,17 @@ const sidebar = document.getElementById('sidebar'); const sidebarCollapse = document.getElementById('sidebarCollapse'); - sidebarCollapse.addEventListener('click', function (e) { - e.stopPropagation(); - sidebar.classList.toggle('active'); - }); + if (sidebarCollapse) { + sidebarCollapse.addEventListener('click', function (e) { + e.stopPropagation(); + sidebar.classList.toggle('active'); + }); + } // Close sidebar when clicking outside on mobile document.addEventListener('click', function (e) { - if (window.innerWidth <= 992 && sidebar.classList.contains('active')) { - if (!sidebar.contains(e.target) && e.target !== sidebarCollapse) { + if (window.innerWidth <= 992 && sidebar && sidebar.classList.contains('active')) { + if (!sidebar.contains(e.target) && e.target !== sidebarCollapse && !sidebarCollapse.contains(e.target)) { sidebar.classList.remove('active'); } } diff --git a/core/templates/core/invoice_detail.html b/core/templates/core/invoice_detail.html index cbd00db..222d2e6 100644 --- a/core/templates/core/invoice_detail.html +++ b/core/templates/core/invoice_detail.html @@ -31,18 +31,18 @@ -
+
{% trans "Account" %}{% trans "Debit" %}{% trans "Credit" %}{% trans "Date" %}{% trans "Ref #" %}{% trans "Description" %}{% trans "Debit" %}{% trans "Credit" %}{% trans "Actions" %}
{{ entry.date }} - {{ item.account.code }} - - {% if LANGUAGE_CODE == 'ar' %}{{ item.account.name_ar }}{% else %}{{ item.account.name_en }}{% endif %} + {% if entry.reference %} + {{ entry.reference }} + {% else %} + - + {% endif %} - {% if item.type == 'debit' %}{{ item.amount|floatformat:global_settings.decimal_places }}{% endif %} + {{ entry.description|truncatechars:60 }}{{ entry.total_debit|floatformat:global_settings.decimal_places }}{{ entry.total_credit|floatformat:global_settings.decimal_places }} + - {% if item.type == 'credit' %}{{ item.amount|floatformat:global_settings.decimal_places }}{% endif %} +
+
+
+
{% trans "Transaction Details" %} #{{ entry.id }}
+ {% trans "Created" %}: {{ entry.created_at|date:"Y-m-d H:i" }} +
+ + + + + + + + + + {% for item in entry.items.all %} + + + + + + {% endfor %} + +
{% trans "Account" %}{% trans "Debit" %}{% trans "Credit" %}
+ {{ item.account.code }} - + {% if LANGUAGE_CODE == 'ar' %}{{ item.account.name_ar }}{% else %}{{ item.account.name_en }}{% endif %} + + {% if item.type == 'debit' %}{{ item.amount|floatformat:global_settings.decimal_places }}{% endif %} + + {% if item.type == 'credit' %}{{ item.amount|floatformat:global_settings.decimal_places }}{% endif %} +
+
+
+ {% trans "No journal entries found." %}
- +
+ - - - - @@ -121,74 +121,74 @@ {% for item in sale.items.all %} - - - - + + + {% endfor %} - - + - - + {% if sale.discount > 0 %} - - + {% endif %} - - + - - + - - +
+
{% trans "Item Description" %}
وصف العنصر
+
{% trans "Unit Price" %}
سعر الوحدة
+
{% trans "Quantity" %}
الكمية
+
{% trans "Total" %}
المجموع
+ {{ settings.currency_symbol }}{{ item.unit_price|floatformat:3 }}{{ item.quantity|floatformat:2 }}{{ settings.currency_symbol }}{{ item.line_total|floatformat:3 }}
+ {{ settings.currency_symbol }}{{ sale.subtotal|floatformat:3 }}
+ {{ settings.currency_symbol }}{{ sale.vat_amount|floatformat:3 }}
+ -{{ settings.currency_symbol }}{{ sale.discount|floatformat:3 }}
+ {{ settings.currency_symbol }}{{ sale.total_amount|floatformat:3 }}
+ {{ settings.currency_symbol }}{{ sale.paid_amount|floatformat:3 }}
+ {{ settings.currency_symbol }}{{ sale.balance_due|floatformat:3 }}
-
-
+