1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Updates for multi invoice payment flow

This commit is contained in:
David Bomba 2024-08-09 14:44:39 +10:00
parent c4f93e4d12
commit 2baebffc32
10 changed files with 114 additions and 81 deletions

View File

@ -516,9 +516,10 @@ class CompanySettings extends BaseSettings
public $quote_late_fee_amount1 = 0;
public $quote_late_fee_percent1 = 0;
public string $payment_flow = 'default'; //smooth
public static $casts = [
'payment_flow' => 'string',
'enable_quote_reminder1' => 'bool',
'quote_num_days_reminder1' => 'int',
'quote_schedule_reminder1' => 'string',

View File

@ -79,13 +79,16 @@ class InvoiceController extends Controller
'hash' => $hash,
'variables' => $variables,
'invoices' => [$invoice->hashed_id],
'db' => $invoice->company->db,
];
if ($request->query('mode') === 'fullscreen') {
return render('invoices.show-fullscreen', $data);
}
return $this->render('invoices.show_smooth', $data);
return auth()->guard('contact')->user()->client->getSetting('payment_flow') == 'default' ? $this->render('invoices.show', $data) : $this->render('invoices.show_smooth', $data);
// return $this->render('invoices.show_smooth', $data);
}
public function showBlob($hash)
@ -237,9 +240,12 @@ class InvoiceController extends Controller
'hashed_ids' => $invoices->pluck('hashed_id'),
'total' => $total,
'variables' => $variables,
'invitation' => $invitation,
'db' => $invitation->company->db,
];
return $this->render('invoices.payment', $data);
// return $this->render('invoices.payment', $data);
return auth()->guard('contact')->user()->client->getSetting('payment_flow') === 'default' ? $this->render('invoices.payment', $data) : $this->render('invoices.show_smooth_multi', $data);
}
/**

View File

@ -238,9 +238,12 @@ class InvoicePay extends Component
$this->setContext('settings', $settings); // $this->context['settings'] = $settings;
$this->setContext('db', $this->db); // $this->context['db'] = $this->db;
$invoices = Invoice::find($this->transformKeys($this->invoices));
nlog($this->invoices);
if(is_array($this->invoices))
$this->invoices = Invoice::find($this->transformKeys($this->invoices));
$invoices = $invoices->filter(function ($i) {
$invoices = $this->invoices->filter(function ($i) {
$i = $i->service()
->markSent()
->removeUnpaidGatewayFees()

View File

@ -20,12 +20,12 @@ class InvoiceSummary extends Component
{
use WithSecureContext;
public $invoice;
public $invoices;
public function mount()
{
//@TODO for a single invoice - show all details, for multi-invoices, only show the summaries
$this->invoice = $this->getContext()['invitation']->invoice; // $this->context['invitation']->invoice;
$this->invoices = $this->getContext()['invoices']; // $this->context['invitation']->invoice;
}
#[On(self::CONTEXT_UPDATE)]
@ -33,13 +33,15 @@ class InvoiceSummary extends Component
{
// refactor logic for updating the price for eg if it changes with under/over pay
$this->invoice = $this->getContext()['invitation']->invoice;
$this->invoices = $this->getContext()['invoices'];
}
public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
{
return render('flow2.invoice-summary', [
'invoice' => $this->invoice
return render('flow2.invoices-summary', [
'invoice' => $this->invoices,
'client' => $this->invoices->first()->client,
]);
}
}

View File

@ -25,7 +25,7 @@ class Terms extends Component
public function mount()
{
$this->invoice = $this->getContext()['invoice'];
$this->invoice = $this->getContext()['invoices']->first();
$this->variables = $this->getContext()['variables'];
}

View File

@ -89,6 +89,8 @@ class LivewireInstantPayment
public function run()
{
nlog($this->data);
$company_gateway = CompanyGateway::query()->find($this->data['company_gateway_id']);
if ($this->data['company_gateway_id'] == CompanyGateway::GATEWAY_CREDIT) {

View File

@ -1,67 +0,0 @@
<div class="w-full">
<div class="rounded-lg border bg-card bg-white text-card-foreground shadow-sm overflow-hidden" x-chunk="An order details card with order details, shipping information, customer information and payment information.">
<div class="space-y-1.5 p-6 flex flex-row items-start bg-muted/50">
<div class="grid gap-0.5">
<h3 class="font-semibold tracking-tight group flex items-center gap-2 text-lg">
{{ ctrans('texts.invoice') }} {{ $invoice->number }}
<button class="inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-6 w-6 opacity-0 transition-opacity group-hover:opacity-100">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy h-3 w-3">
<rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect>
<path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path>
</svg>
<span class="sr-only">{{ ctrans('texts.copy') }}</span>
</button>
</h3>
<p class="text-sm text-muted-foreground">{{ ctrans('texts.date') }}: {{ $invoice->translateDate($invoice->date, $invoice->client->date_format(), $invoice->client->locale()) }}</p>
</div>
</div>
<div class="p-6 text-sm">
<div class="grid gap-3">
<div class="font-semibold">{{ ctrans('texts.invoice_details') }} </div>
<ul class="grid gap-3">
@foreach($invoice->line_items as $item)
<li class="flex items-center justify-between"><span class="text-muted-foreground">{{ $item->notes }}<span></span></span><span> {{ App\Utils\Number::formatMoney($item->line_total, $invoice->client) }}</span></li>
@endforeach
</ul>
<div data-orientation="horizontal" role="none" class="shrink-0 bg-border h-[1px] w-full my-2"></div>
<ul class="grid gap-3">
@if($invoice->total_taxes > 0)
<li class="flex items-center justify-between"><span class="text-muted-foreground">{{ ctrans('texts.tax')}}</span><span>{{App\Utils\Number::formatMoney($invoice->total_taxes, $invoice->client) }} </span></li>
@endif
<li class="flex items-center justify-between font-semibold"><span class="text-muted-foreground">{{ ctrans('texts.total') }}</span><span>{{ App\Utils\Number::formatMoney($invoice->amount, $invoice->client) }}</span></li>
</ul>
</div>
<div data-orientation="horizontal" role="none" class="shrink-0 bg-border h-[1px] w-full my-4"></div>
<div class="grid grid-cols-2 gap-4">
<div class="grid auto-rows-max gap-3">
<div class="font-semibold"></div>
</div>
</div>
<div data-orientation="horizontal" role="none" class="shrink-0 bg-border h-[1px] w-full my-4"></div>
<div class="grid gap-3">
<div class="font-semibold">{{ ctrans('texts.client_information') }}</div>
<dl class="grid gap-3">
<div class="flex items-center justify-between">
<dt class="text-muted-foreground">{{ ctrans('texts.client') }}</dt>
<dd>{{ $invoice->client->present()->name() }}</dd>
</div>
<div class="flex items-center justify-between">
<dt class="text-muted-foreground">{{ ctrans('texts.email') }}</dt>
<dd><a href="mailto:">{{ $invoice->client->present()->email() }}</a></dd>
</div>
<div class="flex items-center justify-between">
<dt class="text-muted-foreground">{{ ctrans('texts.phone') }}</dt>
<dd><a href="tel:">{{ $invoice->client->present()->phone() }} </a></dd>
</div>
</dl>
</div>
<div data-orientation="horizontal" role="none" class="shrink-0 bg-border h-[1px] w-full my-4"></div>
<div class="grid gap-3">
<div class="font-semibold"></div>
<dl class="grid gap-3">
</dl>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,71 @@
<div class="w-full">
<div class="rounded-lg border bg-card bg-white text-card-foreground shadow-sm overflow-hidden" x-chunk="An order details card with order details, shipping information, customer information and payment information.">
<div class="pt-6 px-6 flex flex-row items-start bg-muted/50">
<div class="grid gap-0.5">
<h3 class="font-semibold tracking-tight group flex items-center gap-2 text-lg">
{{ ctrans('texts.invoices') }}
<button class="inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-6 w-6 opacity-0 transition-opacity group-hover:opacity-100">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy h-3 w-3">
<rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect>
<path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path>
</svg>
</button>
</h3>
</div>
</div>
<div class="p-6 text-sm">
@foreach($invoices as $invoice)
<div class="mb-4 grid gap-3">
<div class="font-semibold">{{ ctrans('texts.invoice') }} {{ $invoice->number }}</div>
<dl class="grid gap-3">
<div class="flex items-center justify-between">
<dt class="text-muted-foreground">{{ ctrans('texts.invoice_date') }}</dt>
<dd>{{ $invoice->translateDate($invoice->date, $invoice->client->date_format(), $invoice->client->locale()) }}</dd>
</div>
@if($invoice->due_date)
<div class="flex items-center justify-between">
<dt class="text-muted-foreground">{{ ctrans('texts.due_date') }}</dt>
<dd>{{ $invoice->translateDate($invoice->due_date, $invoice->client->date_format(), $invoice->client->locale()) }}</dd>
</div>
@endif
<div class="flex items-center justify-between">
<dt class="text-muted-foreground">{{ ctrans('texts.amount_due') }}</dt>
<dd>
{{ $invoice->client->currency()->code }} ({{ $invoice->client->currency()->symbol }})
{{ $invoice->partial > 0 ? $invoice->partial : $invoice->balance }}
</dd>
</div>
</dl>
</div>
@endforeach
<div data-orientation="horizontal" role="none" class="shrink-0 bg-border h-[1px] w-full my-4"></div>
<div class="grid gap-3">
<div class="font-semibold">{{ ctrans('texts.client_information') }}</div>
<dl class="grid gap-3">
<div class="flex items-center justify-between">
<dt class="text-muted-foreground">{{ ctrans('texts.client') }}</dt>
<dd>{{ $client->present()->name() }}</dd>
</div>
<div class="flex items-center justify-between">
<dt class="text-muted-foreground">{{ ctrans('texts.email') }}</dt>
<dd><a href="mailto:">{{ $client->present()->email() }}</a></dd>
</div>
@if($client->present()->phone())
<div class="flex items-center justify-between">
<dt class="text-muted-foreground">{{ ctrans('texts.phone') }}</dt>
<dd><a href="tel:">{{ $client->present()->phone() }} </a></dd>
</div>
@endif
</dl>
</div>
<div data-orientation="horizontal" role="none" class="shrink-0 bg-border h-[1px] w-full my-4"></div>
<div class="grid gap-3">
<div class="font-semibold"></div>
<dl class="grid gap-3">
</dl>
</div>
</div>
</div>
</div>

View File

@ -17,11 +17,9 @@
@endif
@if($invoice->isPayable())
@livewire('flow2.invoice-pay', ['invoices' => $invoices, 'invitation_id' => $invitation->id, 'db' => $invoice->company->db, 'variables' => $variables])
@livewire('flow2.invoice-pay', ['invoices' => $invoices, 'invitation_id' => $invitation->id, 'db' => $db, 'variables' => $variables])
@endif
@include('portal.ninja2020.components.entity-documents', ['entity' => $invoice])
@endsection
@section('footer')

View File

@ -0,0 +1,17 @@
@extends('portal.ninja2020.layout.app')
@section('meta_title', ctrans('texts.view_invoice'))
@push('head')
@endpush
@section('body')
@livewire('flow2.invoice-pay', ['invoices' => $invoices, 'invitation_id' => $invitation->id, 'db' => $db, 'variables' => $variables])
@endsection
@section('footer')
@endsection
@push('head')
@endpush