<?php

namespace Database\Seeders;

use App\Enums\PropertyType;
use App\Models\Property;
use App\Models\Department;
use Illuminate\Database\Seeder;

class DepartamentSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {

        $departments = [
            // Tipo A (62.38 m²)
            ['title' => 'PISO 1 TIPO A', 'status'=>'AVAILABLE','code' => '1-A', 'surface' => 62.38, 'base_price' => 86900, 'floor' => 1, 'type_department_id' => 1, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1393.07],
            ['title' => 'PISO 2 TIPO A', 'status'=>'AVAILABLE','code' => '2-A', 'surface' => 62.38, 'base_price' => 87900, 'floor' => 2, 'type_department_id' => 1, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1409.11],
            ['title' => 'PISO 3 TIPO A', 'status'=>'AVAILABLE','code' => '3-A', 'surface' => 62.38, 'base_price' => 88900, 'floor' => 3, 'type_department_id' => 1, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1425.14],
            ['title' => 'PISO 4 TIPO A', 'status'=>'SALE','code' => '4-A', 'surface' => 62.38, 'base_price' => 89900, 'floor' => 4, 'type_department_id' => 1, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1441.17],
            ['title' => 'PISO 5 TIPO A', 'status'=>'SALE','code' => '5-A', 'surface' => 62.38, 'base_price' => 90900, 'floor' => 5, 'type_department_id' => 1, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1457.20],
            ['title' => 'PISO 6 TIPO A', 'status'=>'AVAILABLE','code' => '6-A', 'surface' => 62.38, 'base_price' => 66900, 'floor' => 6, 'type_department_id' => 1, 'number_bedrooms' => 1, 'isfacade' => true ],
            ['title' => 'PISO 7 TIPO A', 'status'=>'AVAILABLE','code' => '7-A', 'surface' => 62.38, 'base_price' => 51900, 'floor' => 7, 'type_department_id' => 1, 'number_bedrooms' => 1, 'isfacade' => true , 'precio_por_m2' => 1425.04],

            // Tipo B (59.82 m²)
            ['title' => 'PISO 1 TIPO B', 'status'=>'AVAILABLE', 'code' => '1-B', 'surface' => 59.82, 'base_price' => 83500, 'floor' => 1, 'type_department_id' => 2, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1395.85],
            ['title' => 'PISO 2 TIPO B', 'status'=>'AVAILABLE', 'code' => '2-B', 'surface' => 59.82, 'base_price' => 84500, 'floor' => 2, 'type_department_id' => 2, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1412.57],
            ['title' => 'PISO 3 TIPO B', 'status'=>'AVAILABLE', 'code' => '3-B', 'surface' => 59.82, 'base_price' => 85500, 'floor' => 3, 'type_department_id' => 2, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1429.29],
            ['title' => 'PISO 4 TIPO B', 'status'=>'SALE', 'code' => '4-B', 'surface' => 59.82, 'base_price' => 86500, 'floor' => 4, 'type_department_id' => 2, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1446.00],
            ['title' => 'PISO 5 TIPO B', 'status'=>'AVAILABLE', 'code' => '5-B', 'surface' => 59.82, 'base_price' => 87500, 'floor' => 5, 'type_department_id' => 2, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1462.72],
            ['title' => 'PISO 6 TIPO B', 'status'=>'AVAILABLE', 'code' => '6-B', 'surface' => 59.82, 'base_price' => 59500, 'floor' => 6, 'type_department_id' => 2, 'number_bedrooms' => 1, 'isfacade' => true ],
            ['title' => 'PISO 7 TIPO B', 'status'=>'AVAILABLE', 'code' => '7-B', 'surface' => 59.82, 'base_price' => 51900, 'floor' => 7, 'type_department_id' => 2, 'number_bedrooms' => 1, 'isfacade' => true , 'precio_por_m2' => 1421.92],

            // Tipo C
            ['title' => 'PISO 1 TIPO C', 'status'=>'AVAILABLE', 'code' => '1-C', 'surface' => 59.81, 'base_price' => 83500, 'floor' => 1, 'type_department_id' => 3, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1396.09],
            ['title' => 'PISO 2 TIPO C', 'status'=>'AVAILABLE', 'code' => '2-C', 'surface' => 59.81, 'base_price' => 84500, 'floor' => 2, 'type_department_id' => 3, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1412.81],
            ['title' => 'PISO 3 TIPO C', 'status'=>'SALE', 'code' => '3-C', 'surface' => 59.81, 'base_price' => 85500, 'floor' => 3, 'type_department_id' => 3, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1429.53],
            ['title' => 'PISO 4 TIPO C', 'status'=>'AVAILABLE', 'code' => '4-C', 'surface' => 59.81, 'base_price' => 86500, 'floor' => 4, 'type_department_id' => 3, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1446.25],
            ['title' => 'PISO 5 TIPO C', 'status'=>'AVAILABLE', 'code' => '5-C', 'surface' => 59.81, 'base_price' => 87500, 'floor' => 5, 'type_department_id' => 3, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1462.97],
            ['title' => 'PISO 6 TIPO C', 'status'=>'AVAILABLE', 'code' => '6-C', 'surface' => 59.81, 'base_price' => 59900, 'floor' => 6, 'type_department_id' => 3, 'number_bedrooms' => 1, 'isfacade' => true ],
            ['title' => 'PISO 7 TIPO C', 'status'=>'SALE', 'code' => '7-C', 'surface' => 59.81, 'base_price' => 50000, 'floor' => 7, 'type_department_id' => 3, 'number_bedrooms' => 1, 'isfacade' => true , 'precio_por_m2' => 1437.61],

            //Tipo D
            ['title' => 'PISO 1 TIPO D', 'status'=>'AVAILABLE', 'code' => '1-D', 'surface' => 59.74, 'base_price' => 83500, 'floor' => 1, 'type_department_id' => 4, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1397.72],
            ['title' => 'PISO 2 TIPO D', 'status'=>'AVAILABLE', 'code' => '2-D', 'surface' => 59.74, 'base_price' => 84500, 'floor' => 2, 'type_department_id' => 4, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1414.46],
            ['title' => 'PISO 3 TIPO D', 'status'=>'AVAILABLE', 'code' => '3-D', 'surface' => 59.74, 'base_price' => 85500, 'floor' => 3, 'type_department_id' => 4, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1431.20],
            ['title' => 'PISO 4 TIPO D', 'status'=>'AVAILABLE', 'code' => '4-D', 'surface' => 59.74, 'base_price' => 86500, 'floor' => 4, 'type_department_id' => 4, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1447.94],
            ['title' => 'PISO 5 TIPO D', 'status'=>'AVAILABLE', 'code' => '5-D', 'surface' => 59.74, 'base_price' => 87500, 'floor' => 5, 'type_department_id' => 4, 'number_bedrooms' => 2, 'isfacade' => true , 'precio_por_m2' => 1464.68],
            ['title' => 'PISO 6 TIPO D', 'status'=>'AVAILABLE', 'code' => '6-D', 'surface' => 59.74, 'base_price' => 66900, 'floor' => 6, 'type_department_id' => 4, 'number_bedrooms' => 1, 'isfacade' => true ],
            ['title' => 'PISO 7 TIPO D', 'status'=>'AVAILABLE', 'code' => '7-D', 'surface' => 59.74, 'base_price' => 49900, 'floor' => 7, 'type_department_id' => 4, 'number_bedrooms' => 1, 'isfacade' => true , 'precio_por_m2' => 1412.29],

            //Tipo E
            ['title' => 'PISO 1 TIPO E', 'status'=>'AVAILABLE', 'code' => '1-E', 'surface' => 56.40, 'base_price' => 76900, 'floor' => 1, 'type_department_id' => 5, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1363.48],
            ['title' => 'PISO 2 TIPO E', 'status'=>'AVAILABLE', 'code' => '2-E', 'surface' => 56.40, 'base_price' => 77900, 'floor' => 2, 'type_department_id' => 5, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1381.21],
            ['title' => 'PISO 3 TIPO E', 'status'=>'AVAILABLE', 'code' => '3-E', 'surface' => 56.40, 'base_price' => 78900, 'floor' => 3, 'type_department_id' => 5, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1398.94],
            ['title' => 'PISO 4 TIPO E', 'status'=>'AVAILABLE', 'code' => '4-E', 'surface' => 56.40, 'base_price' => 79900, 'floor' => 4, 'type_department_id' => 5, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1416.67],
            ['title' => 'PISO 5 TIPO E', 'status'=>'AVAILABLE', 'code' => '5-E', 'surface' => 56.40, 'base_price' => 80900, 'floor' => 5, 'type_department_id' => 5, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1434.40],
            ['title' => 'PISO 6 TIPO E', 'status'=>'AVAILABLE', 'code' => '6-E', 'surface' => 56.40, 'base_price' => 62900, 'floor' => 6, 'type_department_id' => 5, 'number_bedrooms' => 1, 'isfacade' => false],
            ['title' => 'PISO 7 TIPO E', 'status'=>'AVAILABLE', 'code' => '7-E', 'surface' => 56.40, 'base_price' => 53900, 'floor' => 7, 'type_department_id' => 5, 'number_bedrooms' => 1, 'isfacade' => false, 'precio_por_m2' => 1397.60],

            //Tipo F
            ['title' => 'PISO 1 TIPO F', 'status'=>'AVAILABLE', 'code' => '1-F', 'surface' => 56.09, 'base_price' => 76500, 'floor' => 1, 'type_department_id' => 6, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1363.88],
            ['title' => 'PISO 2 TIPO F', 'status'=>'AVAILABLE', 'code' => '2-F', 'surface' => 56.09, 'base_price' => 77500, 'floor' => 2, 'type_department_id' => 6, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1381.71],
            ['title' => 'PISO 3 TIPO F', 'status'=>'AVAILABLE', 'code' => '3-F', 'surface' => 56.09, 'base_price' => 78500, 'floor' => 3, 'type_department_id' => 6, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1399.54],
            ['title' => 'PISO 4 TIPO F', 'status'=>'AVAILABLE', 'code' => '4-F', 'surface' => 56.09, 'base_price' => 79500, 'floor' => 4, 'type_department_id' => 6, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1417.36],
            ['title' => 'PISO 5 TIPO F', 'status'=>'AVAILABLE', 'code' => '5-F', 'surface' => 56.09, 'base_price' => 80500, 'floor' => 5, 'type_department_id' => 6, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1435.19],
            ['title' => 'PISO 6 TIPO F', 'status'=>'AVAILABLE', 'code' => '6-F', 'surface' => 56.09, 'base_price' => 49900, 'floor' => 6, 'type_department_id' => 6, 'number_bedrooms' => 1, 'isfacade' => false],
            ['title' => 'PISO 7 TIPO F', 'status'=>'AVAILABLE', 'code' => '7-F', 'surface' => 56.09, 'base_price' => 52900, 'floor' => 7, 'type_department_id' => 6, 'number_bedrooms' => 1, 'isfacade' => false, 'precio_por_m2' => 1392.84],

            //Tipo G
            ['title' => 'PISO 1 TIPO G', 'status'=>'AVAILABLE', 'code' => '1-G', 'surface' => 58.32, 'base_price' => 79500, 'floor' => 1, 'type_department_id' => 7, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1363.17],
            ['title' => 'PISO 2 TIPO G', 'status'=>'AVAILABLE', 'code' => '2-G', 'surface' => 58.32, 'base_price' => 80500, 'floor' => 2, 'type_department_id' => 7, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1380.32],
            ['title' => 'PISO 3 TIPO G', 'status'=>'AVAILABLE', 'code' => '3-G', 'surface' => 58.32, 'base_price' => 81500, 'floor' => 3, 'type_department_id' => 7, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1397.46],
            ['title' => 'PISO 4 TIPO G', 'status'=>'AVAILABLE', 'code' => '4-G', 'surface' => 58.32, 'base_price' => 82500, 'floor' => 4, 'type_department_id' => 7, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1414.61],
            ['title' => 'PISO 5 TIPO G', 'status'=>'AVAILABLE', 'code' => '5-G', 'surface' => 58.32, 'base_price' => 83500, 'floor' => 5, 'type_department_id' => 7, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1431.76],
            ['title' => 'PISO 6 TIPO G', 'status'=>'AVAILABLE', 'code' => '6-G', 'surface' => 58.32, 'base_price' => 52900, 'floor' => 6, 'type_department_id' => 7, 'number_bedrooms' => 1, 'isfacade' => false],
            ['title' => 'PISO 7 TIPO G', 'status'=>'AVAILABLE', 'code' => '7-G', 'surface' => 58.32, 'base_price' => 58900, 'floor' => 7, 'type_department_id' => 7, 'number_bedrooms' => 1, 'isfacade' => false, 'precio_por_m2' => 1392.11],

            //tipo H
            ['title' => 'PISO 1 TIPO H', 'status'=>'AVAILABLE', 'code' => '1-H', 'surface' => 56.60, 'base_price' => 81200, 'floor' => 1, 'type_department_id' => 8, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1362.42],
            ['title' => 'PISO 2 TIPO H', 'status'=>'AVAILABLE', 'code' => '2-H', 'surface' => 56.60, 'base_price' => 82200, 'floor' => 2, 'type_department_id' => 8, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1379.19],
            ['title' => 'PISO 3 TIPO H', 'status'=>'AVAILABLE', 'code' => '3-H', 'surface' => 56.60, 'base_price' => 83200, 'floor' => 3, 'type_department_id' => 8, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1395.97],
            ['title' => 'PISO 5 TIPO H', 'status'=>'AVAILABLE', 'code' => '5-H', 'surface' => 56.60, 'base_price' => 84900, 'floor' => 5, 'type_department_id' => 8, 'number_bedrooms' => 2, 'isfacade' => false, 'precio_por_m2' => 1424.50],
            ['title' => 'PISO 6 TIPO H', 'status'=>'AVAILABLE', 'code' => '6-H', 'surface' => 56.60, 'base_price' => 61900, 'floor' => 6, 'type_department_id' => 8, 'number_bedrooms' => 1, 'isfacade' => false],
            ['title' => 'PISO 7 TIPO H', 'status'=>'AVAILABLE', 'code' => '7-H', 'surface' => 56.60, 'base_price' => 56900, 'floor' => 7, 'type_department_id' => 8, 'number_bedrooms' => 1, 'isfacade' => false, 'precio_por_m2' => 1390.18],
    ];

        foreach ($departments as $deptData) {
            $property = Property::create([
                'title' => $deptData['title'],
                'code' => $deptData['code'],
                'surface' => $deptData['surface'],
                'base_price' => $deptData['base_price'],
                'status' => $deptData['status'],
                // 'percentage_initial_fee' =>20,
                // 'initial_fee' => $deptData['initial_fee'],
                'percentage_initial_fee' => 20.00,
                'initial_fee' => $deptData['base_price']* 0.20,
                'precio_por_m2' => $deptData['precio_por_m2'] ?? null,

                'property_type_id' => 2,
                'project_id' => 1,
                'property_type' => PropertyType::DEPARTAMENT->name
            ]);

            Department::create([
                'property_id' => $property->id,
                'floor' => $deptData['floor'],
                'isfacade' => $deptData['isfacade'],
                'number_bedrooms' => $deptData['number_bedrooms'],
                'number_bathrooms' => 1,
                'type_department_id' => $deptData['type_department_id'],
            ]);
            if ($deptData['floor'] == 6) {
                $property->features()->attach(7);
            }
        }
    }
}
