This commit is contained in:
Juan Pablo Vial
2025-03-03 14:57:22 -03:00
parent d165440483
commit 8f16f33a1e
56 changed files with 749 additions and 105 deletions

View File

@ -4,6 +4,7 @@ namespace Incoviba\Service;
use Exception;
use DateTimeImmutable;
use DateInterval;
use DateMalformedStringException;
use Psr\Log\LoggerInterface;
use Incoviba\Common\Ideal\Service;
use Incoviba\Common\Implement;
@ -98,7 +99,7 @@ class Venta extends Service
public function getFacturacionById(int $venta_id): array
{
$venta = $this->getById($venta_id);
$escritura = (in_array($venta->currentEstado()->tipoEstadoVenta->descripcion, ['escriturando'])) ? $venta->currentEstado()->fecha : $venta->fecha;
$escritura = (in_array($venta->currentEstado()->tipoEstadoVenta->descripcion, ['escriturando', 'firmado por inmobiliaria'])) ? $venta->currentEstado()->fecha : $venta->fecha;
$data = [
'id' => $venta->id,
'fecha' => $venta->fecha->format('Y-m-d'),
@ -289,7 +290,7 @@ class Venta extends Service
{
try {
$fecha = new DateTimeImmutable($data['fecha']);
} catch (\DateMalformedStringException) {
} catch (DateMalformedStringException) {
$fecha = new DateTimeImmutable();
}
$estadoData = [
@ -348,7 +349,7 @@ class Venta extends Service
{
try {
$fecha = new DateTimeImmutable($data['fecha_reajuste']);
} catch (\DateMalformedStringException) {
} catch (DateMalformedStringException) {
$fecha = new DateTimeImmutable();
}
$reajusteData = [
@ -363,7 +364,7 @@ class Venta extends Service
{
try {
$fecha = new DateTimeImmutable($data['fecha_pago']);
} catch (\DateMalformedStringException) {
} catch (DateMalformedStringException) {
$fecha = new DateTimeImmutable();
}
$uf = $this->moneyService->getUF($fecha);
@ -389,7 +390,7 @@ class Venta extends Service
{
try {
$fecha = new DateTimeImmutable($data['fecha']);
} catch (\DateMalformedStringException) {
} catch (DateMalformedStringException) {
$fecha = new DateTimeImmutable();
}
$uf = $this->moneyService->getUF($fecha);
@ -399,15 +400,15 @@ class Venta extends Service
'subsidio' => $this->valorService->clean($data['valor_subsidio']),
'uf' => $uf
];
$subsidio = $this->addSubsidio($subsidioData);
$this->ventaRepository->edit($venta, ['subsidio' => $subsidio->id]);
$formaPago = $this->addFormaPago($subsidioData);
$this->ventaRepository->edit($venta, ['subsidio' => $formaPago->subsidio->id]);
}
protected function editCredito(Model\Venta $venta, array $data): void
{
try {
$fecha = new DateTimeImmutable($data['fecha']);
} catch (\DateMalformedStringException) {
} catch (DateMalformedStringException) {
$fecha = new DateTimeImmutable();
}
$uf = $this->moneyService->getUF($fecha);