Mostrar correctamente venta desistida

This commit is contained in:
2023-12-21 19:15:11 -03:00
parent 80a6bf1535
commit d7d17a3051
5 changed files with 23 additions and 5 deletions

View File

@ -55,7 +55,7 @@ class Mapper implements Define\Repository\Mapper
if ($this->hasProperty()) { if ($this->hasProperty()) {
$property = $this->property; $property = $this->property;
} }
if (isset($data[$column])) { if (in_array($column, array_keys($data))) {
if ($this->hasFactory()) { if ($this->hasFactory()) {
$model->addFactory($property, $this->factory); $model->addFactory($property, $this->factory);
return true; return true;

View File

@ -26,6 +26,14 @@
<a href="{{$urls->base}}/venta/{{$venta->id}}/ceder"> <a href="{{$urls->base}}/venta/{{$venta->id}}/ceder">
Ceder <i clasS="right chevron icon"></i> Ceder <i clasS="right chevron icon"></i>
</a> </a>
@else
<div class="ui red icon label">
<i class="ban icon"></i>
{{ucwords($venta->currentEstado()->tipoEstadoVenta->descripcion)}}
(<a href="{{$urls->base}}/venta/{{$venta->id}}/desistida">
{{$format->pesos($venta->resciliacion()->valor)}}
</a>)
</div>
@endif @endif
</div> </div>
<div class="ui segments"> <div class="ui segments">

View File

@ -17,6 +17,7 @@ class Venta extends Ideal\Model
public bool $relacionado; public bool $relacionado;
protected ?Venta\Entrega $entrega; protected ?Venta\Entrega $entrega;
public float $uf; public float $uf;
protected ?Pago $resciliacion;
public array $estados; public array $estados;
public Venta\EstadoVenta $currentEstado; public Venta\EstadoVenta $currentEstado;
@ -49,6 +50,13 @@ class Venta extends Ideal\Model
} }
return $this->entrega; return $this->entrega;
} }
public function resciliacion(): ?Venta\Pago
{
if (!isset($this->resciliacion)) {
$this->resciliacion = $this->runFactory('resciliacion');
}
return $this->resciliacion;
}
public function estados(): array public function estados(): array
{ {

View File

@ -115,9 +115,12 @@ class Venta extends Ideal\Repository
->register('fecha_ingreso', new Implement\Repository\Mapper\DateTime('fecha_ingreso', 'fechaIngreso')) ->register('fecha_ingreso', new Implement\Repository\Mapper\DateTime('fecha_ingreso', 'fechaIngreso'))
//->register('avalchile') //->register('avalchile')
//->register('agente') //->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('relacionado', new Implement\Repository\Mapper\Boolean('relacionado'));
//->register('promocion') //->register('promocion')
//->register('resciliacion')
//->register('devolucion'); //->register('devolucion');
return $this->parseData(new Model\Venta(), $data, $map); return $this->parseData(new Model\Venta(), $data, $map);
} }

View File

@ -14,13 +14,13 @@ class Venta
protected Repository\Venta\TipoEstadoVenta $tipoEstadoVentaRepository, protected Repository\Venta\TipoEstadoVenta $tipoEstadoVentaRepository,
protected Repository\Venta\Credito $creditoRepository, protected Repository\Venta\Credito $creditoRepository,
protected Repository\Venta\Escritura $escrituraRepository, protected Repository\Venta\Escritura $escrituraRepository,
protected Repository\Venta\Pago $pagoRepository,
protected Venta\Propietario $propietarioService, protected Venta\Propietario $propietarioService,
protected Venta\Propiedad $propiedadService, protected Venta\Propiedad $propiedadService,
protected Venta\Pie $pieService, protected Venta\Pie $pieService,
protected Venta\Subsidio $subsidioService, protected Venta\Subsidio $subsidioService,
protected Venta\Credito $creditoService, protected Venta\Credito $creditoService,
protected Venta\BonoPie $bonoPieService, protected Venta\BonoPie $bonoPieService,
protected Venta\Pago $pagoService,
protected Money $moneyService protected Money $moneyService
) {} ) {}
@ -384,8 +384,7 @@ class Venta
{ {
try { try {
if ($this->validarData($data, ['fecha', 'devolucion'])) { if ($this->validarData($data, ['fecha', 'devolucion'])) {
$pago = $this->pagoRepository->create(['fecha' => $data['fecha'], 'valor' => $data['devolucion']]); $pago = $this->pagoService->add(['fecha' => $data['fecha'], 'valor' => $data['devolucion']]);
$pago = $this->pagoRepository->save($pago);
$this->ventaRepository->edit($venta, ['resciliacion' => $pago->id]); $this->ventaRepository->edit($venta, ['resciliacion' => $pago->id]);
} }
$tipoEstado = $this->tipoEstadoVentaRepository->fetchByDescripcion('desistida'); $tipoEstado = $this->tipoEstadoVentaRepository->fetchByDescripcion('desistida');