mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Minor fixes for rules
This commit is contained in:
parent
08630874b8
commit
d34337edb5
@ -35,13 +35,16 @@ class StoreBankTransactionRuleRequest extends Request
|
||||
$rules = [
|
||||
'name' => 'bail|required|string',
|
||||
'rules' => 'bail|array',
|
||||
'rules.*.operator' => 'bail|required|nullable',
|
||||
'rules.*.search_key' => 'bail|required|nullable',
|
||||
'rules.*.value' => 'bail|required|nullable',
|
||||
'auto_convert' => 'bail|sometimes|bool',
|
||||
'matches_on_all' => 'bail|sometimes|bool',
|
||||
'applies_to' => 'bail|sometimes|string',
|
||||
];
|
||||
|
||||
if(isset($this->category_id))
|
||||
$rules['category_id'] = 'bail|sometimes|exists:expense_categories,id,'.auth()->user()->company()->id.',is_deleted,0';
|
||||
$rules['category_id'] = 'bail|sometimes|exists:expense_categories,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
|
||||
|
||||
if(isset($this->vendor_id))
|
||||
$rules['vendor_id'] = 'bail|sometimes|exists:vendors,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
|
||||
|
@ -34,6 +34,9 @@ class UpdateBankTransactionRuleRequest extends Request
|
||||
$rules = [
|
||||
'name' => 'bail|required|string',
|
||||
'rules' => 'bail|array',
|
||||
'rules.*.operator' => 'bail|required|nullable',
|
||||
'rules.*.search_key' => 'bail|required|nullable',
|
||||
'rules.*.value' => 'bail|required|nullable',
|
||||
'auto_convert' => 'bail|sometimes|bool',
|
||||
'matches_on_all' => 'bail|sometimes|bool',
|
||||
'applies_to' => 'bail|sometimes|string',
|
||||
|
@ -60,6 +60,49 @@ if(isset($this->vendor_id))
|
||||
if(isset($this->client_id))
|
||||
$rules['client_id'] = 'bail|sometimes|exists:clients,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
|
||||
*/
|
||||
public function testBankRuleCategoryIdValidation()
|
||||
{
|
||||
$data = [
|
||||
'name' => 'The First Rule',
|
||||
'rules' => [
|
||||
[
|
||||
"operator" => "contains",
|
||||
"search_key" => "description",
|
||||
"value" => "mobile"
|
||||
],
|
||||
],
|
||||
'assigned_user_id' => null,
|
||||
'auto_convert' => false,
|
||||
'matches_on_all' => true,
|
||||
'applies_to' => 'DEBIT',
|
||||
'category_id' => $this->expense_category->hashed_id,
|
||||
'vendor_id' => $this->vendor->hashed_id
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->postJson('/api/v1/bank_transaction_rules/', $data);
|
||||
|
||||
$arr = $response->json();
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
$this->assertEquals('DEBIT', $arr['data']['applies_to']);
|
||||
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->putJson('/api/v1/bank_transaction_rules/'. $arr['data']['id'], $data);
|
||||
|
||||
$arr = $response->json();
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
$this->assertEquals('DEBIT', $arr['data']['applies_to']);
|
||||
}
|
||||
|
||||
public function testBankRulePost()
|
||||
{
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user