Invoice upload by robot

This commit is contained in:
2026-02-14 00:04:00 +01:00
parent 4f4dff2edd
commit 2b458eccd7
15 changed files with 278 additions and 6 deletions

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Tasks;
use App\Domains\Invoice\Actions\UploadInvoice\UploadInvoiceCommand;
use App\Domains\Invoice\Actions\UploadInvoice\UploadInvoiceRequest;
use App\Repositories\InvoiceRepository;
use Psr\Log\LoggerInterface;
class UploadInvoices implements CronTask {
public function handle(): void
{
if (!app('tenant')->upload_exports) {
return;
}
$invoiceRepository = new InvoiceRepository();
foreach ($invoiceRepository->getUnexportedInvoices() as $invoice) {
app('taskLogger')->info("Uploading invoice {$invoice->invoice_number}");
$request = new UploadInvoiceRequest($invoice);
$command = new UploadInvoiceCommand($request);
if ($command->execute()->success) {
app('taskLogger')->info('Upload successful');
} else {
app('taskLogger')->error('Upload failed');
}
app('taskLogger')->info('------------------------------------');
};
}
}