update tgl 27 mei

This commit is contained in:
whywdd 2025-05-27 02:19:04 +07:00
parent d825d1c946
commit 64118b2b7d
3 changed files with 80 additions and 37 deletions

View File

@ -57,9 +57,13 @@ public function exportExcel(Request $request)
try {
$startDate = $request->input('start_date', Carbon::now()->startOfMonth()->format('Y-m-d'));
$endDate = $request->input('end_date', Carbon::now()->endOfMonth()->format('Y-m-d'));
$laporan = LaporanModel::whereBetween('Tanggal', [$startDate, $endDate])
->orderBy('Tanggal', 'desc')
->get();
$sortOrder = $request->input('sort_order', 'asc');
$laporanQuery = LaporanModel::whereBetween('Tanggal', [$startDate, $endDate]);
if ($sortOrder == 'desc') {
$laporan = $laporanQuery->orderBy('Tanggal', 'desc')->get();
} else {
$laporan = $laporanQuery->orderBy('Tanggal', 'asc')->get();
}
$rows = [];
$no = 1;
@ -141,8 +145,8 @@ public function exportExcel(Request $request)
'Kode Akun' => $kodeAkun,
'Nama Akun' => $namaAkun,
'Keterangan' => $item->keterangan . ' ' . $item->nama_karyawan,
'Debit' => $rowDebit > 0 ? number_format($rowDebit, 0, ',', '.') : '-',
'Kredit' => $rowKredit > 0 ? number_format($rowKredit, 0, ',', '.') : '-'
'Debit' => $rowDebit > 0 ? $rowDebit : '',
'Kredit' => $rowKredit > 0 ? $rowKredit : ''
];
}
@ -153,8 +157,8 @@ public function exportExcel(Request $request)
'Kode Akun' => '',
'Nama Akun' => '',
'Keterangan' => 'Total',
'Debit' => number_format($totalDebit, 0, ',', '.'),
'Kredit' => number_format($totalKredit, 0, ',', '.')
'Debit' => $totalDebit,
'Kredit' => $totalKredit
];
$export = new class($rows) implements FromCollection, WithHeadings {
@ -177,9 +181,13 @@ public function exportPDF(Request $request)
try {
$startDate = $request->input('start_date', Carbon::now()->startOfMonth()->format('Y-m-d'));
$endDate = $request->input('end_date', Carbon::now()->endOfMonth()->format('Y-m-d'));
$laporan = LaporanModel::whereBetween('Tanggal', [$startDate, $endDate])
->orderBy('Tanggal', 'desc')
->get();
$sortOrder = $request->input('sort_order', 'asc');
$laporanQuery = LaporanModel::whereBetween('Tanggal', [$startDate, $endDate]);
if ($sortOrder == 'desc') {
$laporan = $laporanQuery->orderBy('Tanggal', 'desc')->get();
} else {
$laporan = $laporanQuery->orderBy('Tanggal', 'asc')->get();
}
$rows = '';
$no = 1;

View File

@ -405,18 +405,36 @@ public function collection()
// Tambahkan data transaksi
$runningBalance = 0;
foreach ($items->sortBy('Tanggal') as $item) {
$accountType = substr($item->kode, 0, 3);
$runningBalance = $this->calculateBalance($runningBalance, $item->debit, $item->kredit, $accountType);
$transaksiPerHari = [];
$exportData->push([
Carbon::parse($item->Tanggal)->format('d/m/Y'),
$item->keterangan,
'-',
$item->debit > 0 ? number_format($item->debit, 0, ',', '.') : '-',
$item->kredit > 0 ? number_format($item->kredit, 0, ',', '.') : '-',
number_format($runningBalance, 0, ',', '.')
]);
// Kelompokkan transaksi berdasarkan tanggal
foreach ($items->sortBy('Tanggal') as $item) {
$tanggalTransaksi = date('Y-m-d', strtotime($item->Tanggal));
if (!isset($transaksiPerHari[$tanggalTransaksi])) {
$transaksiPerHari[$tanggalTransaksi] = [];
}
$transaksiPerHari[$tanggalTransaksi][] = $item;
}
// Proses setiap transaksi per hari
foreach ($transaksiPerHari as $tanggal => $transaksis) {
$nomorUrut = 1;
foreach ($transaksis as $item) {
$accountType = substr($item->kode, 0, 3);
$runningBalance = $this->calculateBalance($runningBalance, $item->debit, $item->kredit, $accountType);
// Format Ref
$ref = 'JU/' . date('Y-m-d', strtotime($tanggal)) . '/' . str_pad($nomorUrut++, 3, '0', STR_PAD_LEFT);
$exportData->push([
Carbon::parse($item->Tanggal)->format('d/m/Y'),
$item->keterangan,
$ref,
$item->debit > 0 ? $item->debit : '',
$item->kredit > 0 ? $item->kredit : '',
$runningBalance
]);
}
}
// Tambahkan baris kosong setelah setiap kategori
@ -607,22 +625,39 @@ public function exportPDF(Request $request)
$runningBalance = 0;
$accountType = substr($kodeAkun, 0, 3);
// Kelompokkan transaksi berdasarkan tanggal
$transaksiPerHari = [];
foreach($items->sortBy('Tanggal') as $item) {
if (in_array($accountType, ['111', '112']) || in_array($accountType, ['251', '252'])) {
$runningBalance = $runningBalance + $item->debit - $item->kredit;
} else {
$runningBalance = $runningBalance - $item->debit + $item->kredit;
$tanggalTransaksi = date('Y-m-d', strtotime($item->Tanggal));
if (!isset($transaksiPerHari[$tanggalTransaksi])) {
$transaksiPerHari[$tanggalTransaksi] = [];
}
$transaksiPerHari[$tanggalTransaksi][] = $item;
}
$html .= '
<tr>
<td>' . date('d/m/Y', strtotime($item->Tanggal)) . '</td>
<td>' . $item->keterangan . '</td>
<td class="text-center">-</td>
<td class="text-right">' . ($item->debit > 0 ? number_format($item->debit, 0, ',', '.') : '-') . '</td>
<td class="text-right">' . ($item->kredit > 0 ? number_format($item->kredit, 0, ',', '.') : '-') . '</td>
<td class="text-right">' . number_format($runningBalance, 0, ',', '.') . '</td>
</tr>';
// Proses setiap transaksi per hari
foreach($transaksiPerHari as $tanggal => $transaksis) {
$nomorUrut = 1;
foreach($transaksis as $item) {
if (in_array($accountType, ['111', '112']) || in_array($accountType, ['251', '252'])) {
$runningBalance = $runningBalance + $item->debit - $item->kredit;
} else {
$runningBalance = $runningBalance - $item->debit + $item->kredit;
}
// Format Ref
$ref = 'JU/' . date('Y-m-d', strtotime($tanggal)) . '/' . str_pad($nomorUrut++, 3, '0', STR_PAD_LEFT);
$html .= '
<tr>
<td>' . date('d/m/Y', strtotime($item->Tanggal)) . '</td>
<td>' . $item->keterangan . '</td>
<td class="text-center">' . $ref . '</td>
<td class="text-right">' . ($item->debit > 0 ? number_format($item->debit, 0, ',', '.') : '-') . '</td>
<td class="text-right">' . ($item->kredit > 0 ? number_format($item->kredit, 0, ',', '.') : '-') . '</td>
<td class="text-right">' . number_format($runningBalance, 0, ',', '.') . '</td>
</tr>';
}
}
$html .= '

View File

@ -311,12 +311,12 @@ class="text-sm font-medium text-gray-500 dark:text-gray-400 hover:text-gray-900
</ul>
</div>
</div>
<a href="#" class="uppercase text-sm font-semibold inline-flex items-center rounded-lg text-blue-600 hover:text-blue-700 dark:hover:text-blue-500 hover:bg-gray-100 dark:hover:bg-gray-700 dark:focus:ring-gray-700 dark:border-gray-700 px-3 py-2">
<!-- <a href="#" class="uppercase text-sm font-semibold inline-flex items-center rounded-lg text-blue-600 hover:text-blue-700 dark:hover:text-blue-500 hover:bg-gray-100 dark:hover:bg-gray-700 dark:focus:ring-gray-700 dark:border-gray-700 px-3 py-2">
LAPORAN KATEGORI
<svg class="w-2.5 h-2.5 ms-1.5 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
</svg>
</a>
</a> -->
</div>
</div>
</div>