Commit a4e9cc61 authored by Fares's avatar Fares

fix(members): prevent empty string for decimal addition_fee in retroactive wizard

Empty form fields post as '' which ?? doesn't catch (only null). MySQL
rejects '' for decimal columns. Switched to ?: so empty strings fall
through to the '0.00' default.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 9d2a1e86
...@@ -200,7 +200,7 @@ class RetroactiveWizardController extends Controller ...@@ -200,7 +200,7 @@ class RetroactiveWizardController extends Controller
'marriage_date' => $post["spouse_marriage_date_{$i}"] ?? null, 'marriage_date' => $post["spouse_marriage_date_{$i}"] ?? null,
'phone_mobile' => $post["spouse_phone_{$i}"] ?? null, 'phone_mobile' => $post["spouse_phone_{$i}"] ?? null,
'join_date' => $post["spouse_join_date_{$i}"] ?? ($post['join_date'] ?? date('Y-m-d')), 'join_date' => $post["spouse_join_date_{$i}"] ?? ($post['join_date'] ?? date('Y-m-d')),
'addition_fee' => $post["spouse_fee_{$i}"] ?? '0.00', 'addition_fee' => $post["spouse_fee_{$i}"] ?: '0.00',
'has_separate_fee'=> !empty($post["spouse_separate_fee_{$i}"]), 'has_separate_fee'=> !empty($post["spouse_separate_fee_{$i}"]),
'payment_method' => $post["spouse_pay_method_{$i}"] ?? 'cash', 'payment_method' => $post["spouse_pay_method_{$i}"] ?? 'cash',
'payment_date' => $post["spouse_pay_date_{$i}"] ?? null, 'payment_date' => $post["spouse_pay_date_{$i}"] ?? null,
...@@ -218,7 +218,7 @@ class RetroactiveWizardController extends Controller ...@@ -218,7 +218,7 @@ class RetroactiveWizardController extends Controller
'date_of_birth' => $post["child_dob_{$i}"] ?? null, 'date_of_birth' => $post["child_dob_{$i}"] ?? null,
'gender' => $post["child_gender_{$i}"] ?? 'male', 'gender' => $post["child_gender_{$i}"] ?? 'male',
'join_date' => $post["child_join_date_{$i}"] ?? ($post['join_date'] ?? date('Y-m-d')), 'join_date' => $post["child_join_date_{$i}"] ?? ($post['join_date'] ?? date('Y-m-d')),
'addition_fee' => $post["child_fee_{$i}"] ?? '0.00', 'addition_fee' => $post["child_fee_{$i}"] ?: '0.00',
'has_separate_fee'=> !empty($post["child_separate_fee_{$i}"]), 'has_separate_fee'=> !empty($post["child_separate_fee_{$i}"]),
'payment_method' => $post["child_pay_method_{$i}"] ?? 'cash', 'payment_method' => $post["child_pay_method_{$i}"] ?? 'cash',
'payment_date' => $post["child_pay_date_{$i}"] ?? null, 'payment_date' => $post["child_pay_date_{$i}"] ?? null,
...@@ -238,7 +238,7 @@ class RetroactiveWizardController extends Controller ...@@ -238,7 +238,7 @@ class RetroactiveWizardController extends Controller
'category' => $post["temp_category_{$i}"] ?? 'parent', 'category' => $post["temp_category_{$i}"] ?? 'parent',
'relationship_to_member' => $post["temp_relationship_{$i}"] ?? null, 'relationship_to_member' => $post["temp_relationship_{$i}"] ?? null,
'join_date' => $post["temp_join_date_{$i}"] ?? ($post['join_date'] ?? date('Y-m-d')), 'join_date' => $post["temp_join_date_{$i}"] ?? ($post['join_date'] ?? date('Y-m-d')),
'addition_fee' => $post["temp_fee_{$i}"] ?? '0.00', 'addition_fee' => $post["temp_fee_{$i}"] ?: '0.00',
'has_separate_fee' => !empty($post["temp_separate_fee_{$i}"]), 'has_separate_fee' => !empty($post["temp_separate_fee_{$i}"]),
'payment_method' => $post["temp_pay_method_{$i}"] ?? 'cash', 'payment_method' => $post["temp_pay_method_{$i}"] ?? 'cash',
'payment_date' => $post["temp_pay_date_{$i}"] ?? null, 'payment_date' => $post["temp_pay_date_{$i}"] ?? null,
......
...@@ -240,7 +240,7 @@ final class RetroactiveMembershipService ...@@ -240,7 +240,7 @@ final class RetroactiveMembershipService
'marriage_date' => self::safeDate($spouse['marriage_date'] ?? null) ?? $joinDate, 'marriage_date' => self::safeDate($spouse['marriage_date'] ?? null) ?? $joinDate,
'join_date' => $spouseJoinDate, 'join_date' => $spouseJoinDate,
'classification' => 'working', 'classification' => 'working',
'addition_fee' => $spouse['addition_fee'] ?? '0.00', 'addition_fee' => $spouse['addition_fee'] ?: '0.00',
'status' => 'active', 'status' => 'active',
'activated_by_payment_id' => $membershipPaymentId, 'activated_by_payment_id' => $membershipPaymentId,
'is_archived' => 0, 'is_archived' => 0,
...@@ -292,7 +292,7 @@ final class RetroactiveMembershipService ...@@ -292,7 +292,7 @@ final class RetroactiveMembershipService
'gender' => $childGender ?: 'male', 'gender' => $childGender ?: 'male',
'relationship' => $childGender === 'female' ? 'daughter' : 'son', 'relationship' => $childGender === 'female' ? 'daughter' : 'son',
'classification' => 'included', 'classification' => 'included',
'addition_fee' => $child['addition_fee'] ?? '0.00', 'addition_fee' => $child['addition_fee'] ?: '0.00',
'status' => 'active', 'status' => 'active',
'activated_by_payment_id' => $membershipPaymentId, 'activated_by_payment_id' => $membershipPaymentId,
'join_date' => $childJoinDate, 'join_date' => $childJoinDate,
...@@ -344,7 +344,7 @@ final class RetroactiveMembershipService ...@@ -344,7 +344,7 @@ final class RetroactiveMembershipService
'relationship_to_member' => self::emptyToNull($temp['relationship_to_member'] ?? null), 'relationship_to_member' => self::emptyToNull($temp['relationship_to_member'] ?? null),
'status' => 'active', 'status' => 'active',
'join_date' => $tempJoinDate, 'join_date' => $tempJoinDate,
'addition_fee' => $temp['addition_fee'] ?? '0.00', 'addition_fee' => $temp['addition_fee'] ?: '0.00',
'is_archived' => 0, 'is_archived' => 0,
'created_at' => self::safeTimestamp($tempJoinDate), 'created_at' => self::safeTimestamp($tempJoinDate),
'updated_at' => $ts, 'updated_at' => $ts,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment