{{-- Faktura, one invoice (DESIGN.md Page patterns 2 detail; #2957 slice 6d, card #3020). Same data and actions as before the reskin (InvoiceController@show): Betala direkt when the invoice is unpaid, its payments do not equal the total and it is not a legacy PDF invoice (invoices.reference set); PDF always; Kreditera faktura (POST admin.invoice.credit, confirmed in a native dialog as the old confirm() did) for users with invoiceCredit on an unpaid, uncredited normal invoice with a total. The success message the controller passes after a Stripe payment ($toastr, a view variable, not a flash) shows as a banner. Registrera betalning (POST admin.invoice.registerPayment, #254) for admins on an unpaid, uncredited normal invoice with an amount left to pay; an empty amount registers the whole remainder. Both it and Skicka fakturan igen (POST admin.invoice.resend, admins, unpaid uncredited payment_method 2 invoices) are confirmed in a native dialog that names the amount or the address. --}} @extends('layouts.nuhet') @php $payments = $invoice->payments()->get(); // Compared in öre: totalWithVat() without true is a formatted string ("1,250.00"), which never equals // a payment sum of 1 000 kr or more (#3089). $canPay = $invoice->paid == 0 && (int) round((float) $payments->sum('sum') * 100) !== (int) round((float) $invoice->totalWithVat(true) * 100) && is_null($invoice->reference); $canCredit = ! ($invoice->status == Invoice::_get('statusTypes')['credit'] || ! is_null($invoice->credit_invoice_id) || $invoice->total === 0 || $invoice->paid == 1 || Auth::user()->hasPermission('invoiceCredit') == false) // The credit route sits behind adminauth (admin or superadmin role), so only offer it to those who can use it. && (Auth::user()->hasRole('admin') || Auth::user()->hasRole('superadmin')); $creditInvoice = $invoice->isCredited() ? $invoice->credited() : null; // Registrera betalning (#254): admins record a payment received outside Nuhet on an unpaid, uncredited invoice. $remainingOre = (int) round((float) $invoice->totalWithVat(true) * 100) - (int) round((float) $payments->sum('sum') * 100); $canRegisterPayment = $invoice->paid == 0 && $invoice->status == Invoice::_get('statusTypes')['normal'] && is_null($invoice->credit_invoice_id) && $remainingOre > 0 && (Auth::user()->hasRole('admin') || Auth::user()->hasRole('superadmin')); $remainingFormatted = formatNumber($remainingOre / 100, 2, ',', ' '); // The confirm text names the amount; the script swaps in a typed amount (an empty field registers the remainder). $registerConfirmHtml = str_replace(':amount_html', ''.e($remainingFormatted).'', e(__('invoice.nh.show.registerPaymentConfirmText', ['number' => $invoice->number, 'amount' => ':amount_html']))); // Skicka fakturan igen (#254): admins resend the PDF invoice of an open invoice-elsewhere invoice, also after a failed first send. $canResend = \App\Services\Billing\InvoiceElsewhere::canResend($invoice) && (Auth::user()->hasRole('admin') || Auth::user()->hasRole('superadmin')); $resendTo = $canResend ? \App\Services\Billing\InvoiceElsewhere::recipient($invoice->company) : null; @endphp @section('_pageTitle', __('invoice.show.pageTitle').' '.$invoice->number) @section('pagename', __('invoice.invoices')) @section('page')

{{ __('invoice.show.title') }} {{ $invoice['number'] }}

{{ __('invoice.nh.show.lead') }}

@include('invoice.partials.status-pill') {{ __('invoice.duedate') }} {{ $invoice['duedate']->format('Y-m-d') }}

@if ($canPay) {{ __('invoice.pay.button') }} @endif {{ __('invoice.print.button') }} @if ($canCredit)
@csrf {{ __('invoice.credit.button') }}
@endif @if ($canResend)
@csrf {{ __('invoice.nh.show.resendButton') }}
@endif
@include('partials.nh-account-tabs') @if (isset($toastr) && is_array($toastr)) {{ $toastr['msg'] ?? '' }} @endif @include('invoice.partials.show', ['invoice' => $invoice, 'creditInvoice' => $creditInvoice, 'payments' => $payments]) @if ($canRegisterPayment)
@csrf {{ __('invoice.nh.show.registerPaymentTitle') }}

{{ __('invoice.nh.show.registerPaymentConfirmTitle') }}

{!! $registerConfirmHtml !!}

@endif @if ($canResend)

{{ __('invoice.nh.show.resendConfirmTitle') }}

{{ __('invoice.nh.show.resendConfirmText', ['number' => $invoice->number, 'email' => $resendTo]) }}

@endif @if ($canRegisterPayment || $canResend) @push('scripts') @endpush @endif @if ($canCredit)

{{ __('invoice.nh.show.creditTitle') }}

{{ __('invoice.nh.show.creditText') }}

@push('scripts') @endpush @endif @endsection