diff --git a/app/common/Implement/Repository/Mapper.php b/app/common/Implement/Repository/Mapper.php
index d54d344..dd23f58 100644
--- a/app/common/Implement/Repository/Mapper.php
+++ b/app/common/Implement/Repository/Mapper.php
@@ -55,7 +55,7 @@ class Mapper implements Define\Repository\Mapper
if ($this->hasProperty()) {
$property = $this->property;
}
- if (isset($data[$column])) {
+ if (in_array($column, array_keys($data))) {
if ($this->hasFactory()) {
$model->addFactory($property, $this->factory);
return true;
diff --git a/app/resources/views/ventas/show.blade.php b/app/resources/views/ventas/show.blade.php
index f60a53a..95dfb44 100644
--- a/app/resources/views/ventas/show.blade.php
+++ b/app/resources/views/ventas/show.blade.php
@@ -26,6 +26,14 @@
Ceder
+ @else
+
@endif
diff --git a/app/src/Model/Venta.php b/app/src/Model/Venta.php
index 19a2c07..50e9bde 100644
--- a/app/src/Model/Venta.php
+++ b/app/src/Model/Venta.php
@@ -17,6 +17,7 @@ class Venta extends Ideal\Model
public bool $relacionado;
protected ?Venta\Entrega $entrega;
public float $uf;
+ protected ?Pago $resciliacion;
public array $estados;
public Venta\EstadoVenta $currentEstado;
@@ -49,6 +50,13 @@ class Venta extends Ideal\Model
}
return $this->entrega;
}
+ public function resciliacion(): ?Venta\Pago
+ {
+ if (!isset($this->resciliacion)) {
+ $this->resciliacion = $this->runFactory('resciliacion');
+ }
+ return $this->resciliacion;
+ }
public function estados(): array
{
diff --git a/app/src/Repository/Venta.php b/app/src/Repository/Venta.php
index d550dfb..ba4102b 100644
--- a/app/src/Repository/Venta.php
+++ b/app/src/Repository/Venta.php
@@ -115,9 +115,12 @@ class Venta extends Ideal\Repository
->register('fecha_ingreso', new Implement\Repository\Mapper\DateTime('fecha_ingreso', 'fechaIngreso'))
//->register('avalchile')
//->register('agente')
+ ->register('resciliacion', (new Implement\Repository\Mapper())
+ ->setFactory((new Implement\Repository\Factory())
+ ->setCallable([$this->pagoService, 'getById'])
+ ->setArgs(['pago_id' => $data['resciliacion']])))
->register('relacionado', new Implement\Repository\Mapper\Boolean('relacionado'));
//->register('promocion')
- //->register('resciliacion')
//->register('devolucion');
return $this->parseData(new Model\Venta(), $data, $map);
}
diff --git a/app/src/Service/Venta.php b/app/src/Service/Venta.php
index 0f485a9..732c785 100644
--- a/app/src/Service/Venta.php
+++ b/app/src/Service/Venta.php
@@ -14,13 +14,13 @@ class Venta
protected Repository\Venta\TipoEstadoVenta $tipoEstadoVentaRepository,
protected Repository\Venta\Credito $creditoRepository,
protected Repository\Venta\Escritura $escrituraRepository,
- protected Repository\Venta\Pago $pagoRepository,
protected Venta\Propietario $propietarioService,
protected Venta\Propiedad $propiedadService,
protected Venta\Pie $pieService,
protected Venta\Subsidio $subsidioService,
protected Venta\Credito $creditoService,
protected Venta\BonoPie $bonoPieService,
+ protected Venta\Pago $pagoService,
protected Money $moneyService
) {}
@@ -384,8 +384,7 @@ class Venta
{
try {
if ($this->validarData($data, ['fecha', 'devolucion'])) {
- $pago = $this->pagoRepository->create(['fecha' => $data['fecha'], 'valor' => $data['devolucion']]);
- $pago = $this->pagoRepository->save($pago);
+ $pago = $this->pagoService->add(['fecha' => $data['fecha'], 'valor' => $data['devolucion']]);
$this->ventaRepository->edit($venta, ['resciliacion' => $pago->id]);
}
$tipoEstado = $this->tipoEstadoVentaRepository->fetchByDescripcion('desistida');