1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Merge pull request #4435 from beganovich/v5-livewire-upgrade

(v5) Livewire upgrade & support for PHP 8
This commit is contained in:
Benjamin Beganović 2020-12-06 00:25:18 +01:00 committed by GitHub
commit 590ae1f6cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 168 additions and 1823 deletions

View File

@ -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;

View File

@ -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;

View File

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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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'))

View File

@ -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');

View File

@ -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');

View File

@ -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;

View File

@ -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");
}
}
}

View File

@ -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)

View File

@ -51,7 +51,7 @@
"league/flysystem-cached-adapter": "^1.1",
"league/fractal": "^0.17.0",
"league/omnipay": "^3.0",
"livewire/livewire": "^1.3",
"livewire/livewire": "^2.0",
"maennchen/zipstream-php": "^1.2",
"nwidart/laravel-modules": "^6.0",
"omnipay/paypal": "^3.0",

35
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "ef60a891b86ee73c6f31b73f0e778e09",
"content-hash": "a96274475177046a99ed701ae4148a3d",
"packages": [
{
"name": "asgrim/ofxparser",
@ -3712,30 +3712,32 @@
},
{
"name": "livewire/livewire",
"version": "v1.3.5",
"version": "v2.3.5",
"source": {
"type": "git",
"url": "https://github.com/livewire/livewire.git",
"reference": "b1673ff9fc78a3296ca4a3b0d1ca26da0a5cdf82"
"reference": "781a1250dc8eab9121fd856ff0b6efca8c32756f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/livewire/livewire/zipball/b1673ff9fc78a3296ca4a3b0d1ca26da0a5cdf82",
"reference": "b1673ff9fc78a3296ca4a3b0d1ca26da0a5cdf82",
"url": "https://api.github.com/repos/livewire/livewire/zipball/781a1250dc8eab9121fd856ff0b6efca8c32756f",
"reference": "781a1250dc8eab9121fd856ff0b6efca8c32756f",
"shasum": ""
},
"require": {
"illuminate/database": "~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0",
"illuminate/support": "~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0",
"illuminate/validation": "~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0",
"php": "^7.1.3",
"symfony/http-kernel": "^4.0|^5.0"
"illuminate/database": "^7.0|^8.0",
"illuminate/support": "^7.0|^8.0",
"illuminate/validation": "^7.0|^8.0",
"php": "^7.2.5|^8.0",
"symfony/http-kernel": "^5.0"
},
"require-dev": {
"laravel/framework": "~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0",
"calebporzio/sushi": "^2.1",
"laravel/framework": "^7.0|^8.0",
"mockery/mockery": "^1.3.1",
"orchestra/testbench": "~3.6.0|~3.7.0|~3.8.0|^4.0|^5.0",
"phpunit/phpunit": "^7.5.15|^8.4|^9.0",
"orchestra/testbench": "^5.0|^6.0",
"orchestra/testbench-dusk": "^5.2|^6.0",
"phpunit/phpunit": "^8.4|^9.0",
"psy/psysh": "@stable"
},
"type": "library",
@ -3750,6 +3752,9 @@
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Livewire\\": "src/"
}
@ -3767,7 +3772,7 @@
"description": "A front-end framework for Laravel.",
"support": {
"issues": "https://github.com/livewire/livewire/issues",
"source": "https://github.com/livewire/livewire/tree/v1.3.5"
"source": "https://github.com/livewire/livewire/tree/v2.3.5"
},
"funding": [
{
@ -3775,7 +3780,7 @@
"type": "github"
}
],
"time": "2020-09-17T04:38:16+00:00"
"time": "2020-12-01T20:51:29+00:00"
},
{
"name": "maennchen/zipstream-php",

2
public/css/app.css vendored

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -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",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"/livewire.js":"/livewire.js?id=d7d975b5d122717a1ee0"}
{"/livewire.js":"/livewire.js?id=eb510e851dceb24afd36"}

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

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

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -49,7 +49,7 @@
<!-- Scripts -->
<script src="{{ mix('js/app.js') }}" defer></script>
<script src="{{ asset('js/vendor/alpinejs/alpine.js') }}" defer></script>
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.7.x/dist/alpine.min.js" defer></script>
<!-- Fonts -->
<link rel="dns-prefetch" href="https://fonts.gstatic.com">

View File

@ -48,7 +48,7 @@
<!-- Scripts -->
<script src="{{ mix('js/app.js') }}" defer></script>
<script src="{{ asset('js/vendor/alpinejs/alpine.js') }}" defer></script>
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.7.x/dist/alpine.min.js" defer></script>
<!-- Fonts -->
<link rel="dns-prefetch" href="https://fonts.gstatic.com">

View File

@ -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">&lsaquo;</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">&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
{{-- 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">&rsaquo;</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">&rsaquo;</span>
</span>
</li>
@endif
</ul>
@endif

View File

@ -3,7 +3,7 @@
@push('head')
<meta name="pdf-url" content="{{ asset($entity->pdf_file_path()) }}">
<script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script>
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.7.x/dist/alpine.min.js" defer></script>
@endpush
@section('body')

View File

@ -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);
}
/**