32 lines
985 B
PHP
32 lines
985 B
PHP
![]() |
<?php
|
||
|
namespace Incoviba\Service\Ventas;
|
||
|
|
||
|
use DateTimeImmutable;
|
||
|
use PDOException;
|
||
|
use Incoviba\Repository;
|
||
|
use Incoviba\Model;
|
||
|
|
||
|
class Pago
|
||
|
{
|
||
|
public function __construct(protected Repository\Venta\Pago $pagoRepository,
|
||
|
protected Repository\Venta\EstadoPago $estadoPagoRepository,
|
||
|
protected Repository\Venta\TipoEstadoPago $tipoEstadoPagoRepository) {}
|
||
|
|
||
|
public function depositar(Model\Venta\Pago $pago): bool
|
||
|
{
|
||
|
$tipo_estado = $this->tipoEstadoPagoRepository->fetchByDescripcion('depositado');
|
||
|
$data = [
|
||
|
'pago' => $pago->id,
|
||
|
'estado' => $tipo_estado->id,
|
||
|
'fecha' => (new DateTimeImmutable())->format('Y-m-d')
|
||
|
];
|
||
|
try {
|
||
|
$estado = $this->estadoPagoRepository->create($data);
|
||
|
$this->estadoPagoRepository->save($estado);
|
||
|
return true;
|
||
|
} catch (PDOException) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|