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:
parent
305e3daeb4
commit
e08fcbaf07
@ -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.
|
||||
|
@ -42,6 +42,10 @@ 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";
|
||||
@ -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']);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user