Set default tax id to 1 for all products

This commit is contained in:
David Bomba 2023-04-04 07:36:58 +10:00
parent fbd47c1e40
commit e14656129f
4 changed files with 17 additions and 4 deletions

View File

@ -55,7 +55,7 @@ class TaxModel
{ {
$this->regions->EU->has_sales_above_threshold = false; $this->regions->EU->has_sales_above_threshold = false;
$this->regions->EU->tax_all = false; $this->regions->EU->tax_all_subregions = false;
$this->regions->EU->vat_threshold = 10000; $this->regions->EU->vat_threshold = 10000;
$this->euSubRegions(); $this->euSubRegions();

View File

@ -1,7 +1,7 @@
region: region:
US: US:
tax_all: false tax_all_subregions: false
seller_region: CA seller_subregion: CA
has_sales_above_threshold: false has_sales_above_threshold: false
subregions: subregions:
AL: AL:

View File

@ -35,7 +35,8 @@ class ProductFactory
$product->custom_value3 = ''; $product->custom_value3 = '';
$product->custom_value4 = ''; $product->custom_value4 = '';
$product->is_deleted = 0; $product->is_deleted = 0;
$product->tax_id = 1;
return $product; return $product;
} }
} }

View File

@ -2,6 +2,7 @@
use App\Models\Client; use App\Models\Client;
use App\Models\Company; use App\Models\Company;
use App\Models\Product;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
@ -26,6 +27,10 @@ return new class extends Migration
$table->dropColumn('tax_all_products'); $table->dropColumn('tax_all_products');
}); });
Schema::table('products', function (Blueprint $table) {
$table->unsignedInteger('tax_id')->nullable(); // the product tax constant
});
Company::query() Company::query()
->cursor() ->cursor()
->each(function ($company) { ->each(function ($company) {
@ -40,6 +45,13 @@ return new class extends Migration
$client->save(); $client->save();
}); });
Product::query()
->cursor()
->each(function ($product) {
$product->tax_id = 1;
$product->save();
});
} }
/** /**