Pārlūkot izejas kodu

feat(tbr): adiciona permissoes necessarias e seeder base

ebagabee 1 nedēļu atpakaļ
vecāks
revīzija
05fa5c2ef0

+ 1 - 0
database/seeders/DatabaseSeeder.php

@@ -16,6 +16,7 @@ public function run(): void
             PermissionSeeder::class,
             UserTypePermissionSeeder::class,
             BrazilCitiesSeeder::class,
+            TbrBaseBracketsSeeder::class,
         ]);
     }
 }

+ 37 - 0
database/seeders/PermissionSeeder.php

@@ -34,6 +34,43 @@ public function run(): void
                     ],
                 ],
             ],
+            [
+                "scope" => "tbr",
+                "description" => "TBR",
+                "bits" => Permission::ALL_PERMS,
+                "children" => [
+                    [
+                        "scope" => "royalties-base-bracket",
+                        "description" => "Faixas de Royalties Base",
+                        "bits" => Permission::ALL_PERMS,
+                        "children" => [],
+                    ],
+                    [
+                        "scope" => "fnm-base-bracket",
+                        "description" => "Faixas de FNM Base",
+                        "bits" => Permission::ALL_PERMS,
+                        "children" => [],
+                    ],
+                    [
+                        "scope" => "maintenance-base-bracket",
+                        "description" => "Faixas de Manutenção Base",
+                        "bits" => Permission::ALL_PERMS,
+                        "children" => [],
+                    ],
+                    [
+                        "scope" => "franchisee-tbr",
+                        "description" => "TBR por Franqueado",
+                        "bits" => Permission::ALL_PERMS,
+                        "children" => [],
+                    ],
+                    [
+                        "scope" => "tbr-calculation",
+                        "description" => "Cálculo de TBR",
+                        "bits" => Permission::VIEW | Permission::ADD,
+                        "children" => [],
+                    ],
+                ],
+            ],
             [
                 "scope" => "config",
                 "description" => "Configurações",

+ 95 - 0
database/seeders/TbrBaseBracketsSeeder.php

@@ -0,0 +1,95 @@
+<?php
+
+namespace Database\Seeders;
+
+use Illuminate\Database\Seeder;
+use Illuminate\Support\Facades\DB;
+
+class TbrBaseBracketsSeeder extends Seeder
+{
+    public function run(): void
+    {
+        $now = now();
+
+        DB::table('royalties_base_brackets')->insert([
+            [
+                'description' => 'Isento',
+                'start_month' => 1,
+                'end_month'   => 3,
+                'percentage'  => 0.0000,
+                'created_at'  => $now,
+                'updated_at'  => $now,
+            ],
+            [
+                'description' => 'Maior entre % fixo TBR ou 8% do faturamento',
+                'start_month' => 4,
+                'end_month'   => 12,
+                'percentage'  => 0.0800,
+                'created_at'  => $now,
+                'updated_at'  => $now,
+            ],
+            [
+                'description' => 'Maior entre % fixo TBR ou 8% do faturamento',
+                'start_month' => 13,
+                'end_month'   => 60,
+                'percentage'  => 0.0800,
+                'created_at'  => $now,
+                'updated_at'  => $now,
+            ],
+        ]);
+
+        DB::table('fnm_base_brackets')->insert([
+            [
+                'description' => 'Isento',
+                'start_month' => 1,
+                'end_month'   => 3,
+                'percentage'  => 0.0000,
+                'created_at'  => $now,
+                'updated_at'  => $now,
+            ],
+            [
+                'description' => 'Maior entre: % fixo TBR ou 2% do faturamento',
+                'start_month' => 4,
+                'end_month'   => 12,
+                'percentage'  => 0.0200,
+                'created_at'  => $now,
+                'updated_at'  => $now,
+            ],
+            [
+                'description' => 'Maior entre: % fixo TBR ou 2% do faturamento',
+                'start_month' => 13,
+                'end_month'   => 60,
+                'percentage'  => 0.0200,
+                'created_at'  => $now,
+                'updated_at'  => $now,
+            ],
+        ]);
+
+        DB::table('maintenance_base_brackets')->insert([
+            [
+                'description' => '30% fixo da TBR',
+                'start_month' => 1,
+                'end_month'   => 3,
+                'percentage'  => 0.3000,
+                'created_at'  => $now,
+                'updated_at'  => $now,
+            ],
+            [
+                'description' => '30% fixo da TBR',
+                'start_month' => 4,
+                'end_month'   => 12,
+                'percentage'  => 0.3000,
+                'created_at'  => $now,
+                'updated_at'  => $now,
+            ],
+            [
+                'description' => '30% fixo da TBR',
+                'start_month' => 13,
+                'end_month'   => 60,
+                'percentage'  => 0.3000,
+                'created_at'  => $now,
+                'updated_at'  => $now,
+            ],
+        ]);
+    }
+}

+ 11 - 5
database/seeders/UserTypePermissionSeeder.php

@@ -25,11 +25,17 @@ public function run(): void
                     break;
                 case UserTypeEnum::USER:
                     $dataToSync = [
-                        ['scope' => 'dashboard',      'bits' => Permission::VIEW],
-                        ['scope' => 'config.user',    'bits' => Permission::VIEW | Permission::EDIT],
-                        ['scope' => 'config.city',    'bits' => Permission::VIEW],
-                        ['scope' => 'config.country', 'bits' => Permission::VIEW],
-                        ['scope' => 'config.state',   'bits' => Permission::VIEW],
+                        ['scope' => 'dashboard',               'bits' => Permission::VIEW],
+                        ['scope' => 'config.user',             'bits' => Permission::VIEW | Permission::EDIT],
+                        ['scope' => 'config.city',             'bits' => Permission::VIEW],
+                        ['scope' => 'config.country',          'bits' => Permission::VIEW],
+                        ['scope' => 'config.state',            'bits' => Permission::VIEW],
+                        ['scope' => 'tbr',                     'bits' => Permission::VIEW],
+                        ['scope' => 'royalties-base-bracket',  'bits' => Permission::VIEW],
+                        ['scope' => 'fnm-base-bracket',        'bits' => Permission::VIEW],
+                        ['scope' => 'maintenance-base-bracket','bits' => Permission::VIEW],
+                        ['scope' => 'franchisee-tbr',          'bits' => Permission::VIEW],
+                        ['scope' => 'tbr-calculation',         'bits' => Permission::VIEW],
                     ];
                     break;
                 case UserTypeEnum::GUEST: