@extends('layouts.app', ['title' => 'Offene Posten Bericht']) @section('content') @php $totalWarnings = 0.0; $totalPayments = 0.0; $bruttoSum = 0.0; $paymentDifference = 0.0; $sumBruttoWithWarnings = 0.0; $sumPaymentDifference = 0.0; $sumPayment = 0.0; $sumTax = 0.0; if (!empty($costCentres)) { $sortedCostCentres = $costCentres->sortByDesc(function ($item) { $w = $item->outgoing_invoices->reduce(fn($c, $inv) => $c + $inv->get_warning->sum('total'), 0); $p = $item->outgoing_invoices->reduce(fn($c, $inv) => $inv->is_paid ? $c + $inv->total : $c + $inv->get_payments->sum('amount'), 0); return $item->outgoing_invoices->sum('total') - $p + $w; }); foreach ($sortedCostCentres as $item) { $w = $item->outgoing_invoices->reduce(fn($c, $inv) => $c + $inv->get_warning->sum('total'), 0); $p = $item->outgoing_invoices->reduce(fn($c, $inv) => $inv->is_paid ? $c + $inv->total : $c + $inv->get_payments->sum('amount'), 0); $b = $item->outgoing_invoices->sum('total'); $sumPayment += $p; $sumBruttoWithWarnings += $b + $w; $sumPaymentDifference += $b - $p + $w; $sumTax += $item->outgoing_invoices->sum('tax'); } } @endphp

Offene Posten Bericht

@if(session('msg'))
{{ session('msg') }}
@endif @if(session('error'))
{{ session('error') }}
@endif @if(!empty($costCentres)) {{-- Stat Cards --}}
Summe MwSt.

{{ number_format($sumTax, 2, ',', '.') }} €

Brutto + Mahngebühren

{{ number_format($sumBruttoWithWarnings, 2, ',', '.') }} €

Zahlungseingang

{{ number_format($sumPayment, 2, ',', '.') }} €

Zahlungs-Differenz (offen)

{{ number_format($sumPaymentDifference, 2, ',', '.') }} €

{{-- Tabelle --}}
@foreach($sortedCostCentres as $idx => $item) @php $w = $item->outgoing_invoices->reduce(fn($c, $inv) => $c + $inv->get_warning->sum('total'), 0); $p = $item->outgoing_invoices->reduce(fn($c, $inv) => $inv->is_paid ? $c + $inv->total : $c + $inv->get_payments->sum('amount'), 0); $b = $item->outgoing_invoices->sum('total'); $diff = $b - $p + $w; $totalBudgetSum = $item->projects->sum('budget_total') + $item->order_spares->sum('budget_total') + $item->order_repairs->sum('budget_total'); @endphp {{-- Hauptzeile --}} {{-- Detail-Zeile --}} @endforeach
Rg.empfänger KST / Projekt ltz. Rg.Nr. ltz. Rg.Datum Netto MwSt. Brutto Mahnungen Zahlung Differenz
{{ $item->outgoing_invoices->first()->customer->name }} {{ $item->number ?? $item->old_number }} – {{ $item->name }} {{ $item->outgoing_invoices->last()->invoice_nr }} {{ date('d.m.Y', strtotime($item->outgoing_invoices->last()->invoice_date)) }} {{ number_format($item->outgoing_invoices->sum('subtotal'), 2, ',', '.') }} € {{ number_format($item->outgoing_invoices->sum('tax'), 2, ',', '.') }} € {{ number_format($b, 2, ',', '.') }} € @if($w > 0){{ number_format($w, 2, ',', '.') }} €@else@endif @if($p > 0){{ number_format($p, 2, ',', '.') }} €@else@endif {{ number_format($diff, 2, ',', '.') }} € @if($diff < 0)
Überbezahlung!@endif
Gesamt ({{ $sortedCostCentres->count() }} Kostenstellen) {{ number_format($sumBruttoWithWarnings, 2, ',', '.') }} € {{ number_format($sumPayment, 2, ',', '.') }} € {{ number_format($sumPaymentDifference, 2, ',', '.') }} €
@else
Keine Daten vorhanden
@endif
@endsection