update tgl 27 mei
This commit is contained in:
parent
d825d1c946
commit
64118b2b7d
|
@ -57,9 +57,13 @@ public function exportExcel(Request $request)
|
||||||
try {
|
try {
|
||||||
$startDate = $request->input('start_date', Carbon::now()->startOfMonth()->format('Y-m-d'));
|
$startDate = $request->input('start_date', Carbon::now()->startOfMonth()->format('Y-m-d'));
|
||||||
$endDate = $request->input('end_date', Carbon::now()->endOfMonth()->format('Y-m-d'));
|
$endDate = $request->input('end_date', Carbon::now()->endOfMonth()->format('Y-m-d'));
|
||||||
$laporan = LaporanModel::whereBetween('Tanggal', [$startDate, $endDate])
|
$sortOrder = $request->input('sort_order', 'asc');
|
||||||
->orderBy('Tanggal', 'desc')
|
$laporanQuery = LaporanModel::whereBetween('Tanggal', [$startDate, $endDate]);
|
||||||
->get();
|
if ($sortOrder == 'desc') {
|
||||||
|
$laporan = $laporanQuery->orderBy('Tanggal', 'desc')->get();
|
||||||
|
} else {
|
||||||
|
$laporan = $laporanQuery->orderBy('Tanggal', 'asc')->get();
|
||||||
|
}
|
||||||
|
|
||||||
$rows = [];
|
$rows = [];
|
||||||
$no = 1;
|
$no = 1;
|
||||||
|
@ -141,8 +145,8 @@ public function exportExcel(Request $request)
|
||||||
'Kode Akun' => $kodeAkun,
|
'Kode Akun' => $kodeAkun,
|
||||||
'Nama Akun' => $namaAkun,
|
'Nama Akun' => $namaAkun,
|
||||||
'Keterangan' => $item->keterangan . ' ' . $item->nama_karyawan,
|
'Keterangan' => $item->keterangan . ' ' . $item->nama_karyawan,
|
||||||
'Debit' => $rowDebit > 0 ? number_format($rowDebit, 0, ',', '.') : '-',
|
'Debit' => $rowDebit > 0 ? $rowDebit : '',
|
||||||
'Kredit' => $rowKredit > 0 ? number_format($rowKredit, 0, ',', '.') : '-'
|
'Kredit' => $rowKredit > 0 ? $rowKredit : ''
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,8 +157,8 @@ public function exportExcel(Request $request)
|
||||||
'Kode Akun' => '',
|
'Kode Akun' => '',
|
||||||
'Nama Akun' => '',
|
'Nama Akun' => '',
|
||||||
'Keterangan' => 'Total',
|
'Keterangan' => 'Total',
|
||||||
'Debit' => number_format($totalDebit, 0, ',', '.'),
|
'Debit' => $totalDebit,
|
||||||
'Kredit' => number_format($totalKredit, 0, ',', '.')
|
'Kredit' => $totalKredit
|
||||||
];
|
];
|
||||||
|
|
||||||
$export = new class($rows) implements FromCollection, WithHeadings {
|
$export = new class($rows) implements FromCollection, WithHeadings {
|
||||||
|
@ -177,9 +181,13 @@ public function exportPDF(Request $request)
|
||||||
try {
|
try {
|
||||||
$startDate = $request->input('start_date', Carbon::now()->startOfMonth()->format('Y-m-d'));
|
$startDate = $request->input('start_date', Carbon::now()->startOfMonth()->format('Y-m-d'));
|
||||||
$endDate = $request->input('end_date', Carbon::now()->endOfMonth()->format('Y-m-d'));
|
$endDate = $request->input('end_date', Carbon::now()->endOfMonth()->format('Y-m-d'));
|
||||||
$laporan = LaporanModel::whereBetween('Tanggal', [$startDate, $endDate])
|
$sortOrder = $request->input('sort_order', 'asc');
|
||||||
->orderBy('Tanggal', 'desc')
|
$laporanQuery = LaporanModel::whereBetween('Tanggal', [$startDate, $endDate]);
|
||||||
->get();
|
if ($sortOrder == 'desc') {
|
||||||
|
$laporan = $laporanQuery->orderBy('Tanggal', 'desc')->get();
|
||||||
|
} else {
|
||||||
|
$laporan = $laporanQuery->orderBy('Tanggal', 'asc')->get();
|
||||||
|
}
|
||||||
|
|
||||||
$rows = '';
|
$rows = '';
|
||||||
$no = 1;
|
$no = 1;
|
||||||
|
|
|
@ -405,18 +405,36 @@ public function collection()
|
||||||
|
|
||||||
// Tambahkan data transaksi
|
// Tambahkan data transaksi
|
||||||
$runningBalance = 0;
|
$runningBalance = 0;
|
||||||
|
$transaksiPerHari = [];
|
||||||
|
|
||||||
|
// Kelompokkan transaksi berdasarkan tanggal
|
||||||
foreach ($items->sortBy('Tanggal') as $item) {
|
foreach ($items->sortBy('Tanggal') as $item) {
|
||||||
$accountType = substr($item->kode, 0, 3);
|
$tanggalTransaksi = date('Y-m-d', strtotime($item->Tanggal));
|
||||||
$runningBalance = $this->calculateBalance($runningBalance, $item->debit, $item->kredit, $accountType);
|
if (!isset($transaksiPerHari[$tanggalTransaksi])) {
|
||||||
|
$transaksiPerHari[$tanggalTransaksi] = [];
|
||||||
$exportData->push([
|
}
|
||||||
Carbon::parse($item->Tanggal)->format('d/m/Y'),
|
$transaksiPerHari[$tanggalTransaksi][] = $item;
|
||||||
$item->keterangan,
|
}
|
||||||
'-',
|
|
||||||
$item->debit > 0 ? number_format($item->debit, 0, ',', '.') : '-',
|
// Proses setiap transaksi per hari
|
||||||
$item->kredit > 0 ? number_format($item->kredit, 0, ',', '.') : '-',
|
foreach ($transaksiPerHari as $tanggal => $transaksis) {
|
||||||
number_format($runningBalance, 0, ',', '.')
|
$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
|
// Tambahkan baris kosong setelah setiap kategori
|
||||||
|
@ -607,22 +625,39 @@ public function exportPDF(Request $request)
|
||||||
$runningBalance = 0;
|
$runningBalance = 0;
|
||||||
$accountType = substr($kodeAkun, 0, 3);
|
$accountType = substr($kodeAkun, 0, 3);
|
||||||
|
|
||||||
|
// Kelompokkan transaksi berdasarkan tanggal
|
||||||
|
$transaksiPerHari = [];
|
||||||
foreach($items->sortBy('Tanggal') as $item) {
|
foreach($items->sortBy('Tanggal') as $item) {
|
||||||
if (in_array($accountType, ['111', '112']) || in_array($accountType, ['251', '252'])) {
|
$tanggalTransaksi = date('Y-m-d', strtotime($item->Tanggal));
|
||||||
$runningBalance = $runningBalance + $item->debit - $item->kredit;
|
if (!isset($transaksiPerHari[$tanggalTransaksi])) {
|
||||||
} else {
|
$transaksiPerHari[$tanggalTransaksi] = [];
|
||||||
$runningBalance = $runningBalance - $item->debit + $item->kredit;
|
}
|
||||||
|
$transaksiPerHari[$tanggalTransaksi][] = $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 .= '
|
|
||||||
<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>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= '
|
$html .= '
|
||||||
|
|
|
@ -311,12 +311,12 @@ class="text-sm font-medium text-gray-500 dark:text-gray-400 hover:text-gray-900
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</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
|
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">
|
<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"/>
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
|
||||||
</svg>
|
</svg>
|
||||||
</a>
|
</a> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue