|
|
@@ -3,32 +3,64 @@
|
|
|
namespace Database\Seeders;
|
|
|
|
|
|
use App\Models\InhabitantClassification;
|
|
|
+use App\Models\MunicipalitySize;
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
|
|
class InhabitantClassificationSeeder extends Seeder
|
|
|
{
|
|
|
public function run(): void
|
|
|
{
|
|
|
- $classifications = [
|
|
|
- ['description' => '50k', 'start' => 1, 'end' => 3, 'tbr_percentage' => 0.0000],
|
|
|
- ['description' => '50k', 'start' => 4, 'end' => 12, 'tbr_percentage' => 0.4000],
|
|
|
- ['description' => '50k', 'start' => 13, 'end' => 60, 'tbr_percentage' => 0.6000],
|
|
|
- ['description' => '50k - 100k', 'start' => 1, 'end' => 3, 'tbr_percentage' => 0.0000],
|
|
|
- ['description' => '50k - 100k', 'start' => 4, 'end' => 12, 'tbr_percentage' => 0.5000],
|
|
|
- ['description' => '50k - 100k', 'start' => 13, 'end' => 60, 'tbr_percentage' => 0.7500],
|
|
|
- ['description' => '100k - 200k', 'start' => 1, 'end' => 3, 'tbr_percentage' => 0.0000],
|
|
|
- ['description' => '100k - 200k', 'start' => 4, 'end' => 12, 'tbr_percentage' => 0.7500],
|
|
|
- ['description' => '100k - 200k', 'start' => 13, 'end' => 60, 'tbr_percentage' => 0.1000],
|
|
|
- ['description' => '> 200k', 'start' => 1, 'end' => 3, 'tbr_percentage' => 0.0000],
|
|
|
- ['description' => '> 200k', 'start' => 4, 'end' => 12, 'tbr_percentage' => 1.0000],
|
|
|
- ['description' => '> 200k', 'start' => 13, 'end' => 60, 'tbr_percentage' => 1.5000],
|
|
|
+ $sizes = MunicipalitySize::pluck('id', 'acronym');
|
|
|
+
|
|
|
+ if ($sizes->isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ $rules = [
|
|
|
+ 'PP' => [
|
|
|
+ ['description' => 'Até 50k — isenção inicial (meses 1 a 3)', 'start' => 1, 'end' => 3, 'tbr_percentage' => 0.0000, 'is_renewal' => false],
|
|
|
+ ['description' => 'Até 50k — meses 4 a 12', 'start' => 4, 'end' => 12, 'tbr_percentage' => 0.4000, 'is_renewal' => false],
|
|
|
+ ['description' => 'Até 50k — meses 13 a 60', 'start' => 13, 'end' => 60, 'tbr_percentage' => 0.6000, 'is_renewal' => false],
|
|
|
+ ['description' => 'Renovação até 50k', 'start' => 1, 'end' => 60, 'tbr_percentage' => 0.6000, 'is_renewal' => true],
|
|
|
+ ],
|
|
|
+ 'MP' => [
|
|
|
+ ['description' => 'De 50k a 100k — isenção inicial (meses 1 a 3)', 'start' => 1, 'end' => 3, 'tbr_percentage' => 0.0000, 'is_renewal' => false],
|
|
|
+ ['description' => 'De 50k a 100k — meses 4 a 12', 'start' => 4, 'end' => 12, 'tbr_percentage' => 0.5000, 'is_renewal' => false],
|
|
|
+ ['description' => 'De 50k a 100k — meses 13 a 60', 'start' => 13, 'end' => 60, 'tbr_percentage' => 0.7500, 'is_renewal' => false],
|
|
|
+ ['description' => 'Renovação 50k–100k', 'start' => 1, 'end' => 60, 'tbr_percentage' => 0.7500, 'is_renewal' => true],
|
|
|
+ ],
|
|
|
+ 'GP' => [
|
|
|
+ ['description' => 'De 100k a 200k — isenção inicial (meses 1 a 3)', 'start' => 1, 'end' => 3, 'tbr_percentage' => 0.0000, 'is_renewal' => false],
|
|
|
+ ['description' => 'De 100k a 200k — meses 4 a 12', 'start' => 4, 'end' => 12, 'tbr_percentage' => 0.7500, 'is_renewal' => false],
|
|
|
+ ['description' => 'De 100k a 200k — meses 13 a 60', 'start' => 13, 'end' => 60, 'tbr_percentage' => 1.0000, 'is_renewal' => false],
|
|
|
+ ['description' => 'Renovação 100k–200k', 'start' => 1, 'end' => 60, 'tbr_percentage' => 1.0000, 'is_renewal' => true],
|
|
|
+ ],
|
|
|
+ 'MGP' => [
|
|
|
+ ['description' => 'Acima de 200k — isenção inicial (meses 1 a 3)', 'start' => 1, 'end' => 3, 'tbr_percentage' => 0.0000, 'is_renewal' => false],
|
|
|
+ ['description' => 'Acima de 200k — meses 4 a 12', 'start' => 4, 'end' => 12, 'tbr_percentage' => 1.0000, 'is_renewal' => false],
|
|
|
+ ['description' => 'Acima de 200k — meses 13 a 60', 'start' => 13, 'end' => 60, 'tbr_percentage' => 1.5000, 'is_renewal' => false],
|
|
|
+ ['description' => 'Renovação +200k', 'start' => 1, 'end' => 60, 'tbr_percentage' => 1.5000, 'is_renewal' => true],
|
|
|
+ ],
|
|
|
];
|
|
|
|
|
|
- foreach ($classifications as $item) {
|
|
|
- InhabitantClassification::firstOrCreate(
|
|
|
- ['description' => $item['description'], 'start' => $item['start'], 'end' => $item['end']],
|
|
|
- $item,
|
|
|
- );
|
|
|
+ foreach ($rules as $acronym => $brackets) {
|
|
|
+ $sizeId = $sizes[$acronym] ?? null;
|
|
|
+
|
|
|
+ if (!$sizeId) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($brackets as $bracket) {
|
|
|
+ InhabitantClassification::firstOrCreate(
|
|
|
+ [
|
|
|
+ 'municipality_size_id' => $sizeId,
|
|
|
+ 'start' => $bracket['start'],
|
|
|
+ 'end' => $bracket['end'],
|
|
|
+ 'is_renewal' => $bracket['is_renewal'],
|
|
|
+ ],
|
|
|
+ array_merge($bracket, ['municipality_size_id' => $sizeId]),
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|