update pagination links & apply php-cs-fixer

This commit is contained in:
Benjamin Beganović 2020-12-05 14:24:21 +01:00
parent 9ba9d08697
commit 1f2c3f2823
23 changed files with 129 additions and 115 deletions

View File

@ -1,5 +1,15 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Models\Credit; use App\Models\Credit;

View File

@ -1,5 +1,15 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Models\Invoice; use App\Models\Invoice;
@ -8,9 +18,6 @@ use Carbon\Carbon;
use Livewire\Component; use Livewire\Component;
use Livewire\WithPagination; use Livewire\WithPagination;
/**
* @todo: Integrate InvoiceFilters
*/
class InvoicesTable extends Component class InvoicesTable extends Component
{ {
use WithPagination, WithSorting; use WithPagination, WithSorting;

View File

@ -1,5 +1,8 @@
<?php <?php
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Models\ClientGatewayToken; use App\Models\ClientGatewayToken;

View File

@ -1,5 +1,15 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Models\Payment; use App\Models\Payment;

View File

@ -1,5 +1,15 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Models\Quote; use App\Models\Quote;

View File

@ -1,5 +1,15 @@
<?php <?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Livewire; namespace App\Http\Livewire;
use App\Models\RecurringInvoice; use App\Models\RecurringInvoice;

View File

@ -30,7 +30,6 @@ class DownloadInvoices extends Mailable
*/ */
public function build() public function build()
{ {
return $this->from(config('mail.from.address'), config('mail.from.name')) return $this->from(config('mail.from.address'), config('mail.from.name'))
->subject(ctrans('texts.download_files')) ->subject(ctrans('texts.download_files'))

View File

@ -27,7 +27,6 @@ class ExistingMigration extends Mailable
*/ */
public function build() public function build()
{ {
return $this->from(config('mail.from.address'), config('mail.from.name')) return $this->from(config('mail.from.address'), config('mail.from.name'))
->view('email.migration.existing'); ->view('email.migration.existing');

View File

@ -31,7 +31,6 @@ class MigrationFailed extends Mailable
*/ */
public function build() public function build()
{ {
return $this->from(config('mail.from.address'), config('mail.from.name')) return $this->from(config('mail.from.address'), config('mail.from.name'))
->view('email.migration.failed'); ->view('email.migration.failed');

View File

@ -79,15 +79,14 @@ class InvoiceRepository extends BaseRepository
/** /**
* Handles the restoration on a deleted invoice. * Handles the restoration on a deleted invoice.
* *
* @param [type] $invoice [description] * @param [type] $invoice [description]
* @return [type] [description] * @return [type] [description]
*/ */
public function restore($invoice) :Invoice public function restore($invoice) :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);
return $invoice; return $invoice;

View File

@ -13,11 +13,9 @@ namespace App\Services\Invoice;
use App\Models\Invoice; use App\Models\Invoice;
use App\Services\AbstractService; use App\Services\AbstractService;
use Illuminate\Support\Facades\DB;
class HandleRestore extends AbstractService class HandleRestore extends AbstractService
{ {
private $invoice; private $invoice;
private $payment_total = 0; private $payment_total = 0;
@ -29,14 +27,13 @@ class HandleRestore extends AbstractService
public function run() public function run()
{ {
if (!$this->invoice->is_deleted) {
if(!$this->invoice->is_deleted)
return $this->invoice; return $this->invoice;
}
//determine whether we need to un-delete payments OR just modify the payment amount /applied balances. //determine whether we need to un-delete payments OR just modify the payment amount /applied balances.
foreach($this->invoice->payments as $payment) foreach ($this->invoice->payments as $payment) {
{
//restore the payment record //restore the payment record
$payment->restore(); $payment->restore();
@ -58,15 +55,12 @@ class HandleRestore extends AbstractService
info($payment->amount . " == " . $payment_amount); info($payment->amount . " == " . $payment_amount);
if($payment->amount == $payment_amount) { if ($payment->amount == $payment_amount) {
$payment->is_deleted = false; $payment->is_deleted = false;
$payment->save(); $payment->save();
$this->payment_total += $payment_amount; $this->payment_total += $payment_amount;
} } else {
else {
$payment->is_deleted = false; $payment->is_deleted = false;
$payment->amount += ($payment_amount - $pre_restore_amount); $payment->amount += ($payment_amount - $pre_restore_amount);
$payment->applied += ($payment_amount - $pre_restore_amount); $payment->applied += ($payment_amount - $pre_restore_amount);
@ -74,13 +68,12 @@ class HandleRestore extends AbstractService
$this->payment_total += ($payment_amount - $pre_restore_amount); $this->payment_total += ($payment_amount - $pre_restore_amount);
} }
} }
//adjust ledger balance //adjust ledger balance
$this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance, 'Restored invoice {$this->invoice->number}')->save(); $this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance, 'Restored invoice {$this->invoice->number}')->save();
//adjust paid to dates //adjust paid to dates
$this->invoice->client->service()->updatePaidToDate($this->payment_total)->save(); $this->invoice->client->service()->updatePaidToDate($this->payment_total)->save();
$this->invoice->client->service()->updateBalance($this->invoice->balance)->save(); $this->invoice->client->service()->updateBalance($this->invoice->balance)->save();
@ -89,13 +82,12 @@ class HandleRestore extends AbstractService
$this->windBackInvoiceNumber(); $this->windBackInvoiceNumber();
return $this->invoice; return $this->invoice;
} }
private function windBackInvoiceNumber() private function windBackInvoiceNumber()
{ {
$findme = '_' . ctrans('texts.deleted'); $findme = '_' . ctrans('texts.deleted');
$pos = strpos($this->invoice->number, $findme); $pos = strpos($this->invoice->number, $findme);
@ -105,11 +97,8 @@ class HandleRestore extends AbstractService
try { try {
$this->invoice->number = $new_invoice_number; $this->invoice->number = $new_invoice_number;
$this->invoice->save(); $this->invoice->save();
} } catch (\Exception $e) {
catch(\Exception $e){
info("I could not wind back the invoice number"); info("I could not wind back the invoice number");
} }
} }
} }

View File

@ -33,8 +33,9 @@ class MarkInvoiceDeleted extends AbstractService
public function run() public function run()
{ {
if($this->invoice->is_deleted) if ($this->invoice->is_deleted) {
return $this->invoice; return $this->invoice;
}
// if(in_array($this->invoice->status_id, ['currencies', 'industries', 'languages', 'countries', 'banks'])) // if(in_array($this->invoice->status_id, ['currencies', 'industries', 'languages', 'countries', 'banks']))
// return $this-> // return $this->
@ -47,7 +48,7 @@ class MarkInvoiceDeleted extends AbstractService
->adjustBalance() ->adjustBalance()
->adjustLedger(); ->adjustLedger();
return $this->invoice; return $this->invoice;
} }
private function adjustLedger() private function adjustLedger()
@ -61,7 +62,7 @@ class MarkInvoiceDeleted extends AbstractService
{ {
$this->invoice->client->service()->updatePaidToDate($this->adjustment_amount * -1)->save(); $this->invoice->client->service()->updatePaidToDate($this->adjustment_amount * -1)->save();
return $this; return $this;
} }
private function adjustBalance() private function adjustBalance()
@ -75,16 +76,12 @@ class MarkInvoiceDeleted extends AbstractService
{ {
//if total payments = adjustment amount - that means we need to delete the payments as well. //if total payments = adjustment amount - that means we need to delete the payments as well.
if($this->adjustment_amount == $this->total_payments) { if ($this->adjustment_amount == $this->total_payments) {
$this->invoice->payments()->update(['payments.deleted_at' => now(), 'payments.is_deleted' => true]); $this->invoice->payments()->update(['payments.deleted_at' => now(), 'payments.is_deleted' => true]);
} else {
}
else {
//adjust payments down by the amount applied to the invoice payment. //adjust payments down by the amount applied to the invoice payment.
$this->invoice->payments->each(function ($payment){ $this->invoice->payments->each(function ($payment) {
$payment_adjustment = $payment->paymentables $payment_adjustment = $payment->paymentables
->where('paymentable_type', '=', 'invoices') ->where('paymentable_type', '=', 'invoices')
->where('paymentable_id', $this->invoice->id) ->where('paymentable_id', $this->invoice->id)
@ -93,7 +90,6 @@ class MarkInvoiceDeleted extends AbstractService
$payment->amount -= $payment_adjustment; $payment->amount -= $payment_adjustment;
$payment->applied -= $payment_adjustment; $payment->applied -= $payment_adjustment;
$payment->save(); $payment->save();
}); });
} }
@ -102,8 +98,7 @@ class MarkInvoiceDeleted extends AbstractService
private function setAdjustmentAmount() private function setAdjustmentAmount()
{ {
foreach ($this->invoice->payments as $payment) {
foreach ($this->invoice->payments as $payment) {
$this->adjustment_amount += $payment->paymentables $this->adjustment_amount += $payment->paymentables
->where('paymentable_type', '=', 'invoices') ->where('paymentable_type', '=', 'invoices')
->where('paymentable_id', $this->invoice->id) ->where('paymentable_id', $this->invoice->id)
@ -118,7 +113,6 @@ class MarkInvoiceDeleted extends AbstractService
private function cleanup() private function cleanup()
{ {
$check = false; $check = false;
$x=0; $x=0;
@ -136,7 +130,6 @@ class MarkInvoiceDeleted extends AbstractService
$this->invoice->expenses()->update(['invoice_id' => null]); $this->invoice->expenses()->update(['invoice_id' => null]);
return $this; return $this;
} }
private function calcNumber($x) private function calcNumber($x)
@ -153,8 +146,7 @@ class MarkInvoiceDeleted extends AbstractService
private function deletePaymentables() private function deletePaymentables()
{ {
$this->invoice->payments->each(function ($payment) {
$this->invoice->payments->each(function ($payment){
$payment->paymentables() $payment->paymentables()
->where('paymentable_type', '=', 'invoices') ->where('paymentable_type', '=', 'invoices')
->where('paymentable_id', $this->invoice->id) ->where('paymentable_id', $this->invoice->id)

2
public/css/app.css vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"/js/app.js": "/js/app.js?id=a33a5a58bfc6e2174841", "/js/app.js": "/js/app.js?id=a33a5a58bfc6e2174841",
"/css/app.css": "/css/app.css?id=2fee89354bd20f89bf73", "/css/app.css": "/css/app.css?id=fb5c591f4280af2b670a",
"/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=a09bb529b8e1826f13b4", "/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=a09bb529b8e1826f13b4",
"/js/clients/invoices/payment.js": "/js/clients/invoices/payment.js?id=8ce8955ba775ea5f47d1", "/js/clients/invoices/payment.js": "/js/clients/invoices/payment.js?id=8ce8955ba775ea5f47d1",
"/js/clients/payment_methods/authorize-authorize-card.js": "/js/clients/payment_methods/authorize-authorize-card.js?id=cddcd46c630c71737bda", "/js/clients/payment_methods/authorize-authorize-card.js": "/js/clients/payment_methods/authorize-authorize-card.js?id=cddcd46c630c71737bda",

View File

@ -76,6 +76,6 @@
{{ ctrans('texts.showing_x_of', ['first' => $credits->firstItem(), 'last' => $credits->lastItem(), 'total' => $credits->total()]) }} {{ ctrans('texts.showing_x_of', ['first' => $credits->firstItem(), 'last' => $credits->lastItem(), 'total' => $credits->total()]) }}
</span> </span>
@endif @endif
{{ $credits->links() }} {{ $credits->links('portal/ninja2020/vendor/pagination') }}
</div> </div>
</div> </div>

View File

@ -104,6 +104,6 @@
{{ ctrans('texts.showing_x_of', ['first' => $documents->firstItem(), 'last' => $documents->lastItem(), 'total' => $documents->total()]) }} {{ ctrans('texts.showing_x_of', ['first' => $documents->firstItem(), 'last' => $documents->lastItem(), 'total' => $documents->total()]) }}
</span> </span>
@endif @endif
{{ $documents->links() }} {{ $documents->links('portal/ninja2020/vendor/pagination') }}
</div> </div>
</div> </div>

View File

@ -122,11 +122,11 @@
</div> </div>
<div class="flex justify-center mt-6 mb-6 md:justify-between"> <div class="flex justify-center mt-6 mb-6 md:justify-between">
@if($invoices->total() > 0) @if($invoices->total() > 0)
<span class="hidden text-sm text-gray-700 md:block"> <span class="hidden text-sm text-gray-700 md:block mr-2">
{{ ctrans('texts.showing_x_of', ['first' => $invoices->firstItem(), 'last' => $invoices->lastItem(), 'total' => $invoices->total()]) }} {{ ctrans('texts.showing_x_of', ['first' => $invoices->firstItem(), 'last' => $invoices->lastItem(), 'total' => $invoices->total()]) }}
</span> </span>
@endif @endif
{{ $invoices->links() }} {{ $invoices->links('portal/ninja2020/vendor/pagination') }}
</div> </div>
</div> </div>

View File

@ -116,6 +116,6 @@
</span> </span>
@endif @endif
{{ $payment_methods->links() }} {{ $payment_methods->links('portal/ninja2020/vendor/pagination') }}
</div> </div>
</div> </div>

View File

@ -82,6 +82,6 @@
{{ ctrans('texts.showing_x_of', ['first' => $payments->firstItem(), 'last' => $payments->lastItem(), 'total' => $payments->total()]) }} {{ ctrans('texts.showing_x_of', ['first' => $payments->firstItem(), 'last' => $payments->lastItem(), 'total' => $payments->total()]) }}
</span> </span>
@endif @endif
{{ $payments->links() }} {{ $payments->links('portal/ninja2020/vendor/pagination') }}
</div> </div>
</div> </div>

View File

@ -112,7 +112,7 @@
{{ ctrans('texts.showing_x_of', ['first' => $quotes->firstItem(), 'last' => $quotes->lastItem(), 'total' => $quotes->total()]) }} {{ ctrans('texts.showing_x_of', ['first' => $quotes->firstItem(), 'last' => $quotes->lastItem(), 'total' => $quotes->total()]) }}
</span> </span>
@endif @endif
{{ $quotes->links() }} {{ $quotes->links('portal/ninja2020/vendor/pagination') }}
</div> </div>
</div> </div>

View File

@ -84,6 +84,6 @@
{{ ctrans('texts.showing_x_of', ['first' => $invoices->firstItem(), 'last' => $invoices->lastItem(), 'total' => $invoices->total()]) }} {{ ctrans('texts.showing_x_of', ['first' => $invoices->firstItem(), 'last' => $invoices->lastItem(), 'total' => $invoices->total()]) }}
</span> </span>
@endif @endif
{{ $invoices->links() }} {{ $invoices->links('portal/ninja2020/vendor/pagination') }}
</div> </div>
</div> </div>

View File

@ -1,67 +1,56 @@
<div class="border-t border-gray-200 px-4 flex items-center justify-between sm:px-0"> @if ($paginator->hasPages())
<div class="w-0 flex-1 flex"> <ul class="pagination" role="navigation">
<a href="{{ $paginator->previousPageUrl() }}" {{-- Previous Page Link --}}
class="-mt-px border-t-2 border-transparent pt-4 pr-1 inline-flex items-center text-sm leading-5 font-medium text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-400 transition ease-in-out duration-150"> @if ($paginator->onFirstPage())
<svg class="mr-3 h-5 w-5 text-gray-400" fill="currentColor" viewBox="0 0 20 20"> <li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.previous')">
<path fill-rule="evenodd" <span class="page-link" aria-hidden="true">
d="M7.707 14.707a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l2.293 2.293a1 1 0 010 1.414z" <span class="d-none d-md-block">&lsaquo;</span>
clip-rule="evenodd"/> <span class="d-block d-md-none">@lang('pagination.previous')</span>
</svg>
@lang('texts.previous')
</a>
</div>
<div class="hidden md:flex">
@foreach ($elements as $element)
@if (is_string($element))
<span
class="-mt-px border-t-2 border-transparent pt-4 px-4 inline-flex items-center text-sm leading-5 font-medium text-gray-500">
...
</span> </span>
</li>
@else
<li class="page-item">
<button type="button" class="page-link" wire:click="previousPage" rel="prev" aria-label="@lang('pagination.previous')">
<span class="d-none d-md-block">&lsaquo;</span>
<span class="d-block d-md-none">@lang('pagination.previous')</span>
</button>
</li>
@endif
{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<li class="page-item disabled d-none d-md-block" aria-disabled="true"><span class="page-link">{{ $element }}</span></li>
@endif @endif
{{-- Array Of Links --}}
@if (is_array($element)) @if (is_array($element))
@foreach ($element as $page => $url) @foreach ($element as $page => $url)
@if ($page == $paginator->currentPage()) @if ($page == $paginator->currentPage())
<a href="#" disabled <li class="page-item active d-none d-md-block" aria-current="page"><span class="page-link">{{ $page }}</span></li>
class="-mt-px border-t-2 border-blue-600 pt-4 px-4 inline-flex items-center text-sm leading-5 font-medium text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-400 transition ease-in-out duration-150"
aria-current="page">
{{ $page }}
</a>
@else @else
<a href="{{ $url }}" <li class="page-item d-none d-md-block"><button type="button" class="page-link" wire:click="gotoPage({{ $page }})">{{ $page }}</button></li>
class="-mt-px border-t-2 border-transparent pt-4 px-4 inline-flex items-center text-sm leading-5 font-medium text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-400 transition ease-in-out duration-150">
{{ $page }}
</a>
@endif @endif
@endforeach @endforeach
@endif @endif
@endforeach @endforeach
</div>
@if ($paginator->hasMorePages()) {{-- Next Page Link --}}
<div class="w-0 flex-1 flex justify-end"> @if ($paginator->hasMorePages())
<a href="{{ $paginator->nextPageUrl() }}" <li class="page-item">
class="-mt-px border-t-2 border-transparent pt-4 pl-1 inline-flex items-center text-sm leading-5 font-medium text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-400 transition ease-in-out duration-150"> <button type="button" class="page-link" wire:click="nextPage" rel="next" aria-label="@lang('pagination.next')">
@lang('texts.next') <span class="d-block d-md-none">@lang('pagination.next')</span>
<svg class="ml-3 h-5 w-5 text-gray-400" fill="currentColor" viewBox="0 0 20 20"> <span class="d-none d-md-block">&rsaquo;</span>
<path fill-rule="evenodd" </button>
d="M12.293 5.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-2.293-2.293a1 1 0 010-1.414z" </li>
clip-rule="evenodd"/>
</svg>
</a>
</div>
@else @else
<div class="w-0 flex-1 flex justify-end"> <li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.next')">
<a href="#" <span class="page-link" aria-hidden="true">
class="-mt-px border-t-2 border-transparent pt-4 pl-1 inline-flex items-center text-sm leading-5 font-medium text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-400 transition ease-in-out duration-150"> <span class="d-block d-md-none">@lang('pagination.next')</span>
@lang('texts.next') <span class="d-none d-md-block">&rsaquo;</span>
<svg class="ml-3 h-5 w-5 text-gray-400" fill="currentColor" viewBox="0 0 20 20"> </span>
<path fill-rule="evenodd" </li>
d="M12.293 5.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-2.293-2.293a1 1 0 010-1.414z" @endif
clip-rule="evenodd"/> </ul>
</svg> @endif
</a>
</div>
@endif
</div>

View File

@ -45,7 +45,6 @@ class DeleteInvoiceTest extends TestCase
*/ */
public function testInvoiceDeletion() public function testInvoiceDeletion()
{ {
$data = [ $data = [
'name' => 'A Nice Client', 'name' => 'A Nice Client',
]; ];
@ -148,7 +147,6 @@ class DeleteInvoiceTest extends TestCase
$this->assertFalse((bool)$invoice->is_deleted); $this->assertFalse((bool)$invoice->is_deleted);
$this->assertNull($invoice->deleted_at); $this->assertNull($invoice->deleted_at);
$this->assertEquals(20, $invoice->client->fresh()->balance); $this->assertEquals(20, $invoice->client->fresh()->balance);
} }
/** /**