MAJOR IMPLEMENTATION COMPLETED: ✅ Modern database structure with Laravel best practices ✅ Complete Eloquent relationships (Amministratore→Stabili→Movements) ✅ 8-character alphanumeric codes system (ADM, ANA, MOV, ALL prefixes) ✅ Multi-database architecture for administrators ✅ Complete property management (anagrafica_condominiale, diritti_reali, contratti) ✅ Distribution system for multi-server deployment ✅ Universal responsive UI with permission-based sidebar NEW MODELS & MIGRATIONS: - AnagraficaCondominiale: Complete person/entity management - ContattoAnagrafica: Multi-contact system with usage flags - DirittoReale: Property rights with quotas and percentages - ContrattoLocazione: Rental contracts with landlord/tenant - TipoUtilizzo: Property usage types (residential, commercial, etc.) - Enhanced Stabile: Cadastral data, SDI, rate configuration - Enhanced UnitaImmobiliare: Modern structure with backward compatibility SERVICES & CONTROLLERS: - DistributionService: Multi-server deployment and migration - FileManagerController: Administrator folder management - DistributionController: API for server-to-server communication - MultiDatabaseService: Dynamic database connections READY FOR PRODUCTION: ✅ Database schema: Complete and tested ✅ Models relationships: All working and verified ✅ Code generation: Automatic 8-char codes implemented ✅ Testing: Successful data creation confirmed ✅ Documentation: Complete internal technical docs NEXT PHASE: Millésimal tables, expense categories, cost distribution engine
73 lines
1.5 KiB
PHP
73 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class VoceSpesa extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'voci_spesa';
|
|
|
|
protected $fillable = [
|
|
'stabile_id',
|
|
'codice',
|
|
'descrizione',
|
|
'tipo_gestione',
|
|
'categoria',
|
|
'tabella_millesimale_default_id',
|
|
'ritenuta_acconto_default',
|
|
'attiva',
|
|
'ordinamento',
|
|
];
|
|
|
|
protected $casts = [
|
|
'ritenuta_acconto_default' => 'decimal:2',
|
|
'attiva' => 'boolean',
|
|
'ordinamento' => 'integer',
|
|
'created_at' => 'datetime',
|
|
'updated_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* Relazione con Stabile
|
|
*/
|
|
public function stabile()
|
|
{
|
|
return $this->belongsTo(Stabile::class, 'stabile_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* Relazione con Tabella Millesimale Default
|
|
*/
|
|
public function tabellaMillesimaleDefault()
|
|
{
|
|
return $this->belongsTo(TabellaMillesimale::class, 'tabella_millesimale_default_id');
|
|
}
|
|
|
|
/**
|
|
* Scope per voci attive
|
|
*/
|
|
public function scopeAttive($query)
|
|
{
|
|
return $query->where('attiva', true);
|
|
}
|
|
|
|
/**
|
|
* Scope per tipo gestione
|
|
*/
|
|
public function scopeTipoGestione($query, $tipo)
|
|
{
|
|
return $query->where('tipo_gestione', $tipo);
|
|
}
|
|
|
|
/**
|
|
* Scope ordinato
|
|
*/
|
|
public function scopeOrdinato($query)
|
|
{
|
|
return $query->orderBy('ordinamento')->orderBy('descrizione');
|
|
}
|
|
} |