Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| InvoicesSyncPaymentDates | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
| handle | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Console\Commands; |
| 4 | |
| 5 | use App\Jobs\SyncG3WPaymentDatesForRegion; |
| 6 | use Illuminate\Console\Command; |
| 7 | use Illuminate\Support\Facades\Log; |
| 8 | |
| 9 | class InvoicesSyncPaymentDates extends Command |
| 10 | { |
| 11 | /** |
| 12 | * FIRE-1293 — daily delta sync. Dispatches one per-region job that |
| 13 | * polls G3W for any reminder rows with a NULL collection_date in |
| 14 | * the last 90 days. Mirrors the dispatch shape used by |
| 15 | * `invoices:send-reminder` (InvoicesSync.php). |
| 16 | * |
| 17 | * Scheduled at 10:00 in Kernel.php so the 08:00 reminder cron has |
| 18 | * finished before this runs. |
| 19 | */ |
| 20 | protected $signature = 'invoices:sync-payment-dates {region?}'; |
| 21 | |
| 22 | protected $description = 'FIRE-1293: daily delta sync of G3W payment dates into tbl_invoice_reminders'; |
| 23 | |
| 24 | public function handle(): int |
| 25 | { |
| 26 | $regions = $this->argument('region') |
| 27 | ? explode(',', (string) $this->argument('region')) |
| 28 | : ['Cataluña', 'Comunidad Valenciana', 'Madrid']; |
| 29 | |
| 30 | $cronStart = microtime(true); |
| 31 | |
| 32 | foreach ($regions as $region) { |
| 33 | SyncG3WPaymentDatesForRegion::dispatch($region)->onQueue('g3w'); |
| 34 | } |
| 35 | |
| 36 | Log::channel('g3w_invoices')->info('invoices:sync-payment-dates dispatched', [ |
| 37 | 'regions' => count($regions), |
| 38 | 'dispatch_ms' => (int) round((microtime(true) - $cronStart) * 1000), |
| 39 | ]); |
| 40 | |
| 41 | return self::SUCCESS; |
| 42 | } |
| 43 | } |