FIX: Fechas revisadas.
This commit is contained in:
@ -285,12 +285,13 @@ class Venta extends Service
|
||||
return $this->formaPagoService->add($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function addEstado(Model\Venta $venta, Model\Venta\TipoEstadoVenta $tipoEstadoVenta, array $data): void
|
||||
{
|
||||
$fecha = new DateTimeImmutable($data['fecha']);
|
||||
try {
|
||||
$fecha = new DateTimeImmutable($data['fecha']);
|
||||
} catch (\DateMalformedStringException) {
|
||||
$fecha = new DateTimeImmutable();
|
||||
}
|
||||
$estadoData = [
|
||||
'venta' => $venta->id,
|
||||
'estado' => $tipoEstadoVenta->id,
|
||||
@ -343,12 +344,13 @@ class Venta extends Service
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function reajustarEscritura(Model\Venta $venta, array $data): void
|
||||
{
|
||||
$fecha = new DateTimeImmutable($data['fecha_reajuste']);
|
||||
try {
|
||||
$fecha = new DateTimeImmutable($data['fecha_reajuste']);
|
||||
} catch (\DateMalformedStringException) {
|
||||
$fecha = new DateTimeImmutable();
|
||||
}
|
||||
$reajusteData = [
|
||||
'valor' => $this->valorService->clean($data['valor_reajuste']),
|
||||
'fecha' => $fecha->format('Y-m-d')
|
||||
@ -357,12 +359,13 @@ class Venta extends Service
|
||||
$this->pieService->reajustar($pie, $reajusteData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function abonoEscritura(Model\Venta $venta, array $data): void
|
||||
{
|
||||
$fecha = new DateTimeImmutable($data['fecha_pago']);
|
||||
try {
|
||||
$fecha = new DateTimeImmutable($data['fecha_pago']);
|
||||
} catch (\DateMalformedStringException) {
|
||||
$fecha = new DateTimeImmutable();
|
||||
}
|
||||
$uf = $this->moneyService->getUF($fecha);
|
||||
$valor = $data['valor_pago_ufs'] !== '' ? $this->valorService->clean($data['valor_pago_ufs']) * $uf : $this->valorService->clean($data['valor_pago_pesos']);
|
||||
$pagoData = [
|
||||
@ -382,12 +385,13 @@ class Venta extends Service
|
||||
$this->ventaRepository->edit($venta, ['escritura' => $escritura->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function subsidioEscritura(Model\Venta $venta, array $data): void
|
||||
{
|
||||
$fecha = new DateTimeImmutable($data['fecha']);
|
||||
try {
|
||||
$fecha = new DateTimeImmutable($data['fecha']);
|
||||
} catch (\DateMalformedStringException) {
|
||||
$fecha = new DateTimeImmutable();
|
||||
}
|
||||
$uf = $this->moneyService->getUF($fecha);
|
||||
$subsidioData = [
|
||||
'fecha_venta' => $fecha->format('Y-m-d'),
|
||||
@ -399,15 +403,19 @@ class Venta extends Service
|
||||
$this->ventaRepository->edit($venta, ['subsidio' => $subsidio->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function editCredito(Model\Venta $venta, array $data): void
|
||||
{
|
||||
$fecha = new DateTimeImmutable($data['fecha']);
|
||||
try {
|
||||
$fecha = new DateTimeImmutable($data['fecha']);
|
||||
} catch (\DateMalformedStringException) {
|
||||
$fecha = new DateTimeImmutable();
|
||||
}
|
||||
$uf = $this->moneyService->getUF($fecha);
|
||||
$valor = $this->valorService->clean($data['valor_credito']) * $uf;
|
||||
if ($venta->formaPago()->credito === null) {
|
||||
if ($data['valor_credito'] === 0) {
|
||||
return;
|
||||
}
|
||||
$pagoData = [
|
||||
'valor' => $valor,
|
||||
'fecha' => $fecha->format('Y-m-d'),
|
||||
@ -424,6 +432,12 @@ class Venta extends Service
|
||||
$this->ventaRepository->edit($venta, ['credito' => $credito->id]);
|
||||
return;
|
||||
}
|
||||
if ($data['valor_credito'] === 0) {
|
||||
$this->pagoRepository->remove($venta->formaPago()->credito->pago);
|
||||
$this->creditoRepository->remove($venta->formaPago()->credito);
|
||||
$this->ventaRepository->edit($venta, ['credito' => null]);
|
||||
return;
|
||||
}
|
||||
$this->pagoRepository->edit($venta->formaPago()->credito->pago, [
|
||||
'valor' => $valor,
|
||||
'banco' => $data['banco_credito'],
|
||||
|
Reference in New Issue
Block a user