commit melhorias sgf
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Sgc;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class OrdemCompra extends Model
|
||||
{
|
||||
protected $table = 'sgc_ordens_compra';
|
||||
|
||||
protected $fillable = [
|
||||
'oc_id',
|
||||
'requisicao_id',
|
||||
'data_oc',
|
||||
'fornecedor_id',
|
||||
'centro_custo_id',
|
||||
'categoria',
|
||||
'valor_comprometido',
|
||||
'moeda',
|
||||
'taxa_cambio',
|
||||
'prazo_pagamento_dias',
|
||||
'data_entrega_prevista',
|
||||
'status',
|
||||
'cabimentado',
|
||||
'sgf_compromisso_id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'data_oc' => 'date',
|
||||
'data_entrega_prevista' => 'date',
|
||||
'valor_comprometido' => 'decimal:2',
|
||||
'taxa_cambio' => 'decimal:6',
|
||||
'cabimentado' => 'boolean',
|
||||
];
|
||||
|
||||
public function fornecedor(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Fornecedor::class);
|
||||
}
|
||||
|
||||
public function centroCusto(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CentroCusto::class);
|
||||
}
|
||||
|
||||
public function faturas(): HasMany
|
||||
{
|
||||
return $this->hasMany(Fatura::class, 'ordem_compra_id');
|
||||
}
|
||||
|
||||
public function recebimentos(): HasMany
|
||||
{
|
||||
return $this->hasMany(Recebimento::class, 'ordem_compra_id');
|
||||
}
|
||||
|
||||
public function scopeEmitidas($query)
|
||||
{
|
||||
return $query->where('status', 'Emitida');
|
||||
}
|
||||
|
||||
public function scopeCabimentadas($query)
|
||||
{
|
||||
return $query->where('cabimentado', true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user