- Menambahkan command baru `webstatement:export-period-statements`: - Mendukung opsi parameter `--account_number` dan `--period` untuk menentukan rekening dan periode ekspor. - Memproses data pernyataan rekening dengan memanggil fungsi `printStatementRekening` pada `WebstatementController`. - Menampilkan log proses, termasuk jumlah job ekspor yang berhasil diajukan dan pesan error jika terjadi. - Memperbarui fungsi `printStatementRekening` di `WebstatementController`: - Menambahkan parameter input `$accountNumber` dan `$period` untuk mendukung multi-periode secara dinamis. - Menyesuaikan periode default ke bulan dan tahun saat ini jika parameter tidak disediakan. - Memvalidasi dan mengambil data saldo berdasarkan `account_number` dan `period`. - Tujuan pembaruan ini: - Mendukung efisiensi proses ekspor data rekening dalam periode tertentu. - Memberikan fleksibilitas lebih dalam command-line operasi pengolahan data pernyataan. - Menyediakan feedback proses yang jelas kepada pengguna, baik sukses maupun error. Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
58 lines
1.8 KiB
PHP
58 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Modules\Webstatement\Console;
|
|
|
|
use Exception;
|
|
use Illuminate\Console\Command;
|
|
use Modules\Webstatement\Http\Controllers\WebstatementController;
|
|
|
|
class ExportPeriodStatements extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'webstatement:export-period-statements
|
|
{--account_number= : Account number to process migration}
|
|
{--period= : Period to process migration format Ym contoh. 202506}';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Export period statements for all configured client accounts';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
$accountNumber = $this->option('account_number');
|
|
$period = $this->option('period');
|
|
|
|
$this->info('Starting period statement export process...');
|
|
|
|
|
|
try {
|
|
$controller = app(WebstatementController::class);
|
|
$response = $controller->printStatementRekening($accountNumber, $period);
|
|
|
|
$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;
|
|
}
|
|
}
|
|
}
|