111 lines
3.0 KiB
PHP
111 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Contabilita\Models;
|
|
|
|
use App\Models\FeRitenutaPrevidenziale;
|
|
use App\Models\FatturaElettronica;
|
|
use App\Models\Fornitore;
|
|
use App\Models\GestioneContabile;
|
|
use App\Models\Stabile;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class FatturaFornitore extends Model
|
|
{
|
|
protected $table = 'contabilita_fatture_fornitori';
|
|
|
|
protected $fillable = [
|
|
'stabile_id',
|
|
'gestione_id',
|
|
'fattura_elettronica_id',
|
|
'fornitore_id',
|
|
'data_registrazione',
|
|
'data_documento',
|
|
'numero_documento',
|
|
'causale_contabile',
|
|
'descrizione',
|
|
'valuta',
|
|
'cambio',
|
|
'imponibile',
|
|
'iva',
|
|
'totale',
|
|
'data_scadenza',
|
|
'modalita_pagamento',
|
|
'data_pagamento',
|
|
'movimento_pagamento_id',
|
|
'data_versamento_ra',
|
|
'movimento_versamento_ra_id',
|
|
'ritenuta_aliquota',
|
|
'ritenuta_importo',
|
|
'ritenuta_codice_tributo',
|
|
'ritenuta_previdenziale_codice',
|
|
'netto_da_pagare',
|
|
'stato',
|
|
'registrazione_id',
|
|
'note',
|
|
'dati_fornitura',
|
|
];
|
|
|
|
protected $casts = [
|
|
'data_registrazione' => 'date',
|
|
'data_documento' => 'date',
|
|
'data_scadenza' => 'date',
|
|
'data_pagamento' => 'date',
|
|
'data_versamento_ra' => 'date',
|
|
'cambio' => 'decimal:6',
|
|
'imponibile' => 'decimal:2',
|
|
'iva' => 'decimal:2',
|
|
'totale' => 'decimal:2',
|
|
'ritenuta_aliquota' => 'decimal:3',
|
|
'ritenuta_importo' => 'decimal:2',
|
|
'netto_da_pagare' => 'decimal:2',
|
|
'dati_fornitura' => 'array',
|
|
];
|
|
|
|
public function stabile(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Stabile::class, 'stabile_id');
|
|
}
|
|
|
|
public function gestione(): BelongsTo
|
|
{
|
|
return $this->belongsTo(GestioneContabile::class, 'gestione_id');
|
|
}
|
|
|
|
public function fatturaElettronica(): BelongsTo
|
|
{
|
|
return $this->belongsTo(FatturaElettronica::class, 'fattura_elettronica_id');
|
|
}
|
|
|
|
public function fornitore(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Fornitore::class, 'fornitore_id');
|
|
}
|
|
|
|
public function ritenutaPrevidenziale(): BelongsTo
|
|
{
|
|
return $this->belongsTo(FeRitenutaPrevidenziale::class, 'ritenuta_previdenziale_codice', 'codice');
|
|
}
|
|
|
|
public function righe(): HasMany
|
|
{
|
|
return $this->hasMany(FatturaFornitoreRiga::class, 'fattura_id');
|
|
}
|
|
|
|
public function registrazione(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Registrazione::class, 'registrazione_id');
|
|
}
|
|
|
|
public function movimentoPagamento(): BelongsTo
|
|
{
|
|
return $this->belongsTo(MovimentoBanca::class, 'movimento_pagamento_id');
|
|
}
|
|
|
|
public function movimentoVersamentoRa(): BelongsTo
|
|
{
|
|
return $this->belongsTo(MovimentoBanca::class, 'movimento_versamento_ra_id');
|
|
}
|
|
}
|