|
- {{$tax->name.' ('.$tax->percent.'%)'}}
+ @if($tax->calculation_type === 'fixed')
+ {{$tax->name }} ({!! format_money_pdf($tax->fixed_amount, $estimate->customer->currency) !!})
+ @else
+ {{$tax->name.' ('.$tax->percent.'%)'}}
+ @endif
|
{!! format_money_pdf($tax->amount, $estimate->customer->currency) !!}
@@ -117,7 +121,11 @@
@foreach ($estimate->taxes as $tax)
|
|
- {{$tax->name.' ('.$tax->percent.'%)'}}
+ @if($tax->calculation_type === 'fixed')
+ {{$tax->name }} ({!! format_money_pdf($tax->fixed_amount, $estimate->customer->currency) !!})
+ @else
+ {{$tax->name.' ('.$tax->percent.'%)'}}
+ @endif
|
{!! format_money_pdf($tax->amount, $estimate->customer->currency) !!}
diff --git a/resources/views/app/pdf/invoice/partials/table.blade.php b/resources/views/app/pdf/invoice/partials/table.blade.php
index 84055b16..5db0a0eb 100644
--- a/resources/views/app/pdf/invoice/partials/table.blade.php
+++ b/resources/views/app/pdf/invoice/partials/table.blade.php
@@ -125,7 +125,11 @@
@foreach ($taxes as $tax)
|
|
- {{$tax->name.' ('.$tax->percent.'%)'}}
+ @if($tax->calculation_type === 'fixed')
+ {{$tax->name }} ({!! format_money_pdf($tax->fixed_amount, $invoice->customer->currency) !!})
+ @else
+ {{$tax->name.' ('.$tax->percent.'%)'}}
+ @endif
|
{!! format_money_pdf($tax->amount, $invoice->customer->currency) !!}
@@ -136,7 +140,11 @@
@foreach ($invoice->taxes as $tax)
|
|
- {{$tax->name.' ('.$tax->percent.'%)'}}
+ @if($tax->calculation_type === 'fixed')
+ {{$tax->name }} ({!! format_money_pdf($tax->fixed_amount, $invoice->customer->currency) !!})
+ @else
+ {{$tax->name.' ('.$tax->percent.'%)'}}
+ @endif
|
{!! format_money_pdf($tax->amount, $invoice->customer->currency) !!}
diff --git a/tests/Feature/Admin/ItemTest.php b/tests/Feature/Admin/ItemTest.php
index bfb6657a..b6ab0cab 100644
--- a/tests/Feature/Admin/ItemTest.php
+++ b/tests/Feature/Admin/ItemTest.php
@@ -141,3 +141,31 @@ test('search items', function () {
$response->assertOk();
});
+
+test('create item with fixed amount tax', function () {
+ $item = Item::factory()->raw([
+ 'taxes' => [
+ Tax::factory()->raw([
+ 'calculation_type' => 'fixed',
+ 'fixed_amount' => 5000,
+ ]),
+ ],
+ ]);
+
+ $response = postJson('api/v1/items', $item);
+
+ $response->assertOk();
+
+ $this->assertDatabaseHas('items', [
+ 'name' => $item['name'],
+ 'description' => $item['description'],
+ 'price' => $item['price'],
+ 'company_id' => $item['company_id'],
+ ]);
+
+ $this->assertDatabaseHas('taxes', [
+ 'item_id' => $response->getData()->data->id,
+ 'calculation_type' => 'fixed',
+ 'fixed_amount' => 5000,
+ ]);
+});
diff --git a/tests/Feature/Admin/TaxTypeTest.php b/tests/Feature/Admin/TaxTypeTest.php
index 4b8ed153..1c0c6413 100644
--- a/tests/Feature/Admin/TaxTypeTest.php
+++ b/tests/Feature/Admin/TaxTypeTest.php
@@ -97,3 +97,16 @@ test('create negative tax type', function () {
$this->assertDatabaseHas('tax_types', $taxType);
});
+
+test('create fixed amount tax type', function () {
+ $taxType = TaxType::factory()->raw([
+ 'calculation_type' => 'fixed',
+ 'percent' => null,
+ 'fixed_amount' => 5000,
+ ]);
+
+ postJson('api/v1/tax-types', $taxType)
+ ->assertStatus(201);
+
+ $this->assertDatabaseHas('tax_types', $taxType);
+});
|