diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index 28d59825f337..17e2023c8643 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -116,13 +116,26 @@ class InvoiceController extends Controller $invoices = Invoice::whereIn('id', $ids) ->whereClientId(auth()->user()->client->id) - ->get() - ->filter(function ($invoice){ - return $invoice->isPayable(); - }); + ->get(); + + $total = $invoices->sum('balance'); + + $invoices->filter(function ($invoice){ + 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 = [ 'invoices' => $invoices, + 'formatted_total' => $formatted_total, + 'total' => $total, ]; return view('portal.default.invoices.payment', $data); diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index e8bcf30c25fd..18eef7e5e14b 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -35,6 +35,7 @@ class Invoice extends BaseModel use MakesDates; use PresentableTrait; use MakesInvoiceValues; + protected $presenter = 'App\Models\Presenters\InvoicePresenter'; protected $hidden = [ diff --git a/app/Models/Presenters/InvoicePresenter.php b/app/Models/Presenters/InvoicePresenter.php index d97ed4c2aceb..496c78c3a1d7 100644 --- a/app/Models/Presenters/InvoicePresenter.php +++ b/app/Models/Presenters/InvoicePresenter.php @@ -11,6 +11,9 @@ namespace App\Models\Presenters; +use App\Utils\Number; +use App\Utils\Traits\MakesDates; + /** * Class InvoicePresenter * @@ -25,6 +28,7 @@ namespace App\Models\Presenters; */ class InvoicePresenter extends EntityPresenter { + use MakesDates; public function clientName() { @@ -61,5 +65,4 @@ class InvoicePresenter extends EntityPresenter return $this->company->present()->address(); } - } diff --git a/resources/views/portal/default/invoices/payment.blade.php b/resources/views/portal/default/invoices/payment.blade.php index a0e1345a9112..41ef15e350b2 100644 --- a/resources/views/portal/default/invoices/payment.blade.php +++ b/resources/views/portal/default/invoices/payment.blade.php @@ -17,9 +17,9 @@
# {{ $invoice->invoice_number }}
- {{$invoice->due_date}} + {{ $invoice->due_date }}
-

${{ $invoice->balance }}

+

{{ $invoice->balance }}

@if($invoice->po_number) {{ $invoice->po_number }} @@ -36,16 +36,8 @@
    -
  • {{ ctrans('texts.subtotal')}} - $314.00 -
  • -
  • {{ ctrans('texts.taxes')}} - $19.00 -
  • -
  • {{ ctrans('texts.fees')}} - $2
  • {{ ctrans('texts.total')}} - $335.00 +

    {{ $formatted_total }}

diff --git a/resources/views/portal/default/invoices/show.blade.php b/resources/views/portal/default/invoices/show.blade.php index 0c16d11a84eb..71bbd6ac95c1 100644 --- a/resources/views/portal/default/invoices/show.blade.php +++ b/resources/views/portal/default/invoices/show.blade.php @@ -3,15 +3,32 @@
-
+{!! 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') !!} + + + +
+
+ +
+ +
+ +
-
+{!! Former::close() !!} + +
+