config
This commit is contained in:
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\nuevo\Common\UF;
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Cuenta cuenta_de
|
||||
* @property Cuenta cuenta_para
|
||||
* @property int valor
|
||||
* @property Date fecha
|
||||
* @property string glosa
|
||||
*
|
||||
*/
|
||||
|
||||
class TransaccionContable extends NewModel
|
||||
{
|
||||
protected static $_table = 'transaccion_contables';
|
||||
|
||||
public function de()
|
||||
{
|
||||
return $this->belongsTo(CuentaContable::class, 'cuenta_de');
|
||||
}
|
||||
public function para()
|
||||
{
|
||||
return $this->belongsTo(CuentaContable::class, 'cuenta_para');
|
||||
}
|
||||
|
||||
public function valor($tipo = 'pesos')
|
||||
{
|
||||
if ($tipo == 'ufs') {
|
||||
$uf = model(UF::class)->where('fecha', $this->fecha)->findOne();
|
||||
if (!$uf) {
|
||||
$uf = model(UF::class)->create();
|
||||
$uf->fecha = $this->fecha;
|
||||
$uf->getValor();
|
||||
$uf->save();
|
||||
}
|
||||
return ($this->valor / $uf->valor) ?: 0;
|
||||
}
|
||||
return $this->valor;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user