diff --git a/app/DataMapper/Tax/BaseRule.php b/app/DataMapper/Tax/BaseRule.php index 1e8de4773eda..547c7dfcb540 100644 --- a/app/DataMapper/Tax/BaseRule.php +++ b/app/DataMapper/Tax/BaseRule.php @@ -48,6 +48,9 @@ class BaseRule implements RuleInterface 'DK', // Denmark 'EE', // Estonia 'ES', // Spain + 'ES-CN', // Canary Islands + 'ES-CE', // Ceuta + 'ES-ML', // Melilla 'FI', // Finland 'FR', // France 'GR', // Greece @@ -78,6 +81,9 @@ class BaseRule implements RuleInterface 'DK' => 'EU', // Denmark 'EE' => 'EU', // Estonia 'ES' => 'EU', // Spain + 'ES-CN' => 'EU', // Canary Islands + 'ES-CE' => 'EU', // Ceuta + 'ES-ML' => 'EU', // Melilla 'FI' => 'EU', // Finland 'FR' => 'EU', // France 'GR' => 'EU', // Greece diff --git a/app/DataMapper/Tax/TaxModel.php b/app/DataMapper/Tax/TaxModel.php index ca84290f58a5..b50c33633d9a 100644 --- a/app/DataMapper/Tax/TaxModel.php +++ b/app/DataMapper/Tax/TaxModel.php @@ -17,7 +17,7 @@ class TaxModel public string $seller_subregion = 'CA'; /** @var string $version */ - public string $version = 'beta'; + public string $version = 'gamma'; /** @var object $regions */ public object $regions; @@ -58,6 +58,32 @@ class TaxModel $this->version = 'beta'; } + if($this->version == 'beta') { + + //CEUTA + $this->regions->EU->subregions->{'ES-CE'} = new \stdClass(); + $this->regions->EU->subregions->{'ES-CE'}->tax_rate = 4; + $this->regions->EU->subregions->{'ES-CE'}->tax_name = 'IGIC'; + $this->regions->EU->subregions->{'ES-CE'}->reduced_tax_rate = 4; + $this->regions->EU->subregions->{'ES-CE'}->apply_tax = false; + + //MELILLA ML 4 + $this->regions->EU->subregions->{'ES-ML'} = new \stdClass(); + $this->regions->EU->subregions->{'ES-ML'}->tax_rate = 4; + $this->regions->EU->subregions->{'ES-ML'}->tax_name = 'IGIC'; + $this->regions->EU->subregions->{'ES-ML'}->reduced_tax_rate = 4; + $this->regions->EU->subregions->{'ES-ML'}->apply_tax = false; + + //CANARIAS CN 7/3 + $this->regions->EU->subregions->{'ES-CN'} = new \stdClass(); + $this->regions->EU->subregions->{'ES-CN'}->tax_rate = 7; + $this->regions->EU->subregions->{'ES-CN'}->tax_name = 'IGIC'; + $this->regions->EU->subregions->{'ES-CN'}->reduced_tax_rate = 3; + $this->regions->EU->subregions->{'ES-CN'}->apply_tax = false; + + $this->version = 'gamma'; + } + return $this; } @@ -419,6 +445,25 @@ class TaxModel $this->regions->EU->subregions->ES->reduced_tax_rate = 10; $this->regions->EU->subregions->ES->apply_tax = false; + $this->regions->EU->subregions->{'ES-CE'} = new \stdClass(); + $this->regions->EU->subregions->{'ES-CE'}->tax_rate = 4; + $this->regions->EU->subregions->{'ES-CE'}->tax_name = 'IGIC'; + $this->regions->EU->subregions->{'ES-CE'}->reduced_tax_rate = 4; + $this->regions->EU->subregions->{'ES-CE'}->apply_tax = false; + + $this->regions->EU->subregions->{'ES-ML'} = new \stdClass(); + $this->regions->EU->subregions->{'ES-ML'}->tax_rate = 4; + $this->regions->EU->subregions->{'ES-ML'}->tax_name = 'IGIC'; + $this->regions->EU->subregions->{'ES-ML'}->reduced_tax_rate = 4; + $this->regions->EU->subregions->{'ES-ML'}->apply_tax = false; + + $this->regions->EU->subregions->{'ES-CN'} = new \stdClass(); + $this->regions->EU->subregions->{'ES-CN'}->tax_rate = 7; + $this->regions->EU->subregions->{'ES-CN'}->tax_name = 'IGIC'; + $this->regions->EU->subregions->{'ES-CN'}->reduced_tax_rate = 3; + $this->regions->EU->subregions->{'ES-CN'}->apply_tax = false; + + $this->regions->EU->subregions->FI = new \stdClass(); $this->regions->EU->subregions->FI->tax_rate = 24; $this->regions->EU->subregions->FI->tax_name = 'ALV'; diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index d1d7dd56cff0..15a9782e52d5 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -42,6 +42,9 @@ class InvoiceItemSum 'DK', // Denmark 'EE', // Estonia 'ES', // Spain + 'ES-CE', + 'ES-CN', + 'ES-ML', 'FI', // Finland 'FR', // France 'GR', // Greece @@ -72,6 +75,9 @@ class InvoiceItemSum 'DK', // Denmark 'EE', // Estonia 'ES', // Spain + 'ES-CE', + 'ES-CN', + 'ES-ML', 'FI', // Finland 'FR', // France 'GR', // Greece @@ -182,7 +188,7 @@ class InvoiceItemSum /** @var \App\DataMapper\Tax\BaseRule $class */ - $class = "App\DataMapper\Tax\\".$this->client->company->country()->iso_3166_2."\\Rule"; + $class = "App\DataMapper\Tax\\".str_replace("-","_",$this->client->company->country()->iso_3166_2)."\\Rule"; $this->rule = new $class(); diff --git a/database/migrations/2024_09_15_022436_add_autonomous_es_regions.php b/database/migrations/2024_09_15_022436_add_autonomous_es_regions.php index 3bd5b5b6eff6..9f7524f6a686 100644 --- a/database/migrations/2024_09_15_022436_add_autonomous_es_regions.php +++ b/database/migrations/2024_09_15_022436_add_autonomous_es_regions.php @@ -9,6 +9,7 @@ * @license https://www.elastic.co/licensing/elastic-license */ +use App\Models\Company; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -22,7 +23,11 @@ return new class extends Migration */ public function up(): void { - + + Schema::table('countries', function (Blueprint $table) { + $table->string('iso_3166_2',5)->change(); + }); + $regions = [ [ 'id' => 1000, // INE code for Canary Islands @@ -95,6 +100,10 @@ return new class extends Migration Model::reguard(); + Company::query()->cursor()->each(function ($company) { + $company->tax_data = new \App\DataMapper\Tax\TaxModel($company->tax_data); + $company->save(); + }); }