Enqueue ventas para enviar a Toku

This commit is contained in:
Juan Pablo Vial
2025-05-27 19:24:23 -04:00
parent f32204df97
commit 026474c63c
5 changed files with 74 additions and 2 deletions

View File

@ -31,9 +31,9 @@ class Toku extends Controller
];
try {
$venta = $ventaService->getById($venta_id);
$cuotas = $tokuService->sendCuotas($venta, $input['cuotas']);
$cuotas = $tokuService->sendCuotas($venta, $input['cuotas'] ?? []);
$output['cuotas'] = array_map(function($row) { return $row['cuota_id']; }, $cuotas);
if (count($cuotas) < count($input['cuotas'])) {
if (count($cuotas) < count($input['cuotas'] ?? [])) {
$output['partial'] = true;
} else {
$output['success'] = true;
@ -111,4 +111,21 @@ class Toku extends Controller
$output = $tokuService->reset();
return $this->withJson($response, $output);
}
public function enqueue(ServerRequestInterface $request, ResponseInterface $response,
Service\Queue $queueService, Service\Venta\MediosPago\Toku $tokuService): ResponseInterface
{
$input = $request->getParsedBody();
$output = [
'input' => $input,
'success' => false
];
$queue = $tokuService->queue($input['venta_ids'] ?? []);
if (count($queue) > 0) {
foreach ($queue as $job) {
$queueService->enqueue($job);
}
$output['success'] = true;
}
return $this->withJson($response, $output);
}
}