Update: 2026-08-08 12:58:16
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
require_once __DIR__ . '/../connect.php';
|
||||
require_once __DIR__ . '/eligibility.php';
|
||||
require_once __DIR__ . '/../obligations/functions.php';
|
||||
|
||||
// الهوية من الـJWT لا من الطلب — الأهلية معلومة عن السائق نفسه،
|
||||
// وقراءتها بمعرّف مُرسَل تكشف أرقام غيره.
|
||||
@@ -37,10 +38,29 @@ try {
|
||||
|
||||
$current = assuranceActivePolicy($con, $driverId);
|
||||
|
||||
// نداء واحد للمحفظة لكل الشاشة: الملخّص عن السائق لا عن الخطة.
|
||||
// بدونه كانت الشاشة تعرض «مؤهَّل» ثم يُرفض الطلب عند الضغط — وهو أسوأ
|
||||
// من الرفض المبكر: يعد السائق بشيء ثم يسحبه.
|
||||
$incomeSummary = obligationWalletIncomeSummary($driverId);
|
||||
|
||||
$out = [];
|
||||
foreach ($plans as $plan) {
|
||||
$check = assuranceCheckEligibility($con, $driverId, $plan);
|
||||
|
||||
// بوابة الائتمان تُقاس على منتج الالتزام المقابل للخطة. غيابه يعني
|
||||
// خطة لم تُرحَّل بعد — لا نحجبها ولا ندّعي أهليةً لها، بل نتركها
|
||||
// لحكم شروط الخطة وحدها ونسجّل الحالة.
|
||||
$product = obligationProduct($con, $plan['code']);
|
||||
if ($product) {
|
||||
$gate = obligationCheckWalletIncome($product, $driverId, $incomeSummary);
|
||||
if (!$gate['eligible']) {
|
||||
$check['eligible'] = false;
|
||||
$check['reasons'] = array_merge($check['reasons'], $gate['reasons']);
|
||||
}
|
||||
} else {
|
||||
error_log("[assurance/plans] لا منتج التزام للخطة {$plan['code']}");
|
||||
}
|
||||
|
||||
$out[] = [
|
||||
'id' => (int) $plan['id'],
|
||||
'code' => $plan['code'],
|
||||
|
||||
Reference in New Issue
Block a user