This commit is contained in:
2023-05-17 11:29:02 +07:00
parent da68ae3e05
commit 3f40170043

View File

@@ -426,13 +426,15 @@ class MemberEnrollmentService
}
// TODO EFFECTIVE DATE VALIDATION
if (empty($row['activation_date'])) {
throw new ImportRowException(__('enrollment.ACTIVATION_DATE_REQUIRED'), 0, null, $row);
}
if(!$this->validateDate($row['activation_date'])){
throw new ImportRowException(__('enrollment.INVALID_DATE', [
'title' => $title['activation_date']
]), 0, null, $row);
// if (empty($row['activation_date'])) {
// throw new ImportRowException(__('enrollment.ACTIVATION_DATE_REQUIRED'), 0, null, $row);
// }
if(!empty($row['activation_date'])){
if(!$this->validateDate($row['activation_date'])){
throw new ImportRowException(__('enrollment.INVALID_DATE', [
'title' => $title['activation_date']
]), 0, null, $row);
}
}
// TODO FKTP VALIDATION
// TODO FKRTL VALIDATION
@@ -495,6 +497,14 @@ class MemberEnrollmentService
public function handleImportRow(Corporate $corporate, $row)
{
try {
$activation_date = NULL;
if (!empty($row['activation_date'])){
$activation_date = $row['activation_date'];
}
$date_terminated = NULL;
if(!empty($row['date_terminated'])){
$date_terminated = $row['date_terminated'];
}
$member_data = [
"name" => $row['name'] ?? null,
"member_id" => $row['member_id'] ?? null,
@@ -533,8 +543,8 @@ class MemberEnrollmentService
"members_effective_date" => $row['member_effective_date'] ?? null,
"members_expire_date" => $row['member_expiry_date'] ?? null,
"activation_date" => $row['activation_date'] ?? null,
"terminated_date" => $row['date_terminated'] ?? null,
"activation_date" => $activation_date,
"terminated_date" => $date_terminated,
"telephone_mobile" => $row['telephone_mobile'] ?? null,
"telephone_res" => $row['telephone_res'] ?? null,
@@ -551,7 +561,30 @@ class MemberEnrollmentService
// validasi member efektif date range date in periode date coroporate
$member_effective_date = date("Y-m-d", strtotime($row['member_effective_date']));
$date_terminated = date("Y-m-d", strtotime($row['date_terminated']));
$activation_date = date("Y-m-d", strtotime($row['activation_date']));
if(!empty($row['activation_date'])){
$activation_date = date("Y-m-d", strtotime($row['activation_date']));
if (($activation_date == $date_terminated) && ($activation_date == $member_effective_date)) {
throw new ImportRowException(__('enrollment.MORE_THAN', [
'date_param' => 'Activation Date',
'date' => $activation_date,
'date_param2' => 'Member Effective Date',
'start' => $activation_date
]), 0, null, $row);
}
}
if (!empty($row['date_terminated'])){
$date_terminated = date("Y-m-d", strtotime($row['date_terminated']));
if($date_terminated){
if ($date_terminated <= $member_effective_date && ($date_terminated != $member_effective_date)) {
throw new ImportRowException(__('enrollment.MORE_THAN', [
'date_param' => 'Date Terminated Date',
'date' => $date_terminated,
'date_param2' => 'Member Effective Date',
'start' => $member_effective_date
]), 0, null, $row);
}
}
}
// validasi member expried date range date in periode date coroporate
$members_expire_date = date("Y-m-d", strtotime($row['member_expiry_date']));
// validasi member expried date must less date member effective
@@ -607,24 +640,8 @@ class MemberEnrollmentService
'start' => $member_effective_date
]), 0, null, $row);
}
if($date_terminated){
if ($date_terminated <= $member_effective_date && ($date_terminated != $member_effective_date)) {
throw new ImportRowException(__('enrollment.MORE_THAN', [
'date_param' => 'Date Terminated Date',
'date' => $date_terminated,
'date_param2' => 'Member Effective Date',
'start' => $member_effective_date
]), 0, null, $row);
}
}
if (($activation_date == $date_terminated) && ($activation_date == $member_effective_date)) {
throw new ImportRowException(__('enrollment.MORE_THAN', [
'date_param' => 'Activation Date',
'date' => $activation_date,
'date_param2' => 'Member Effective Date',
'start' => $activation_date
]), 0, null, $row);
}
if($corporate->code != $row['corporate_id']){
throw new ImportRowException(__('enrollment.CORPORATE_CODE_NOT_MATCH', [
'corporate_id' => $row['corporate_id']
@@ -689,6 +706,7 @@ class MemberEnrollmentService
try {
DB::beginTransaction();
// dd($member_data);
$member->fill($member_data);
if ($member->save()) {