{{-- Invoices of Fakturor (#2957 slice 6d, card #3020). Included by invoice/index only. Expects: $invoices (paginator from InvoiceController@index), $isAdminList (admin.invoice.index). Data table (DESIGN.md Data tables): invoice number with company and creation date, due date, amount with VAT, status pill and the row actions Visa, Betala and PDF. Betala (customer route only, the old admin list had none) shows under the same condition as on the old invoice page (unpaid, payments not equal to the total, not a legacy PDF invoice, i.e. invoices.reference is null). The customer route shows the company name in brackets as before; the admin route links the company and keeps the "Faktura via e-post" (legacy PDF invoices and payment_method 2, #254) and card markers as words. Payment sums, companies and cards are loaded once for the page instead of per row. --}} @php $invoices->appends(request()->query()); $invoices->getCollection()->loadSum('payments', 'sum')->loadMissing($isAdminList ? ['company.card'] : ['company']); $money = fn ($value) => formatNumber($value, 2, ','); @endphp @foreach ($invoices as $invoice) @php // Compared in öre, not against the formatted totalWithVat() string (#3089). $payable = ! $isAdminList && $invoice->paid == 0 && (int) round((float) ($invoice->payments_sum_sum ?? 0) * 100) !== (int) round((float) $invoice->totalWithVat(true) * 100) && is_null($invoice->reference); $show = route('invoice.show', $invoice->id); $unpaidNormal = $invoice->paid == 0 && $invoice->status == Invoice::_get('statusTypes')['normal'] && ! $invoice->isCredited(); // Admin list only (#2957, Nov11): registered payments add up (to the öre) to the // amount of an invoice that is not marked paid. The due-date warning stays, since // the invoice job may still treat the invoice as unpaid. $paidSum = round((float) ($invoice->payments_sum_sum ?? 0), 2); $paymentPending = $isAdminList && $unpaidNormal && $paidSum > 0 && $paidSum === round((float) $invoice->totalWithVat(true), 2); $dueDay = $invoice->duedate?->copy()->startOfDay(); $overdue = $unpaidNormal && $dueDay && $dueDay->lt(\Carbon\Carbon::today()); $dueSoon = $unpaidNormal && $dueDay && ! $overdue && $dueDay->lte(\Carbon\Carbon::today()->addDays(2)); @endphp @endforeach
{{ __('invoice.nh.columnInvoice') }} {{ __('invoice.duedate') }} {{ __('invoice.total') }} {{ __('invoice.status') }} {{ __('invoice.nh.columnActions') }}
{{ $invoice['number'] }} @if ($isAdminList) @if (! is_null($invoice->company)) {{ $invoice->company->name }} @else {{ __('invoice.companyDeleted') }} @endif @if (isset($invoice->company) && (! is_null($invoice->reference) || \App\Services\Billing\InvoiceElsewhere::appliesTo($invoice->company))) {{ __('invoice.nh.pdfInvoice') }} @endif @if (isset($invoice->company->card) && ! is_null($invoice->company->card)) {{ __('invoice.nh.card') }} @endif @else ({{ $invoice->company->name ?? __('invoice.companyDeleted') }}) @endif {{ __('invoice.nh.created', ['date' => $invoice->created_at->toDateString()]) }} $overdue || $dueSoon, 'nh-due-overdue' => $overdue, 'nh-due-soon' => $dueSoon])> {{ $invoice['duedate']->toDateString() }} @if ($overdue || $dueSoon){{ __($overdue ? 'feedback_oct23.overdue' : 'feedback_oct23.dueSoon') }}@endif {{ $money($invoice->totalWithVat(true)) }} @if ($invoice->status != Invoice::_get('statusTypes')['credit'] && $invoice->isCredited()) @include('invoice.partials.status-pill') @else @include('invoice.partials.status-pill') @endif {{ __('invoice.nh.open') }} @if ($payable) {{ __('invoice.nh.payButton') }} @endif {{ __('invoice.print.button') }}
{{ trans_choice('invoice.nh.count', $invoices->total(), ['count' => formatNumber($invoices->total())]) }}