feat(webstatement): perbarui penamaan file PDF dan tambahkan log debug pada PrintStatementController
- **Perubahan Penamaan File PDF:**
- Mengubah format nama file dari `{account_number}.pdf` menjadi `{account_number}_{period_from}.pdf`.
- Penyesuaian pada semua lokasi logika penentuan path file di SFTP:
- Path file period single.
- Path file pada mode period range.
- Path file saat kompresi ke dalam ZIP.
- **Penambahan Logging untuk Debugging:**
- Menambahkan **Log::info** untuk mencatat informasi terkait path file, termasuk:
- Path relatif file berdasarkan periode dan kode cabang.
- Root path konfigurasi SFTP.
- Path final lengkap pada SFTP.
- **Penyesuaian Logika Path:**
- Memastikan format nama file konsisten di semua fungsi handling periode tunggal dan periode range.
- Menambahkan logging sebelum proses pengecekan eksistensi file pada SFTP.
- **Peningkatan Monitoring:**
- Memastikan struktur file dan path dapat dipantau dengan logging untuk mendukung debugging lebih baik.
- Memberikan konteks tambahan pada setiap log yang relevan untuk memudahkan tracking.
Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
This commit is contained in:
@@ -141,7 +141,14 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$disk = Storage::disk('sftpStatement');
|
$disk = Storage::disk('sftpStatement');
|
||||||
$filePath = "{$statement->period_from}/Print/{$statement->branch_code}/{$statement->account_number}.pdf";
|
$filePath = "{$statement->period_from}/{$statement->branch_code}/{$statement->account_number}_{$statement->period_from}.pdf";
|
||||||
|
|
||||||
|
// Log untuk debugging
|
||||||
|
Log::info('Checking SFTP file path', [
|
||||||
|
'file_path' => $filePath,
|
||||||
|
'sftp_root' => config('filesystems.disks.sftpStatement.root'),
|
||||||
|
'full_path' => config('filesystems.disks.sftpStatement.root') . '/' . $filePath
|
||||||
|
]);
|
||||||
|
|
||||||
if ($statement->is_period_range && $statement->period_to) {
|
if ($statement->is_period_range && $statement->period_to) {
|
||||||
$periodFrom = Carbon::createFromFormat('Ym', $statement->period_from);
|
$periodFrom = Carbon::createFromFormat('Ym', $statement->period_from);
|
||||||
@@ -152,7 +159,7 @@
|
|||||||
|
|
||||||
for ($period = clone $periodFrom; $period->lte($periodTo); $period->addMonth()) {
|
for ($period = clone $periodFrom; $period->lte($periodTo); $period->addMonth()) {
|
||||||
$periodFormatted = $period->format('Ym');
|
$periodFormatted = $period->format('Ym');
|
||||||
$periodPath = $periodFormatted . "/Print/{$statement->branch_code}/{$statement->account_number}.pdf";
|
$periodPath = $periodFormatted . "/{$statement->branch_code}/{$statement->account_number}_{$periodFormatted}.pdf";
|
||||||
|
|
||||||
if ($disk->exists($periodPath)) {
|
if ($disk->exists($periodPath)) {
|
||||||
$availablePeriods[] = $periodFormatted;
|
$availablePeriods[] = $periodFormatted;
|
||||||
@@ -274,7 +281,7 @@
|
|||||||
|
|
||||||
// Generate or fetch the statement file
|
// Generate or fetch the statement file
|
||||||
$disk = Storage::disk('sftpStatement');
|
$disk = Storage::disk('sftpStatement');
|
||||||
$filePath = "{$statement->period_from}/Print/{$statement->branch_code}/{$statement->account_number}.pdf";
|
$filePath = "{$statement->period_from}/{$statement->branch_code}/{$statement->account_number}_{$statement->period_from}.pdf";
|
||||||
|
|
||||||
if ($statement->is_period_range && $statement->period_to) {
|
if ($statement->is_period_range && $statement->period_to) {
|
||||||
// Handle period range download (existing logic)
|
// Handle period range download (existing logic)
|
||||||
@@ -480,7 +487,7 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$disk = Storage::disk('sftpStatement');
|
$disk = Storage::disk('sftpStatement');
|
||||||
$filePath = "{$statement->period_from}/Print/{$statement->branch_code}/{$statement->account_number}.pdf";
|
$filePath = "{$statement->period_from}/{$statement->branch_code}/{$statement->account_number}_{$statement->period_from}.pdf";
|
||||||
|
|
||||||
if ($statement->is_period_range && $statement->period_to) {
|
if ($statement->is_period_range && $statement->period_to) {
|
||||||
$periodFrom = Carbon::createFromFormat('Ym', $statement->period_from);
|
$periodFrom = Carbon::createFromFormat('Ym', $statement->period_from);
|
||||||
@@ -492,7 +499,7 @@
|
|||||||
|
|
||||||
for ($period = clone $periodFrom; $period->lte($periodTo); $period->addMonth()) {
|
for ($period = clone $periodFrom; $period->lte($periodTo); $period->addMonth()) {
|
||||||
$periodFormatted = $period->format('Ym');
|
$periodFormatted = $period->format('Ym');
|
||||||
$periodPath = $periodFormatted . "/Print/{$statement->branch_code}/{$statement->account_number}.pdf";
|
$periodPath = $periodFormatted . "/{$statement->branch_code}/{$statement->account_number}_{$periodFormatted}.pdf";
|
||||||
|
|
||||||
if ($disk->exists($periodPath)) {
|
if ($disk->exists($periodPath)) {
|
||||||
$availablePeriods[] = $periodFormatted;
|
$availablePeriods[] = $periodFormatted;
|
||||||
@@ -517,7 +524,7 @@
|
|||||||
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
|
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
|
||||||
// Add each available statement to the zip
|
// Add each available statement to the zip
|
||||||
foreach ($availablePeriods as $period) {
|
foreach ($availablePeriods as $period) {
|
||||||
$filePath = "{$period}/Print/{$statement->branch_code}/{$statement->account_number}.pdf";
|
$filePath = "{$period}/{$statement->branch_code}/{$statement->account_number}_{$statement->period_from}.pdf";
|
||||||
$localFilePath = storage_path("app/temp/{$statement->account_number}_{$period}.pdf");
|
$localFilePath = storage_path("app/temp/{$statement->account_number}_{$period}.pdf");
|
||||||
|
|
||||||
// Download the file from SFTP to local storage temporarily
|
// Download the file from SFTP to local storage temporarily
|
||||||
|
|||||||
Reference in New Issue
Block a user