diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index 2cc72fb4e846..9460026c63ef 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -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 diff --git a/tests/Feature/InvoiceTest.php b/tests/Feature/InvoiceTest.php index 60f5db3ae254..8730566b12b0 100644 --- a/tests/Feature/InvoiceTest.php +++ b/tests/Feature/InvoiceTest.php @@ -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([