diff --git a/app/Jobs/ExportStatementJob.php b/app/Jobs/ExportStatementJob.php index da7527e..9005df7 100644 --- a/app/Jobs/ExportStatementJob.php +++ b/app/Jobs/ExportStatementJob.php @@ -156,7 +156,7 @@ 'description' => $this->generateNarrative($item), 'end_balance' => $runningBalance, 'actual_date' => $actualDate, - 'recipt_no' => $item->ft?->recipt_no ?? '-', + 'recipt_no' => $item->ft?->recipt_no ?? '-', 'created_at' => now(), 'updated_at' => now(), ]; @@ -371,31 +371,9 @@ if (!empty($this->client)) { // Di fungsi exportToCsv untuk basePath Storage::disk($this->disk)->makeDirectory($basePath); - // Tambahkan permission dan ownership setelah membuat directory - if ($this->disk === 'local') { - $fullPath = storage_path("app/{$basePath}"); - if (is_dir($fullPath)) { - chmod($fullPath, 0777); - if (function_exists('chown') && posix_getuid() === 0) { - @chown(dirname($fullPath), 'www-data'); // Gunakan www-data instead of root - @chgrp(dirname($fullPath), 'www-data'); - } - } - } // Untuk accountPath Storage::disk($this->disk)->makeDirectory($accountPath); - // Tambahkan permission dan ownership setelah membuat directory - if ($this->disk === 'local') { - $fullPath = storage_path("app/{$accountPath}"); - if (is_dir($fullPath)) { - chmod($fullPath, 0777); - if (function_exists('chown') && posix_getuid() === 0) { - @chown(dirname($fullPath), 'www-data'); // Gunakan www-data instead of root - @chgrp(dirname($fullPath), 'www-data'); - } - } - } } $filePath = "{$accountPath}/{$this->fileName}"; diff --git a/app/Jobs/ExportStatementPeriodJob.php b/app/Jobs/ExportStatementPeriodJob.php index 107a9af..7534243 100644 --- a/app/Jobs/ExportStatementPeriodJob.php +++ b/app/Jobs/ExportStatementPeriodJob.php @@ -201,25 +201,27 @@ class ExportStatementPeriodJob implements ShouldQueue $processedData = []; foreach ($entries as $item) { - $globalSequence++; - $runningBalance += (float) $item->amount_lcy; + $globalSequence++; + $runningBalance += (float) $item->amount_lcy; - $actualDate = $this->formatActualDate($item); + $transactionDate = $this->formatTransactionDate($item); + $actualDate = $this->formatActualDate($item); - $processedData[] = [ - 'account_number' => $this->account_number, - 'period' => $this->period, - 'sequence_no' => $globalSequence, - 'transaction_date' => $item->booking_date, - 'reference_number' => $item->trans_reference, - 'transaction_amount' => $item->amount_lcy, - 'transaction_type' => $item->amount_lcy < 0 ? 'D' : 'C', - 'description' => $this->generateNarrative($item), - 'end_balance' => $runningBalance, - 'actual_date' => $actualDate, - 'created_at' => now(), - 'updated_at' => now(), - ]; + $processedData[] = [ + 'account_number' => $this->account_number, + 'period' => $this->period, + 'sequence_no' => $globalSequence, + 'transaction_date' => $item->booking_date, + 'reference_number' => $item->trans_reference, + 'transaction_amount' => $item->amount_lcy, + 'transaction_type' => $item->amount_lcy < 0 ? 'D' : 'C', + 'description' => $this->generateNarrative($item), + 'end_balance' => $runningBalance, + 'actual_date' => $actualDate, + 'recipt_no' => $item->ft?->recipt_no ?? '-', + 'created_at' => now(), + 'updated_at' => now(), + ]; } return $processedData; @@ -480,27 +482,10 @@ class ExportStatementPeriodJob implements ShouldQueue // Buat direktori temp jika belum ada if (!is_dir(dirname($tempPath))) { mkdir(dirname($tempPath), 0777, true); - // Tambahkan pengecekan function dan error handling - if (function_exists('chown') && posix_getuid() === 0) { - @chown(dirname($tempPath), 'www-data'); // Gunakan www-data instead of root - @chgrp(dirname($tempPath), 'www-data'); - } } // Pastikan direktori storage ada Storage::makeDirectory($storagePath); - // Tambahkan permission dan ownership setelah membuat directory - if ($this->disk === 'local') { - $fullPath = storage_path("app/{$storagePath}"); - if (is_dir($fullPath)) { - chmod($fullPath, 0777); - // Tambahkan pengecekan function dan error handling - if (function_exists('chown') && posix_getuid() === 0) { - @chown($fullPath, 'www-data'); // Gunakan www-data instead of root - @chgrp($fullPath, 'www-data'); - } - } - } $period = $this->period; @@ -629,17 +614,7 @@ class ExportStatementPeriodJob implements ShouldQueue $storagePath = "statements/{$this->period}/{$account->branch_code}"; Storage::disk($this->disk)->makeDirectory($storagePath); - // Tambahkan permission dan ownership setelah membuat directory - if ($this->disk === 'local') { - $fullPath = storage_path("app/{$storagePath}"); - if (is_dir($fullPath)) { - chmod($fullPath, 0777); - if (function_exists('chown') && posix_getuid() === 0) { - @chown(dirname($fullPath), 'www-data'); // Gunakan www-data instead of root - @chgrp(dirname($fullPath), 'www-data'); - } - } - } + $filePath = "{$storagePath}/{$this->fileName}"; // Delete existing file if it exists @@ -669,7 +644,6 @@ class ExportStatementPeriodJob implements ShouldQueue // Write to file incrementally to reduce memory usage Storage::disk($this->disk)->append($filePath, $csvContent); - $csvContent = ''; // Reset content after writing }); Log::info("Statement exported to {$this->disk} disk: {$filePath}"); diff --git a/app/Jobs/GenerateMultiAccountPdfJob.php b/app/Jobs/GenerateMultiAccountPdfJob.php index 86d3758..cdb2961 100644 --- a/app/Jobs/GenerateMultiAccountPdfJob.php +++ b/app/Jobs/GenerateMultiAccountPdfJob.php @@ -239,16 +239,6 @@ class GenerateMultiAccountPdfJob implements ShouldQueue // Ensure directory exists Storage::disk('local')->makeDirectory($storagePath); - // Tambahkan permission dan ownership setelah membuat directory - $fullPath = storage_path("app/{$storagePath}"); - if (is_dir($fullPath)) { - chmod($fullPath, 0777); - // Tambahkan pengecekan function dan error handling untuk chown - if (function_exists('chown') && posix_getuid() === 0) { - @chown($fullPath, 'www-data'); // Gunakan www-data instead of root - @chgrp($fullPath, 'www-data'); - } - } // Generate PDF path $pdfPath = storage_path("app/{$fullStoragePath}");