fix: memperbaiki penggajian untuk transaksinya diambil dari tanggal 1-30/31 bukan diambil dari 1 bulan kebelakang saat ini

This commit is contained in:
Yoga Pangestu 2025-01-04 16:25:50 +07:00
parent df48211ad1
commit 2d87c15ba5

View File

@ -156,10 +156,18 @@ public function getSalaryEmployee(string $employeeId): JsonResponse
->where('is_paid', '0');
})
->when($latestPayroll, function ($query) use ($latestPayroll, $employee) {
$query->whereBetween('created_at', [$latestPayroll->created_at, now()]);
$query->whereBetween('created_at', [
$latestPayroll->created_at->startOfMonth(),
$latestPayroll->created_at->endOfMonth(),
]);
if ($employee->role_id === 4 && $latestPayroll->created_at->isToday()) {
$query->where('is_paid', '0');
}
}, function ($query) {
$query->whereBetween('created_at', [
now()->subMonth()->startOfMonth(),
now()->subMonth()->endOfMonth(),
]);
})
->sum('total');
$debt = Debt::where('user_id', $employeeId)->where('is_paid', '0')->sum('amount');