✨ feat(webstatement): dukung endPeriod dan format folder baru untuk statement
- Ubah konstruksi path SFTP dan storage lokal agar konsisten dengan format folder baru `YYYYMMDD.YYYYMMDD`
- Tambahkan dukungan periode akhir (`endPeriod`) pada alur cetak dan ekspor statement, lengkap dengan propagasi ke view dan log
- Perkuat logging di controller dan job untuk audit proses, serta sesuaikan penamaan file pada jalur PRINT
Rincian Perubahan
- PrintStatementController.php
- Ganti path SFTP awal dari `{$period_from}/{$branch_code}/{$account_number}_{$period_from}.pdf` menjadi:
- `{$periodPath}/PRINT/{$branch_code}/{$account_number}.1.pdf` pada cek file awal
- Gunakan `$periodPath = formatPeriodForFolder($statement->period_from)` untuk semua referensi path
- Iterasi ketersediaan periode:
- Gunakan `formatPeriodForFolder($periodFormatted)` saat membentuk `periodPath` dalam loop bulan
- Generate atau fetch statement:
- Ubah path menjadi `{$periodPath}/{$branch_code}/{$account_number}_{$period}.pdf` untuk konsistensi
- ZIP multi-periode:
- Cari file ZIP pada `statements/{$periodPath}/multi_account/{$statementId}` sesuai format folder baru
- Variabel periode:
- Tambahkan `$endPeriod = $statement->period_to ?? $period` dan propagasikan ke:
- Pemanggilan `generateStatementPdf($norek, $period, $endPeriod, ...)`
- View `statements.stmt` melalui `compact(..., 'endPeriod')`
- Perbarui logging untuk menampilkan `endPeriod`
- Generate PDF:
- Tandai storage path menjadi `statements/{$periodPath}/{$norek}`
- Ubah signature: `generateStatementPdf($norek, $period, $endPeriod, ...)`
- Akses file lokal/SFTP:
- Ubah path storage menjadi `statements/{$periodPath}/{$account->branch_code}/{$filename}`
- Penyesuaian delete path: `statements/{$periodPath}/{$norek}/{$filename}`
- ExportStatementPeriodJob.php
- Tambah properti dan parameter konstruktor: `$endPeriod`
- Ubah inisialisasi periode:
- Ganti `calculatePeriodDates()` menjadi `formatPeriodForFolder()` (metode internal yang menetapkan `startDate` dan `endDate`)
- Jika `$endPeriod` diisi, jadikan akhir bulan dari `endPeriod` sebagai `endDate` pemrosesan
- Render view:
- Tambahkan `endPeriod` ke `compact(...)` agar view mengetahui batas periode akhir
- Storage path:
- Gunakan `formatPeriodForFolder($this->period)` untuk path `statements/{$periodPath}/{$account->branch_code}`
- Controller dispatch:
- Ubah pemanggilan job menjadi `ExportStatementPeriodJob::dispatch($statementId, $accountNumber, $period, $endPeriod, $balance, $clientName)`
- resources/views/statements/stmt.blade.php
- Periode:
- Hitung `periodDates` via `calculatePeriodDates($period)`
- Jika `endPeriod` ada, gunakan `calculatePeriodDates($endPeriod)` sebagai referensi `endDate`
- Data customer:
- Gunakan `$customer` langsung, bukan `$account->customer`
- Kondisional alamat berdasarkan `stmt_sent_type == 'BY.MAIL.TO.DOM.ADDR'`:
- Utamakan `l_dom_street` jika tersedia, fallback ke `address`
- Susun RT/RW/kelurahan/kota/provinsi/kode pos sesuai preferensi pengiriman
- Format angka:
- Penyesuaian spasi dan casting `(float)` untuk konsistensi number_format
- Logging:
- Tambahkan informasi hasil perhitungan period dates untuk audit
This commit is contained in:
@@ -172,7 +172,11 @@ ini_set('max_execution_time', 300000);
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$disk = Storage::disk('sftpStatement');
|
$disk = Storage::disk('sftpStatement');
|
||||||
$filePath = "{$statement->period_from}/{$statement->branch_code}/{$statement->account_number}_{$statement->period_from}.pdf";
|
|
||||||
|
// Convert period format from YYYYMM to YYYYMMDD.YYYYMMDD for folder path
|
||||||
|
$periodPath = formatPeriodForFolder($statement->period_from);
|
||||||
|
|
||||||
|
$filePath = "{$periodPath}/PRINT/{$statement->branch_code}/{$statement->account_number}.1.pdf";
|
||||||
|
|
||||||
// Log untuk debugging
|
// Log untuk debugging
|
||||||
Log::info('Checking SFTP file path', [
|
Log::info('Checking SFTP file path', [
|
||||||
@@ -190,7 +194,8 @@ ini_set('max_execution_time', 300000);
|
|||||||
|
|
||||||
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 . "/{$statement->branch_code}/{$statement->account_number}_{$periodFormatted}.pdf";
|
$periodFolderPath = formatPeriodForFolder($periodFormatted);
|
||||||
|
$periodPath = $periodFolderPath . "/{$statement->branch_code}/{$statement->account_number}_{$periodFormatted}.pdf";
|
||||||
|
|
||||||
if ($disk->exists($periodPath)) {
|
if ($disk->exists($periodPath)) {
|
||||||
$availablePeriods[] = $periodFormatted;
|
$availablePeriods[] = $periodFormatted;
|
||||||
@@ -320,7 +325,8 @@ ini_set('max_execution_time', 300000);
|
|||||||
|
|
||||||
// Generate or fetch the statement file
|
// Generate or fetch the statement file
|
||||||
$disk = Storage::disk('sftpStatement');
|
$disk = Storage::disk('sftpStatement');
|
||||||
$filePath = "{$statement->period_from}/{$statement->branch_code}/{$statement->account_number}_{$statement->period_from}.pdf";
|
$periodPath = formatPeriodForFolder($statement->period_from);
|
||||||
|
$filePath = "{$periodPath}/{$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) {
|
||||||
// Log: Memulai proses download period range
|
// Log: Memulai proses download period range
|
||||||
@@ -343,7 +349,8 @@ ini_set('max_execution_time', 300000);
|
|||||||
|
|
||||||
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 . "/{$statement->branch_code}/{$statement->account_number}_{$periodFormatted}.pdf";
|
$periodFolderPath = formatPeriodForFolder($periodFormatted);
|
||||||
|
$periodPath = $periodFolderPath . "/{$statement->branch_code}/{$statement->account_number}_{$periodFormatted}.pdf";
|
||||||
|
|
||||||
if ($disk->exists($periodPath)) {
|
if ($disk->exists($periodPath)) {
|
||||||
$availablePeriods[] = $periodFormatted;
|
$availablePeriods[] = $periodFormatted;
|
||||||
@@ -387,7 +394,8 @@ ini_set('max_execution_time', 300000);
|
|||||||
|
|
||||||
// Add each available statement to the zip
|
// Add each available statement to the zip
|
||||||
foreach ($availablePeriods as $period) {
|
foreach ($availablePeriods as $period) {
|
||||||
$periodFilePath = "{$period}/{$statement->branch_code}/{$statement->account_number}_{$period}.pdf";
|
$periodFolderPath = formatPeriodForFolder($period);
|
||||||
|
$periodFilePath = "{$periodFolderPath}/{$statement->branch_code}/{$statement->account_number}_{$period}.pdf";
|
||||||
$localFilePath = storage_path("app/temp/{$statement->account_number}_{$period}.pdf");
|
$localFilePath = storage_path("app/temp/{$statement->account_number}_{$period}.pdf");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -672,7 +680,8 @@ ini_set('max_execution_time', 300000);
|
|||||||
$localDisk = Storage::disk('local');
|
$localDisk = Storage::disk('local');
|
||||||
$sftpDisk = Storage::disk('sftpStatement');
|
$sftpDisk = Storage::disk('sftpStatement');
|
||||||
|
|
||||||
$filePath = "{$statement->period_from}/{$statement->branch_code}/{$statement->account_number}_{$statement->period_from}.pdf";
|
$periodPath = formatPeriodForFolder($statement->period_from);
|
||||||
|
$filePath = "{$periodPath}/{$statement->branch_code}/{$statement->account_number}_{$statement->period_from}.pdf";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fungsi helper untuk mendapatkan file dari disk dengan prioritas local
|
* Fungsi helper untuk mendapatkan file dari disk dengan prioritas local
|
||||||
@@ -722,7 +731,8 @@ ini_set('max_execution_time', 300000);
|
|||||||
|
|
||||||
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}/{$statement->branch_code}/{$statement->account_number}_{$periodFormatted}.pdf";
|
$periodFolderPath = formatPeriodForFolder($periodFormatted);
|
||||||
|
$periodPath = "{$periodFolderPath}/{$statement->branch_code}/{$statement->account_number}_{$periodFormatted}.pdf";
|
||||||
|
|
||||||
$fileInfo = $getFileFromDisk($periodPath);
|
$fileInfo = $getFileFromDisk($periodPath);
|
||||||
|
|
||||||
@@ -910,6 +920,7 @@ ini_set('max_execution_time', 300000);
|
|||||||
|
|
||||||
$norek = $statement->account_number;
|
$norek = $statement->account_number;
|
||||||
$period = $statement->period_from;
|
$period = $statement->period_from;
|
||||||
|
$endPeriod = $statement->period_to ?? $period;
|
||||||
$format='pdf';
|
$format='pdf';
|
||||||
|
|
||||||
// Generate nama file PDF
|
// Generate nama file PDF
|
||||||
@@ -981,20 +992,21 @@ ini_set('max_execution_time', 300000);
|
|||||||
Log::info('Statement data prepared successfully', [
|
Log::info('Statement data prepared successfully', [
|
||||||
'account_number' => $norek,
|
'account_number' => $norek,
|
||||||
'period' => $period,
|
'period' => $period,
|
||||||
|
'endPeriod' => $endPeriod ?? $period,
|
||||||
'saldo_period' => $saldoPeriod,
|
'saldo_period' => $saldoPeriod,
|
||||||
'saldo_awal' => $saldoAwalBulan->actual_balance ?? 0,
|
'saldo_awal' => $saldoAwalBulan->actual_balance ?? 0,
|
||||||
'entries_count' => $stmtEntries->count()
|
'entries_count' => $stmtEntries->count()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$periodDates = calculatePeriodDates($period);
|
$periodDates = formatPeriodForFolder($period);
|
||||||
|
|
||||||
// Jika format adalah PDF, generate PDF
|
// Jika format adalah PDF, generate PDF
|
||||||
if ($format === 'pdf') {
|
if ($format === 'pdf') {
|
||||||
return $this->generateStatementPdf($norek, $period, $stmtEntries, $account, $customer, $headerTableBg, $branch, $saldoAwalBulan, $statement->id, $tempPath, $filename);
|
return $this->generateStatementPdf($norek, $period, $endPeriod, $stmtEntries, $account, $customer, $headerTableBg, $branch, $saldoAwalBulan, $statement->id, $tempPath, $filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default return HTML view
|
// Default return HTML view
|
||||||
return view('webstatement::statements.stmt', compact('stmtEntries', 'account', 'customer', 'headerTableBg', 'branch', 'period', 'saldoAwalBulan'));
|
return view('webstatement::statements.stmt', compact('stmtEntries', 'account', 'customer', 'headerTableBg', 'branch', 'period', 'saldoAwalBulan', 'endPeriod'));
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
@@ -1032,7 +1044,7 @@ ini_set('max_execution_time', 300000);
|
|||||||
* @param object $saldoAwalBulan Data saldo awal
|
* @param object $saldoAwalBulan Data saldo awal
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
protected function generateStatementPdf($norek, $period, $stmtEntries, $account, $customer, $headerTableBg, $branch, $saldoAwalBulan, $statementId, $tempPath, $filename)
|
protected function generateStatementPdf($norek, $period, $endPeriod, $stmtEntries, $account, $customer, $headerTableBg, $branch, $saldoAwalBulan, $statementId, $tempPath, $filename)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
@@ -1040,6 +1052,7 @@ ini_set('max_execution_time', 300000);
|
|||||||
Log::info('Starting PDF generation with storage', [
|
Log::info('Starting PDF generation with storage', [
|
||||||
'account_number' => $norek,
|
'account_number' => $norek,
|
||||||
'period' => $period,
|
'period' => $period,
|
||||||
|
'endPeriod' => $endPeriod ?? $period,
|
||||||
'user_id' => Auth::id()
|
'user_id' => Auth::id()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -1051,10 +1064,12 @@ ini_set('max_execution_time', 300000);
|
|||||||
'headerTableBg',
|
'headerTableBg',
|
||||||
'branch',
|
'branch',
|
||||||
'period',
|
'period',
|
||||||
|
'endPeriod',
|
||||||
'saldoAwalBulan'
|
'saldoAwalBulan'
|
||||||
))->render();
|
))->render();
|
||||||
// Tentukan path storage
|
// Tentukan path storage dengan format folder baru
|
||||||
$storagePath = "statements/{$period}/{$norek}";
|
$periodPath = formatPeriodForFolder($period);
|
||||||
|
$storagePath = "statements/{$periodPath}/{$norek}";
|
||||||
$fullStoragePath = "{$storagePath}/{$filename}";
|
$fullStoragePath = "{$storagePath}/{$filename}";
|
||||||
|
|
||||||
// Generate PDF menggunakan Browsershot dan simpan langsung ke storage
|
// Generate PDF menggunakan Browsershot dan simpan langsung ke storage
|
||||||
@@ -1230,7 +1245,8 @@ ini_set('max_execution_time', 300000);
|
|||||||
|
|
||||||
$account = Account::where('account_number',$norek)->first();
|
$account = Account::where('account_number',$norek)->first();
|
||||||
|
|
||||||
$storagePath = "statements/{$period}/{$account->branch_code}/{$filename}";
|
$periodPath = formatPeriodForFolder($period);
|
||||||
|
$storagePath = "statements/{$periodPath}/{$account->branch_code}/{$filename}";
|
||||||
|
|
||||||
// Cek apakah file ada di storage
|
// Cek apakah file ada di storage
|
||||||
if (!Storage::disk('local')->exists($storagePath)) {
|
if (!Storage::disk('local')->exists($storagePath)) {
|
||||||
@@ -1289,7 +1305,8 @@ ini_set('max_execution_time', 300000);
|
|||||||
$filename = $this->generatePdfFileName($norek, $period);
|
$filename = $this->generatePdfFileName($norek, $period);
|
||||||
}
|
}
|
||||||
|
|
||||||
$storagePath = "statements/{$period}/{$norek}/{$filename}";
|
$periodPath = formatPeriodForFolder($period);
|
||||||
|
$storagePath = "statements/{$periodPath}/{$norek}/{$filename}";
|
||||||
|
|
||||||
if (Storage::disk('local')->exists($storagePath)) {
|
if (Storage::disk('local')->exists($storagePath)) {
|
||||||
$deleted = Storage::disk('local')->delete($storagePath);
|
$deleted = Storage::disk('local')->delete($storagePath);
|
||||||
@@ -1523,6 +1540,8 @@ ini_set('max_execution_time', 300000);
|
|||||||
|
|
||||||
$accountNumber = $statement->account_number;
|
$accountNumber = $statement->account_number;
|
||||||
$period = $statement->period_from ?? date('Ym');
|
$period = $statement->period_from ?? date('Ym');
|
||||||
|
$endPeriod = $statement->period_to ?? $period;
|
||||||
|
|
||||||
$balance = AccountBalance::where('account_number', $accountNumber)
|
$balance = AccountBalance::where('account_number', $accountNumber)
|
||||||
->when($period === '202505', function($query) {
|
->when($period === '202505', function($query) {
|
||||||
return $query->where('period', '>=', '20250512')
|
return $query->where('period', '>=', '20250512')
|
||||||
@@ -1546,7 +1565,7 @@ ini_set('max_execution_time', 300000);
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dispatch the job
|
// Dispatch the job
|
||||||
$job = ExportStatementPeriodJob::dispatch($statement->id, $accountNumber, $period, $balance, $clientName);
|
$job = ExportStatementPeriodJob::dispatch($statement->id, $accountNumber, $period, $endPeriod, $balance, $clientName);
|
||||||
|
|
||||||
Log::info("Statement export job dispatched successfully", [
|
Log::info("Statement export job dispatched successfully", [
|
||||||
'job_id' => $job->job_id ?? null,
|
'job_id' => $job->job_id ?? null,
|
||||||
@@ -1606,8 +1625,9 @@ ini_set('max_execution_time', 300000);
|
|||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find ZIP file
|
// Find ZIP file dengan format folder baru
|
||||||
$zipFiles = Storage::disk('local')->files("statements/{$statement->period_from}/multi_account/{$statementId}");
|
$periodPath = formatPeriodForFolder($statement->period_from);
|
||||||
|
$zipFiles = Storage::disk('local')->files("statements/{$periodPath}/multi_account/{$statementId}");
|
||||||
|
|
||||||
$zipFile = null;
|
$zipFile = null;
|
||||||
foreach ($zipFiles as $file) {
|
foreach ($zipFiles as $file) {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class ExportStatementPeriodJob implements ShouldQueue
|
|||||||
|
|
||||||
protected $account_number;
|
protected $account_number;
|
||||||
protected $period; // Format: YYYYMM (e.g., 202505)
|
protected $period; // Format: YYYYMM (e.g., 202505)
|
||||||
|
protected $endPeriod; // Format: YYYYMM (e.g., 202505)
|
||||||
protected $saldo;
|
protected $saldo;
|
||||||
protected $disk;
|
protected $disk;
|
||||||
protected $client;
|
protected $client;
|
||||||
@@ -57,11 +58,12 @@ class ExportStatementPeriodJob implements ShouldQueue
|
|||||||
* @param string $client
|
* @param string $client
|
||||||
* @param string $disk
|
* @param string $disk
|
||||||
*/
|
*/
|
||||||
public function __construct(int $statementId, string $account_number, string $period, string $saldo, string $client = '', string $disk = 'local', bool $toCsv = true)
|
public function __construct(int $statementId, string $account_number, string $period, string $endPeriod, string $saldo, string $client = '', string $disk = 'local', bool $toCsv = true)
|
||||||
{
|
{
|
||||||
$this->statementId = $statementId;
|
$this->statementId = $statementId;
|
||||||
$this->account_number = $account_number;
|
$this->account_number = $account_number;
|
||||||
$this->period = $period;
|
$this->period = $period;
|
||||||
|
$this->endPeriod = $endPeriod;
|
||||||
$this->saldo = $saldo;
|
$this->saldo = $saldo;
|
||||||
$this->disk = $disk;
|
$this->disk = $disk;
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
@@ -69,13 +71,13 @@ class ExportStatementPeriodJob implements ShouldQueue
|
|||||||
$this->toCsv = $toCsv;
|
$this->toCsv = $toCsv;
|
||||||
|
|
||||||
// Calculate start and end dates based on period
|
// Calculate start and end dates based on period
|
||||||
$this->calculatePeriodDates();
|
$this->formatPeriodForFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate start and end dates for the given period
|
* Calculate start and end dates for the given period
|
||||||
*/
|
*/
|
||||||
private function calculatePeriodDates(): void
|
private function formatPeriodForFolder(): void
|
||||||
{
|
{
|
||||||
$year = substr($this->period, 0, 4);
|
$year = substr($this->period, 0, 4);
|
||||||
$month = substr($this->period, 4, 2);
|
$month = substr($this->period, 4, 2);
|
||||||
@@ -90,6 +92,13 @@ class ExportStatementPeriodJob implements ShouldQueue
|
|||||||
|
|
||||||
// End date is always the last day of the month
|
// End date is always the last day of the month
|
||||||
$this->endDate = Carbon::createFromDate($year, $month, 1)->endOfMonth()->endOfDay();
|
$this->endDate = Carbon::createFromDate($year, $month, 1)->endOfMonth()->endOfDay();
|
||||||
|
|
||||||
|
// If endPeriod is provided, use it instead of endDate
|
||||||
|
if($this->endPeriod){
|
||||||
|
$year = substr($this->endPeriod, 0, 4);
|
||||||
|
$month = substr($this->endPeriod, 4, 2);
|
||||||
|
$this->endDate = Carbon::createFromDate($year, $month, 1)->endOfMonth()->endOfDay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -478,8 +487,9 @@ class ExportStatementPeriodJob implements ShouldQueue
|
|||||||
// Generate filename
|
// Generate filename
|
||||||
$filename = "{$this->account_number}_{$this->period}.pdf";
|
$filename = "{$this->account_number}_{$this->period}.pdf";
|
||||||
|
|
||||||
// Tentukan path storage
|
// Tentukan path storage dengan format folder baru
|
||||||
$storagePath = "statements/{$this->period}/{$account->branch_code}";
|
$periodPath = formatPeriodForFolder($this->period);
|
||||||
|
$storagePath = "statements/{$periodPath}/{$account->branch_code}";
|
||||||
$tempPath = storage_path("app/temp/{$filename}");
|
$tempPath = storage_path("app/temp/{$filename}");
|
||||||
$fullStoragePath = "{$storagePath}/{$filename}";
|
$fullStoragePath = "{$storagePath}/{$filename}";
|
||||||
|
|
||||||
@@ -492,6 +502,7 @@ class ExportStatementPeriodJob implements ShouldQueue
|
|||||||
Storage::makeDirectory($storagePath);
|
Storage::makeDirectory($storagePath);
|
||||||
|
|
||||||
$period = $this->period;
|
$period = $this->period;
|
||||||
|
$endPeriod = $this->endPeriod;
|
||||||
|
|
||||||
// Render HTML view
|
// Render HTML view
|
||||||
$html = view('webstatement::statements.stmt', compact(
|
$html = view('webstatement::statements.stmt', compact(
|
||||||
@@ -501,6 +512,7 @@ class ExportStatementPeriodJob implements ShouldQueue
|
|||||||
'headerTableBg',
|
'headerTableBg',
|
||||||
'branch',
|
'branch',
|
||||||
'period',
|
'period',
|
||||||
|
'endPeriod',
|
||||||
'saldoAwalBulan'
|
'saldoAwalBulan'
|
||||||
))->render();
|
))->render();
|
||||||
|
|
||||||
@@ -616,7 +628,8 @@ class ExportStatementPeriodJob implements ShouldQueue
|
|||||||
// Determine the base path based on client
|
// Determine the base path based on client
|
||||||
$account = Account::where('account_number', $this->account_number)->first();
|
$account = Account::where('account_number', $this->account_number)->first();
|
||||||
|
|
||||||
$storagePath = "statements/{$this->period}/{$account->branch_code}";
|
$periodPath = formatPeriodForFolder($this->period);
|
||||||
|
$storagePath = "statements/{$periodPath}/{$account->branch_code}";
|
||||||
Storage::disk($this->disk)->makeDirectory($storagePath);
|
Storage::disk($this->disk)->makeDirectory($storagePath);
|
||||||
|
|
||||||
$filePath = "{$storagePath}/{$this->fileName}";
|
$filePath = "{$storagePath}/{$this->fileName}";
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="grid grid-cols-8 gap-5">
|
<div class="grid grid-cols-8 gap-5">
|
||||||
<div class="col-span-2 card">
|
<div class="col-span-2 bg-gray-100 card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3 class="card-title">Request Print Stetement</h3>
|
<h3 class="card-title">Request Print Stetement</h3>
|
||||||
</div>
|
</div>
|
||||||
@@ -71,10 +71,6 @@
|
|||||||
{{ in_array('BY.MAIL.TO.KTP.ADDR', old('stmt_sent_type', $statement->stmt_sent_type ?? [])) ? 'selected' : '' }}>
|
{{ in_array('BY.MAIL.TO.KTP.ADDR', old('stmt_sent_type', $statement->stmt_sent_type ?? [])) ? 'selected' : '' }}>
|
||||||
BY MAIL TO KTP ADDR
|
BY MAIL TO KTP ADDR
|
||||||
</option>
|
</option>
|
||||||
<option value="NO.PRINT"
|
|
||||||
{{ in_array('NO.PRINT', old('stmt_sent_type', $statement->stmt_sent_type ?? [])) ? 'selected' : '' }}>
|
|
||||||
NO PRINT
|
|
||||||
</option>
|
|
||||||
<option value="PRINT"
|
<option value="PRINT"
|
||||||
{{ in_array('PRINT', old('stmt_sent_type', $statement->stmt_sent_type ?? [])) ? 'selected' : '' }}>
|
{{ in_array('PRINT', old('stmt_sent_type', $statement->stmt_sent_type ?? [])) ? 'selected' : '' }}>
|
||||||
PRINT
|
PRINT
|
||||||
|
|||||||
@@ -288,8 +288,12 @@
|
|||||||
@php
|
@php
|
||||||
// Hitung tanggal periode berdasarkan $period
|
// Hitung tanggal periode berdasarkan $period
|
||||||
$periodDates = calculatePeriodDates($period);
|
$periodDates = calculatePeriodDates($period);
|
||||||
|
|
||||||
|
// Jika endPeriod ada, gunakan endPeriod sebagai batas akhir, jika tidak, gunakan period
|
||||||
|
$endPeriodDate = $endPeriod ? calculatePeriodDates($endPeriod) : $periodDates;
|
||||||
|
|
||||||
$startDate = $periodDates['start'];
|
$startDate = $periodDates['start'];
|
||||||
$endDate = $periodDates['end'];
|
$endDate = $endPeriodDate['end'] ?? $periodDates['end'];
|
||||||
|
|
||||||
// Log hasil perhitungan
|
// Log hasil perhitungan
|
||||||
\Log::info('Period dates calculated', [
|
\Log::info('Period dates calculated', [
|
||||||
@@ -366,13 +370,22 @@
|
|||||||
<div class="column">
|
<div class="column">
|
||||||
<p>{{ $branch->name }}</p>
|
<p>{{ $branch->name }}</p>
|
||||||
<p style="text-transform: capitalize">Kepada</p>
|
<p style="text-transform: capitalize">Kepada</p>
|
||||||
<p>{{ $account->customer->name }}</p>
|
<p>{{ $customer->name }}</p>
|
||||||
<p>{{ $account->customer->address }}</p>
|
@if ($account->stmt_sent_type == 'BY.MAIL.TO.DOM.ADDR')
|
||||||
<p>{{ $account->customer->district }}
|
<p>{{ $customer->l_dom_street ?? $customer->address }}</p>
|
||||||
{{ ($account->customer->ktp_rt ?: $account->customer->home_rt) ? 'RT ' . ($account->customer->ktp_rt ?: $account->customer->home_rt) : '' }}
|
<p>{{ $customer->district }}
|
||||||
{{ ($account->customer->ktp_rw ?: $account->customer->home_rw) ? 'RW ' . ($account->customer->ktp_rw ?: $account->customer->home_rw) : '' }}
|
{{ ($customer->ktp_rt ?: $customer->home_rt) ? 'RT ' . ($customer->ktp_rt ?: $customer->home_rt) : '' }}
|
||||||
</p>
|
{{ ($customer->ktp_rw ?: $customer->home_rw) ? 'RW ' . ($customer->ktp_rw ?: $customer->home_rw) : '' }}
|
||||||
<p>{{ trim($account->customer->city . ' ' . ($account->customer->province ? getProvinceCoreName($account->customer->province) . ' ' : '') . ($account->customer->postal_code ?? '')) }}
|
</p>
|
||||||
|
<p>{{ trim($customer->city . ' ' . ($customer->province ? getProvinceCoreName($customer->province) . ' ' : '') . ($customer->postal_code ?? '')) }}
|
||||||
|
@else
|
||||||
|
<p>{{ $customer->address }}</p>
|
||||||
|
<p>{{ $customer->district }}
|
||||||
|
{{ ($customer->ktp_rt ?: $customer->home_rt) ? 'RT ' . ($customer->ktp_rt ?: $customer->home_rt) : '' }}
|
||||||
|
{{ ($customer->ktp_rw ?: $customer->home_rw) ? 'RW ' . ($customer->ktp_rw ?: $customer->home_rw) : '' }}
|
||||||
|
</p>
|
||||||
|
<p>{{ trim($customer->city . ' ' . ($customer->province ? getProvinceCoreName($customer->province) . ' ' : '') . ($customer->postal_code ?? '')) }}
|
||||||
|
@endif
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div style="text-transform: capitalize;" class="column">
|
<div style="text-transform: capitalize;" class="column">
|
||||||
@@ -408,7 +421,7 @@
|
|||||||
<td class="text-right"> </td>
|
<td class="text-right"> </td>
|
||||||
<td class="text-right"> </td>
|
<td class="text-right"> </td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
<strong>{{ number_format((float)$saldoAwalBulan->actual_balance, 2, ',', '.') }}</strong>
|
<strong>{{ number_format((float) $saldoAwalBulan->actual_balance, 2, ',', '.') }}</strong>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@@ -443,10 +456,12 @@
|
|||||||
<td class="text-center">{{ substr($row->actual_date, 0, 10) }}</td>
|
<td class="text-center">{{ substr($row->actual_date, 0, 10) }}</td>
|
||||||
<td>{{ str_replace(['[', ']'], ' ', $narrativeLines[0] ?? '') }}</td>
|
<td>{{ str_replace(['[', ']'], ' ', $narrativeLines[0] ?? '') }}</td>
|
||||||
<td>{{ $row->reference_number }}</td>
|
<td>{{ $row->reference_number }}</td>
|
||||||
<td class="text-right">{{ $debit > 0 ? number_format((float)$debit, 2, ',', '.') : '' }}</td>
|
<td class="text-right">
|
||||||
<td class="text-right">{{ $kredit > 0 ? number_format((float)$kredit, 2, ',', '.') : '' }}
|
{{ $debit > 0 ? number_format((float) $debit, 2, ',', '.') : '' }}</td>
|
||||||
|
<td class="text-right">
|
||||||
|
{{ $kredit > 0 ? number_format((float) $kredit, 2, ',', '.') : '' }}
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">{{ number_format((float)$saldo, 2, ',', '.') }}</td>
|
<td class="text-right">{{ number_format((float) $saldo, 2, ',', '.') }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@for ($i = 1; $i < count($narrativeLines); $i++)
|
@for ($i = 1; $i < count($narrativeLines); $i++)
|
||||||
<tr class="narrative-line">
|
<tr class="narrative-line">
|
||||||
|
|||||||
Reference in New Issue
Block a user