{{-- 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.nh.show.lead') }}