Autosave: 20260203-030052

This commit is contained in:
Flatlogic Bot 2026-02-03 03:00:53 +00:00
parent 82334fa523
commit 7a5e1a7044
17 changed files with 924 additions and 26 deletions

Binary file not shown.

View File

@ -53,11 +53,11 @@
<!-- Sales Group --> <!-- Sales Group -->
<li class="sidebar-group-header mt-2"> <li class="sidebar-group-header mt-2">
<a href="#salesSubmenu" data-bs-toggle="collapse" aria-expanded="{% if url_name == 'pos' or url_name == 'invoice_create' or url_name == 'invoices' or url_name == 'invoice_detail' or url_name == 'quotations' or url_name == 'quotation_create' or url_name == 'quotation_detail' or 'sales/returns' in path or url_name == 'customer_payments' %}true{% else %}false{% endif %}" class="dropdown-toggle-custom"> <a href="#salesSubmenu" data-bs-toggle="collapse" aria-expanded="{% if url_name == 'pos' or url_name == 'invoice_create' or url_name == 'invoices' or url_name == 'invoice_detail' or url_name == 'quotations' or url_name == 'quotation_create' or url_name == 'quotation_detail' or 'sales/returns' in path %}true{% else %}false{% endif %}" class="dropdown-toggle-custom">
<span>{% trans "Sales" %}</span> <span>{% trans "Sales" %}</span>
<i class="bi bi-chevron-down chevron"></i> <i class="bi bi-chevron-down chevron"></i>
</a> </a>
<ul class="collapse list-unstyled sub-menu {% if url_name == 'pos' or url_name == 'invoice_create' or url_name == 'invoices' or url_name == 'invoice_detail' or url_name == 'quotations' or url_name == 'quotation_create' or url_name == 'quotation_detail' or 'sales/returns' in path or url_name == 'customer_payments' %}show{% endif %}" id="salesSubmenu"> <ul class="collapse list-unstyled sub-menu {% if url_name == 'pos' or url_name == 'invoice_create' or url_name == 'invoices' or url_name == 'invoice_detail' or url_name == 'quotations' or url_name == 'quotation_create' or url_name == 'quotation_detail' or 'sales/returns' in path %}show{% endif %}" id="salesSubmenu">
<li> <li>
<a href="{% url 'pos' %}" class="{% if url_name == 'pos' %}active{% endif %}"> <a href="{% url 'pos' %}" class="{% if url_name == 'pos' %}active{% endif %}">
<i class="bi bi-shop"></i> {% trans "POS System" %} <i class="bi bi-shop"></i> {% trans "POS System" %}
@ -83,11 +83,6 @@
<i class="bi bi-arrow-return-left"></i> {% trans "Sales Return" %} <i class="bi bi-arrow-return-left"></i> {% trans "Sales Return" %}
</a> </a>
</li> </li>
<li>
<a href="{% url 'customer_payments' %}" class="{% if url_name == 'customer_payments' %}active{% endif %}">
<i class="bi bi-receipt-cutoff"></i> {% trans 'Customer Receipts' %}
</a>
</li>
</ul> </ul>
</li> </li>
@ -138,11 +133,7 @@
<i class="bi bi-upc-scan"></i> {% trans "Barcode Printing" %} <i class="bi bi-upc-scan"></i> {% trans "Barcode Printing" %}
</a> </a>
</li> </li>
<li>
<a href="{% url 'reports' %}" class="{% if url_name == 'reports' %}active{% endif %}">
<i class="bi bi-graph-up-arrow"></i> {% trans "Reports" %}
</a>
</li>
</ul> </ul>
</li> </li>
@ -187,6 +178,32 @@
</li> </li>
{% if user.is_superuser or user.is_staff %} {% if user.is_superuser or user.is_staff %}
<!-- Reports Group -->
<li class="sidebar-group-header mt-2">
<a href="#reportsSubmenu" data-bs-toggle="collapse" aria-expanded="{% if url_name == 'reports' or url_name == 'customer_statement' or url_name == 'supplier_statement' %}true{% else %}false{% endif %}" class="dropdown-toggle-custom">
<span>{% trans "Reports" %}</span>
<i class="bi bi-chevron-down chevron"></i>
</a>
<ul class="collapse list-unstyled sub-menu {% if url_name == 'reports' or url_name == 'customer_statement' or url_name == 'supplier_statement' %}show{% endif %}" id="reportsSubmenu">
<li>
<a href="{% url 'reports' %}" class="{% if url_name == 'reports' %}active{% endif %}">
<i class="bi bi-graph-up-arrow"></i> {% trans "Overview Reports" %}
</a>
</li>
<li>
<a href="{% url 'customer_statement' %}" class="{% if url_name == 'customer_statement' %}active{% endif %}">
<i class="bi bi-person-lines-fill"></i> {% trans "Customer Statement" %}
</a>
</li>
<li>
<a href="{% url 'supplier_statement' %}" class="{% if url_name == 'supplier_statement' %}active{% endif %}">
<i class="bi bi-truck-flatbed"></i> {% trans "Supplier Statement" %}
</a>
</li>
</ul>
</li>
<!-- System Group --> <!-- System Group -->
<li class="sidebar-group-header mt-2"> <li class="sidebar-group-header mt-2">
<a href="#systemSubmenu" data-bs-toggle="collapse" aria-expanded="{% if url_name == 'settings' or url_name == 'user_management' or '/admin/' in path %}true{% else %}false{% endif %}" class="dropdown-toggle-custom"> <a href="#systemSubmenu" data-bs-toggle="collapse" aria-expanded="{% if url_name == 'settings' or url_name == 'user_management' or '/admin/' in path %}true{% else %}false{% endif %}" class="dropdown-toggle-custom">

View File

@ -116,6 +116,15 @@
font-weight: 700; font-weight: 700;
margin-top: 5px; margin-top: 5px;
} }
.amount-in-words {
text-align: center;
margin-top: 15px;
font-style: italic;
color: #666;
font-size: 14px;
border-top: 1px solid #eee;
padding-top: 10px;
}
.footer { .footer {
text-align: center; text-align: center;
margin-top: 40px; margin-top: 40px;
@ -212,6 +221,10 @@
<div class="amount">{{ settings.currency_symbol }}{{ payment.amount|floatformat:3 }}</div> <div class="amount">{{ settings.currency_symbol }}{{ payment.amount|floatformat:3 }}</div>
</div> </div>
<div class="amount-in-words">
<strong>{% trans "Amount in Words" %}:</strong> {{ amount_in_words }}
</div>
<div class="footer"> <div class="footer">
<p>{% trans "Thank you for your business!" %}</p> <p>{% trans "Thank you for your business!" %}</p>
<p>{{ settings.business_name }} &copy; {% now "Y" %}</p> <p>{{ settings.business_name }} &copy; {% now "Y" %}</p>

View File

@ -0,0 +1,165 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Customer Statement" %} | {{ site_settings.business_name }}{% endblock %}
{% block content %}
<div class="container-fluid">
<div class="row mb-4 no-print">
<div class="col-md-6">
<h1 class="h3 fw-bold">{% trans "Customer Statement" %}</h1>
<p class="text-muted">{% trans "View transaction history and balance for customers." %}</p>
</div>
<div class="col-md-6 text-end">
<button onclick="window.print()" class="btn btn-outline-primary rounded-pill px-4">
<i class="bi bi-printer me-2"></i> {% trans "Print Statement" %}
</button>
</div>
</div>
<!-- Filters -->
<div class="card border-0 shadow-sm p-4 mb-4 no-print rounded-4">
<form method="get" class="row g-3 align-items-end">
<div class="col-md-4">
<label class="form-label small fw-bold">{% trans "Customer" %}</label>
<select name="customer" class="form-select rounded-pill" required>
<option value="">{% trans "Select Customer" %}</option>
{% for c in customers %}
<option value="{{ c.id }}" {% if customer.id == c.id %}selected{% endif %}>{{ c.name }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-3">
<label class="form-label small fw-bold">{% trans "From Date" %}</label>
<input type="date" name="start_date" class="form-select rounded-pill" value="{{ start_date }}">
</div>
<div class="col-md-3">
<label class="form-label small fw-bold">{% trans "To Date" %}</label>
<input type="date" name="end_date" class="form-select rounded-pill" value="{{ end_date }}">
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-primary w-100 rounded-pill">
<i class="bi bi-search me-2"></i> {% trans "Filter" %}
</button>
</div>
</form>
</div>
{% if customer %}
<div class="statement-print">
<div class="card border-0 shadow-sm overflow-hidden rounded-4">
<div class="card-header bg-white border-0 p-4">
<div class="row align-items-center">
<div class="col-sm-6">
{% if settings.logo %}
<img src="{{ settings.logo.url }}" alt="Logo" height="50" class="mb-3">
{% endif %}
<h4 class="fw-bold mb-1">{{ settings.business_name }}</h4>
<p class="text-muted mb-0 small">{{ settings.address }}</p>
<p class="text-muted mb-0 small">{{ settings.phone }} | {{ settings.email }}</p>
</div>
<div class="col-sm-6 text-sm-end mt-3 mt-sm-0">
<h2 class="text-primary fw-bold mb-1">{% trans "STATEMENT" %}</h2>
<p class="mb-0"><strong>{% trans "Date" %}:</strong> {% now "Y-m-d" %}</p>
{% if start_date or end_date %}
<p class="mb-0 small text-muted">
{% if start_date %}{% trans "From" %}: {{ start_date }}{% endif %}
{% if end_date %} {% trans "To" %}: {{ end_date }}{% endif %}
</p>
{% endif %}
</div>
</div>
<hr class="my-4">
<div class="row">
<div class="col-sm-6">
<h6 class="text-uppercase text-muted small fw-bold mb-2">{% trans "Bill To" %}</h6>
<h5 class="fw-bold mb-1">{{ customer.name }}</h5>
<p class="text-muted mb-0">{{ customer.address }}</p>
<p class="text-muted mb-0">{{ customer.phone }}</p>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="bg-light">
<tr>
<th class="ps-4">{% trans "Date" %}</th>
<th>{% trans "Transaction" %}</th>
<th>{% trans "Reference" %}</th>
<th class="text-end">{% trans "Debit" %} (+)</th>
<th class="text-end">{% trans "Credit" %} (-)</th>
<th class="text-end pe-4">{% trans "Balance" %}</th>
</tr>
</thead>
<tbody>
{% if opening_balance != 0 or start_date %}
<tr class="table-light italic">
<td class="ps-4 text-muted">{{ start_date|default:"---" }}</td>
<td colspan="2" class="fw-bold text-muted">{% trans "Opening Balance" %}</td>
<td class="text-end">{% if opening_balance > 0 %}{{ settings.currency_symbol }}{{ opening_balance|floatformat:settings.decimal_places }}{% endif %}</td>
<td class="text-end">{% if opening_balance < 0 %}{{ settings.currency_symbol }}{{ opening_balance_abs|floatformat:settings.decimal_places }}{% endif %}</td>
<td class="text-end pe-4 fw-bold">{{ settings.currency_symbol }}{{ opening_balance|floatformat:settings.decimal_places }}</td>
</tr>
{% endif %}
{% for item in statement_data %}
<tr>
<td class="ps-4">{{ item.date|date:"Y-m-d" }}</td>
<td>{{ item.type }}</td>
<td><span class="badge bg-light text-dark fw-normal">{{ item.reference }}</span></td>
<td class="text-end text-danger">
{% if item.debit > 0 %}
{{ settings.currency_symbol }}{{ item.debit|floatformat:settings.decimal_places }}
{% else %}-{% endif %}
</td>
<td class="text-end text-success">
{% if item.credit > 0 %}
{{ settings.currency_symbol }}{{ item.credit|floatformat:settings.decimal_places }}
{% else %}-{% endif %}
</td>
<td class="text-end pe-4 fw-bold">{{ settings.currency_symbol }}{{ item.balance|floatformat:settings.decimal_places }}</td>
</tr>
{% empty %}
<tr>
<td colspan="6" class="text-center py-5 text-muted">{% trans "No transactions found for the selected period." %}</td>
</tr>
{% endfor %}
</tbody>
<tfoot class="bg-primary text-white">
<tr>
<td colspan="5" class="ps-4 fw-bold text-uppercase">{% trans "Closing Balance" %}</td>
<td class="text-end pe-4 fw-bold fs-5">
{% with last=statement_data|last %}
{{ settings.currency_symbol }}{{ last.balance|default:opening_balance|floatformat:settings.decimal_places }}
{% endwith %}
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
{% else %}
<div class="text-center py-5">
<div class="bg-light rounded-circle d-inline-flex align-items-center justify-content-center mb-4" style="width: 100px; height: 100px;">
<i class="bi bi-person-lines-fill fs-1 text-primary"></i>
</div>
<h4 class="fw-bold">{% trans "Select a Customer" %}</h4>
<p class="text-muted">{% trans "Please select a customer and date range to view their statement." %}</p>
</div>
{% endif %}
</div>
<style>
@media print {
.no-print { display: none !important; }
body { background: white !important; }
.statement-print { margin: 0; padding: 0; }
.card { border: none !important; shadow: none !important; }
#sidebar, .top-navbar { display: none !important; }
#content { margin-left: 0 !important; width: 100% !important; padding: 0 !important; }
.main { padding: 0 !important; }
}
</style>
{% endblock %}

View File

@ -168,6 +168,14 @@
</table> </table>
</div> </div>
<!-- Amount in Words -->
<div class="mb-5 px-5">
<div class="p-3 bg-light rounded-3">
<div class="small text-muted fw-bold text-uppercase mb-1">{% trans "Amount in Words" %} / المبلغ بالحروف</div>
<div class="fw-bold text-dark">{{ amount_in_words }}</div>
</div>
</div>
<!-- Payment History --> <!-- Payment History -->
{% if sale.payments.exists %} {% if sale.payments.exists %}
<div class="mb-5 px-5"> <div class="mb-5 px-5">

View File

@ -251,7 +251,7 @@
this.cart.splice(index, 1); this.cart.splice(index, 1);
}, },
saveSale() { saveSale() {
this.isProcessing = true; this.isProcessing = true; if (!this.customerId && this.paymentType !== 'cash') { alert('{% trans "Credit or Partial payments are not allowed for Guest customers." %}'); this.isProcessing = false; return; }
let actualPaidAmount = 0; let actualPaidAmount = 0;
if (this.paymentType === 'cash') { if (this.paymentType === 'cash') {

View File

@ -106,6 +106,11 @@
</td> </td>
<td class="text-end pe-4"> <td class="text-end pe-4">
<div class="btn-group shadow-sm rounded-3"> <div class="btn-group shadow-sm rounded-3">
{% if sale.status == 'paid' %}
<a href="{% url 'sale_receipt' sale.id %}" class="btn btn-sm btn-white border text-success" title="{% trans 'Payment Receipt' %}">
<i class="bi bi-receipt"></i>
</a>
{% endif %}
<a href="{% url 'invoice_detail' sale.id %}" class="btn btn-sm btn-white border" title="{% trans 'View & Print' %}"> <a href="{% url 'invoice_detail' sale.id %}" class="btn btn-sm btn-white border" title="{% trans 'View & Print' %}">
<i class="bi bi-printer"></i> <i class="bi bi-printer"></i>
</a> </a>

View File

@ -345,7 +345,7 @@
<div class="row g-4"> <div class="row g-4">
<!-- Left: Payment Types --> <!-- Left: Payment Types -->
<div class="col-md-3 border-md-end"> <div class="col-md-3 border-md-end">
<label class="small fw-bold text-muted mb-2 d-block">{% trans "Payment Method" %}</label> <div class="mb-4"><label class="small fw-bold text-muted mb-2 d-block">{% trans "Payment Type" %}</label><div class="d-grid gap-2"><button id="typeCashBtn" class="btn btn-sm btn-primary active rounded-3" onclick="selectPaymentType('cash')">{% trans "Cash" %}</button><button id="typeCreditBtn" class="btn btn-sm btn-outline-primary rounded-3" onclick="selectPaymentType('credit')">{% trans "Credit" %}</button></div></div><label class="small fw-bold text-muted mb-2 d-block" id="paymentMethodLabel">{% trans "Payment Method" %}</label>
<div class="row g-2 row-cols-3 row-cols-md-1" id="paymentMethodButtons"> <div class="row g-2 row-cols-3 row-cols-md-1" id="paymentMethodButtons">
{% for method in payment_methods %} {% for method in payment_methods %}
<div class="col"> <div class="col">
@ -637,7 +637,7 @@
selectPaymentMethod(firstBtn, firstBtn.dataset.id); selectPaymentMethod(firstBtn, firstBtn.dataset.id);
} }
const paymentModal = new bootstrap.Modal(document.getElementById('paymentModal')); selectPaymentType('cash'); const paymentModal = new bootstrap.Modal(document.getElementById('paymentModal'));
paymentModal.show(); paymentModal.show();
} }
@ -692,7 +692,7 @@
calculateBalance(); calculateBalance();
} }
function selectPaymentMethod(btn, id) { let currentPaymentType = 'cash'; function selectPaymentType(type) { const customerId = document.getElementById('customerSelect').value; if (type === 'credit' && !customerId) { alert('{% trans "Credit sales are not allowed for Walking Customers. Please select a customer." %}'); return; } currentPaymentType = type; document.getElementById('typeCashBtn').classList.toggle('active', type === 'cash'); document.getElementById('typeCashBtn').classList.toggle('btn-primary', type === 'cash'); document.getElementById('typeCashBtn').classList.toggle('btn-outline-primary', type !== 'cash'); document.getElementById('typeCreditBtn').classList.toggle('active', type === 'credit'); document.getElementById('typeCreditBtn').classList.toggle('btn-primary', type === 'credit'); document.getElementById('typeCreditBtn').classList.toggle('btn-outline-primary', type !== 'credit'); const isCredit = type === 'credit'; document.getElementById('cashReceivedInput').disabled = isCredit; document.getElementById('paymentMethodButtons').querySelectorAll('button').forEach(btn => btn.disabled = isCredit); if (isCredit) { document.getElementById('cashReceivedInput').value = 0; calculateBalance(); } else { setExactAmount(); } } function selectPaymentMethod(btn, id) {
document.querySelectorAll('.payment-method-btn').forEach(b => b.classList.remove('active')); document.querySelectorAll('.payment-method-btn').forEach(b => b.classList.remove('active'));
btn.classList.add('active'); btn.classList.add('active');
selectedPaymentMethodId = id; selectedPaymentMethodId = id;
@ -757,13 +757,13 @@
const data = { const data = {
customer_id: document.getElementById('customerSelect').value, customer_id: document.getElementById('customerSelect').value,
payment_method_id: selectedPaymentMethodId, payment_method_id: currentPaymentType === 'cash' ? selectedPaymentMethodId : null,
items: cart, items: cart,
total_amount: totalAmount, total_amount: totalAmount,
paid_amount: totalAmount, paid_amount: currentPaymentType === 'cash' ? totalAmount : 0,
discount: discount, discount: discount,
loyalty_points_redeemed: loyaltyRedeem, loyalty_points_redeemed: loyaltyRedeem,
payment_type: 'cash' payment_type: currentPaymentType
}; };
fetch('{% url "create_sale_api" %}', { fetch('{% url "create_sale_api" %}', {

View File

@ -154,6 +154,14 @@
</table> </table>
</div> </div>
<!-- Amount in Words -->
<div class="mb-5 px-5">
<div class="p-3 bg-light rounded-3">
<div class="small text-muted fw-bold text-uppercase mb-1">{% trans "Amount in Words" %} / المبلغ بالحروف</div>
<div class="fw-bold text-dark">{{ amount_in_words }}</div>
</div>
</div>
<!-- Payment History --> <!-- Payment History -->
{% if purchase.payments.exists %} {% if purchase.payments.exists %}
<div class="mb-5 px-5"> <div class="mb-5 px-5">

View File

@ -178,6 +178,14 @@
</table> </table>
</div> </div>
<!-- Amount in Words -->
<div class="mb-5 px-5">
<div class="p-3 bg-light rounded-3">
<div class="small text-muted fw-bold text-uppercase mb-1">{% trans "Amount in Words" %} / المبلغ بالحروف</div>
<div class="fw-bold text-dark">{{ amount_in_words }}</div>
</div>
</div>
<!-- Terms & Conditions --> <!-- Terms & Conditions -->
<div class="mb-5"> <div class="mb-5">
<h6 class="fw-bold small text-uppercase mb-3 text-muted border-bottom pb-2">{% trans "Terms and Conditions" %} / الشروط والأحكام</h6> <h6 class="fw-bold small text-uppercase mb-3 text-muted border-bottom pb-2">{% trans "Terms and Conditions" %} / الشروط والأحكام</h6>

View File

@ -0,0 +1,235 @@
{% load i18n static %}
<!DOCTYPE html>
<html lang="{{ LANGUAGE_CODE }}" dir="{% if LANGUAGE_CODE == 'ar' %}rtl{% else %}ltr{% endif %}">
<head>
<meta charset="UTF-8">
<title>{% trans "Payment Receipt" %} #{{ sale.invoice_number|default:sale.id }}</title>
<style>
@media print {
.no-print { display: none; }
body { padding: 0; margin: 0; }
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
color: #333;
line-height: 1.6;
padding: 40px;
background-color: #f8f9fa;
}
.receipt-container {
max-width: 800px;
margin: 0 auto;
background: #fff;
padding: 40px;
border-radius: 12px;
box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}
.header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 40px;
border-bottom: 2px solid #eee;
padding-bottom: 20px;
}
.business-info h1 {
margin: 0;
color: #0d6efd;
font-size: 28px;
}
.business-info p {
margin: 5px 0;
color: #666;
font-size: 14px;
}
.receipt-title {
text-align: right;
}
.receipt-title h2 {
margin: 0;
font-size: 24px;
color: #333;
text-transform: uppercase;
letter-spacing: 2px;
}
.receipt-meta {
margin-top: 10px;
font-size: 14px;
color: #666;
}
.info-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 40px;
margin-bottom: 40px;
}
.info-box h3 {
font-size: 14px;
text-transform: uppercase;
color: #999;
margin-bottom: 10px;
border-bottom: 1px solid #eee;
padding-bottom: 5px;
}
.info-box p {
margin: 0;
font-weight: 600;
}
.payment-details {
background-color: #fcfcfc;
border: 1px solid #eee;
border-radius: 8px;
padding: 20px;
margin-bottom: 40px;
}
.detail-row {
display: flex;
justify-content: space-between;
padding: 10px 0;
border-bottom: 1px dashed #eee;
}
.detail-row:last-child {
border-bottom: none;
}
.label {
color: #666;
}
.value {
font-weight: 600;
}
.amount-box {
background-color: #198754;
color: #fff;
padding: 20px;
border-radius: 8px;
text-align: center;
margin-top: 20px;
}
.amount-box h4 {
margin: 0;
font-size: 14px;
text-transform: uppercase;
opacity: 0.8;
}
.amount-box .amount {
font-size: 32px;
font-weight: 700;
margin-top: 5px;
}
.amount-in-words {
text-align: center;
margin-top: 15px;
font-style: italic;
color: #666;
font-size: 14px;
border-top: 1px solid #eee;
padding-top: 10px;
}
.footer {
text-align: center;
margin-top: 40px;
color: #999;
font-size: 12px;
border-top: 1px solid #eee;
padding-top: 20px;
}
.btn-print {
background: #333;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 6px;
cursor: pointer;
font-weight: 600;
margin-bottom: 20px;
}
.btn-print:hover { background: #000; }
[dir="rtl"] .header, [dir="rtl"] .detail-row {
flex-direction: row-reverse;
}
[dir="rtl"] .receipt-title {
text-align: left;
}
</style>
</head>
<body>
<div class="no-print" style="text-align: center;">
<button class="btn-print" onclick="window.print()">{% trans "Print Receipt" %}</button>
<a href="{% url 'invoices' %}" class="btn-print" style="text-decoration: none; display: inline-block; background: #6c757d;">{% trans "Back to Invoices" %}</a>
</div>
<div class="receipt-container">
<div class="header">
<div class="business-info">
{% if settings.logo %}
<img src="{{ settings.logo.url }}" alt="Logo" height="50" style="margin-bottom: 10px;">
{% endif %}
<h1>{{ settings.business_name }}</h1>
<p>{{ settings.address|linebreaksbr }}</p>
<p>{% trans "Phone" %}: {{ settings.phone }}</p>
{% if settings.vat_number %}
<p>{% trans "VAT No" %}: {{ settings.vat_number }}</p>
{% endif %}
</div>
<div class="receipt-title">
<h2>{% trans "Payment Receipt" %}</h2>
<div class="receipt-meta">
<p><strong>{% trans "Invoice #" %}:</strong> {{ sale.invoice_number|default:sale.id }}</p>
<p><strong>{% trans "Date" %}:</strong> {{ sale.created_at|date:"Y-m-d" }}</p>
</div>
</div>
</div>
<div class="info-grid">
<div class="info-box">
<h3>{% trans "Received From" %}</h3>
<p>{{ sale.customer.name|default:"Guest" }}</p>
{% if sale.customer.phone %}
<p class="text-muted" style="font-weight: normal; font-size: 14px;">{{ sale.customer.phone }}</p>
{% endif %}
</div>
<div class="info-box">
<h3>{% trans "Status" %}</h3>
<p style="color: #198754; font-weight: bold; text-transform: uppercase;">{% trans "Paid In Full" %}</p>
<p class="text-muted" style="font-weight: normal; font-size: 14px;">{% trans "Total Invoice" %}: {{ settings.currency_symbol }}{{ sale.total_amount|floatformat:3 }}</p>
</div>
</div>
<div class="payment-details">
<div class="detail-row">
<span class="label">{% trans "Payment Type" %}</span>
<span class="value">{{ sale.get_payment_type_display }}</span>
</div>
<div class="detail-row">
<span class="label">{% trans "Transaction Status" %}</span>
<span class="value" style="color: #198754;">{% trans "Settled" %}</span>
</div>
<div class="detail-row">
<span class="label">{% trans "Sold By" %}</span>
<span class="value">{{ sale.created_by.get_full_name|default:sale.created_by.username }}</span>
</div>
{% if sale.notes %}
<div class="detail-row">
<span class="label">{% trans "Notes" %}</span>
<span class="value">{{ sale.notes }}</span>
</div>
{% endif %}
</div>
<div class="amount-box">
<h4>{% trans "Total Amount Received" %}</h4>
<div class="amount">{{ settings.currency_symbol }}{{ sale.total_amount|floatformat:3 }}</div>
</div>
<div class="amount-in-words">
<strong>{% trans "Amount in Words" %}:</strong> {{ amount_in_words }}
</div>
<div class="footer">
<p>{% trans "Thank you for your business!" %}</p>
<p>{{ settings.business_name }} &copy; {% now "Y" %}</p>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,164 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Supplier Statement" %} | {{ site_settings.business_name }}{% endblock %}
{% block content %}
<div class="container-fluid">
<div class="row mb-4 no-print">
<div class="col-md-6">
<h1 class="h3 fw-bold">{% trans "Supplier Statement" %}</h1>
<p class="text-muted">{% trans "View transaction history and balance for suppliers." %}</p>
</div>
<div class="col-md-6 text-end">
<button onclick="window.print()" class="btn btn-outline-primary rounded-pill px-4">
<i class="bi bi-printer me-2"></i> {% trans "Print Statement" %}
</button>
</div>
</div>
<!-- Filters -->
<div class="card border-0 shadow-sm p-4 mb-4 no-print rounded-4">
<form method="get" class="row g-3 align-items-end">
<div class="col-md-4">
<label class="form-label small fw-bold">{% trans "Supplier" %}</label>
<select name="supplier" class="form-select rounded-pill" required>
<option value="">{% trans "Select Supplier" %}</option>
{% for s in suppliers %}
<option value="{{ s.id }}" {% if supplier.id == s.id %}selected{% endif %}>{{ s.name }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-3">
<label class="form-label small fw-bold">{% trans "From Date" %}</label>
<input type="date" name="start_date" class="form-select rounded-pill" value="{{ start_date }}">
</div>
<div class="col-md-3">
<label class="form-label small fw-bold">{% trans "To Date" %}</label>
<input type="date" name="end_date" class="form-select rounded-pill" value="{{ end_date }}">
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-primary w-100 rounded-pill">
<i class="bi bi-search me-2"></i> {% trans "Filter" %}
</button>
</div>
</form>
</div>
{% if supplier %}
<div class="statement-print">
<div class="card border-0 shadow-sm overflow-hidden rounded-4">
<div class="card-header bg-white border-0 p-4">
<div class="row align-items-center">
<div class="col-sm-6">
{% if settings.logo %}
<img src="{{ settings.logo.url }}" alt="Logo" height="50" class="mb-3">
{% endif %}
<h4 class="fw-bold mb-1">{{ settings.business_name }}</h4>
<p class="text-muted mb-0 small">{{ settings.address }}</p>
<p class="text-muted mb-0 small">{{ settings.phone }} | {{ settings.email }}</p>
</div>
<div class="col-sm-6 text-sm-end mt-3 mt-sm-0">
<h2 class="text-primary fw-bold mb-1">{% trans "SUPPLIER STATEMENT" %}</h2>
<p class="mb-0"><strong>{% trans "Date" %}:</strong> {% now "Y-m-d" %}</p>
{% if start_date or end_date %}
<p class="mb-0 small text-muted">
{% if start_date %}{% trans "From" %}: {{ start_date }}{% endif %}
{% if end_date %} {% trans "To" %}: {{ end_date }}{% endif %}
</p>
{% endif %}
</div>
</div>
<hr class="my-4">
<div class="row">
<div class="col-sm-6">
<h6 class="text-uppercase text-muted small fw-bold mb-2">{% trans "Supplier" %}</h6>
<h5 class="fw-bold mb-1">{{ supplier.name }}</h5>
<p class="text-muted mb-0">{{ supplier.phone }}</p>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="bg-light">
<tr>
<th class="ps-4">{% trans "Date" %}</th>
<th>{% trans "Transaction" %}</th>
<th>{% trans "Reference" %}</th>
<th class="text-end">{% trans "Debit" %} (+)</th>
<th class="text-end">{% trans "Credit" %} (-)</th>
<th class="text-end pe-4">{% trans "Balance" %}</th>
</tr>
</thead>
<tbody>
{% if opening_balance != 0 or start_date %}
<tr class="table-light italic">
<td class="ps-4 text-muted">{{ start_date|default:"---" }}</td>
<td colspan="2" class="fw-bold text-muted">{% trans "Opening Balance" %}</td>
<td class="text-end">{% if opening_balance > 0 %}{{ settings.currency_symbol }}{{ opening_balance|floatformat:settings.decimal_places }}{% endif %}</td>
<td class="text-end">{% if opening_balance < 0 %}{{ settings.currency_symbol }}{{ opening_balance_abs|floatformat:settings.decimal_places }}{% endif %}</td>
<td class="text-end pe-4 fw-bold">{{ settings.currency_symbol }}{{ opening_balance|floatformat:settings.decimal_places }}</td>
</tr>
{% endif %}
{% for item in statement_data %}
<tr>
<td class="ps-4">{{ item.date|date:"Y-m-d" }}</td>
<td>{{ item.type }}</td>
<td><span class="badge bg-light text-dark fw-normal">{{ item.reference }}</span></td>
<td class="text-end text-danger">
{% if item.debit > 0 %}
{{ settings.currency_symbol }}{{ item.debit|floatformat:settings.decimal_places }}
{% else %}-{% endif %}
</td>
<td class="text-end text-success">
{% if item.credit > 0 %}
{{ settings.currency_symbol }}{{ item.credit|floatformat:settings.decimal_places }}
{% else %}-{% endif %}
</td>
<td class="text-end pe-4 fw-bold">{{ settings.currency_symbol }}{{ item.balance|floatformat:settings.decimal_places }}</td>
</tr>
{% empty %}
<tr>
<td colspan="6" class="text-center py-5 text-muted">{% trans "No transactions found for the selected period." %}</td>
</tr>
{% endfor %}
</tbody>
<tfoot class="bg-primary text-white">
<tr>
<td colspan="5" class="ps-4 fw-bold text-uppercase">{% trans "Closing Balance" %}</td>
<td class="text-end pe-4 fw-bold fs-5">
{% with last=statement_data|last %}
{{ settings.currency_symbol }}{{ last.balance|default:opening_balance|floatformat:settings.decimal_places }}
{% endwith %}
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
{% else %}
<div class="text-center py-5">
<div class="bg-light rounded-circle d-inline-flex align-items-center justify-content-center mb-4" style="width: 100px; height: 100px;">
<i class="bi bi-truck-flatbed fs-1 text-primary"></i>
</div>
<h4 class="fw-bold">{% trans "Select a Supplier" %}</h4>
<p class="text-muted">{% trans "Please select a supplier and date range to view their statement." %}</p>
</div>
{% endif %}
</div>
<style>
@media print {
.no-print { display: none !important; }
body { background: white !important; }
.statement-print { margin: 0; padding: 0; }
.card { border: none !important; shadow: none !important; }
#sidebar, .top-navbar { display: none !important; }
#content { margin-left: 0 !important; width: 100% !important; padding: 0 !important; }
.main { padding: 0 !important; }
}
</style>
{% endblock %}

View File

@ -9,6 +9,8 @@ urlpatterns = [
path('suppliers/', views.suppliers, name='suppliers'), path('suppliers/', views.suppliers, name='suppliers'),
path('purchases/', views.purchases, name='purchases'), path('purchases/', views.purchases, name='purchases'),
path('reports/', views.reports, name='reports'), path('reports/', views.reports, name='reports'),
path('reports/customer-statement/', views.customer_statement, name='customer_statement'),
path('reports/supplier-statement/', views.supplier_statement, name='supplier_statement'),
path('settings/', views.settings_view, name='settings'), path('settings/', views.settings_view, name='settings'),
path('profile/', views.profile_view, name='profile'), path('profile/', views.profile_view, name='profile'),
path('users/', views.user_management, name='user_management'), path('users/', views.user_management, name='user_management'),
@ -22,6 +24,7 @@ urlpatterns = [
path('invoices/delete/<int:pk>/', views.delete_sale, name='delete_sale'), path('invoices/delete/<int:pk>/', views.delete_sale, name='delete_sale'),
path('invoices/payments/', views.customer_payments, name='customer_payments'), path('invoices/payments/', views.customer_payments, name='customer_payments'),
path('invoices/receipt/<int:pk>/', views.customer_payment_receipt, name='customer_payment_receipt'), path('invoices/receipt/<int:pk>/', views.customer_payment_receipt, name='customer_payment_receipt'),
path('invoices/sale-receipt/<int:pk>/', views.sale_receipt, name='sale_receipt'),
path("invoices/edit/<int:pk>/", views.edit_invoice, name="edit_invoice"), path("invoices/edit/<int:pk>/", views.edit_invoice, name="edit_invoice"),
# Quotations # Quotations

64
core/utils.py Normal file
View File

@ -0,0 +1,64 @@
def number_to_words_en(number):
"""
Converts a number to English words.
Handles decimals up to 3 places (common for some currencies).
"""
if number == 0:
return "Zero"
units = ["", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten",
"Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"]
tens = ["", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"]
thousands = ["", "Thousand", "Million", "Billion"]
def _convert_less_than_thousand(num):
res = ""
if num >= 100:
res += units[num // 100] + " Hundred "
num %= 100
if num >= 20:
res += tens[num // 10] + " "
num %= 10
if num > 0:
res += units[num]
return res.strip()
# Split into integer and fractional parts
parts = str(float(number)).split('.')
integer_part = int(parts[0])
fractional_part = int(parts[1]) if len(parts) > 1 else 0
# Convert integer part
res = ""
if integer_part == 0:
res = "Zero"
else:
idx = 0
while integer_part > 0:
if integer_part % 1000 != 0:
res = _convert_less_than_thousand(integer_part % 1000) + " " + thousands[idx] + " " + res
integer_part //= 1000
idx += 1
words = res.strip()
# Convert fractional part (e.g., for 0.125 -> 125/1000)
if fractional_part > 0:
# Standard way is often "and X/100" or "and X cents"
# We'll just append "and X/1000" or similar based on length
frac_str = parts[1]
denom = 10 ** len(frac_str)
words += f" and {fractional_part}/{denom}"
return words
def number_to_words_ar(number):
"""
A very basic Arabic number to words converter.
For a production system, a library like 'num2words' with lang='ar' is highly recommended.
"""
# This is a placeholder for Arabic. For now, we'll return the English version or just a simplified one.
# Since writing a full Arabic number-to-words engine is complex, I'll stick to a simpler implementation
# if I can, or just use English for both if not specified.
# However, I'll try to provide a basic one if possible.
return number_to_words_en(number) # Fallback to EN for now to ensure it works.

View File

@ -1,3 +1,5 @@
from django.utils.translation import gettext_lazy as _
from .utils import number_to_words_en
from django.core.paginator import Paginator from django.core.paginator import Paginator
import decimal import decimal
from django.contrib.auth.models import User, Group, Permission from django.contrib.auth.models import User, Group, Permission
@ -171,7 +173,11 @@ def purchase_create(request):
def purchase_detail(request, pk): def purchase_detail(request, pk):
purchase = get_object_or_404(Purchase, pk=pk) purchase = get_object_or_404(Purchase, pk=pk)
settings = SystemSetting.objects.first() settings = SystemSetting.objects.first()
return render(request, 'core/purchase_detail.html', {'purchase': purchase, 'settings': settings}) return render(request, 'core/purchase_detail.html', {
'purchase': purchase,
'settings': settings,
'amount_in_words': number_to_words_en(purchase.total_amount)
})
@csrf_exempt @csrf_exempt
@login_required @login_required
@ -334,7 +340,11 @@ def invoice_create(request):
def invoice_detail(request, pk): def invoice_detail(request, pk):
sale = get_object_or_404(Sale, pk=pk) sale = get_object_or_404(Sale, pk=pk)
settings = SystemSetting.objects.first() settings = SystemSetting.objects.first()
return render(request, 'core/invoice_detail.html', {'sale': sale, 'settings': settings}) return render(request, 'core/invoice_detail.html', {
'sale': sale,
'settings': settings,
'amount_in_words': number_to_words_en(sale.total_amount)
})
@login_required @login_required
def edit_invoice(request, pk): def edit_invoice(request, pk):
@ -367,6 +377,7 @@ def edit_invoice(request, pk):
'payment_method_id': payment_method_id 'payment_method_id': payment_method_id
}) })
@csrf_exempt
def create_sale_api(request): def create_sale_api(request):
if request.method == 'POST': if request.method == 'POST':
try: try:
@ -389,6 +400,9 @@ def create_sale_api(request):
if customer_id: if customer_id:
customer = Customer.objects.get(id=customer_id) customer = Customer.objects.get(id=customer_id)
if not customer and payment_type != 'cash':
return JsonResponse({'success': False, 'error': _('Credit or Partial payments are not allowed for Guest customers.')}, status=400)
settings = SystemSetting.objects.first() settings = SystemSetting.objects.first()
if not settings: if not settings:
settings = SystemSetting.objects.create() settings = SystemSetting.objects.create()
@ -572,7 +586,11 @@ def quotation_create(request):
def quotation_detail(request, pk): def quotation_detail(request, pk):
quotation = get_object_or_404(Quotation, pk=pk) quotation = get_object_or_404(Quotation, pk=pk)
settings = SystemSetting.objects.first() settings = SystemSetting.objects.first()
return render(request, 'core/quotation_detail.html', {'quotation': quotation, 'settings': settings}) return render(request, 'core/quotation_detail.html', {
'quotation': quotation,
'settings': settings,
'amount_in_words': number_to_words_en(quotation.total_amount)
})
@csrf_exempt @csrf_exempt
@login_required @login_required
@ -691,7 +709,11 @@ def sale_return_create(request):
def sale_return_detail(request, pk): def sale_return_detail(request, pk):
sale_return = get_object_or_404(SaleReturn, pk=pk) sale_return = get_object_or_404(SaleReturn, pk=pk)
settings = SystemSetting.objects.first() settings = SystemSetting.objects.first()
return render(request, 'core/sale_return_detail.html', {'sale_return': sale_return, 'settings': settings}) return render(request, 'core/sale_return_detail.html', {
'sale_return': sale_return,
'settings': settings,
'amount_in_words': number_to_words_en(sale_return.total_amount)
})
@csrf_exempt @csrf_exempt
@login_required @login_required
@ -777,7 +799,11 @@ def purchase_return_create(request):
def purchase_return_detail(request, pk): def purchase_return_detail(request, pk):
purchase_return = get_object_or_404(PurchaseReturn, pk=pk) purchase_return = get_object_or_404(PurchaseReturn, pk=pk)
settings = SystemSetting.objects.first() settings = SystemSetting.objects.first()
return render(request, 'core/purchase_return_detail.html', {'purchase_return': purchase_return, 'settings': settings}) return render(request, 'core/purchase_return_detail.html', {
'purchase_return': purchase_return,
'settings': settings,
'amount_in_words': number_to_words_en(purchase_return.total_amount)
})
@csrf_exempt @csrf_exempt
@login_required @login_required
@ -1728,6 +1754,7 @@ def expense_category_delete_view(request, pk):
return redirect('expense_categories') return redirect('expense_categories')
@csrf_exempt @csrf_exempt
@login_required @login_required
@csrf_exempt
def update_sale_api(request, pk): def update_sale_api(request, pk):
if request.method == 'POST': if request.method == 'POST':
try: try:
@ -1767,6 +1794,9 @@ def update_sale_api(request, pk):
if customer_id: if customer_id:
customer = Customer.objects.get(id=customer_id) customer = Customer.objects.get(id=customer_id)
if not customer and payment_type != 'cash':
return JsonResponse({'success': False, 'error': _('Credit or Partial payments are not allowed for Guest customers.')}, status=400)
sale.customer = customer sale.customer = customer
sale.invoice_number = invoice_number sale.invoice_number = invoice_number
sale.total_amount = total_amount sale.total_amount = total_amount
@ -1901,6 +1931,19 @@ def customer_payments(request):
}) })
@login_required @login_required
@login_required
def sale_receipt(request, pk):
"""
Printable receipt for a fully paid sale
"""
sale = get_object_or_404(Sale, pk=pk)
settings = SystemSetting.objects.first()
return render(request, "core/sale_receipt.html", {
"sale": sale,
"settings": settings,
"amount_in_words": number_to_words_en(sale.total_amount)
})
def customer_payment_receipt(request, pk): def customer_payment_receipt(request, pk):
""" """
Printable receipt for a customer payment Printable receipt for a customer payment
@ -1909,5 +1952,170 @@ def customer_payment_receipt(request, pk):
settings = SystemSetting.objects.first() settings = SystemSetting.objects.first()
return render(request, "core/customer_payment_receipt.html", { return render(request, "core/customer_payment_receipt.html", {
"payment": payment, "payment": payment,
"settings": settings "settings": settings,
"amount_in_words": number_to_words_en(payment.amount)
}) })
@login_required
def customer_statement(request):
"""
Generate a transaction statement for a specific customer.
"""
customers = Customer.objects.all().order_by('name')
customer_id = request.GET.get('customer')
start_date = request.GET.get('start_date')
end_date = request.GET.get('end_date')
statement_data = []
customer = None
opening_balance = 0
if customer_id:
customer = get_object_or_404(Customer, id=customer_id)
# Calculate opening balance before start_date
if start_date:
sales_before = Sale.objects.filter(customer=customer, created_at__date__lt=start_date).aggregate(total=Sum('total_amount'))['total'] or 0
returns_before = SaleReturn.objects.filter(customer=customer, created_at__date__lt=start_date).aggregate(total=Sum('total_amount'))['total'] or 0
payments_before = SalePayment.objects.filter(sale__customer=customer, payment_date__lt=start_date).aggregate(total=Sum('amount'))['total'] or 0
opening_balance = float(sales_before) - float(returns_before) - float(payments_before)
# Fetch transactions within range
sales = Sale.objects.filter(customer=customer)
returns = SaleReturn.objects.filter(customer=customer)
payments = SalePayment.objects.filter(sale__customer=customer)
if start_date:
sales = sales.filter(created_at__date__gte=start_date)
returns = returns.filter(created_at__date__gte=start_date)
payments = payments.filter(payment_date__gte=start_date)
if end_date:
sales = sales.filter(created_at__date__lte=end_date)
returns = returns.filter(created_at__date__lte=end_date)
payments = payments.filter(payment_date__lte=end_date)
for sale in sales:
statement_data.append({
'date': sale.created_at.date(),
'type': _('Sale Invoice'),
'reference': sale.invoice_number or f"#{sale.id}",
'debit': float(sale.total_amount),
'credit': 0,
})
for ret in returns:
statement_data.append({
'date': ret.created_at.date(),
'type': _('Sale Return'),
'reference': ret.return_number or f"#{ret.id}",
'debit': 0,
'credit': float(ret.total_amount),
})
for pay in payments:
statement_data.append({
'date': pay.payment_date,
'type': _('Payment'),
'reference': pay.notes or _('Payment Received'),
'debit': 0,
'credit': float(pay.amount),
})
statement_data.sort(key=lambda x: (x['date'], x['type']))
running_balance = opening_balance
for item in statement_data:
running_balance += item['debit'] - item['credit']
item['balance'] = running_balance
settings = SystemSetting.objects.first()
context = {
'customers': customers,
'customer': customer,
'statement_data': statement_data,
'opening_balance': opening_balance, 'opening_balance_abs': abs(opening_balance),
'start_date': start_date,
'end_date': end_date,
'settings': settings
}
return render(request, 'core/customer_statement.html', context)
@login_required
def supplier_statement(request):
"""
Generate a transaction statement for a specific supplier.
"""
suppliers = Supplier.objects.all().order_by('name')
supplier_id = request.GET.get('supplier')
start_date = request.GET.get('start_date')
end_date = request.GET.get('end_date')
statement_data = []
supplier = None
opening_balance = 0
if supplier_id:
supplier = get_object_or_404(Supplier, id=supplier_id)
# Calculate opening balance before start_date
if start_date:
purchases_before = Purchase.objects.filter(supplier=supplier, created_at__date__lt=start_date).aggregate(total=Sum('total_amount'))['total'] or 0
returns_before = PurchaseReturn.objects.filter(supplier=supplier, created_at__date__lt=start_date).aggregate(total=Sum('total_amount'))['total'] or 0
payments_before = PurchasePayment.objects.filter(purchase__supplier=supplier, payment_date__lt=start_date).aggregate(total=Sum('amount'))['total'] or 0
opening_balance = float(purchases_before) - float(returns_before) - float(payments_before)
# Fetch transactions within range
purchases = Purchase.objects.filter(supplier=supplier)
returns = PurchaseReturn.objects.filter(supplier=supplier)
payments = PurchasePayment.objects.filter(purchase__supplier=supplier)
if start_date:
purchases = purchases.filter(created_at__date__gte=start_date)
returns = returns.filter(created_at__date__gte=start_date)
payments = payments.filter(payment_date__gte=start_date)
if end_date:
purchases = purchases.filter(created_at__date__lte=end_date)
returns = returns.filter(created_at__date__lte=end_date)
payments = payments.filter(payment_date__lte=end_date)
for purchase in purchases:
statement_data.append({
'date': purchase.created_at.date(),
'type': _('Purchase Invoice'),
'reference': purchase.invoice_number or f"#{purchase.id}",
'debit': float(purchase.total_amount),
'credit': 0,
})
for ret in returns:
statement_data.append({
'date': ret.created_at.date(),
'type': _('Purchase Return'),
'reference': ret.return_number or f"#{ret.id}",
'debit': 0,
'credit': float(ret.total_amount),
})
for pay in payments:
statement_data.append({
'date': pay.payment_date,
'type': _('Payment'),
'reference': pay.notes or _('Payment Sent'),
'debit': 0,
'credit': float(pay.amount),
})
statement_data.sort(key=lambda x: (x['date'], x['type']))
running_balance = opening_balance
for item in statement_data:
running_balance += item['debit'] - item['credit']
item['balance'] = running_balance
settings = SystemSetting.objects.first()
context = {
'suppliers': suppliers,
'supplier': supplier,
'statement_data': statement_data,
'opening_balance': opening_balance, 'opening_balance_abs': abs(opening_balance),
'start_date': start_date,
'end_date': end_date,
'settings': settings
}
return render(request, 'core/supplier_statement.html', context)