1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Minor fixes for validation rules

This commit is contained in:
David Bomba 2022-11-22 07:10:17 +11:00
parent 4b4e023cb3
commit b3fefb3ac8
2 changed files with 48 additions and 1 deletions

View File

@ -40,7 +40,7 @@ class UpdateBankTransactionRuleRequest extends Request
];
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';

View File

@ -39,6 +39,53 @@ class BankTransactionRuleTest extends TestCase
);
}
public function testUpdateValidationRules()
{
$br = BankTransactionRule::factory()->create([
'company_id' => $this->company->id,
'user_id' => $this->user->id,
'matches_on_all' => false,
'auto_convert' => true,
'applies_to' => 'DEBIT',
'client_id' => $this->client->id,
'vendor_id' => $this->vendor->id,
'rules' => [
[
'search_key' => 'amount',
'operator' => '<=',
'value' => 100,
]
]
]);
$data = [
"applies_to" => "DEBIT",
"archived_at" => 0,
"auto_convert" => False,
"category_id" => $this->expense_category,
"is_deleted" => False,
"isChanged" => True,
"matches_on_all" => True,
"name" => "TEST 22",
"updated_at" => 1669060432,
"vendor_id" => $this->vendor->hashed_id
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->putJson('/api/v1/bank_transaction_rules/'. $br->hashed_id, $data);
$arr = $response->json();
$response->assertStatus(200);
}
public function testMatchingBankTransactionExpenseAmountLessThanEqualTo()
{