fix non business where unit is more than one
This commit is contained in:
@@ -73,11 +73,27 @@ class BigdataResume extends Model
|
||||
->whereYear('task_created_at', $year)
|
||||
->count();
|
||||
|
||||
// Business count (same logic as RequestAssignmentController)
|
||||
// Business count: function_type LIKE usaha OR (non-business with unit > 1)
|
||||
$business_count = PbgTask::where(function ($q) {
|
||||
$q->where(function ($q2) {
|
||||
$q2->whereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%fungsi usaha%'])
|
||||
->orWhereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%sebagai tempat usaha%']);
|
||||
// Traditional business: function_type LIKE usaha
|
||||
$q2->where(function ($q3) {
|
||||
$q3->whereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%fungsi usaha%'])
|
||||
->orWhereRaw("LOWER(TRIM(function_type)) LIKE ?", ['%sebagai tempat usaha%']);
|
||||
})
|
||||
// OR non-business with unit > 1 (becomes business)
|
||||
->orWhere(function ($q3) {
|
||||
$q3->where(function ($q4) {
|
||||
$q4->where(function ($q5) {
|
||||
$q5->whereRaw("LOWER(TRIM(function_type)) NOT LIKE ?", ['%fungsi usaha%'])
|
||||
->whereRaw("LOWER(TRIM(function_type)) NOT LIKE ?", ['%sebagai tempat usaha%']);
|
||||
})
|
||||
->orWhereNull('function_type');
|
||||
})
|
||||
->whereHas('pbg_task_detail', function ($q4) {
|
||||
$q4->where('unit', '>', 1);
|
||||
});
|
||||
});
|
||||
})
|
||||
->whereIn("status", PbgTaskStatus::getNonVerified());
|
||||
})
|
||||
@@ -85,7 +101,7 @@ class BigdataResume extends Model
|
||||
->whereYear('task_created_at', $year)
|
||||
->count();
|
||||
|
||||
// Non-business count (same logic as RequestAssignmentController)
|
||||
// Non-business count: function_type NOT LIKE usaha AND (unit IS NULL OR unit <= 1)
|
||||
$non_business_count = PbgTask::where(function ($q) {
|
||||
$q->where(function ($q2) {
|
||||
$q2->where(function ($q3) {
|
||||
@@ -94,7 +110,14 @@ class BigdataResume extends Model
|
||||
})
|
||||
->orWhereNull('function_type');
|
||||
})
|
||||
->whereIn("status", PbgTaskStatus::getNonVerified());
|
||||
->whereIn("status", PbgTaskStatus::getNonVerified())
|
||||
// Additional condition: unit IS NULL OR unit <= 1
|
||||
->where(function ($q3) {
|
||||
$q3->whereDoesntHave('pbg_task_detail', function ($q4) {
|
||||
$q4->where('unit', '>', 1);
|
||||
})
|
||||
->orWhereDoesntHave('pbg_task_detail');
|
||||
});
|
||||
})
|
||||
->where('is_valid', true)
|
||||
->whereYear('task_created_at', $year)
|
||||
@@ -271,8 +294,6 @@ class BigdataResume extends Model
|
||||
')
|
||||
->value('total_count') ?? 0;
|
||||
|
||||
|
||||
|
||||
// Debug: Check if there are non-verified tasks and their retribution data
|
||||
$debug_non_verified = PbgTask::whereIn('status', PbgTaskStatus::getNonVerified())
|
||||
->where('is_valid', true)
|
||||
|
||||
Reference in New Issue
Block a user