70 lines
1.6 KiB
PHP
70 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Sgc;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class Fatura extends Model
|
|
{
|
|
protected $table = 'sgc_faturas';
|
|
|
|
protected $fillable = [
|
|
'fatura_id',
|
|
'ordem_compra_id',
|
|
'fornecedor_id',
|
|
'data_fatura',
|
|
'data_vencimento',
|
|
'data_pagamento',
|
|
'valor_fatura',
|
|
'valor_pago',
|
|
'desconto_obtido',
|
|
'iva_valor',
|
|
'moeda',
|
|
'taxa_cambio',
|
|
'status_3_way_match',
|
|
'status_pagamento',
|
|
'numero_comprovativo',
|
|
'motivo_excecao',
|
|
'sgf_doc_number',
|
|
'sgf_sync_timestamp',
|
|
];
|
|
|
|
protected $casts = [
|
|
'data_fatura' => 'date',
|
|
'data_vencimento' => 'date',
|
|
'data_pagamento' => 'date',
|
|
'valor_fatura' => 'decimal:2',
|
|
'valor_pago' => 'decimal:2',
|
|
'desconto_obtido' => 'decimal:2',
|
|
'iva_valor' => 'decimal:2',
|
|
'taxa_cambio' => 'decimal:6',
|
|
'sgf_sync_timestamp' => 'datetime',
|
|
];
|
|
|
|
public function ordemCompra(): BelongsTo
|
|
{
|
|
return $this->belongsTo(OrdemCompra::class);
|
|
}
|
|
|
|
public function fornecedor(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Fornecedor::class);
|
|
}
|
|
|
|
public function scopeConformes($query)
|
|
{
|
|
return $this->where('status_3_way_match', 'Conforme');
|
|
}
|
|
|
|
public function scopePagas($query)
|
|
{
|
|
return $this->where('status_pagamento', 'Pago');
|
|
}
|
|
|
|
public function scopeComExcecao($query)
|
|
{
|
|
return $this->where('status_3_way_match', 'Com Excecao');
|
|
}
|
|
}
|