mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Update payment display screen in Client Portal.
This commit is contained in:
parent
67d6edfcd0
commit
c213e8705d
@ -174,7 +174,9 @@ class CheckData extends Command
|
|||||||
|
|
||||||
CompanyUser::query()->cursor()->each(function ($cu) {
|
CompanyUser::query()->cursor()->each(function ($cu) {
|
||||||
if (CompanyToken::where('user_id', $cu->user_id)->where('company_id', $cu->company_id)->where('is_system', 1)->doesntExist()) {
|
if (CompanyToken::where('user_id', $cu->user_id)->where('company_id', $cu->company_id)->where('is_system', 1)->doesntExist()) {
|
||||||
$this->logMessage("Creating missing company token for user # {$cu->user->id} for company id # {$cu->company->id}");
|
$this->logMessage("Creating missing company token for user # {$cu->user_id} for company id # {$cu->company_id}");
|
||||||
|
|
||||||
|
if($cu->company && $cu->user)
|
||||||
(new CreateCompanyToken($cu->company, $cu->user, 'System'))->handle();
|
(new CreateCompanyToken($cu->company, $cu->user, 'System'))->handle();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -47,19 +47,17 @@ class PrePaymentController extends Controller
|
|||||||
public function process(StorePrePaymentRequest $request)
|
public function process(StorePrePaymentRequest $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$invoices = collect();
|
|
||||||
|
|
||||||
$invoice = InvoiceFactory::create(auth()->guard('contact')->user()->company_id, auth()->guard('contact')->user()->user_id);
|
$invoice = InvoiceFactory::create(auth()->guard('contact')->user()->company_id, auth()->guard('contact')->user()->user_id);
|
||||||
$invoice->due_date = now()->format('Y-m-d');
|
$invoice->due_date = now()->format('Y-m-d');
|
||||||
$invoice->is_proforma = true;
|
$invoice->is_proforma = true;
|
||||||
$invoice->client_id = auth()->guard('contact')->user()->client_id;
|
$invoice->client_id = auth()->guard('contact')->user()->client_id;
|
||||||
|
|
||||||
$line_item = new InvoiceItem();
|
$line_item = new InvoiceItem();
|
||||||
$line_item->cost = $request->amount;
|
$line_item->cost = (float)$request->amount;
|
||||||
$line_item->quantity = 1;
|
$line_item->quantity = 1;
|
||||||
$line_item->product_key = ctrans('texts.pre_payment');
|
$line_item->product_key = ctrans('texts.pre_payment');
|
||||||
$line_item->notes = $request->notes;
|
$line_item->notes = $request->notes;
|
||||||
$line_item->type_id = 1;
|
$line_item->type_id = '1';
|
||||||
|
|
||||||
$items = [];
|
$items = [];
|
||||||
$items[] = $line_item;
|
$items[] = $line_item;
|
||||||
@ -80,25 +78,33 @@ class PrePaymentController extends Controller
|
|||||||
->fillDefaults()
|
->fillDefaults()
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
$total = $invoice->balance;
|
||||||
|
|
||||||
//format totals
|
//format totals
|
||||||
$formatted_total = Number::formatMoney($request->amount, auth()->guard('contact')->user()->client);
|
$formatted_total = Number::formatMoney($invoice->amount, auth()->guard('contact')->user()->client);
|
||||||
|
|
||||||
$payment_methods = auth()->guard('contact')->user()->client->service()->getPaymentMethods($request->amount);
|
$payment_methods = auth()->guard('contact')->user()->client->service()->getPaymentMethods($request->amount);
|
||||||
|
|
||||||
//if there is only one payment method -> lets return straight to the payment page
|
//if there is only one payment method -> lets return straight to the payment page
|
||||||
|
$invoices = collect();
|
||||||
$invoices->push($invoice);
|
$invoices->push($invoice);
|
||||||
|
|
||||||
|
$invoices->map(function ($invoice) {
|
||||||
|
$invoice->balance = Number::formatValue($invoice->balance, $invoice->client->currency());
|
||||||
|
return $invoice;
|
||||||
|
});
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'settings' => auth()->guard('contact')->user()->client->getMergedSettings(),
|
'settings' => auth()->guard('contact')->user()->client->getMergedSettings(),
|
||||||
'invoices' => $invoices,
|
'invoices' => $invoices,
|
||||||
'formatted_total' => $formatted_total,
|
'formatted_total' => $formatted_total,
|
||||||
'payment_methods' => $payment_methods,
|
'payment_methods' => $payment_methods,
|
||||||
'hashed_ids' => $invoices->pluck('hashed_id'),
|
'hashed_ids' => $invoices->pluck('hashed_id'),
|
||||||
'total' => $request->amount,
|
'total' => $total,
|
||||||
'pre_payment' => true,
|
'pre_payment' => true,
|
||||||
];
|
];
|
||||||
nlog($data);
|
|
||||||
|
|
||||||
return $this->render('invoices.payment', $data);
|
return $this->render('invoices.payment', $data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,9 @@ class InvoiceRepository extends BaseRepository
|
|||||||
*/
|
*/
|
||||||
public function restore($invoice) :Invoice
|
public function restore($invoice) :Invoice
|
||||||
{
|
{
|
||||||
|
if($invoice->is_proforma)
|
||||||
|
return $invoice;
|
||||||
|
|
||||||
//if we have just archived, only perform a soft restore
|
//if we have just archived, only perform a soft restore
|
||||||
if (! $invoice->is_deleted) {
|
if (! $invoice->is_deleted) {
|
||||||
parent::restore($invoice);
|
parent::restore($invoice);
|
||||||
|
@ -214,7 +214,7 @@ class InstantPayment
|
|||||||
$credit_totals = 0;
|
$credit_totals = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$hash_data = ['invoices' => $payable_invoices->toArray(), 'credits' => $credit_totals, 'amount_with_fee' => max(0, (($invoice_totals + $fee_totals) - $credit_totals))];
|
$hash_data = ['invoices' => $payable_invoices->toArray(), 'credits' => $credit_totals, 'amount_with_fee' => max(0, (($invoice_totals + $fee_totals) - $credit_totals)), 'pre_payment' => $this->request->pre_payment];
|
||||||
|
|
||||||
if ($this->request->query('hash')) {
|
if ($this->request->query('hash')) {
|
||||||
$hash_data['billing_context'] = Cache::get($this->request->query('hash'));
|
$hash_data['billing_context'] = Cache::get($this->request->query('hash'));
|
||||||
|
@ -82,10 +82,22 @@ class UpdateInvoicePayment
|
|||||||
->save();
|
->save();
|
||||||
|
|
||||||
if ($invoice->is_proforma) {
|
if ($invoice->is_proforma) {
|
||||||
if (strlen($invoice->number) > 1 && str_starts_with($invoice->number, "####")) {
|
|
||||||
$invoice->number = '';
|
//keep proforma's hidden
|
||||||
|
if(property_exists($this->payment_hash->data, 'pre_payment') && $this->payment_hash->data->pre_payment == "1"){
|
||||||
|
|
||||||
|
$invoice->payments()->each(function ($p) {
|
||||||
|
$p->pivot->forceDelete();
|
||||||
|
});
|
||||||
|
|
||||||
|
$invoice->is_deleted = true;
|
||||||
|
$invoice->deleted_at = now();
|
||||||
|
$invoice->saveQuietly();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strlen($invoice->number) > 1 && str_starts_with($invoice->number, "####"))
|
||||||
|
$invoice->number = '';
|
||||||
|
|
||||||
$invoice->is_proforma = false;
|
$invoice->is_proforma = false;
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
<input type="hidden" name="company_gateway_id" id="company_gateway_id">
|
<input type="hidden" name="company_gateway_id" id="company_gateway_id">
|
||||||
<input type="hidden" name="payment_method_id" id="payment_method_id">
|
<input type="hidden" name="payment_method_id" id="payment_method_id">
|
||||||
<input type="hidden" name="signature">
|
<input type="hidden" name="signature">
|
||||||
|
<input type="hidden" name="pre_payment" value="{{ isset($pre_payment) ? $pre_payment : false }}">
|
||||||
|
|
||||||
<div class="container mx-auto">
|
<div class="container mx-auto">
|
||||||
<div class="grid grid-cols-6 gap-4">
|
<div class="grid grid-cols-6 gap-4">
|
||||||
|
@ -14,6 +14,18 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<dl>
|
<dl>
|
||||||
|
|
||||||
|
@if(!empty($payment->status_id) && !is_null($payment->status_id))
|
||||||
|
<div class="px-4 py-5 bg-white sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
|
<dt class="text-sm font-medium leading-5 text-gray-500">
|
||||||
|
{{ ctrans('texts.status') }}
|
||||||
|
</dt>
|
||||||
|
<div class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||||
|
{!! \App\Models\Payment::badgeForStatus($payment->status_id) !!}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
@if(!empty($payment->clientPaymentDate()) && !is_null($payment->clientPaymentDate()))
|
@if(!empty($payment->clientPaymentDate()) && !is_null($payment->clientPaymentDate()))
|
||||||
<div class="px-4 py-5 bg-white sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
<div class="px-4 py-5 bg-white sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
<dt class="text-sm font-medium leading-5 text-gray-500">
|
<dt class="text-sm font-medium leading-5 text-gray-500">
|
||||||
@ -72,14 +84,6 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if(!empty($payment->status_id) && !is_null($payment->status_id))
|
@if(!empty($payment->status_id) && !is_null($payment->status_id))
|
||||||
<div class="px-4 py-5 bg-white sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
|
||||||
<dt class="text-sm font-medium leading-5 text-gray-500">
|
|
||||||
{{ ctrans('texts.status') }}
|
|
||||||
</dt>
|
|
||||||
<div class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
|
||||||
{!! \App\Models\Payment::badgeForStatus($payment->status_id) !!}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@if($payment->refunded > 0)
|
@if($payment->refunded > 0)
|
||||||
<div class="px-4 py-5 bg-white sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
<div class="px-4 py-5 bg-white sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
@ -91,6 +95,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if($payment->applied != $payment->amount)
|
||||||
|
<div class="px-4 py-5 bg-white sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
|
<dt class="text-sm font-medium leading-5 text-gray-500">
|
||||||
|
{{ ctrans('texts.remaining') }}
|
||||||
|
</dt>
|
||||||
|
<div class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||||
|
{{ \App\Utils\Number::formatMoney($payment->amount - $payment->applied, $payment->client) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
@endif
|
@endif
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
@ -107,6 +123,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<dl>
|
<dl>
|
||||||
@foreach($payment->invoices as $invoice)
|
@foreach($payment->invoices as $invoice)
|
||||||
|
@if(!$invoice->is_proforma)
|
||||||
<div class="px-4 py-5 bg-white sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
<div class="px-4 py-5 bg-white sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
<dt class="text-sm font-medium leading-5 text-gray-500">
|
<dt class="text-sm font-medium leading-5 text-gray-500">
|
||||||
{{ ctrans('texts.invoice_number') }}
|
{{ ctrans('texts.invoice_number') }}
|
||||||
@ -119,6 +136,7 @@
|
|||||||
- {{ \App\Utils\Number::formatMoney($payment->invoices->where('id', $invoice->id)->sum('pivot.amount') - $payment->invoices->where('id', $invoice->id)->sum('pivot.refunded'), $payment->client) }}
|
- {{ \App\Utils\Number::formatMoney($payment->invoices->where('id', $invoice->id)->sum('pivot.amount') - $payment->invoices->where('id', $invoice->id)->sum('pivot.refunded'), $payment->client) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user