Payment screen

This commit is contained in:
David Bomba 2019-09-05 15:04:52 +10:00
parent 374cc88c06
commit f5e19ece06
5 changed files with 47 additions and 21 deletions

View File

@ -116,13 +116,26 @@ class InvoiceController extends Controller
$invoices = Invoice::whereIn('id', $ids) $invoices = Invoice::whereIn('id', $ids)
->whereClientId(auth()->user()->client->id) ->whereClientId(auth()->user()->client->id)
->get() ->get();
->filter(function ($invoice){
$total = $invoices->sum('balance');
$invoices->filter(function ($invoice){
return $invoice->isPayable(); return $invoice->isPayable();
})->map(function ($invoice){
$invoice->balance = Number::formatMoney($invoice->balance, $invoice->client->currency(), $invoice->client->country, $invoice->client->getMergedSettings());
$invoice->due_date = $this->formatDate($invoice->due_date, $invoice->client->date_format());
return $invoice;
}); });
$formatted_total = Number::formatMoney($total, auth()->user()->client->currency(), auth()->user()->client->country, auth()->user()->client->getMergedSettings());
$data = [ $data = [
'invoices' => $invoices, 'invoices' => $invoices,
'formatted_total' => $formatted_total,
'total' => $total,
]; ];
return view('portal.default.invoices.payment', $data); return view('portal.default.invoices.payment', $data);

View File

@ -35,6 +35,7 @@ class Invoice extends BaseModel
use MakesDates; use MakesDates;
use PresentableTrait; use PresentableTrait;
use MakesInvoiceValues; use MakesInvoiceValues;
protected $presenter = 'App\Models\Presenters\InvoicePresenter'; protected $presenter = 'App\Models\Presenters\InvoicePresenter';
protected $hidden = [ protected $hidden = [

View File

@ -11,6 +11,9 @@
namespace App\Models\Presenters; namespace App\Models\Presenters;
use App\Utils\Number;
use App\Utils\Traits\MakesDates;
/** /**
* Class InvoicePresenter * Class InvoicePresenter
* *
@ -25,6 +28,7 @@ namespace App\Models\Presenters;
*/ */
class InvoicePresenter extends EntityPresenter class InvoicePresenter extends EntityPresenter
{ {
use MakesDates;
public function clientName() public function clientName()
{ {
@ -61,5 +65,4 @@ class InvoicePresenter extends EntityPresenter
return $this->company->present()->address(); return $this->company->present()->address();
} }
} }

View File

@ -17,9 +17,9 @@
<a class="list-group-item list-group-item-action flex-column align-items-start" href="javascript:void(0);"> <a class="list-group-item list-group-item-action flex-column align-items-start" href="javascript:void(0);">
<div class="d-flex w-100 justify-content-between"> <div class="d-flex w-100 justify-content-between">
<h5 class="mr-4"># {{ $invoice->invoice_number }}</h5> <h5 class="mr-4"># {{ $invoice->invoice_number }}</h5>
<small>{{$invoice->due_date}}</small> <small>{{ $invoice->due_date }}</small>
</div> </div>
<p class="mb-1 pull-right">${{ $invoice->balance }}</p> <p class="mb-1 pull-right">{{ $invoice->balance }}</p>
<small> <small>
@if($invoice->po_number) @if($invoice->po_number)
{{ $invoice->po_number }} {{ $invoice->po_number }}
@ -36,16 +36,8 @@
<div class="py-md-5"> <div class="py-md-5">
<ul class="list-group"> <ul class="list-group">
<li class="list-group-item d-flex list-group-item-action justify-content-between align-items-center">{{ ctrans('texts.subtotal')}}
<span class="badge badge-primary badge-pill">$314.00</span>
</li>
<li class="list-group-item d-flex list-group-item-action justify-content-between align-items-center">{{ ctrans('texts.taxes')}}
<span class="badge badge-primary badge-pill">$19.00</span>
</li>
<li class="list-group-item d-flex list-group-item-action justify-content-between align-items-center">{{ ctrans('texts.fees')}}
<span class="badge badge-primary badge-pill">$2</span>
<li class="list-group-item d-flex list-group-item-action justify-content-between align-items-center"><strong>{{ ctrans('texts.total')}}</strong> <li class="list-group-item d-flex list-group-item-action justify-content-between align-items-center"><strong>{{ ctrans('texts.total')}}</strong>
<span class="badge badge-primary badge-pill"><strong>$335.00</strong></span> <h3><span class="badge badge-primary badge-pill"><strong>{{ $formatted_total }}</strong></span></h3>
</li> </li>
</ul> </ul>
</div> </div>

View File

@ -3,15 +3,32 @@
<main class="main"> <main class="main">
<div class="container-fluid"> <div class="container-fluid">
<div class="col-md-12 mt-4"> {!! Former::framework('TwitterBootstrap4'); !!}
{!! Former::horizontal_open()
->id('payment_form')
->route('client.invoices.bulk')
->method('POST'); !!}
{!! Former::hidden('hashed_ids')->id('hashed_ids')->value( $invoice->hashed_id ) !!}
{!! Former::hidden('action')->id('action')->value('payment') !!}
<div class="row mt-4">
<div class="col-md-12">
<div class="float-right"> <div class="float-right">
<button class="btn btn-primary">{{ ctrans('texts.pay_now') }}</button> <button class="btn btn-primary">{{ ctrans('texts.pay_now') }}</button>
</div> </div>
</div> </div>
</div>
<div class="col-md-12 mt-4"> {!! Former::close() !!}
<div class="row mt-4">
<div class="col-md-12">
<embed src="{{ asset($invoice->pdf_url()) }}#toolbar=1&navpanes=1&scrollbar=1" type="application/pdf" width="100%" height="1180px" /> <embed src="{{ asset($invoice->pdf_url()) }}#toolbar=1&navpanes=1&scrollbar=1" type="application/pdf" width="100%" height="1180px" />