Add status_id filters

This commit is contained in:
David Bomba 2023-05-02 19:57:29 +10:00
parent c67e6c9259
commit 45bcbe85cb
2 changed files with 37 additions and 0 deletions

View File

@ -114,6 +114,23 @@ class InvoiceFilters extends QueryFilters
});
}
/**
* @return Builder
* @throws RuntimeException
*/
public function status_id(string $status = ''): Builder
{
if (strlen($status) == 0) {
return $this->builder;
}
return $this->builder->whereIn('status_id', explode(",", $status));
}
/**
* @return Builder
* @throws RuntimeException

View File

@ -33,6 +33,8 @@ class InvoiceTest extends TestCase
use DatabaseTransactions;
use MockAccountData;
public $faker;
protected function setUp() :void
{
parent::setUp();
@ -47,6 +49,24 @@ class InvoiceTest extends TestCase
}
public function testInvoiceGetPaidReversedInvoice()
{
$this->invoice->service()->handleReversal()->save();
$this->assertEquals(6, $this->invoice->fresh()->status_id);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->get('/api/v1/invoices?status_id=6', )
->assertStatus(200);
$arr = $response->json();
$this->assertCount(1, $arr['data']);
}
public function testInvoiceGetPaidInvoices()
{
$response = $this->withHeaders([