webmoney/backend/database/seeders/DemoUserSeeder.php
marcoitaloesp-ai 9c9d6443e7
v1.57.0: Redesign category modals + i18n updates + demo transactions fix
- Redesigned category create/edit modal with elegant wizard-style UI
- Redesigned batch categorization modal with visual cards and better preview
- Added missing i18n translations (common.continue, creating, remove)
- Added budgets.general and wizard translations for ES, PT-BR, EN
- Fixed 3 demo user transactions that were missing categories
2025-12-18 19:06:07 +00:00

321 lines
12 KiB
PHP

<?php
namespace Database\Seeders;
use App\Models\User;
use App\Models\LiabilityAccount;
use App\Models\AssetAccount;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
use Carbon\Carbon;
class DemoUserSeeder extends Seeder
{
public function run(): void
{
// 1. Criar usuário DEMO
$user = User::updateOrCreate(
['email' => 'demo@webmoney.com'],
[
'name' => 'Usuario Demo',
'first_name' => 'Demo',
'last_name' => 'WebMoney',
'password' => Hash::make('DEMO'),
'is_demo' => true,
'is_admin' => false,
'email_verified_at' => now(),
'country' => 'ES',
'timezone' => 'Europe/Madrid',
'locale' => 'es_ES',
'language' => 'es',
'currency' => 'EUR',
]
);
$this->command->info("✓ Usuario demo creado: demo@webmoney.com / DEMO");
// 2. Criar passivos de exemplo
$this->createSampleLiabilities($user);
// 3. Criar ativos de exemplo
$this->createSampleAssets($user);
}
protected function createSampleLiabilities(User $user): void
{
$liabilities = [
[
'contract_type' => 'personal_loan',
'name' => 'Préstamo Personal Santander',
'creditor' => 'Banco Santander',
'contract_number' => 'PL-2024-001234',
'description' => 'Préstamo personal para reforma del hogar',
'currency' => 'EUR',
'principal_amount' => 15000.00,
'total_pending' => 12500.00,
'total_paid' => 2500.00,
'annual_interest_rate' => 7.5,
'monthly_interest_rate' => 0.625,
'amortization_system' => 'price',
'total_installments' => 48,
'paid_installments' => 12,
'start_date' => '2024-01-15',
'first_due_date' => '2024-02-15',
'index_type' => 'fixed',
'alert_days_before' => 5,
'color' => '#3B82F6',
'status' => 'active',
],
[
'contract_type' => 'vehicle',
'name' => 'Financiación Coche BMW X3',
'creditor' => 'BMW Financial Services',
'contract_number' => 'VF-2024-BMW-5678',
'description' => 'Financiación vehículo BMW X3 xDrive20d',
'currency' => 'EUR',
'principal_amount' => 45000.00,
'total_pending' => 38750.00,
'total_paid' => 6250.00,
'annual_interest_rate' => 5.9,
'amortization_system' => 'price',
'total_installments' => 60,
'paid_installments' => 10,
'start_date' => '2024-03-01',
'first_due_date' => '2024-04-01',
'guarantee_type' => 'fiduciary_alienation',
'guarantee_value' => 45000.00,
'index_type' => 'fixed',
'color' => '#10B981',
'status' => 'active',
],
[
'contract_type' => 'mortgage',
'name' => 'Hipoteca Vivienda Principal',
'creditor' => 'CaixaBank',
'contract_number' => 'HIP-2020-987654',
'description' => 'Hipoteca vivienda familiar - Madrid Centro',
'currency' => 'EUR',
'principal_amount' => 250000.00,
'total_pending' => 215000.00,
'total_paid' => 35000.00,
'annual_interest_rate' => 2.5,
'amortization_system' => 'sac',
'total_installments' => 300,
'paid_installments' => 48,
'start_date' => '2020-06-15',
'first_due_date' => '2020-07-15',
'guarantee_type' => 'mortgage_guarantee',
'guarantee_value' => 350000.00,
'index_type' => 'euribor',
'index_spread' => 0.80,
'color' => '#F59E0B',
'status' => 'active',
],
[
'contract_type' => 'credit_card',
'name' => 'Tarjeta Visa Oro BBVA',
'creditor' => 'BBVA',
'contract_number' => 'CC-VISA-4242',
'currency' => 'EUR',
'principal_amount' => 5000.00,
'total_pending' => 3250.00,
'total_paid' => 1750.00,
'annual_interest_rate' => 18.99,
'amortization_system' => 'revolving',
'total_installments' => 0,
'paid_installments' => 0,
'start_date' => '2023-01-01',
'first_due_date' => '2023-02-01',
'color' => '#EF4444',
'status' => 'active',
],
[
'contract_type' => 'leasing',
'name' => 'Leasing Maquinaria Industrial',
'creditor' => 'Banco Sabadell Leasing',
'contract_number' => 'LEA-2024-MAQ-456',
'currency' => 'EUR',
'principal_amount' => 120000.00,
'total_pending' => 105000.00,
'total_paid' => 15000.00,
'annual_interest_rate' => 4.5,
'amortization_system' => 'price',
'total_installments' => 48,
'paid_installments' => 6,
'start_date' => '2024-05-01',
'first_due_date' => '2024-06-01',
'color' => '#06B6D4',
'status' => 'active',
],
];
foreach ($liabilities as $data) {
LiabilityAccount::updateOrCreate(
['user_id' => $user->id, 'contract_number' => $data['contract_number']],
array_merge($data, ['user_id' => $user->id])
);
}
$this->command->info("" . count($liabilities) . " pasivos de ejemplo creados");
}
protected function createSampleAssets(User $user): void
{
$assets = [
[
'asset_type' => 'real_estate',
'name' => 'Vivienda Principal Madrid',
'description' => 'Piso de 120m² en el centro de Madrid',
'currency' => 'EUR',
'acquisition_value' => 350000.00,
'current_value' => 420000.00,
'acquisition_date' => '2020-06-15',
'property_type' => 'apartment',
'address' => 'Calle Mayor 45, 3º A',
'city' => 'Madrid',
'postal_code' => '28013',
'country' => 'ES',
'property_area_m2' => 120.00,
'color' => '#3B82F6',
],
[
'asset_type' => 'real_estate',
'name' => 'Local Comercial Barcelona',
'description' => 'Local comercial en zona turística',
'currency' => 'EUR',
'acquisition_value' => 180000.00,
'current_value' => 210000.00,
'acquisition_date' => '2019-03-20',
'property_type' => 'commercial',
'city' => 'Barcelona',
'property_area_m2' => 85.00,
'color' => '#10B981',
],
[
'asset_type' => 'vehicle',
'name' => 'BMW X3 xDrive20d',
'description' => 'SUV premium para uso personal',
'currency' => 'EUR',
'acquisition_value' => 55000.00,
'current_value' => 42000.00,
'acquisition_date' => '2022-09-01',
'vehicle_brand' => 'BMW',
'vehicle_model' => 'X3 xDrive20d',
'vehicle_year' => 2022,
'vehicle_plate' => '1234 ABC',
'vehicle_mileage' => 45000,
'color' => '#F59E0B',
],
[
'asset_type' => 'investment',
'name' => 'Cartera Acciones IBEX',
'description' => 'Cartera diversificada de acciones españolas',
'currency' => 'EUR',
'acquisition_value' => 25000.00,
'current_value' => 28500.00,
'acquisition_date' => '2023-01-15',
'investment_type' => 'stocks',
'institution' => 'Interactive Brokers',
'ticker' => 'IBEX35',
'color' => '#8B5CF6',
],
[
'asset_type' => 'investment',
'name' => 'Fondo Indexado S&P 500',
'description' => 'ETF que replica el índice S&P 500',
'currency' => 'USD',
'acquisition_value' => 15000.00,
'current_value' => 18200.00,
'acquisition_date' => '2022-06-01',
'investment_type' => 'etf',
'institution' => 'Vanguard',
'ticker' => 'VOO',
'color' => '#06B6D4',
],
[
'asset_type' => 'investment',
'name' => 'Depósito a Plazo Fijo',
'currency' => 'EUR',
'acquisition_value' => 50000.00,
'current_value' => 51500.00,
'acquisition_date' => '2024-01-15',
'investment_type' => 'fixed_deposit',
'institution' => 'Openbank',
'interest_rate' => 3.00,
'maturity_date' => '2025-01-15',
'color' => '#14B8A6',
],
[
'asset_type' => 'investment',
'name' => 'Bitcoin (BTC)',
'currency' => 'EUR',
'acquisition_value' => 10000.00,
'current_value' => 15800.00,
'acquisition_date' => '2023-08-01',
'investment_type' => 'crypto',
'institution' => 'Binance',
'ticker' => 'BTC',
'color' => '#F97316',
],
[
'asset_type' => 'equipment',
'name' => 'MacBook Pro 16"',
'description' => 'Ordenador portátil profesional',
'currency' => 'EUR',
'acquisition_value' => 3500.00,
'current_value' => 2800.00,
'acquisition_date' => '2023-03-15',
'equipment_brand' => 'Apple',
'equipment_model' => 'MacBook Pro 16 M2 Pro',
'serial_number' => 'C02XL234H1',
'warranty_expiry' => '2026-03-15',
'color' => '#64748B',
],
[
'asset_type' => 'receivable',
'name' => 'Factura Cliente ABC Corp',
'description' => 'Factura pendiente de cobro',
'currency' => 'EUR',
'acquisition_value' => 12500.00,
'current_value' => 12500.00,
'acquisition_date' => '2024-11-15',
'debtor_name' => 'ABC Corporation S.L.',
'receivable_due_date' => '2025-01-15',
'receivable_amount' => 12500.00,
'color' => '#84CC16',
],
[
'asset_type' => 'cash',
'name' => 'Reserva de Emergencia',
'description' => 'Fondo de emergencia en cuenta de ahorro',
'currency' => 'EUR',
'acquisition_value' => 20000.00,
'current_value' => 20500.00,
'acquisition_date' => '2023-01-01',
'institution' => 'ING Direct',
'interest_rate' => 2.50,
'color' => '#22C55E',
],
[
'asset_type' => 'other',
'name' => 'Colección de Arte',
'description' => 'Obras de arte y antigüedades',
'currency' => 'EUR',
'acquisition_value' => 35000.00,
'current_value' => 42000.00,
'acquisition_date' => '2021-01-01',
'color' => '#A855F7',
],
];
foreach ($assets as $data) {
AssetAccount::updateOrCreate(
['user_id' => $user->id, 'name' => $data['name']],
array_merge($data, ['user_id' => $user->id, 'status' => 'active'])
);
}
$this->command->info("" . count($assets) . " activos de ejemplo creados");
}
}