fix double calculation when mechanic created and auto claim work

This commit is contained in:
2025-07-14 11:06:29 +07:00
parent 720e314bbd
commit 68e7eb3087
2 changed files with 7 additions and 12 deletions

View File

@@ -414,9 +414,10 @@ class KpiService
->whereMonth('date', $month)
->sum('qty');
// Get transactions claimed by the user
// Get transactions claimed by the user (excluding those created by the same user to avoid double counting)
$claimedTransactions = Transaction::where('claimed_by', $user->id)
->whereNotNull('claimed_at')
->where('user_id', '!=', $user->id) // Exclude transactions created by the same user
->whereYear('claimed_at', $year)
->whereMonth('claimed_at', $month)
->sum('qty');