Integracion Toku a flujo
This commit is contained in:
@ -4,6 +4,7 @@ namespace Incoviba\Service\Venta;
|
||||
use DateTimeInterface;
|
||||
use DateTimeImmutable;
|
||||
use DateMalformedStringException;
|
||||
use Incoviba\Exception\ServiceAction\Create;
|
||||
use Incoviba\Exception\ServiceAction\Read;
|
||||
use Incoviba\Exception\ServiceAction\Update;
|
||||
use PDOException;
|
||||
@ -129,6 +130,11 @@ class Pago
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return Model\Venta\Pago
|
||||
* @throws Create
|
||||
*/
|
||||
public function add(array $data): Model\Venta\Pago
|
||||
{
|
||||
if (array_key_exists('fecha', $data)) {
|
||||
@ -146,16 +152,24 @@ class Pago
|
||||
|
||||
$filtered_data = $this->pagoRepository->filterData($data);
|
||||
|
||||
$pago = $this->pagoRepository->create($filtered_data);
|
||||
$pago = $this->pagoRepository->save($pago);
|
||||
try {
|
||||
$pago = $this->pagoRepository->create($filtered_data);
|
||||
$pago = $this->pagoRepository->save($pago);
|
||||
} catch (PDOException $exception) {
|
||||
throw new Create(__CLASS__, $exception);
|
||||
}
|
||||
|
||||
$tipoEstado = $this->tipoEstadoPagoRepository->fetchByDescripcion('no pagado');
|
||||
$estado = $this->estadoPagoRepository->create([
|
||||
'pago' => $pago->id,
|
||||
'fecha' => $pago->fecha->format('Y-m-d'),
|
||||
'estado' => $tipoEstado->id
|
||||
]);
|
||||
$estado = $this->estadoPagoRepository->save($estado);
|
||||
try {
|
||||
$estado = $this->estadoPagoRepository->create([
|
||||
'pago' => $pago->id,
|
||||
'fecha' => $pago->fecha->format('Y-m-d'),
|
||||
'estado' => $tipoEstado->id
|
||||
]);
|
||||
$estado = $this->estadoPagoRepository->save($estado);
|
||||
} catch (PDOException $exception) {
|
||||
throw new Create(__CLASS__, $exception);
|
||||
}
|
||||
$pago->currentEstado = $estado;
|
||||
return $pago;
|
||||
}
|
||||
|
Reference in New Issue
Block a user