feat(webstatement): tambahkan fitur retry laporan transaksi ATM
- Menambahkan method baru `retry` pada `AtmTransactionReportController` untuk memproses ulang laporan transaksi ATM:
- Mengizinkan retry untuk laporan dengan status `failed` atau `pending`.
- Mereset status laporan menjadi `processing` dan membersihkan informasi error sebelumnya.
- Dispatch ulang job `GenerateAtmTransactionReportJob`.
- Menambahkan mekanisme error handling dengan memperbarui status laporan jika terjadi kegagalan.
- Memperbarui view `atm-reports/index.blade.php`:
- Menambahkan tombol `Retry Job` pada baris laporan dengan status `failed` atau `pending`.
- Menyediakan fungsi JavaScript untuk memproses retry dengan AJAX:
- Menampilkan konfirmasi sebelum retry.
- Reload halaman setelah retry selesai.
- Memperbarui view `atm-reports/show.blade.php`:
- Menambahkan tombol `Retry Job` untuk laporan dengan status `failed`, `pending`, atau `completed` yang kehilangan file.
- Menampilkan form retry dalam pesan error jika file laporan tidak tersedia.
- Memperbarui routing pada `web.php`:
- Menambahkan route baru `atm-reports.retry` untuk endpoint retry dengan HTTP POST.
- Mendaftarkan ulang command `GenerateAtmTransactionReport` pada provider:
- Memastikan job untuk retry sudah terdaftar pada sistem.
Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
This commit is contained in:
@@ -292,4 +292,41 @@ class AtmTransactionReportController extends Controller
|
||||
return redirect()->back()->with('error', 'Failed to send email: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retry generating the ATM transaction report
|
||||
*/
|
||||
public function retry(AtmTransactionReportLog $atmReport)
|
||||
{
|
||||
// Check if retry is allowed (only for failed or pending status)
|
||||
if (!in_array($atmReport->status, ['failed', 'pending'])) {
|
||||
return back()->with('error', 'Report can only be retried if status is failed or pending.');
|
||||
}
|
||||
|
||||
try {
|
||||
// Reset the report status and clear error message
|
||||
$atmReport->update([
|
||||
'status' => 'processing',
|
||||
'error_message' => null,
|
||||
'file_path' => null,
|
||||
'file_size' => null,
|
||||
'record_count' => null,
|
||||
'updated_by' => Auth::id()
|
||||
]);
|
||||
|
||||
// Dispatch the job again
|
||||
GenerateAtmTransactionReportJob::dispatch($atmReport->period, $atmReport->id);
|
||||
|
||||
return back()->with('success', 'ATM Transaction report job has been retried successfully.');
|
||||
|
||||
} catch (Exception $e) {
|
||||
$atmReport->update([
|
||||
'status' => 'failed',
|
||||
'error_message' => $e->getMessage(),
|
||||
'updated_by' => Auth::id()
|
||||
]);
|
||||
|
||||
return back()->with('error', 'Failed to retry report generation: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user