✅ Completato: - Database modernizzato con chiavi id standard Laravel - Relazioni corrette Amministratore→Stabili→Movimenti - UI universale responsive con sidebar permission-based - Codici alfanumerici 8 caratteri implementati - Seeders con dati di test funzionanti - Documentazione tecnica completa (INSTALL_LINUX, TECHNICAL_SPECS, UPDATE_SYSTEM) 🔧 Miglioramenti: - Helper userSetting() funzionante - Sistema multi-database preparato - .gitignore aggiornato per sicurezza - Migration cleanup e ottimizzazione 📚 Documentazione: - Guida installazione Linux completa - Specifiche tecniche dettagliate - Sistema aggiornamenti progettato - Progress log aggiornato
118 lines
5.1 KiB
PHP
118 lines
5.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class MovimentiContabiliSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
$stabili = \App\Models\Stabile::take(3)->get();
|
|
$gestioni = \App\Models\Gestione::take(2)->get();
|
|
$fornitori = \App\Models\Fornitore::take(5)->get();
|
|
$users = \App\Models\User::take(2)->get();
|
|
|
|
if ($stabili->isEmpty() || $gestioni->isEmpty() || $users->isEmpty()) {
|
|
$this->command->info('Skipping MovimentiContabiliSeeder: missing related data');
|
|
return;
|
|
}
|
|
|
|
$movimenti = [
|
|
// Prima nota - da confermare
|
|
[
|
|
'stabile_id' => $stabili->first()->id_stabile,
|
|
'gestione_id' => $gestioni->first()->id,
|
|
'fornitore_id' => $fornitori->isNotEmpty() ? $fornitori->first()->id : null,
|
|
'stato_movimento' => 'prima_nota',
|
|
'data_registrazione' => now()->subDays(5),
|
|
'descrizione' => 'Fattura ENEL - Energia elettrica parti comuni',
|
|
'tipo_movimento' => 'uscita',
|
|
'categoria_movimento' => 'ordinario',
|
|
'importo_totale' => 450.00,
|
|
'iva' => 45.00,
|
|
'importo_netto' => 495.00,
|
|
'numero_documento' => 'FAT-2024-001',
|
|
'data_documento' => now()->subDays(7),
|
|
'creato_da' => $users->first()->id,
|
|
],
|
|
[
|
|
'stabile_id' => $stabili->first()->id_stabile,
|
|
'gestione_id' => $gestioni->first()->id,
|
|
'stato_movimento' => 'prima_nota',
|
|
'data_registrazione' => now()->subDays(3),
|
|
'descrizione' => 'Rate condominiali gennaio 2025',
|
|
'tipo_movimento' => 'entrata',
|
|
'categoria_movimento' => 'ordinario',
|
|
'importo_totale' => 2500.00,
|
|
'importo_netto' => 2500.00,
|
|
'creato_da' => $users->first()->id,
|
|
],
|
|
// Movimenti confermati
|
|
[
|
|
'stabile_id' => $stabili->first()->id_stabile,
|
|
'gestione_id' => $gestioni->first()->id,
|
|
'fornitore_id' => $fornitori->count() > 1 ? $fornitori->skip(1)->first()->id : null,
|
|
'stato_movimento' => 'confermato',
|
|
'data_registrazione' => now()->subDays(10),
|
|
'data_conferma' => now()->subDays(8),
|
|
'confermato_da' => $users->count() > 1 ? $users->skip(1)->first()->id : $users->first()->id,
|
|
'descrizione' => 'Pulizia scale - Ditta XYZ',
|
|
'tipo_movimento' => 'uscita',
|
|
'categoria_movimento' => 'ordinario',
|
|
'importo_totale' => 300.00,
|
|
'iva' => 30.00,
|
|
'importo_netto' => 330.00,
|
|
'numero_documento' => 'FAT-2024-002',
|
|
'data_documento' => now()->subDays(12),
|
|
'creato_da' => $users->first()->id,
|
|
],
|
|
// Movimento straordinario
|
|
[
|
|
'stabile_id' => $stabili->count() > 1 ? $stabili->skip(1)->first()->id_stabile : $stabili->first()->id_stabile,
|
|
'gestione_id' => $gestioni->count() > 1 ? $gestioni->skip(1)->first()->id : $gestioni->first()->id,
|
|
'stato_movimento' => 'confermato',
|
|
'data_registrazione' => now()->subDays(15),
|
|
'data_conferma' => now()->subDays(12),
|
|
'confermato_da' => $users->first()->id,
|
|
'descrizione' => 'Riparazione ascensore - Intervento urgente',
|
|
'tipo_movimento' => 'uscita',
|
|
'categoria_movimento' => 'straordinario',
|
|
'importo_totale' => 1500.00,
|
|
'iva' => 150.00,
|
|
'importo_netto' => 1650.00,
|
|
'numero_documento' => 'FAT-2024-003',
|
|
'data_documento' => now()->subDays(16),
|
|
'note_interne' => 'Intervento urgente per guasto improvviso',
|
|
'creato_da' => $users->first()->id,
|
|
],
|
|
// Girofondi
|
|
[
|
|
'stabile_id' => $stabili->first()->id_stabile,
|
|
'gestione_id' => $gestioni->first()->id,
|
|
'stato_movimento' => 'confermato',
|
|
'data_registrazione' => now()->subDays(20),
|
|
'data_conferma' => now()->subDays(18),
|
|
'confermato_da' => $users->first()->id,
|
|
'descrizione' => 'Trasferimento da fondo ordinario a fondo straordinario',
|
|
'tipo_movimento' => 'girofondi',
|
|
'categoria_movimento' => 'fondo',
|
|
'importo_totale' => 1000.00,
|
|
'importo_netto' => 1000.00,
|
|
'note_interne' => 'Delibera assembleare N.5/2024',
|
|
'creato_da' => $users->first()->id,
|
|
]
|
|
];
|
|
|
|
foreach ($movimenti as $movimento) {
|
|
\App\Models\MovimentoContabile::create($movimento);
|
|
}
|
|
|
|
$this->command->info('Creati ' . count($movimenti) . ' movimenti contabili di test');
|
|
}
|
|
}
|