Files
webstatement/app/Console/ExportDailyStatements.php
Daeng Deni Mardaeni b894a2c9c4 feat(webstatement): tambahkan fitur schedule dan console command untuk migrasi dan ekspor data harian
- Menambahkan dua console command baru:
  1. `webstatement:process-daily-migration` untuk memproses migrasi data harian.
  2. `webstatement:export-statements` untuk mengekspor laporan harian.

- Mendefinisikan command `webstatement:process-daily-migration`:
  - Menggunakan `MigrasiController` untuk memproses data migrasi.
  - Menangkap error selama proses migrasi dan memberikan output informasi status.

- Mendefinisikan command `webstatement:export-statements`:
  - Menggunakan `WebstatementController` untuk memproses ekspor laporan harian.
  - Memberikan informasi terkait jumlah job ekspor yang berhasil di-queue dan menangkap error selama proses.

- Menambahkan schedule untuk kedua command:
  1. `webstatement:process-daily-migration` dijalankan setiap hari pukul 09:00 dan log aktivitas disimpan di `daily-migration.log`.
  2. `webstatement:export-statements` dijalankan setiap hari pukul 09:30 dan log aktivitas disimpan di `statement-export.log`.

- Melengkapi `WebstatementServiceProvider` dengan pendaftaran command dan konfigurasi jadwal baru.

Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
2025-05-24 16:12:33 +07:00

52 lines
1.5 KiB
PHP

<?php
namespace Modules\Webstatement\Console;
use Exception;
use Illuminate\Console\Command;
use Modules\Webstatement\Http\Controllers\WebstatementController;
class ExportDailyStatements extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'webstatement:export-statements';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Export daily statements for all configured client accounts';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$this->info('Starting daily statement export process...');
try {
$controller = app(WebstatementController::class);
$response = $controller->index();
$responseData = json_decode($response->getContent(), true);
$this->info($responseData['message']);
// Display summary of jobs queued
$jobCount = count($responseData['jobs'] ?? []);
$this->info("Successfully queued {$jobCount} statement export jobs");
return Command::SUCCESS;
} catch (Exception $e) {
$this->error('Error exporting statements: ' . $e->getMessage());
return Command::FAILURE;
}
}
}