mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 03:29:03 -05:00 
			
		
		
		
	Minor fixes for validation rules
This commit is contained in:
		
							parent
							
								
									4b4e023cb3
								
							
						
					
					
						commit
						b3fefb3ac8
					
				@ -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';
 | 
			
		||||
 | 
			
		||||
@ -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()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user