@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
| 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, ',', '.') }} € | |||||