From bcbffdcf30f1a7d56c5b2f1c2cd4dd04aee71a2a Mon Sep 17 00:00:00 2001 From: harshjagad20 Date: Tue, 1 Jun 2021 14:18:08 +0530 Subject: [PATCH 1/4] Solved negative tax options issue --- resources/assets/js/components/base/modal/TaxTypeModal.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/js/components/base/modal/TaxTypeModal.vue b/resources/assets/js/components/base/modal/TaxTypeModal.vue index b0c83861..b786744e 100644 --- a/resources/assets/js/components/base/modal/TaxTypeModal.vue +++ b/resources/assets/js/components/base/modal/TaxTypeModal.vue @@ -157,7 +157,7 @@ export default { }, percent: { required, - between: between(0, 100), + between: between(-100, 100), }, description: { maxLength: maxLength(255), From ed966b02eb24b0a4fdbc93c2bd661aebf6940a99 Mon Sep 17 00:00:00 2001 From: harshjagad20 Date: Tue, 1 Jun 2021 16:32:06 +0530 Subject: [PATCH 2/4] Added test for negative taxtype test --- tests/Feature/TaxTypeTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/Feature/TaxTypeTest.php b/tests/Feature/TaxTypeTest.php index 010ff409..e587b0dd 100644 --- a/tests/Feature/TaxTypeTest.php +++ b/tests/Feature/TaxTypeTest.php @@ -92,3 +92,14 @@ test('delete tax type', function () { $this->assertDeleted($taxType); }); + + +test('create negative tax type', function () { + $taxType = TaxType::factory()->raw([ + 'percent' => -9.99 + ]); + + postJson('api/v1/tax-types', $taxType)->assertOk(); + + $this->assertDatabaseHas('tax_types', $taxType); +}); From b4956d38f7ec43e718244bc0612783cf0ec7e88c Mon Sep 17 00:00:00 2001 From: harshjagad20 Date: Tue, 1 Jun 2021 16:33:07 +0530 Subject: [PATCH 3/4] Minor fix taxtype test --- tests/Feature/TaxTypeTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Feature/TaxTypeTest.php b/tests/Feature/TaxTypeTest.php index e587b0dd..001a3a05 100644 --- a/tests/Feature/TaxTypeTest.php +++ b/tests/Feature/TaxTypeTest.php @@ -99,7 +99,8 @@ test('create negative tax type', function () { 'percent' => -9.99 ]); - postJson('api/v1/tax-types', $taxType)->assertOk(); + postJson('api/v1/tax-types', $taxType) + ->assertOk(); $this->assertDatabaseHas('tax_types', $taxType); }); From b2d4b7212b356939c2ff73a989e1a248b654891a Mon Sep 17 00:00:00 2001 From: harshjagad20 Date: Wed, 2 Jun 2021 16:25:20 +0530 Subject: [PATCH 4/4] Added invoice test with negative tax --- tests/Feature/InvoiceTest.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/Feature/InvoiceTest.php b/tests/Feature/InvoiceTest.php index 8e2bd17e..a552bb56 100644 --- a/tests/Feature/InvoiceTest.php +++ b/tests/Feature/InvoiceTest.php @@ -257,3 +257,31 @@ test('clone invoice', function () { 'success' => true, ]); }); + +test('create invoice with negative tax', function () { + $invoice = Invoice::factory() + ->raw([ + 'taxes' => [Tax::factory()->raw([ + 'percent' => -9.99 + ])], + 'items' => [InvoiceItem::factory()->raw()], + ]); + + $response = postJson('api/v1/invoices', $invoice); + + $response->assertOk(); + + $this->assertDatabaseHas('invoices', [ + 'invoice_number' => $invoice['invoice_number'], + 'sub_total' => $invoice['sub_total'], + 'total' => $invoice['total'], + 'tax' => $invoice['tax'], + 'discount' => $invoice['discount'], + 'user_id' => $invoice['user_id'], + 'invoice_template_id' => $invoice['invoice_template_id'], + ]); + + $this->assertDatabaseHas('invoice_items', $invoice['items'][0]); + + $this->assertDatabaseHas('taxes', $invoice['taxes'][0]); +});