mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
update pagination links & apply php-cs-fixer
This commit is contained in:
parent
9ba9d08697
commit
1f2c3f2823
@ -1,5 +1,15 @@
|
||||
<?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;
|
||||
|
||||
use App\Models\Credit;
|
||||
|
@ -1,5 +1,15 @@
|
||||
<?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;
|
||||
|
||||
use App\Models\Invoice;
|
||||
@ -8,9 +18,6 @@ use Carbon\Carbon;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
/**
|
||||
* @todo: Integrate InvoiceFilters
|
||||
*/
|
||||
class InvoicesTable extends Component
|
||||
{
|
||||
use WithPagination, WithSorting;
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\ClientGatewayToken;
|
||||
|
@ -1,5 +1,15 @@
|
||||
<?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;
|
||||
|
||||
use App\Models\Payment;
|
||||
|
@ -1,5 +1,15 @@
|
||||
<?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;
|
||||
|
||||
use App\Models\Quote;
|
||||
|
@ -1,5 +1,15 @@
|
||||
<?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;
|
||||
|
||||
use App\Models\RecurringInvoice;
|
||||
|
@ -30,7 +30,6 @@ class DownloadInvoices extends Mailable
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name'))
|
||||
|
||||
->subject(ctrans('texts.download_files'))
|
||||
|
@ -27,7 +27,6 @@ class ExistingMigration extends Mailable
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name'))
|
||||
|
||||
->view('email.migration.existing');
|
||||
|
@ -31,7 +31,6 @@ class MigrationFailed extends Mailable
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name'))
|
||||
|
||||
->view('email.migration.failed');
|
||||
|
@ -79,15 +79,14 @@ class InvoiceRepository extends BaseRepository
|
||||
|
||||
/**
|
||||
* Handles the restoration on a deleted invoice.
|
||||
*
|
||||
*
|
||||
* @param [type] $invoice [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function restore($invoice) :Invoice
|
||||
{
|
||||
//if we have just archived, only perform a soft restore
|
||||
if(!$invoice->is_deleted) {
|
||||
|
||||
if (!$invoice->is_deleted) {
|
||||
parent::restore($invoice);
|
||||
|
||||
return $invoice;
|
||||
|
@ -13,11 +13,9 @@ namespace App\Services\Invoice;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use App\Services\AbstractService;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class HandleRestore extends AbstractService
|
||||
{
|
||||
|
||||
private $invoice;
|
||||
|
||||
private $payment_total = 0;
|
||||
@ -29,14 +27,13 @@ class HandleRestore extends AbstractService
|
||||
|
||||
public function run()
|
||||
{
|
||||
|
||||
if(!$this->invoice->is_deleted)
|
||||
if (!$this->invoice->is_deleted) {
|
||||
return $this->invoice;
|
||||
}
|
||||
|
||||
//determine whether we need to un-delete payments OR just modify the payment amount /applied balances.
|
||||
|
||||
foreach($this->invoice->payments as $payment)
|
||||
{
|
||||
//determine whether we need to un-delete payments OR just modify the payment amount /applied balances.
|
||||
|
||||
foreach ($this->invoice->payments as $payment) {
|
||||
//restore the payment record
|
||||
$payment->restore();
|
||||
|
||||
@ -58,15 +55,12 @@ class HandleRestore extends AbstractService
|
||||
|
||||
info($payment->amount . " == " . $payment_amount);
|
||||
|
||||
if($payment->amount == $payment_amount) {
|
||||
|
||||
if ($payment->amount == $payment_amount) {
|
||||
$payment->is_deleted = false;
|
||||
$payment->save();
|
||||
|
||||
$this->payment_total += $payment_amount;
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
$payment->is_deleted = false;
|
||||
$payment->amount += ($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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//adjust ledger balance
|
||||
$this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance, 'Restored invoice {$this->invoice->number}')->save();
|
||||
//adjust ledger balance
|
||||
$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()->updateBalance($this->invoice->balance)->save();
|
||||
@ -89,13 +82,12 @@ class HandleRestore extends AbstractService
|
||||
|
||||
$this->windBackInvoiceNumber();
|
||||
|
||||
return $this->invoice;
|
||||
return $this->invoice;
|
||||
}
|
||||
|
||||
|
||||
private function windBackInvoiceNumber()
|
||||
{
|
||||
|
||||
$findme = '_' . ctrans('texts.deleted');
|
||||
|
||||
$pos = strpos($this->invoice->number, $findme);
|
||||
@ -105,11 +97,8 @@ class HandleRestore extends AbstractService
|
||||
try {
|
||||
$this->invoice->number = $new_invoice_number;
|
||||
$this->invoice->save();
|
||||
}
|
||||
catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
info("I could not wind back the invoice number");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,9 @@ class MarkInvoiceDeleted extends AbstractService
|
||||
|
||||
public function run()
|
||||
{
|
||||
if($this->invoice->is_deleted)
|
||||
if ($this->invoice->is_deleted) {
|
||||
return $this->invoice;
|
||||
}
|
||||
|
||||
// if(in_array($this->invoice->status_id, ['currencies', 'industries', 'languages', 'countries', 'banks']))
|
||||
// return $this->
|
||||
@ -47,7 +48,7 @@ class MarkInvoiceDeleted extends AbstractService
|
||||
->adjustBalance()
|
||||
->adjustLedger();
|
||||
|
||||
return $this->invoice;
|
||||
return $this->invoice;
|
||||
}
|
||||
|
||||
private function adjustLedger()
|
||||
@ -61,7 +62,7 @@ class MarkInvoiceDeleted extends AbstractService
|
||||
{
|
||||
$this->invoice->client->service()->updatePaidToDate($this->adjustment_amount * -1)->save();
|
||||
|
||||
return $this;
|
||||
return $this;
|
||||
}
|
||||
|
||||
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($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]);
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//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
|
||||
->where('paymentable_type', '=', 'invoices')
|
||||
->where('paymentable_id', $this->invoice->id)
|
||||
@ -93,7 +90,6 @@ class MarkInvoiceDeleted extends AbstractService
|
||||
$payment->amount -= $payment_adjustment;
|
||||
$payment->applied -= $payment_adjustment;
|
||||
$payment->save();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -102,8 +98,7 @@ class MarkInvoiceDeleted extends AbstractService
|
||||
|
||||
private function setAdjustmentAmount()
|
||||
{
|
||||
|
||||
foreach ($this->invoice->payments as $payment) {
|
||||
foreach ($this->invoice->payments as $payment) {
|
||||
$this->adjustment_amount += $payment->paymentables
|
||||
->where('paymentable_type', '=', 'invoices')
|
||||
->where('paymentable_id', $this->invoice->id)
|
||||
@ -118,7 +113,6 @@ class MarkInvoiceDeleted extends AbstractService
|
||||
|
||||
private function cleanup()
|
||||
{
|
||||
|
||||
$check = false;
|
||||
|
||||
$x=0;
|
||||
@ -136,7 +130,6 @@ class MarkInvoiceDeleted extends AbstractService
|
||||
$this->invoice->expenses()->update(['invoice_id' => null]);
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
private function calcNumber($x)
|
||||
@ -153,8 +146,7 @@ class MarkInvoiceDeleted extends AbstractService
|
||||
|
||||
private function deletePaymentables()
|
||||
{
|
||||
|
||||
$this->invoice->payments->each(function ($payment){
|
||||
$this->invoice->payments->each(function ($payment) {
|
||||
$payment->paymentables()
|
||||
->where('paymentable_type', '=', 'invoices')
|
||||
->where('paymentable_id', $this->invoice->id)
|
||||
|
2
public/css/app.css
vendored
2
public/css/app.css
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"/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/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",
|
||||
|
@ -76,6 +76,6 @@
|
||||
{{ ctrans('texts.showing_x_of', ['first' => $credits->firstItem(), 'last' => $credits->lastItem(), 'total' => $credits->total()]) }}
|
||||
</span>
|
||||
@endif
|
||||
{{ $credits->links() }}
|
||||
{{ $credits->links('portal/ninja2020/vendor/pagination') }}
|
||||
</div>
|
||||
</div>
|
@ -104,6 +104,6 @@
|
||||
{{ ctrans('texts.showing_x_of', ['first' => $documents->firstItem(), 'last' => $documents->lastItem(), 'total' => $documents->total()]) }}
|
||||
</span>
|
||||
@endif
|
||||
{{ $documents->links() }}
|
||||
{{ $documents->links('portal/ninja2020/vendor/pagination') }}
|
||||
</div>
|
||||
</div>
|
@ -122,11 +122,11 @@
|
||||
</div>
|
||||
<div class="flex justify-center mt-6 mb-6 md:justify-between">
|
||||
@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()]) }}
|
||||
</span>
|
||||
@endif
|
||||
{{ $invoices->links() }}
|
||||
{{ $invoices->links('portal/ninja2020/vendor/pagination') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -116,6 +116,6 @@
|
||||
</span>
|
||||
@endif
|
||||
|
||||
{{ $payment_methods->links() }}
|
||||
{{ $payment_methods->links('portal/ninja2020/vendor/pagination') }}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -82,6 +82,6 @@
|
||||
{{ ctrans('texts.showing_x_of', ['first' => $payments->firstItem(), 'last' => $payments->lastItem(), 'total' => $payments->total()]) }}
|
||||
</span>
|
||||
@endif
|
||||
{{ $payments->links() }}
|
||||
{{ $payments->links('portal/ninja2020/vendor/pagination') }}
|
||||
</div>
|
||||
</div>
|
@ -112,7 +112,7 @@
|
||||
{{ ctrans('texts.showing_x_of', ['first' => $quotes->firstItem(), 'last' => $quotes->lastItem(), 'total' => $quotes->total()]) }}
|
||||
</span>
|
||||
@endif
|
||||
{{ $quotes->links() }}
|
||||
{{ $quotes->links('portal/ninja2020/vendor/pagination') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -84,6 +84,6 @@
|
||||
{{ ctrans('texts.showing_x_of', ['first' => $invoices->firstItem(), 'last' => $invoices->lastItem(), 'total' => $invoices->total()]) }}
|
||||
</span>
|
||||
@endif
|
||||
{{ $invoices->links() }}
|
||||
{{ $invoices->links('portal/ninja2020/vendor/pagination') }}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,67 +1,56 @@
|
||||
<div class="border-t border-gray-200 px-4 flex items-center justify-between sm:px-0">
|
||||
<div class="w-0 flex-1 flex">
|
||||
<a href="{{ $paginator->previousPageUrl() }}"
|
||||
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">
|
||||
<svg class="mr-3 h-5 w-5 text-gray-400" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd"
|
||||
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"
|
||||
clip-rule="evenodd"/>
|
||||
</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">
|
||||
...
|
||||
@if ($paginator->hasPages())
|
||||
<ul class="pagination" role="navigation">
|
||||
{{-- Previous Page Link --}}
|
||||
@if ($paginator->onFirstPage())
|
||||
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.previous')">
|
||||
<span class="page-link" aria-hidden="true">
|
||||
<span class="d-none d-md-block">‹</span>
|
||||
<span class="d-block d-md-none">@lang('pagination.previous')</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">‹</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
|
||||
|
||||
{{-- Array Of Links --}}
|
||||
@if (is_array($element))
|
||||
@foreach ($element as $page => $url)
|
||||
@if ($page == $paginator->currentPage())
|
||||
<a href="#" disabled
|
||||
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>
|
||||
<li class="page-item active d-none d-md-block" aria-current="page"><span class="page-link">{{ $page }}</span></li>
|
||||
@else
|
||||
<a href="{{ $url }}"
|
||||
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>
|
||||
<li class="page-item d-none d-md-block"><button type="button" class="page-link" wire:click="gotoPage({{ $page }})">{{ $page }}</button></li>
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
@if ($paginator->hasMorePages())
|
||||
<div class="w-0 flex-1 flex justify-end">
|
||||
<a href="{{ $paginator->nextPageUrl() }}"
|
||||
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">
|
||||
@lang('texts.next')
|
||||
<svg class="ml-3 h-5 w-5 text-gray-400" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd"
|
||||
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"
|
||||
clip-rule="evenodd"/>
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
{{-- Next Page Link --}}
|
||||
@if ($paginator->hasMorePages())
|
||||
<li class="page-item">
|
||||
<button type="button" class="page-link" wire:click="nextPage" rel="next" aria-label="@lang('pagination.next')">
|
||||
<span class="d-block d-md-none">@lang('pagination.next')</span>
|
||||
<span class="d-none d-md-block">›</span>
|
||||
</button>
|
||||
</li>
|
||||
@else
|
||||
<div class="w-0 flex-1 flex justify-end">
|
||||
<a href="#"
|
||||
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">
|
||||
@lang('texts.next')
|
||||
<svg class="ml-3 h-5 w-5 text-gray-400" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd"
|
||||
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"
|
||||
clip-rule="evenodd"/>
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.next')">
|
||||
<span class="page-link" aria-hidden="true">
|
||||
<span class="d-block d-md-none">@lang('pagination.next')</span>
|
||||
<span class="d-none d-md-block">›</span>
|
||||
</span>
|
||||
</li>
|
||||
@endif
|
||||
</ul>
|
||||
@endif
|
@ -45,7 +45,6 @@ class DeleteInvoiceTest extends TestCase
|
||||
*/
|
||||
public function testInvoiceDeletion()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'name' => 'A Nice Client',
|
||||
];
|
||||
@ -148,7 +147,6 @@ class DeleteInvoiceTest extends TestCase
|
||||
$this->assertFalse((bool)$invoice->is_deleted);
|
||||
$this->assertNull($invoice->deleted_at);
|
||||
$this->assertEquals(20, $invoice->client->fresh()->balance);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user