Files
fuel_track/app/templates/admin_reports.html
T
Mateusz Gruszczyński 72757cad55 fix w kalkulacji last price
2026-07-14 14:22:08 +02:00

22 lines
6.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% extends 'base.html' %}{% block content %}
<div class="mb-4"><h1 class="h2 mb-1">Zestawienia kosztów</h1><p class="text-body-secondary mb-0">Porównanie detalu brutto z ostatecznymi kwotami faktur, rabatami, Last Price, VAT i kosztem po odliczeniu.</p></div>
{% include '_admin_nav.html' %}
<div class="card mb-4"><div class="card-body"><form method="get" class="row g-3 ajax-nav-form" action="{{url_for('main.admin_reports')}}">
{% if current_user.role=='admin' %}<div class="col-lg-3"><label class="form-label">Firma</label><select class="form-select" name="company_id"><option value="">Wszystkie firmy</option>{% for c in companies %}<option value="{{c.id}}" {% if company_id==c.id %}selected{% endif %}>{{c.name}}</option>{% endfor %}</select></div>{% endif %}
<div class="col-lg-2"><label class="form-label">Zakres</label><select class="form-select" name="period" id="report-period"><option value="month" {% if period=='month' %}selected{% endif %}>Miesiąc</option><option value="year" {% if period=='year' %}selected{% endif %}>Rok</option><option value="custom" {% if period=='custom' %}selected{% endif %}>Zakres dat</option></select></div>
<div class="col-lg-2 report-filter report-month"><label class="form-label">Miesiąc</label><input class="form-control" type="month" name="month" value="{{month}}"></div><div class="col-lg-2 report-filter report-year"><label class="form-label">Rok</label><input class="form-control" type="number" min="2000" max="2100" name="year" value="{{year}}"></div><div class="col-lg-2 report-filter report-custom"><label class="form-label">Od</label><input class="form-control" type="date" name="date_from" value="{{date_from}}"></div><div class="col-lg-2 report-filter report-custom"><label class="form-label">Do</label><input class="form-control" type="date" name="date_to" value="{{date_to}}"></div><div class="col-lg-2 d-flex align-items-end"><button class="btn btn-primary w-100">Pokaż zestawienie</button></div></form></div></div>
<p class="small text-body-secondary">Okres: <strong>{{start_date.strftime('%d.%m.%Y')}}{{end_date.strftime('%d.%m.%Y')}}</strong></p>
<div class="row g-3 mb-4">
<div class="col-6 col-xl-2"><div class="card metric h-100"><div class="card-body"><small>Detal brutto</small><strong>{{'%.2f'|format(totals.retail_gross)}} zł</strong></div></div></div>
<div class="col-6 col-xl-2"><div class="card metric h-100"><div class="card-body"><small>Do zapłaty brutto</small><strong>{{'%.2f'|format(totals.invoice)}} zł</strong><span>po rabatach i dopłatach</span></div></div></div>
<div class="col-6 col-xl-2"><div class="card metric h-100"><div class="card-body"><small>Różnica brutto do detalu</small><strong>{{'%.2f'|format(totals.gross_saving)}} zł</strong><span>faktura vs detal</span></div></div></div>
<div class="col-6 col-xl-2"><div class="card metric h-100"><div class="card-body"><small>Oszczędność Last Price netto</small><strong>{{'%.2f'|format(totals.saving_net)}} zł</strong><span>{{'%.2f'|format(totals.saving_percent)}}%</span></div></div></div>
<div class="col-6 col-xl-2"><div class="card metric h-100"><div class="card-body"><small>Koszt po VAT</small><strong>{{'%.2f'|format(totals.effective)}} zł</strong><span>odliczono {{'%.2f'|format(totals.vat_deducted)}} zł VAT</span></div></div></div>
<div class="col-6 col-xl-2"><div class="card metric h-100"><div class="card-body"><small>Tankowania / litry</small><strong>{{totals.count}} / {{'%.2f'|format(totals.liters)}} l</strong><span>Last Price: {{totals.last_price_count}}</span></div></div></div>
</div>
<div class="alert alert-info small"><strong>Metoda:</strong> wykres porównuje detal brutto z ostateczną fakturą brutto po zastosowaniu reguły danej karty i stacji. Reguła stacji ma pierwszeństwo; gdy jej brak, używana jest polityka pojazdu. Last Price i oszczędność handlowa pozostają liczone netto, a VAT jest prezentowany osobno.</div>
<div class="card mb-4"><div class="card-body"><h2 class="h5">Kwoty brutto w czasie</h2><p class="small text-body-secondary">Detal brutto, ostateczna kwota do zapłaty brutto i różnica dla każdego miesiąca.</p><div class="chart-box"><canvas id="report-cost-chart"></canvas><div id="report-cost-chart-empty" class="chart-empty d-none">Brak danych dla wybranego okresu.</div></div></div></div>
<div class="row g-4"><div class="col-xl-6"><div class="card h-100"><div class="card-body"><h2 class="h5">Według pojazdu</h2><div class="table-responsive"><table class="table table-hover align-middle"><thead><tr><th>Pojazd</th><th>Tank.</th><th>Litry</th><th>Detal brutto</th><th>Do zapłaty brutto</th><th>Różnica brutto</th><th>Oszczędność LP netto</th><th>Koszt po VAT</th></tr></thead><tbody>{% for name,row in by_vehicle.items() %}<tr><td><strong>{{name}}</strong></td><td>{{row.count}}</td><td>{{'%.2f'|format(row.liters)}}</td><td>{{'%.2f'|format(row.retail_gross)}} zł</td><td>{{'%.2f'|format(row.invoice)}} zł</td><td><strong>{{'%.2f'|format(row.gross_saving)}} zł</strong></td><td>{{'%.2f'|format(row.saving_net)}} zł</td><td>{{'%.2f'|format(row.effective)}} zł</td></tr>{% else %}<tr><td colspan="8">Brak danych.</td></tr>{% endfor %}</tbody></table></div></div></div></div>
<div class="col-xl-6"><div class="card h-100"><div class="card-body"><h2 class="h5">Według firmy</h2><div class="table-responsive"><table class="table table-hover align-middle"><thead><tr><th>Firma</th><th>Tank.</th><th>Litry</th><th>Detal brutto</th><th>Do zapłaty brutto</th><th>Różnica brutto</th><th>Oszczędność LP netto</th><th>Koszt po VAT</th></tr></thead><tbody>{% for name,row in by_company.items() %}<tr><td><strong>{{name}}</strong></td><td>{{row.count}}</td><td>{{'%.2f'|format(row.liters)}}</td><td>{{'%.2f'|format(row.retail_gross)}} zł</td><td>{{'%.2f'|format(row.invoice)}} zł</td><td><strong>{{'%.2f'|format(row.gross_saving)}} zł</strong></td><td>{{'%.2f'|format(row.saving_net)}} zł</td><td>{{'%.2f'|format(row.effective)}} zł</td></tr>{% else %}<tr><td colspan="8">Brak danych.</td></tr>{% endfor %}</tbody></table></div></div></div></div></div>
{% endblock %}{% block scripts %}<script>FuelTrack.renderCostReportChart('report-cost-chart', {{by_month|tojson}});(()=>{const select=document.getElementById('report-period');const refresh=()=>{document.querySelectorAll('.report-filter').forEach(el=>el.classList.add('d-none'));document.querySelectorAll('.report-'+select.value).forEach(el=>el.classList.remove('d-none'));};select?.addEventListener('change',refresh);refresh();})();</script>{% endblock %}