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

@ -261,6 +261,21 @@ class Toku extends Ideal\Service
}
return $output;
}
public function queue(array $venta_ids): array
{
$queues = [];
foreach ($venta_ids as $venta_id) {
if ($this->subscription->queue($venta_id)) {
$queues []= [
'type' => 'request',
'url' => "/api/external/toku/cuotas/{$venta_id}",
'method' => 'post',
'body' => []
];
}
}
return $queues;
}
/**
* @param array $request

View File

@ -94,6 +94,21 @@ class Subscription extends AbstractEndPoint
}
return compact('existingSubscriptions', 'missingVentas');
}
public function queue(int $venta_id): bool
{
try {
$venta = $this->ventaService->getById($venta_id);
} catch (Read $exception) {
$this->logger->warning($exception);
return false;
}
try {
$subscription = $this->subscriptionRepsitory->fetchByVenta($venta_id);
return false;
} catch (EmptyResult) {
return true;
}
}
public function save(array $data): bool
{