Merge remote-tracking branch 'origin/staging' into origin/production
This commit is contained in:
@@ -326,6 +326,7 @@ class MemberEnrollmentService
|
||||
|
||||
public function __construct(Member $member)
|
||||
{
|
||||
app()->setLocale('en');
|
||||
$this->member = $member;
|
||||
}
|
||||
|
||||
@@ -580,6 +581,7 @@ class MemberEnrollmentService
|
||||
"telephone_mobile" => $row['telephone_mobile'] ?? null,
|
||||
"telephone_res" => $row['telephone_res'] ?? null,
|
||||
"telephone_office" => $row['telephone_office'] ?? null,
|
||||
"suspended" => $row['member_suspended'] ?? null,
|
||||
];
|
||||
// $this->validateRow($row);
|
||||
if (!isset($corporate->currentPolicy) || $corporate->currentPolicy->code != $row['policy_number']) {
|
||||
@@ -731,12 +733,25 @@ class MemberEnrollmentService
|
||||
|
||||
// Validate If Plan Exist
|
||||
// TODO validate corporate plan
|
||||
$plan = Plan::query()
|
||||
->where('code', $row['plan_id'])
|
||||
->where('corporate_id', $corporate->id)
|
||||
->first();
|
||||
if (!$plan) {
|
||||
throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
|
||||
$plans = explode(",",$row['plan_id']);
|
||||
if (count($plans) > 0) {
|
||||
foreach($plans as $d){
|
||||
$plan = Plan::query()
|
||||
->where('code', $d)
|
||||
->where('corporate_id', $corporate->id)
|
||||
->first();
|
||||
if (!$plan) {
|
||||
throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$plan = Plan::query()
|
||||
->where('code', $row['plan_id'])
|
||||
->where('corporate_id', $corporate->id)
|
||||
->first();
|
||||
if (!$plan) {
|
||||
throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -787,12 +802,40 @@ class MemberEnrollmentService
|
||||
'status' => $row['employment_status']
|
||||
]);
|
||||
// Bisa disini penyebab data dobel
|
||||
$member->memberPlans()->create([
|
||||
'plan_id' => $plan->id,
|
||||
'status' => 'active',
|
||||
'start' => $this->dateParser($row['member_effective_date']),
|
||||
'end' => $this->dateParser($row['member_expiry_date']),
|
||||
]);
|
||||
|
||||
$plans = explode(",",$row['plan_id']);
|
||||
if (count($plans) > 0) {
|
||||
foreach($plans as $d){
|
||||
$plan = Plan::query()
|
||||
->where('code', $d)
|
||||
->where('corporate_id', $corporate->id)
|
||||
->first();
|
||||
if (!$plan) {
|
||||
throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
|
||||
}
|
||||
$member->memberPlans()->create([
|
||||
'plan_id' => $plan->id,
|
||||
'status' => 'active',
|
||||
'start' => $this->dateParser($row['member_effective_date']),
|
||||
'end' => $this->dateParser($row['member_expiry_date']),
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$plan = Plan::query()
|
||||
->where('code', $row['plan_id'])
|
||||
->where('corporate_id', $corporate->id)
|
||||
->first();
|
||||
if (!$plan) {
|
||||
throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
|
||||
}
|
||||
$member->memberPlans()->create([
|
||||
'plan_id' => $plan->id,
|
||||
'status' => 'active',
|
||||
'start' => $this->dateParser($row['member_effective_date']),
|
||||
'end' => $this->dateParser($row['member_expiry_date']),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
DB::commit();
|
||||
} catch (\Exception $e) {
|
||||
@@ -834,7 +877,6 @@ class MemberEnrollmentService
|
||||
$member->person_id = $person->id;
|
||||
$member->save();
|
||||
try {
|
||||
|
||||
$memberPolicy = MemberPolicy::query()
|
||||
->where('policy_id', $row['policy_number'])
|
||||
->where('member_id', $row['member_id'])
|
||||
@@ -852,17 +894,63 @@ class MemberEnrollmentService
|
||||
$memberPlan->save();
|
||||
}
|
||||
|
||||
// Pengecekan jika ada perubahan di plan
|
||||
$plan = Plan::query()
|
||||
->where('code', $row['plan_id'])
|
||||
->first();
|
||||
if ($plan){
|
||||
$memberPlan = MemberPlan::query()
|
||||
->where('member_id', $member->id)
|
||||
->first();
|
||||
$memberPlan->plan_id = $plan->id;
|
||||
$memberPlan->save();
|
||||
}
|
||||
// // Pengecekan jika ada perubahan di plan
|
||||
// $plan = Plan::query()
|
||||
// ->where('code', $row['plan_id'])
|
||||
// ->first();
|
||||
// if ($plan){
|
||||
// $memberPlan = MemberPlan::query()
|
||||
// ->where('member_id', $member->id)
|
||||
// ->first();
|
||||
// $memberPlan->plan_id = $plan->id;
|
||||
// $memberPlan->save();
|
||||
// }
|
||||
|
||||
// Update plan
|
||||
// $plans = explode(",",$row['plan_id']);
|
||||
// if (count($plans) > 0) {
|
||||
// foreach($plans as $d){
|
||||
// $plan = Plan::query()
|
||||
// ->where('code', $d)
|
||||
// ->where('corporate_id', $corporate->id)
|
||||
// ->first();
|
||||
// if (!$plan) {
|
||||
// throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
|
||||
// }
|
||||
// $member->memberPlans()->updateOrCreate([
|
||||
// 'member_id' => $member->id,
|
||||
// 'plan_id' => $plan->id,
|
||||
// ],
|
||||
// [
|
||||
// 'plan_id' => $plan->id,
|
||||
// 'status' => 'active',
|
||||
// 'start' => $this->dateParser($row['member_effective_date']),
|
||||
// 'end' => $this->dateParser($row['member_expiry_date']),
|
||||
// ]);
|
||||
// }
|
||||
// } else {
|
||||
// $plan = Plan::query()
|
||||
// ->where('code', $row['plan_id'])
|
||||
// ->where('corporate_id', $corporate->id)
|
||||
// ->first();
|
||||
// if (!$plan) {
|
||||
// throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
|
||||
// }
|
||||
// $member->memberPlans()->updateOrCreate([
|
||||
// 'member_id' => $member->id,
|
||||
// 'plan_id' => $plan->id,
|
||||
// ],
|
||||
// [
|
||||
// 'plan_id' => $plan->id,
|
||||
// 'status' => 'active',
|
||||
// 'start' => $this->dateParser($row['member_effective_date']),
|
||||
// 'end' => $this->dateParser($row['member_expiry_date']),
|
||||
// ]);
|
||||
// }
|
||||
|
||||
|
||||
// end update plan
|
||||
|
||||
// Update jika ada perubahaan di ASO maka akan teriflek ke LMS juga\
|
||||
$userInsuranceLms = UserInsurance::query()
|
||||
->where('sNoPolis', $row['member_id'])
|
||||
|
||||
Reference in New Issue
Block a user