FIX: Venta nueva no se ingresaba
This commit is contained in:
@ -2,14 +2,17 @@
|
||||
namespace Incoviba\Service;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Ideal\Service;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
use PhpParser\Node\Expr\AssignOp\Mod;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Venta
|
||||
class Venta extends Service
|
||||
{
|
||||
public function __construct(
|
||||
LoggerInterface $logger,
|
||||
protected Repository\Venta $ventaRepository,
|
||||
protected Repository\Venta\EstadoVenta $estadoVentaRepository,
|
||||
protected Repository\Venta\TipoEstadoVenta $tipoEstadoVentaRepository,
|
||||
@ -25,7 +28,9 @@ class Venta
|
||||
protected Venta\BonoPie $bonoPieService,
|
||||
protected Venta\Pago $pagoService,
|
||||
protected Money $moneyService
|
||||
) {}
|
||||
) {
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
public function getById(int $venta_id): Model\Venta
|
||||
{
|
||||
@ -51,6 +56,10 @@ class Venta
|
||||
$ventas = $this->ventaRepository->fetchByUnidad($unidad, $tipo);
|
||||
return array_map([$this, 'process'], $ventas);
|
||||
}
|
||||
public function getByUnidadId(int $unidad_id): Model\Venta
|
||||
{
|
||||
return $this->process($this->ventaRepository->fetchByUnidadId($unidad_id));
|
||||
}
|
||||
public function getByPropietario(string $propietario): array
|
||||
{
|
||||
$ventas = $this->ventaRepository->fetchByPropietario($propietario);
|
||||
@ -89,7 +98,7 @@ class Venta
|
||||
'propietario' => $propietario->rut,
|
||||
'propiedad' => $propiedad->id,
|
||||
'fecha' => $fecha->format('Y-m-d'),
|
||||
'valor_uf' => $data['valor'],
|
||||
'valor_uf' => $this->cleanValue($data['valor']),
|
||||
'fecha_ingreso' => (new DateTimeImmutable())->format('Y-m-d'),
|
||||
'uf' => $data['uf']
|
||||
];
|
||||
@ -249,6 +258,7 @@ class Venta
|
||||
'cuotas',
|
||||
'uf'
|
||||
], $filtered_data);
|
||||
$mapped_data['valor'] = $this->cleanValue($mapped_data['valor']);
|
||||
return $this->pieService->add($mapped_data);
|
||||
}
|
||||
protected function addSubsidio(array $data): Model\Venta\Subsidio
|
||||
@ -307,6 +317,13 @@ class Venta
|
||||
$estado = $this->estadoVentaRepository->create($estadoData);
|
||||
$this->estadoVentaRepository->save($estado);
|
||||
}
|
||||
protected function cleanValue($value): float
|
||||
{
|
||||
if ((float) $value == $value) {
|
||||
return (float) $value;
|
||||
}
|
||||
return (float) str_replace(['.', ','], ['', '.'], $value);
|
||||
}
|
||||
|
||||
public function escriturar(Model\Venta $venta, array $data): bool
|
||||
{
|
||||
|
Reference in New Issue
Block a user