fix pbg payments
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Http\Resources\BigdataResumeResource;
|
||||
use App\Models\BigdataResume;
|
||||
use App\Models\DataSetting;
|
||||
use App\Models\SpatialPlanning;
|
||||
use App\Models\PbgTaskPayment;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -59,6 +60,11 @@ class BigDataResumeController extends Controller
|
||||
$tata_ruang = $spatialData['sum'];
|
||||
$tata_ruang_count = $spatialData['count'];
|
||||
|
||||
// Get real-time PBG Task Payments data
|
||||
$pbgPaymentsData = $this->getPbgTaskPaymentsData();
|
||||
$pbg_task_payments_sum = $pbgPaymentsData['sum'];
|
||||
$pbg_task_payments_count = $pbgPaymentsData['count'];
|
||||
|
||||
$kekurangan_potensi = $target_pad - $big_data_resume->potention_sum;
|
||||
|
||||
// percentage kekurangan potensi
|
||||
@@ -107,6 +113,10 @@ class BigDataResumeController extends Controller
|
||||
$proses_dinas_teknis_percentage = $big_data_resume->verified_sum > 0 && $proses_dinas_teknis_sum >= 0
|
||||
? round(($proses_dinas_teknis_sum / $big_data_resume->verified_sum) * 100, 2) : 0;
|
||||
|
||||
// percentage pbg_task_payments (payments / verified)
|
||||
$pbg_task_payments_percentage = $realisasi_terbit_pbg_sum > 0 && $pbg_task_payments_sum >= 0
|
||||
? round(($pbg_task_payments_sum / $realisasi_terbit_pbg_sum) * 100, 2) : 0;
|
||||
|
||||
$business_rab_count = $big_data_resume->business_rab_count;
|
||||
$business_krk_count = $big_data_resume->business_krk_count;
|
||||
$non_business_rab_count = $big_data_resume->non_business_rab_count;
|
||||
@@ -171,7 +181,12 @@ class BigDataResumeController extends Controller
|
||||
'business_krk_count' => $business_krk_count,
|
||||
'non_business_rab_count' => $non_business_rab_count,
|
||||
'non_business_krk_count' => $non_business_krk_count,
|
||||
'business_dlh_count' => $business_dlh_count
|
||||
'business_dlh_count' => $business_dlh_count,
|
||||
'pbg_task_payments' => [
|
||||
'sum' => (float) $pbg_task_payments_sum,
|
||||
'count' => $pbg_task_payments_count,
|
||||
'percentage' => $pbg_task_payments_percentage
|
||||
]
|
||||
];
|
||||
return response()->json($result);
|
||||
}catch(\Exception $e){
|
||||
@@ -398,6 +413,11 @@ class BigDataResumeController extends Controller
|
||||
'sum' => 0,
|
||||
'count' => 0,
|
||||
'percentage' => 0
|
||||
],
|
||||
'pbg_task_payments' => [
|
||||
'sum' => 0,
|
||||
'count' => 0,
|
||||
'percentage' => 0
|
||||
]
|
||||
];
|
||||
|
||||
@@ -457,4 +477,33 @@ class BigDataResumeController extends Controller
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PBG Task Payments data from database
|
||||
*/
|
||||
private function getPbgTaskPaymentsData(): array
|
||||
{
|
||||
try {
|
||||
// Get sum and count from PbgTaskPayment model
|
||||
$totalSum = PbgTaskPayment::whereYear('payment_date', date('Y'))->sum('pad_amount') ?? 0;
|
||||
$totalCount = PbgTaskPayment::whereYear('payment_date', date('Y'))->count() ?? 0;
|
||||
|
||||
Log::info("Real-time PBG Task Payments Data", [
|
||||
'total_records' => $totalCount,
|
||||
'total_sum' => $totalSum,
|
||||
'source' => 'pbg_task_payments table'
|
||||
]);
|
||||
|
||||
return [
|
||||
'sum' => (float) $totalSum,
|
||||
'count' => (int) $totalCount,
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Error getting PBG task payments data", ['error' => $e->getMessage()]);
|
||||
return [
|
||||
'sum' => 0.0,
|
||||
'count' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user