paulwer 2023-12-28 10:18:24 +01:00
parent 77a615adb6
commit ad009b5837
2 changed files with 5 additions and 12 deletions

View File

@ -56,7 +56,7 @@ class StoreCompanyRequest extends Request
}
}
$rules['expense_mailbox'] = new ValidExpenseMailbox($this->company->key, $this->company->account->isPaid() && $this->company->account->plan == 'enterprise'); // @turbo124 check if this is right
$rules['expense_mailbox'] = new ValidExpenseMailbox($this->company->key);
return $rules;
}
@ -77,6 +77,10 @@ class StoreCompanyRequest extends Request
$input['portal_domain'] = rtrim(strtolower($input['portal_domain']), "/");
}
if (isset($input['expense_mailbox']) && Ninja::isHosted() && !($this->company->account->isPaid() && $this->company->account->plan == 'enterprise')) {
unset($input['expense_mailbox']);
}
$this->replace($input);
}
}

View File

@ -21,7 +21,6 @@ use Illuminate\Contracts\Validation\Rule;
class ValidExpenseMailbox implements Rule
{
private $is_enterprise_error = false;
private $validated_schema = false;
private $company_key = false;
private $isEnterprise = false;
@ -32,7 +31,6 @@ class ValidExpenseMailbox implements Rule
public function __construct(string $company_key, bool $isEnterprise = false)
{
$this->company_key = $company_key;
$this->isEnterprise = $isEnterprise;
$this->endings = explode(",", config('ninja.ingest_mail.expense_mailbox_endings'));
}
@ -42,12 +40,6 @@ class ValidExpenseMailbox implements Rule
return true;
}
// denie on hosted and not enterprise
if (Ninja::isHosted() && !$this->isEnterprise) {
$this->is_enterprise_error = true;
return false;
}
// early return, if we dont have any additional validation
if (!config('ninja.ingest_mail.expense_mailbox_endings')) {
$this->validated_schema = true;
@ -75,9 +67,6 @@ class ValidExpenseMailbox implements Rule
*/
public function message()
{
if ($this->is_enterprise_error)
return ctrans('texts.expense_mailbox_not_available');
if (!$this->validated_schema)
return ctrans('texts.expense_mailbox_invalid');