2023-09-12
This commit is contained in:
@ -40,4 +40,9 @@ class Direccion extends Ideal\Repository
|
||||
$query = "SELECT * FROM `{$this->getTable()}` WHERE `calle` = ? AND `numero` = ?";
|
||||
return $this->fetchMany($query, [$calle, $numero]);
|
||||
}
|
||||
public function fetchByCalleAndNumeroAndExtra(string $calle, int $numero, string $extra): Model\Direccion
|
||||
{
|
||||
$query = "SELECT * FROM `{$this->getTable()}` WHERE `calle` = ? AND `numero` = ? AND `extra` = ?";
|
||||
return $this->fetchOne($query, [$calle, $numero, $extra]);
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ class Venta extends Ideal\Repository
|
||||
$this->setTable('venta');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
public function create(?array $data = null): Model\Venta
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser())
|
||||
$map = (new Implement\Repository\MapperParser(['uf']))
|
||||
->register('propietario', (new Implement\Repository\Mapper())
|
||||
->setFactory((new Implement\Repository\Factory())
|
||||
->setCallable([$this->propietarioRepository, 'fetchById'])
|
||||
@ -65,7 +65,7 @@ class Venta extends Ideal\Repository
|
||||
]
|
||||
];
|
||||
foreach ($map as $column => $settings) {
|
||||
if ($data[$column] !== null and $data[$column] !== 0) {
|
||||
if (isset($data[$column]) and $data[$column] !== 0) {
|
||||
if (isset($settings['repository'])) {
|
||||
$fp->{$settings['property'] ?? $column} = $settings['repository']->fetchById($data[$column]);
|
||||
continue;
|
||||
@ -89,7 +89,7 @@ class Venta extends Ideal\Repository
|
||||
->setFunction(function($data) {
|
||||
return $data['escritura'] !== null;
|
||||
}))*/
|
||||
->register('entrega', (new Implement\Repository\Mapper())
|
||||
/*->register('entrega', (new Implement\Repository\Mapper())
|
||||
->setFactory((new Implement\Repository\Factory())
|
||||
->setCallable(function($entrega_id) {
|
||||
if ($entrega_id !== null and $entrega_id !== 0) {
|
||||
@ -97,7 +97,8 @@ class Venta extends Ideal\Repository
|
||||
}
|
||||
return null;
|
||||
})
|
||||
->setArgs([$data['entrega']])))
|
||||
->setArgs([$data['entrega']]))
|
||||
->setDefault(null))*/
|
||||
/*->register('entregado', (new Implement\Repository\Mapper())
|
||||
->setFactory((new Implement\Repository\Factory())
|
||||
->setCallable(function($entrega_id) {
|
||||
@ -114,28 +115,27 @@ class Venta extends Ideal\Repository
|
||||
->register('fecha_ingreso', new Implement\Repository\Mapper\DateTime('fecha_ingreso', 'fechaIngreso'))
|
||||
//->register('avalchile')
|
||||
//->register('agente')
|
||||
//->register('uf')
|
||||
->register('relacionado', new Implement\Repository\Mapper\Boolean('relacionado'));
|
||||
//->register('promocion')
|
||||
//->register('resciliacion')
|
||||
//->register('devolucion');
|
||||
return $this->parseData(new Model\Venta(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Define\Model
|
||||
public function save(Define\Model $model): Model\Venta
|
||||
{
|
||||
$model->id = $this->saveNew(
|
||||
['propietario', 'propiedad', 'pie', 'bono_pie', 'credito', 'escritura', 'subsidio', 'escriturado',
|
||||
'entrega', 'entregado', 'fecha', 'valor_uf', 'estado', 'fecha_ingreso', 'avalchile', 'agente', 'uf',
|
||||
'relacionado', 'promocion', 'resciliacion', 'devolucion'],
|
||||
[$model->propietario->rut, $model->propiedad()->id, $model->formaPago()->Pie?->id, $model->formaPago()->bonoPie?->id,
|
||||
[$model->propietario()->rut, $model->propiedad()->id, $model->formaPago()->pie?->id, $model->formaPago()->bonoPie?->id,
|
||||
$model->formaPago()->credito?->id, $model->formaPago()->escritura?->id, $model->formaPago()->subsidio?->id,
|
||||
$model->formaPago()->escritura !== null ? 1 : 0, null, 0, $model->fecha->format('Y-m-d'), $model->valor,
|
||||
$model->currentEstado->vigente ? 1 : 0, $model->fechaIngreso->format('Y-m-d'), '', null, 0,
|
||||
$model->relacionado ? 1 : 0, null, null, null]
|
||||
$model->formaPago()->escritura !== null ? $model->formaPago()->escritura->pago->fecha->format('Y-m-d') : null,
|
||||
null, null, $model->fecha->format('Y-m-d'), $model->valor, 1, $model->fechaIngreso->format('Y-m-d'),
|
||||
null, null, $model->uf, $model->relacionado ? 1 : 0, null, null, null]
|
||||
);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Define\Model
|
||||
public function edit(Define\Model $model, array $new_data): Model\Venta
|
||||
{
|
||||
return $this->update($model, ['propietario', 'propiedad', 'pie', 'bono_pie', 'credito', 'escritura', 'subsidio', 'escriturado',
|
||||
'entrega', 'entregado', 'fecha', 'valor_uf', 'estado', 'fecha_ingreso', 'avalchile', 'agente', 'uf',
|
||||
@ -155,7 +155,7 @@ WHERE ptu.`proyecto` = ? AND tev.`activa`
|
||||
GROUP BY a.`id`";
|
||||
return $this->fetchMany($query, [$proyecto_id]);
|
||||
}
|
||||
public function fetchByProyectoAndUnidad(string $proyecto_nombre, int $unidad_descripcion): Define\Model
|
||||
public function fetchByProyectoAndUnidad(string $proyecto_nombre, int $unidad_descripcion): Model\Venta
|
||||
{
|
||||
$query = "SELECT a.*
|
||||
FROM `{$this->getTable()}` a
|
||||
@ -168,4 +168,9 @@ FROM `{$this->getTable()}` a
|
||||
WHERE `proyecto`.`descripcion` = ? AND `unidad`.`descripcion` = ? AND tev.`activa`";
|
||||
return $this->fetchOne($query, [$proyecto_nombre, $unidad_descripcion]);
|
||||
}
|
||||
public function fetchByPie(int $pie_id): Model\Venta
|
||||
{
|
||||
$query = "SELECT * FROM `{$this->getTable()}` WHERE `pie` = ?";
|
||||
return $this->fetchOne($query, [$pie_id]);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class Credito extends Ideal\Repository
|
||||
$this->setTable('credito');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
public function create(?array $data = null): Model\Venta\Credito
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser())
|
||||
->register('pago', (new Implement\Repository\Mapper())
|
||||
@ -24,15 +24,15 @@ class Credito extends Ideal\Repository
|
||||
}));
|
||||
return $this->parseData(new Model\Venta\Credito(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Define\Model
|
||||
public function save(Define\Model $model): Model\Venta\Credito
|
||||
{
|
||||
$model->id = $this->saveNew(
|
||||
['banco', 'valor', 'fecha', 'uf', 'abonado', 'fecha_abono', 'pago'],
|
||||
[$model->pago->banco->id, $model->pago->valor, $model->pago->fecha->format('Y-m-d'), $model->pago->uf, null, null, $model->pago->id]
|
||||
[$model->pago->banco?->id, $model->valor ?? (($model->pago->uf > 0) ? $model->pago->valor / $model->pago->uf : null), $model->pago->fecha->format('Y-m-d'), $model->pago->uf, null, null, $model->pago->id]
|
||||
);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Define\Model
|
||||
public function edit(Define\Model $model, array $new_data): Model\Venta\Credito
|
||||
{
|
||||
return $this->update($model, ['banco', 'valor', 'fecha', 'uf', 'abonado', 'fecha_abono', 'pago'], $new_data);
|
||||
}
|
||||
|
@ -23,14 +23,17 @@ class Cuota extends Ideal\Repository
|
||||
$this->setTable('cuota');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
public function create(?array $data = null): Model\Venta\Cuota
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser(['valor', 'uf', 'numero']))
|
||||
$map = (new Implement\Repository\MapperParser(['uf', 'numero']))
|
||||
->register('pie', (new Implement\Repository\Mapper())
|
||||
->setFunction(function($data) {
|
||||
return $this->pieRepository->fetchById($data['pie']);
|
||||
}))
|
||||
->register('fecha', new Implement\Repository\Mapper\DateTime('fecha'))
|
||||
->register('valor_$', (new Implement\Repository\Mapper())
|
||||
->setProperty('valor')
|
||||
)
|
||||
->register('estado', new Implement\Repository\Mapper\Boolean('estado'))
|
||||
->register('banco', (new Implement\Repository\Mapper())
|
||||
->setFunction(function($data) {
|
||||
@ -55,18 +58,18 @@ class Cuota extends Ideal\Repository
|
||||
return $this->parseData(new Model\Venta\Cuota(), $data, $map);
|
||||
}
|
||||
|
||||
public function save(Define\Model $model): Define\Model
|
||||
public function save(Define\Model $model): Model\Venta\Cuota
|
||||
{
|
||||
$model->id = $this->saveNew(
|
||||
['pie', 'fecha', 'valor', 'estado', 'banco', 'fecha_pago', 'abonado', 'fecha_abonado', 'uf', 'pago', 'numero'],
|
||||
[$model->pie->id, $model->fecha->format('Y-m-d H:i:s'), $model->valor, $model->estado ? 1 : 0, $model?->banco->id,
|
||||
$model?->fechaPago->format('Y-m-d H:i:s'), $model?->abonado ? 1 : 0, $model?->fechaAbonado->format('Y-m-d H:i:s'),
|
||||
$model?->uf, $model?->pago->id, $model?->numero]
|
||||
['pie', 'fecha', 'valor_$', 'estado', 'banco', 'fecha_pago', 'abonado', 'fecha_abono', 'uf', 'pago', 'numero'],
|
||||
[$model->pie->id, $model->fecha->format('Y-m-d H:i:s'), $model->valor, $model->estado ? 1 : 0, $model->banco?->id,
|
||||
null, null, null,
|
||||
$model->uf, $model->pago->id, $model->numero]
|
||||
);
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function edit(Define\Model $model, array $new_data): Define\Model
|
||||
public function edit(Define\Model $model, array $new_data): Model\Venta\Cuota
|
||||
{
|
||||
return $this->update($model, ['pie', 'fecha', 'valor', 'estado', 'banco', 'fecha_pago', 'abonado', 'fecha_abonado', 'uf', 'pago', 'numero'], $new_data);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class EstadoPago extends Ideal\Repository
|
||||
$this->setTable('estado_pago');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
public function create(?array $data = null): Model\Venta\EstadoPago
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser())
|
||||
->register('pago', (new Implement\Repository\Mapper())
|
||||
@ -34,7 +34,7 @@ class EstadoPago extends Ideal\Repository
|
||||
return $this->parseData(new Model\Venta\EstadoPago(), $data, $map);
|
||||
}
|
||||
|
||||
public function save(Define\Model $model): Define\Model
|
||||
public function save(Define\Model $model): Model\Venta\EstadoPago
|
||||
{
|
||||
$model->id = $this->saveNew(
|
||||
['pago', 'estado', 'fecha'],
|
||||
@ -43,7 +43,7 @@ class EstadoPago extends Ideal\Repository
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function edit(Define\Model $model, array $new_data): Define\Model
|
||||
public function edit(Define\Model $model, array $new_data): Model\Venta\EstadoPago
|
||||
{
|
||||
return $this->update($model, ['pago', 'estado', 'fecha'], $new_data);
|
||||
}
|
||||
@ -53,7 +53,7 @@ class EstadoPago extends Ideal\Repository
|
||||
$query = "SELECT * FROM `{$this->getTable()}` WHERE `pago` = ?";
|
||||
return $this->fetchMany($query, [$pago_id]);
|
||||
}
|
||||
public function fetchCurrentByPago(int $pago_id): Define\Model
|
||||
public function fetchCurrentByPago(int $pago_id): Model\Venta\EstadoPago
|
||||
{
|
||||
$query = "SELECT a.*
|
||||
FROM `{$this->getTable()}` a
|
||||
@ -61,7 +61,7 @@ FROM `{$this->getTable()}` a
|
||||
WHERE a.`pago` = ?";
|
||||
return $this->fetchOne($query, [$pago_id]);
|
||||
}
|
||||
public function fetchByPagoAndEstado(int $pago_id, int $estado_id): Define\Model
|
||||
public function fetchByPagoAndEstado(int $pago_id, int $estado_id): Model\Venta\EstadoPago
|
||||
{
|
||||
$query = "SELECT * FROM `{$this->getTable()}` WHERE `pago` = ? AND `estado` = ?";
|
||||
return $this->fetchOne($query, [$pago_id, $estado_id]);
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace Incoviba\Repository\Venta;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
@ -10,13 +9,17 @@ use Incoviba\Repository;
|
||||
|
||||
class Pago extends Ideal\Repository
|
||||
{
|
||||
public function __construct(Define\Connection $connection, protected Repository\Banco $bancoRepository, protected TipoPago $tipoPagoRepository)
|
||||
public function __construct(
|
||||
Define\Connection $connection,
|
||||
protected Repository\Banco $bancoRepository,
|
||||
protected TipoPago $tipoPagoRepository
|
||||
)
|
||||
{
|
||||
parent::__construct($connection);
|
||||
$this->setTable('pago');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
public function create(?array $data = null): Model\Venta\Pago
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser(['valor', 'identificador', 'uf', 'pagador']))
|
||||
->register('banco', (new Implement\Repository\Mapper())
|
||||
@ -45,15 +48,15 @@ class Pago extends Ideal\Repository
|
||||
}));
|
||||
return $this->parseData(new Model\Venta\Pago(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Define\Model
|
||||
public function save(Define\Model $model): Model\Venta\Pago
|
||||
{
|
||||
$model->id = $this->saveNew(
|
||||
['valor', 'banco', 'tipo', 'identificador', 'fecha', 'uf', 'pagador', 'asociado'],
|
||||
[$model->valor, $model?->banco->id, $model?->tipoPago->id, $model?->identificador, $model?->fecha->format('Y-m-d H:i:s'), $model?->uf, $model?->pagador, $model?->asociado->id]
|
||||
[$model->valor, $model->banco?->id, $model->tipoPago?->id, $model->identificador, $model->fecha?->format('Y-m-d H:i:s'), $model->uf, $model->pagador, $model->asociado?->id]
|
||||
);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Define\Model
|
||||
public function edit(Define\Model $model, array $new_data): Model\Venta\Pago
|
||||
{
|
||||
return $this->update($model, ['valor', 'banco', 'tipo', 'identificador', 'fecha', 'uf', 'pagador', 'asociado'], $new_data);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class Pie extends Ideal\Repository
|
||||
$this->setTable('pie');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
public function create(?array $data = null): Model\Venta\Pie
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser(['valor', 'uf', 'cuotas']))
|
||||
->register('fecha', new Implement\Repository\Mapper\DateTime('fecha'))
|
||||
@ -35,15 +35,15 @@ class Pie extends Ideal\Repository
|
||||
}));
|
||||
return $this->parseData(new Model\Venta\Pie(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Define\Model
|
||||
public function save(Define\Model $model): Model\Venta\Pie
|
||||
{
|
||||
$model->id = $this->saveNew(
|
||||
['fecha', 'valor', 'uf', 'cuotas', 'asociado', 'reajuste'],
|
||||
[$model->fecha->format('Y-m-d H:i:s'), $model->valor, $model?->uf, $model->cuotas, $model?->asociado->id, $model?->reajuste->id]
|
||||
[$model->fecha->format('Y-m-d H:i:s'), $model->valor, $model->uf, $model->cuotas, $model->asociado?->id, $model->reajuste?->id]
|
||||
);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Define\Model
|
||||
public function edit(Define\Model $model, array $new_data): Model\Venta\Pie
|
||||
{
|
||||
return $this->update($model, ['fecha', 'valor', 'uf', 'cuotas', 'asociado', 'reajuste'], $new_data);
|
||||
}
|
||||
|
@ -15,27 +15,39 @@ class Propiedad extends Ideal\Repository
|
||||
$this->setTable('propiedad');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
public function create(?array $data = null): Model\Venta\Propiedad
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser())
|
||||
->register('unidad_principal', (new Implement\Repository\Mapper())
|
||||
->setProperty('unidades')
|
||||
->setFunction(function($data) {
|
||||
return $this->unidadService->getByPropiedad($data['id']);
|
||||
if (isset($data['id'])) {
|
||||
return $this->unidadService->getByPropiedad($data['id']);
|
||||
}
|
||||
return [$this->unidadService->getById($data['unidad_principal'])];
|
||||
}))
|
||||
->register('estado', new Implement\Repository\Mapper\Boolean('estado'));
|
||||
return $this->parseData(new Model\Venta\Propiedad(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Define\Model
|
||||
public function save(Define\Model $model): Model\Venta\Propiedad
|
||||
{
|
||||
$model->id = $this->saveNew(
|
||||
['unidad_principal', 'estacionamientos', 'bodegas', 'estado'],
|
||||
[$model->departamentos()[0]->id, null, null, 1]
|
||||
[$model->departamentos()[0]->id,
|
||||
implode(',', array_map(function(Model\Venta\Unidad $unidad) {return $unidad->id;}, $model->estacionamientos())),
|
||||
implode(',', array_map(function(Model\Venta\Unidad $unidad) {return $unidad->id;}, $model->bodegas())),
|
||||
1]
|
||||
);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Define\Model
|
||||
public function edit(Define\Model $model, array $new_data): Model\Venta\Propiedad
|
||||
{
|
||||
return $this->update($model, ['unidad_principal', 'estacionamientos', 'bodegas', 'estado'], $new_data);
|
||||
}
|
||||
|
||||
public function fetchVigenteByUnidad(int $unidad_id): Model\Venta\Propiedad
|
||||
{
|
||||
$query = "SELECT * FROM `{$this->getTable()}` WHERE `unidad_principal` = ?";
|
||||
return $this->fetchOne($query, [$unidad_id]);
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,13 @@ class Propietario extends Ideal\Repository
|
||||
}
|
||||
return $this->fetchById($data['representante']);
|
||||
}))
|
||||
->register('otro', (new Implement\Repository\Mapper\Boolean('otro'))
|
||||
->register('otro', (new Implement\Repository\Mapper())
|
||||
->setFunction(function($data) {
|
||||
if ($data['otro'] === null or $data['otro'] === 0) {
|
||||
return null;
|
||||
}
|
||||
return $this->fetchById($data['otro']);
|
||||
})
|
||||
->setDefault(null));
|
||||
return $this->parseData(new Model\Venta\Propietario(), $data, $map);
|
||||
}
|
||||
@ -58,14 +64,14 @@ class Propietario extends Ideal\Repository
|
||||
public function save(Define\Model $model): Define\Model
|
||||
{
|
||||
$model->rut = $this->saveNew(
|
||||
['dv', 'nombres', 'apellido_paterno', 'apellido_materno'],
|
||||
[$model->dv, $model->nombres, $model->apellidos['paterno'], $model->apellidos['materno']]
|
||||
['dv', 'nombres', 'apellido_paterno', 'apellido_materno', 'direccion', 'otro', 'representante'],
|
||||
[$model->dv, $model->nombres, $model->apellidos['paterno'], $model->apellidos['materno'], $model->datos->direccion->id, $model->otro->rut ?? 0, $model->representante->rut ?? 0]
|
||||
);
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function edit(Define\Model $model, array $new_data): Define\Model
|
||||
{
|
||||
return $this->update($model, ['dv', 'nombres', 'apellido_paterno', 'apellido_materno'], $new_data);
|
||||
return $this->update($model, ['dv', 'nombres', 'apellido_paterno', 'apellido_materno', 'direccion', 'otro', 'representante'], $new_data);
|
||||
}
|
||||
}
|
||||
|
@ -14,12 +14,12 @@ class Subsidio extends Ideal\Repository
|
||||
$this->setTable('subsidio');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
public function create(?array $data = null): Model\Venta\Subsidio
|
||||
{
|
||||
$map = new Implement\Repository\MapperParser(['pago', 'subsidio']);
|
||||
return $this->parseData(new Model\Venta\Subsidio(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Define\Model
|
||||
public function save(Define\Model $model): Model\Venta\Subsidio
|
||||
{
|
||||
$model->id = $this->saveNew(
|
||||
['pago', 'subsidio'],
|
||||
@ -27,7 +27,7 @@ class Subsidio extends Ideal\Repository
|
||||
);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Define\Model
|
||||
public function edit(Define\Model $model, array $new_data): Model\Venta\Subsidio
|
||||
{
|
||||
return $this->update($model, ['pago', 'subsidio'], $new_data);
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ class TipoEstadoVenta extends Ideal\Repository
|
||||
$this->setTable('tipo_estado_venta');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
public function create(?array $data = null): Model\Venta\TipoEstadoVenta
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser(['descripcion']))
|
||||
->register('activa', new Implement\Repository\Mapper\Boolean('activa'));
|
||||
return $this->parseData(new Model\Venta\TipoEstadoVenta(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Define\Model
|
||||
public function save(Define\Model $model): Model\Venta\TipoEstadoVenta
|
||||
{
|
||||
$model->id = $this->saveNew(
|
||||
['descripcion', 'activa'],
|
||||
@ -28,8 +28,14 @@ class TipoEstadoVenta extends Ideal\Repository
|
||||
);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Define\Model
|
||||
public function edit(Define\Model $model, array $new_data): Model\Venta\TipoEstadoVenta
|
||||
{
|
||||
return $this->update($model, ['descripcion', 'activa'], $new_data);
|
||||
}
|
||||
|
||||
public function fetchByDescripcion(string $descripcion): Model\Venta\TipoEstadoVenta
|
||||
{
|
||||
$query = "SELECT * FROM `{$this->getTable()}` WHERE `descripcion` = ?";
|
||||
return $this->fetchOne($query, [$descripcion]);
|
||||
}
|
||||
}
|
||||
|
@ -14,12 +14,12 @@ class TipoPago extends Ideal\Repository
|
||||
$this->setTable('tipo_pago');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
public function create(?array $data = null): Model\Venta\TipoPago
|
||||
{
|
||||
$map = new Implement\Repository\MapperParser(['descripcion']);
|
||||
return $this->parseData(new Model\Venta\TipoPago(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Define\Model
|
||||
public function save(Define\Model $model): Model\Venta\TipoPago
|
||||
{
|
||||
$model->id = $this->saveNew(
|
||||
['descripcion'],
|
||||
@ -27,8 +27,14 @@ class TipoPago extends Ideal\Repository
|
||||
);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Define\Model
|
||||
public function edit(Define\Model $model, array $new_data): Model\Venta\TipoPago
|
||||
{
|
||||
return $this->update($model, ['descripcion'], $new_data);
|
||||
}
|
||||
|
||||
public function fetchByDescripcion(string $descripcion): Model\Venta\TipoPago
|
||||
{
|
||||
$query = "SELECT * FROM `{$this->getTable()}` WHERE `descripcion` = ?";
|
||||
return $this->fetchOne($query, [$descripcion]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user