mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Update validation rules for subscriptions
This commit is contained in:
parent
60341c7c07
commit
4ea0d03b5c
@ -181,7 +181,7 @@ class MigrationController extends BaseController
|
||||
$company->tasks()->forceDelete();
|
||||
$company->vendors()->forceDelete();
|
||||
$company->expenses()->forceDelete();
|
||||
// $company->bank_transaction_rules()->forceDelete();
|
||||
$company->bank_transaction_rules()->forceDelete();
|
||||
$company->bank_transactions()->forceDelete();
|
||||
$company->bank_integrations()->forceDelete();
|
||||
|
||||
|
@ -35,26 +35,34 @@ class StoreSubscriptionRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
$rules = [
|
||||
'product_ids' => ['sometimes'],
|
||||
'recurring_product_ids' => ['sometimes'],
|
||||
'assigned_user_id' => ['sometimes'],
|
||||
'is_recurring' => ['sometimes'],
|
||||
'frequency_id' => ['required_with:recurring_product_ids'],
|
||||
'auto_bill' => ['sometimes'],
|
||||
'promo_code' => ['sometimes'],
|
||||
'promo_discount' => ['sometimes'],
|
||||
'is_amount_discount' => ['sometimes'],
|
||||
'allow_cancellation' => ['sometimes'],
|
||||
'per_set_enabled' => ['sometimes'],
|
||||
'min_seats_limit' => ['sometimes'],
|
||||
'max_seats_limit' => ['sometimes'],
|
||||
'trial_enabled' => ['sometimes'],
|
||||
'trial_duration' => ['sometimes'],
|
||||
'allow_query_overrides' => ['sometimes'],
|
||||
'allow_plan_changes' => ['sometimes'],
|
||||
'refund_period' => ['sometimes'],
|
||||
'webhook_configuration' => ['array'],
|
||||
'name' => ['required', Rule::unique('subscriptions')->where('company_id', auth()->user()->company()->id)],
|
||||
'group_id' => ['bail','sometimes', 'nullable', Rule::exists('group_settings','id')->where('company_id', auth()->user()->company()->id)],
|
||||
'assigned_user_id' => ['bail','sometimes', 'nullable', Rule::exists('users','id')->where('account_id', auth()->user()->account_id)],
|
||||
'product_ids' => 'bail|sometimes|nullable|string',
|
||||
'recurring_product_ids' => 'bail|sometimes|nullable|string',
|
||||
'is_recurring' => 'bail|sometimes|bool',
|
||||
'frequency_id' => 'bail|required_with:recurring_product_ids',
|
||||
'auto_bill' => 'bail|sometimes|nullable|string',
|
||||
'promo_code' => 'bail|sometimes|nullable|string',
|
||||
'promo_discount' => 'bail|sometimes|numeric',
|
||||
'is_amount_discount' => 'bail|sometimes|bool',
|
||||
'allow_cancellation' => 'bail|sometimes|bool',
|
||||
'per_set_enabled' => 'bail|sometimes|bool',
|
||||
'min_seats_limit' => 'bail|sometimes|numeric',
|
||||
'max_seats_limit' => 'bail|sometimes|numeric',
|
||||
'trial_enabled' => 'bail|sometimes|bool',
|
||||
'trial_duration' => 'bail|sometimes|numeric',
|
||||
'allow_query_overrides' => 'bail|sometimes|bool',
|
||||
'allow_plan_changes' => 'bail|sometimes|bool',
|
||||
'refund_period' => 'bail|sometimes|numeric',
|
||||
'webhook_configuration' => 'bail|array',
|
||||
'webhook_configuration.post_purchase_url' => 'bail|sometimes|nullable|string',
|
||||
'webhook_configuration.post_purchase_rest_method' => 'bail|sometimes|nullable|string',
|
||||
'webhook_configuration.post_purchase_headers' => 'bail|sometimes|array',
|
||||
'registration_required' => 'bail|sometimes|bool',
|
||||
'optional_recurring_product_ids' => 'bail|sometimes|nullable|string',
|
||||
'optional_product_ids' => 'bail|sometimes|nullable|string',
|
||||
'use_inventory_management' => 'bail|sometimes|bool'
|
||||
];
|
||||
|
||||
return $this->globalRules($rules);
|
||||
|
@ -37,26 +37,34 @@ class UpdateSubscriptionRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
$rules = [
|
||||
'product_ids' => ['sometimes'],
|
||||
'recurring_product_ids' => ['sometimes'],
|
||||
'assigned_user_id' => ['sometimes'],
|
||||
'is_recurring' => ['sometimes'],
|
||||
'frequency_id' => ['required_with:recurring_product_ids'],
|
||||
'auto_bill' => ['sometimes'],
|
||||
'promo_code' => ['sometimes'],
|
||||
'promo_discount' => ['sometimes'],
|
||||
'is_amount_discount' => ['sometimes'],
|
||||
'allow_cancellation' => ['sometimes'],
|
||||
'per_set_enabled' => ['sometimes'],
|
||||
'min_seats_limit' => ['sometimes'],
|
||||
'max_seats_limit' => ['sometimes'],
|
||||
'trial_enabled' => ['sometimes'],
|
||||
'trial_duration' => ['sometimes'],
|
||||
'allow_query_overrides' => ['sometimes'],
|
||||
'allow_plan_changes' => ['sometimes'],
|
||||
'refund_period' => ['sometimes'],
|
||||
'webhook_configuration' => ['array'],
|
||||
'name' => ['sometimes', Rule::unique('subscriptions')->where('company_id', auth()->user()->company()->id)->ignore($this->subscription->id)],
|
||||
'name' => ['bail','sometimes', Rule::unique('subscriptions')->where('company_id', auth()->user()->company()->id)->ignore($this->subscription->id)],
|
||||
'group_id' => ['bail','sometimes', 'nullable', Rule::exists('group_settings','id')->where('company_id', auth()->user()->company()->id)],
|
||||
'assigned_user_id' => ['bail','sometimes', 'nullable', Rule::exists('users','id')->where('account_id', auth()->user()->account_id)],
|
||||
'product_ids' => 'bail|sometimes|nullable|string',
|
||||
'recurring_product_ids' => 'bail|sometimes|nullable|string',
|
||||
'is_recurring' => 'bail|sometimes|bool',
|
||||
'frequency_id' => 'bail|required_with:recurring_product_ids',
|
||||
'auto_bill' => 'bail|sometimes|nullable|string',
|
||||
'promo_code' => 'bail|sometimes|nullable|string',
|
||||
'promo_discount' => 'bail|sometimes|numeric',
|
||||
'is_amount_discount' => 'bail|sometimes|bool',
|
||||
'allow_cancellation' => 'bail|sometimes|bool',
|
||||
'per_set_enabled' => 'bail|sometimes|bool',
|
||||
'min_seats_limit' => 'bail|sometimes|numeric',
|
||||
'max_seats_limit' => 'bail|sometimes|numeric',
|
||||
'trial_enabled' => 'bail|sometimes|bool',
|
||||
'trial_duration' => 'bail|sometimes|numeric',
|
||||
'allow_query_overrides' => 'bail|sometimes|bool',
|
||||
'allow_plan_changes' => 'bail|sometimes|bool',
|
||||
'refund_period' => 'bail|sometimes|numeric',
|
||||
'webhook_configuration' => 'bail|array',
|
||||
'webhook_configuration.post_purchase_url' => 'bail|sometimes|nullable|string',
|
||||
'webhook_configuration.post_purchase_rest_method' => 'bail|sometimes|nullable|string',
|
||||
'webhook_configuration.post_purchase_headers' => 'bail|sometimes|array',
|
||||
'registration_required' => 'bail|sometimes|bool',
|
||||
'optional_recurring_product_ids' => 'bail|sometimes|nullable|string',
|
||||
'optional_product_ids' => 'bail|sometimes|nullable|string',
|
||||
'use_inventory_management' => 'bail|sometimes|bool',
|
||||
];
|
||||
|
||||
return $this->globalRules($rules);
|
||||
|
@ -57,6 +57,7 @@ class Subscription extends BaseModel
|
||||
'registration_required',
|
||||
'optional_product_ids',
|
||||
'optional_recurring_product_ids',
|
||||
'use_inventory_management',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
|
@ -68,6 +68,10 @@ class SubscriptionTransformer extends EntityTransformer
|
||||
'updated_at' => (int) $subscription->updated_at,
|
||||
'archived_at' => (int) $subscription->deleted_at,
|
||||
'plan_map' => '', //@deprecated 03/04/2021
|
||||
'use_inventory_management' => (bool) $subscription->use_inventory_management,
|
||||
'optional_recurring_product_ids' =>(string)$subscription->optional_recurring_product_ids,
|
||||
'optional_product_ids' => (string) $subscription->optional_product_ids,
|
||||
'registration_required' => (bool) $subscription->registration_required,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ return new class extends Migration
|
||||
Schema::table('subscriptions', function (Blueprint $table)
|
||||
{
|
||||
$table->boolean('registration_required')->default(false);
|
||||
$table->boolean('use_inventory_management')->default(false);
|
||||
$table->text('optional_product_ids')->nullable();
|
||||
$table->text('optional_recurring_product_ids')->nullable();
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user