forked from invoiceninja/invoiceninja
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request invoiceninja#10169 from turbo124/v5-develop
Support ids on sidebars
- Loading branch information
Showing
14 changed files
with
311 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
app/Http/Requests/EInvoice/UpdateEInvoiceConfiguration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
/** | ||
* Invoice Ninja (https://invoiceninja.com). | ||
* | ||
* @link https://github.com/invoiceninja/invoiceninja source repository | ||
* | ||
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com) | ||
* | ||
* @license https://www.elastic.co/licensing/elastic-license | ||
*/ | ||
|
||
namespace App\Http\Requests\EInvoice; | ||
|
||
use App\Utils\Ninja; | ||
use App\Models\Client; | ||
use App\Models\Company; | ||
use App\Models\Invoice; | ||
use App\Http\Requests\Request; | ||
use App\Services\EDocument\Adapters\CII\PaymentMeans; | ||
use Illuminate\Validation\Rule; | ||
|
||
class UpdateEInvoiceConfiguration extends Request | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize(): bool | ||
{ | ||
|
||
/** @var \App\Models\User $user */ | ||
$user = auth()->user(); | ||
|
||
return $user->isAdmin(); | ||
} | ||
|
||
public function rules() | ||
{ | ||
|
||
/** @var \App\Models\User $user */ | ||
$user = auth()->user(); | ||
|
||
return [ | ||
'entity' => 'required|bail|in:invoice,client,company', | ||
'payment_means' => 'sometimes|bail|array', | ||
'payment_means.code' => ['required_with:payment_means', 'bail', Rule::in(PaymentMeans::getPaymentMeansCodelist())], | ||
'payment_means.bic' => ['bail', | ||
Rule::requiredIf(function () { | ||
return in_array($this->input('payment_means.code'), ['58', '59', '49', '42', '30']); | ||
}), | ||
], | ||
'payment_means.iban' => ['bail', 'string', 'min:8', 'max:11', | ||
Rule::requiredIf(function () { | ||
return in_array($this->input('payment_means.code'), ['58', '59', '49', '42', '30']); | ||
}), | ||
], | ||
'payment_means.account_name' => ['bail', 'string', 'min:15', 'max:34', | ||
Rule::requiredIf(function () { | ||
return in_array($this->input('payment_means.code'), ['58', '59', '49', '42', '30']); | ||
}), | ||
], | ||
'payment_means.information' => ['bail', 'sometimes', 'string'], | ||
'payment_means.card_type' => ['bail', 'string', 'min:4', | ||
Rule::requiredIf(function () { | ||
return in_array($this->input('payment_means.code'), ['48']); | ||
}), | ||
], | ||
'payment_means.cardholder_name' => ['bail','string', 'min:4', | ||
Rule::requiredIf(function () { | ||
return in_array($this->input('payment_means.code'), ['48']); | ||
}), | ||
], | ||
]; | ||
} | ||
|
||
public function prepareForValidation() | ||
{ | ||
$input = $this->all(); | ||
|
||
$this->replace($input); | ||
} | ||
|
||
public function getLevel() | ||
{ | ||
/** @var \App\Models\User $user */ | ||
$user = auth()->user(); | ||
|
||
return match($this->entity){ | ||
'company' => $user->company(), | ||
'invoice' => Invoice::class, | ||
'client' => Client::class, | ||
default => $user->company(), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.