feat: Tax included (#370)

* feat: Tax included

* Added a toggle switch in tax settings to enable the feature.
* Database migration adding tax_included field into estimates, invoices
  and recurring invoices table.
* Toggle switch to enable and store the tax_included by estimates,
  invoices and recurring invoices.
* In case of tax included enabled, total taxes will be recalculated and
  the invoices, estimates and recurring invoices total won't be sum with
  taxes.
* Apply tax included when discount_per_item/tax_per_item item is enabled.
* Custom component to show the net total when tax included is enabled.
* Update invoice and estimates pdfs with net total.

* chore: Tax included by default

A switch button inside the tax settings to enable the tax included by
default in invoices, estimates and recurring invoices.
This commit is contained in:
Fabio Ribeiro
2025-08-28 10:28:24 +02:00
committed by GitHub
parent 08e1bb2e22
commit d69a56e2d5
32 changed files with 582 additions and 83 deletions

View File

@@ -93,6 +93,7 @@ class EstimateFactory extends Factory
return $estimate['discount_type'] == 'percentage' ? (($estimate['discount_val'] * $estimate['total']) / 100) : $estimate['discount_val'];
},
'tax_per_item' => 'YES',
'tax_included' => false,
'discount_per_item' => 'No',
'tax' => $this->faker->randomDigitNotNull(),
'notes' => $this->faker->text(80),

View File

@@ -93,6 +93,7 @@ class InvoiceFactory extends Factory
'template_name' => 'invoice1',
'status' => Invoice::STATUS_DRAFT,
'tax_per_item' => 'NO',
'tax_included' => false,
'discount_per_item' => 'NO',
'paid_status' => Invoice::STATUS_UNPAID,
'company_id' => User::find(1)->companies()->first()->id,

View File

@@ -26,6 +26,7 @@ class RecurringInvoiceFactory extends Factory
'send_automatically' => false,
'status' => $this->faker->randomElement(['COMPLETED', 'ON_HOLD', 'ACTIVE']),
'tax_per_item' => 'NO',
'tax_included' => false,
'discount_per_item' => 'NO',
'sub_total' => $this->faker->randomDigitNotNull(),
'total' => $this->faker->randomDigitNotNull(),

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('invoices', function (Blueprint $table) {
$table->boolean('tax_included')->default(false);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('invoices', function (Blueprint $table) {
$table->dropColumn('tax_included');
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('estimates', function (Blueprint $table) {
$table->boolean('tax_included')->default(false);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('estimates', function (Blueprint $table) {
$table->dropColumn('tax_included');
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('recurring_invoices', function (Blueprint $table) {
$table->boolean('tax_included')->default(false);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('recurring_invoices', function (Blueprint $table) {
$table->dropColumn('tax_included');
});
}
};