feat(webstatement): tambahkan command untuk ekspor pernyataan rekening berdasarkan periode
- 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>
This commit is contained in:
57
app/Console/ExportPeriodStatements.php
Normal file
57
app/Console/ExportPeriodStatements.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,15 +5,9 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Bus\Dispatcher;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Modules\Webstatement\Jobs\ExportStatementJob;
|
||||
use Modules\Webstatement\Models\AccountBalance;
|
||||
use Modules\Webstatement\Models\StmtEntry;
|
||||
use Modules\Webstatement\Models\TempFundsTransfer;
|
||||
use Modules\Webstatement\Models\TempStmtNarrFormat;
|
||||
use Modules\Webstatement\Models\TempStmtNarrParam;
|
||||
use Modules\Webstatement\Jobs\ExportStatementPeriodJob;
|
||||
|
||||
class WebstatementController extends Controller
|
||||
{
|
||||
@@ -142,9 +136,8 @@
|
||||
}
|
||||
|
||||
|
||||
function printStatementRekening() {
|
||||
$accountNumber = '1234567890';
|
||||
$period = '202505';
|
||||
function printStatementRekening($accountNumber, $period = null) {
|
||||
$period = $period ?? date('Ym');
|
||||
$balance = AccountBalance::where('account_number', $accountNumber)
|
||||
->when($period === '202505', function($query) {
|
||||
return $query->where('period', '>=', '20250512')
|
||||
|
||||
Reference in New Issue
Block a user