1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 22:54:25 +01:00

only show active transactions

This commit is contained in:
David Bomba 2024-09-10 15:40:17 +10:00
parent 305e3daeb4
commit e08fcbaf07
2 changed files with 29 additions and 3 deletions

View File

@ -68,7 +68,7 @@ class BankTransactionFilters extends QueryFilters
*/
public function client_status(string $value = ''): Builder
{
if (strlen($value) == 0) {
if (strlen($value ?? '') == 0) {
return $this->builder;
}
@ -115,6 +115,17 @@ class BankTransactionFilters extends QueryFilters
return $this->builder;
}
public function active_banks(string $value = ''): Builder
{
if (strlen($value) == 0 || $value != 'true') {
return $this->builder;
}
return $this->builder->whereHas('bank_integration', function ($query){
$query->where('is_deleted', 0)->whereNull('deleted_at');
});
}
/**
* Filters the list based on Bank Accounts.

View File

@ -42,7 +42,11 @@ class BankTransactionTest extends TestCase
public function testBankIntegrationFilters()
{
BankTransaction::where('company_id', $this->company->id)
->cursor()->each(function($bt){
$bt->forceDelete();
});
$bi = BankIntegrationFactory::create($this->company->id, $this->user->id, $this->account->id);
$bi->bank_account_name = "Bank1";
$bi->save();
@ -102,7 +106,6 @@ class BankTransactionTest extends TestCase
$this->assertCount(1, $arr['data']);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
@ -129,6 +132,18 @@ class BankTransactionTest extends TestCase
$this->assertCount(2, $arr['data']);
$bi2->delete();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->getJson('/api/v1/bank_transactions?active_banks=true');
$response->assertStatus(200);
$arr = $response->json();
$this->assertCount(1, $arr['data']);
}