This commit is contained in:
Juan Pablo Vial
2023-09-07 23:03:21 -03:00
parent 59825259b6
commit fa15da1ee2
40 changed files with 1787 additions and 71 deletions

View File

@ -1,6 +1,7 @@
<?php
namespace Incoviba\Service\Venta;
use DateTimeInterface;
use DateTimeImmutable;
use PDOException;
use Incoviba\Repository;
@ -12,13 +13,45 @@ class Pago
protected Repository\Venta\EstadoPago $estadoPagoRepository,
protected Repository\Venta\TipoEstadoPago $tipoEstadoPagoRepository) {}
public function depositar(Model\Venta\Pago $pago): bool
public function depositar(Model\Venta\Pago $pago, DateTimeInterface $fecha): bool
{
$tipo_estado = $this->tipoEstadoPagoRepository->fetchByDescripcion('depositado');
$data = [
'pago' => $pago->id,
'estado' => $tipo_estado->id,
'fecha' => (new DateTimeImmutable())->format('Y-m-d')
'fecha' => $fecha->format('Y-m-d')
];
try {
$estado = $this->estadoPagoRepository->create($data);
$this->estadoPagoRepository->save($estado);
return true;
} catch (PDOException) {
return false;
}
}
public function abonar(Model\Venta\Pago $pago, DateTimeInterface $fecha): bool
{
$tipo_estado = $this->tipoEstadoPagoRepository->fetchByDescripcion('abonado');
$data = [
'pago' => $pago->id,
'estado' => $tipo_estado->id,
'fecha' => $fecha->format('Y-m-d')
];
try {
$estado = $this->estadoPagoRepository->create($data);
$this->estadoPagoRepository->save($estado);
return true;
} catch (PDOException) {
return false;
}
}
public function devolver(Model\Venta\Pago $pago, DateTimeInterface $fecha): bool
{
$tipo_estado = $this->tipoEstadoPagoRepository->fetchByDescripcion('devuelto');
$data = [
'pago' => $pago->id,
'estado' => $tipo_estado->id,
'fecha' => $fecha->format('Y-m-d')
];
try {
$estado = $this->estadoPagoRepository->create($data);
@ -35,4 +68,17 @@ class Pago
$pago->currentEstado = $this->estadoPagoRepository->fetchCurrentByPago($pago_id);
return $pago;
}
public function getPendientes(): array
{
return [];
}
public function getDepositados(): array
{
return [];
}
public function getRebotes(): array
{
return [];
}
}