mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 19:44:30 -04:00
Minor fixes
This commit is contained in:
parent
aabcb41090
commit
69007836ac
@ -55,14 +55,12 @@ class Handler extends ExceptionHandler
|
|||||||
|
|
||||||
protected $selfHostDontReport = [
|
protected $selfHostDontReport = [
|
||||||
FilePermissionsFailure::class,
|
FilePermissionsFailure::class,
|
||||||
PDOException::class,
|
|
||||||
MaxAttemptsExceededException::class,
|
MaxAttemptsExceededException::class,
|
||||||
CommandNotFoundException::class,
|
CommandNotFoundException::class,
|
||||||
ValidationException::class,
|
ValidationException::class,
|
||||||
ModelNotFoundException::class,
|
ModelNotFoundException::class,
|
||||||
NotFoundHttpException::class,
|
NotFoundHttpException::class,
|
||||||
UnableToCreateDirectory::class,
|
UnableToCreateDirectory::class,
|
||||||
ConnectException::class,
|
|
||||||
RuntimeException::class,
|
RuntimeException::class,
|
||||||
InvalidArgumentException::class,
|
InvalidArgumentException::class,
|
||||||
CredentialsException::class,
|
CredentialsException::class,
|
||||||
|
@ -77,6 +77,7 @@ class StoreInvoiceRequest extends Request
|
|||||||
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
$rules['partial'] = 'bail|sometimes|nullable|numeric|gte:0';
|
$rules['partial'] = 'bail|sometimes|nullable|numeric|gte:0';
|
||||||
$rules['partial_due_date'] = ['bail', 'sometimes', 'exclude_if:partial,0', Rule::requiredIf(fn () => $this->partial > 0), 'date'];
|
$rules['partial_due_date'] = ['bail', 'sometimes', 'exclude_if:partial,0', Rule::requiredIf(fn () => $this->partial > 0), 'date'];
|
||||||
|
$rules['due_date'] = ['bail', 'sometimes', 'nullable', 'after:partial_due_date', Rule::requiredIf(fn () => strlen($this->partial_due_date) > 1), 'date'];
|
||||||
|
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
@ -112,6 +113,15 @@ class StoreInvoiceRequest extends Request
|
|||||||
$input['exchange_rate'] = 1;
|
$input['exchange_rate'] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nlog($input['partial_due_date']);
|
||||||
|
nlog(strlen($input['partial_due_date']));
|
||||||
|
|
||||||
|
//handles edge case where we need for force set the due date of the invoice.
|
||||||
|
if((isset($input['partial_due_date']) && strlen($input['partial_due_date']) > 1) && (!array_key_exists('due_date', $input) || strlen($input['due_date']) == 0)) {
|
||||||
|
$client = \App\Models\Client::withTrashed()->find($input['client_id']);
|
||||||
|
$input['due_date'] = \Illuminate\Support\Carbon::parse($input['date'])->addDays($client->getSetting('payment_terms'))->format('Y-m-d');
|
||||||
|
}
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,7 @@ class UpdateInvoiceRequest extends Request
|
|||||||
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
$rules['partial'] = 'bail|sometimes|nullable|numeric';
|
$rules['partial'] = 'bail|sometimes|nullable|numeric';
|
||||||
$rules['partial_due_date'] = ['bail', 'sometimes', 'exclude_if:partial,0', Rule::requiredIf(fn () => $this->partial > 0), 'date', 'before:due_date'];
|
$rules['partial_due_date'] = ['bail', 'sometimes', 'exclude_if:partial,0', Rule::requiredIf(fn () => $this->partial > 0), 'date', 'before:due_date'];
|
||||||
|
$rules['due_date'] = ['bail', 'sometimes', 'nullable', 'after:partial_due_date', Rule::requiredIf(fn () => strlen($this->partial_due_date) > 1), 'date'];
|
||||||
|
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
@ -107,6 +108,12 @@ class UpdateInvoiceRequest extends Request
|
|||||||
$input['exchange_rate'] = 1;
|
$input['exchange_rate'] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//handles edge case where we need for force set the due date of the invoice.
|
||||||
|
if((isset($input['partial_due_date']) && strlen($input['partial_due_date']) > 1) && (!array_key_exists('due_date', $input) || strlen($input['due_date']) == 0 || empty($this->invoice->due_date))) {
|
||||||
|
$client = \App\Models\Client::withTrashed()->find($input['client_id']);
|
||||||
|
$input['due_date'] = \Illuminate\Support\Carbon::parse($input['date'])->addDays($client->getSetting('payment_terms'))->format('Y-m-d');
|
||||||
|
}
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,10 @@ class StoreWebhookRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
return auth()->user()->isAdmin() && auth()->user()->account->hasFeature(Account::FEATURE_API);
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
return $user->isAdmin() && $user->account->hasFeature(Account::FEATURE_API);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
@ -31,7 +34,6 @@ class StoreWebhookRequest extends Request
|
|||||||
return [
|
return [
|
||||||
'target_url' => 'bail|required|url',
|
'target_url' => 'bail|required|url',
|
||||||
'event_id' => 'bail|required',
|
'event_id' => 'bail|required',
|
||||||
// 'headers' => 'bail|sometimes|json',
|
|
||||||
'rest_method' => 'required|in:post,put'
|
'rest_method' => 'required|in:post,put'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -43,9 +45,7 @@ class StoreWebhookRequest extends Request
|
|||||||
if (!isset($input['rest_method'])) {
|
if (!isset($input['rest_method'])) {
|
||||||
$input['rest_method'] = 'post';
|
$input['rest_method'] = 'post';
|
||||||
}
|
}
|
||||||
// if(isset($input['headers']) && count($input['headers']) == 0)
|
|
||||||
// $input['headers'] = null;
|
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,6 +180,7 @@ class Webhook extends BaseModel
|
|||||||
self::EVENT_DELETE_PURCHASE_ORDER,
|
self::EVENT_DELETE_PURCHASE_ORDER,
|
||||||
self::EVENT_RESTORE_PURCHASE_ORDER,
|
self::EVENT_RESTORE_PURCHASE_ORDER,
|
||||||
self::EVENT_ARCHIVE_PURCHASE_ORDER,
|
self::EVENT_ARCHIVE_PURCHASE_ORDER,
|
||||||
|
self::EVENT_CREATE_PRODUCT,
|
||||||
self::EVENT_UPDATE_PRODUCT,
|
self::EVENT_UPDATE_PRODUCT,
|
||||||
self::EVENT_DELETE_PRODUCT,
|
self::EVENT_DELETE_PRODUCT,
|
||||||
self::EVENT_RESTORE_PRODUCT,
|
self::EVENT_RESTORE_PRODUCT,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user