Adding Flat Tax support with fixed amount (#253)

* Possibility to set a fixed amount on tax types settings

* Pint and manage flat taxes on items

* Fix display errors and handle global taxes

* Tests

* Pint with PHP 8.2 cause with PHP 8.3 version it cause workflow error

* Merging percent and fixed amount into one column

* Now display the currency on SelectTaxPopup on fixed taxes
This commit is contained in:
mchev
2025-05-04 02:24:56 +02:00
committed by GitHub
parent 546f75d3a6
commit bf5b544ca3
22 changed files with 306 additions and 39 deletions

View File

@@ -22,8 +22,10 @@ class TaxTypeFactory extends Factory
{
return [
'name' => $this->faker->word(),
'calculation_type' => 'percentage',
'company_id' => User::find(1)->companies()->first()->id,
'percent' => $this->faker->numberBetween($min = 0, $max = 100),
'fixed_amount' => null,
'description' => $this->faker->text(),
'compound_tax' => 0,
'collective_tax' => 0,

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::table('tax_types', function (Blueprint $table) {
$table->enum('calculation_type', ['percentage', 'fixed'])->default('percentage')->after('name');
$table->integer('fixed_amount')->nullable()->after('percent');
$table->decimal('percent', 5, 2)->nullable()->change();
});
Schema::table('taxes', function (Blueprint $table) {
$table->enum('calculation_type', ['percentage', 'fixed'])->default('percentage')->after('name');
$table->integer('fixed_amount')->nullable()->after('percent');
$table->decimal('percent', 5, 2)->nullable()->change();
});
}
public function down()
{
Schema::table('tax_types', function (Blueprint $table) {
$table->dropColumn(['calculation_type', 'fixed_amount']);
$table->decimal('percent', 5, 2)->change();
});
Schema::table('taxes', function (Blueprint $table) {
$table->dropColumn(['calculation_type', 'fixed_amount']);
$table->decimal('percent', 5, 2)->change();
});
}
};