Comando para resetear Toku

This commit is contained in:
Juan Pablo Vial
2025-05-27 18:17:56 -04:00
parent a9a10e012d
commit 892cdf324f
8 changed files with 114 additions and 0 deletions

View File

@ -51,6 +51,26 @@ class Invoice extends AbstractEndPoint
$request_uri = "/invoices/{$id}";
$this->sendDelete($request_uri, [204], [404, 409]);
}
public function reset(array $skip = []): array
{
try {
$invoices = $this->invoiceRepository->fetchAll();
$invoices = array_filter($invoices, function (Model\Venta\MediosPago\Toku\Invoice $invoice) use ($skip) {
return !in_array($invoice->toku_id, $skip);
});
} catch (EmptyResult $exception) {
$this->logger->warning($exception);
return [];
}
foreach ($invoices as $invoice) {
try {
$this->delete($invoice->toku_id);
} catch (EmptyResponse $exception) {
$this->logger->warning($exception, ['invoice' => $invoice]);
}
}
return $invoices;
}
/**
* @param string $customer_id