- Menambahkan command baru `webstatement:generate-atm-report`: - Membuat laporan transaksi ATM berdasarkan periode yang ditentukan melalui opsi `--period` dengan format `Ymd` (contoh: 20250512). - Melakukan validasi format periode untuk memastikan input sesuai. - Menampilkan pesan error jika format periode tidak valid atau tidak disertakan. - Mengintegrasikan dengan job `GenerateAtmTransactionReportJob`: - Mendukung antrian jalur background untuk pengelolaan laporan besar. - Menyediakan informasi log tambahan, seperti periode laporan dan status pembuatan laporan di background. - Menangani error saat proses: - Menampilkan pesan error detail jika terjadi exception saat dispatch job. Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
60 lines
1.7 KiB
PHP
60 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Modules\Webstatement\Console;
|
|
|
|
use Exception;
|
|
use Illuminate\Console\Command;
|
|
use Modules\Webstatement\Jobs\GenerateAtmTransactionReportJob;
|
|
|
|
class GenerateAtmTransactionReport extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'webstatement:generate-atm-report {--period= : Period to generate report format Ymd, contoh: 20250512}';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Generate ATM Transaction report for specified period';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
$this->info('Starting ATM Transaction report generation...');
|
|
$period = $this->option('period');
|
|
|
|
if (!$period) {
|
|
$this->error('Period parameter is required. Format: Ymd (example: 20250512)');
|
|
return Command::FAILURE;
|
|
}
|
|
|
|
// Validate period format
|
|
if (!preg_match('/^\d{8}$/', $period)) {
|
|
$this->error('Invalid period format. Use Ymd format (example: 20250512)');
|
|
return Command::FAILURE;
|
|
}
|
|
|
|
try {
|
|
// Dispatch the job
|
|
GenerateAtmTransactionReportJob::dispatch($period);
|
|
|
|
$this->info("ATM Transaction report generation job queued for period: {$period}");
|
|
$this->info('The report will be generated in the background.');
|
|
|
|
return Command::SUCCESS;
|
|
} catch (Exception $e) {
|
|
$this->error('Error queuing ATM Transaction report job: ' . $e->getMessage());
|
|
return Command::FAILURE;
|
|
}
|
|
}
|
|
}
|