Fix Member Import
This commit is contained in:
@@ -29,9 +29,17 @@ class MemberController extends Controller
|
||||
$benefits = Member::query()
|
||||
->filter($request->all())
|
||||
// ->where('corporate_id', $corporate_id)
|
||||
->whereHas('employeds', function ($query) use ($corporate_id) {
|
||||
$query->where('corporate_id', $corporate_id);
|
||||
->whereHas('employeds', function ($employeds) use ($corporate_id) {
|
||||
$employeds->where('corporate_id', $corporate_id);
|
||||
})
|
||||
->with([
|
||||
'employeds',
|
||||
'currentPolicy' => function ($policy) use ($corporate_id) {
|
||||
$policy->whereHas('corporatePolicy', function($corporatePolicy) use ($corporate_id) {
|
||||
$corporatePolicy->where('corporate_id', $corporate_id);
|
||||
});
|
||||
}
|
||||
])
|
||||
->paginate(20)
|
||||
->appends($request->all());
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ class MemberEnrollmentService
|
||||
"member_id" => $row['member_id'],
|
||||
"payor_id" => $row['payor_id'],
|
||||
"nik" => $row['nik'],
|
||||
"birth_date" => Carbon::parse($row['date_of_birth']),
|
||||
"birth_date" => Carbon::parse(strtotime($row['date_of_birth'])),
|
||||
"gender" => Helper::genderNormalization($row['sex']),
|
||||
"language" => $row['language'],
|
||||
"race" => $row['race'],
|
||||
@@ -144,9 +144,29 @@ class MemberEnrollmentService
|
||||
"principal_id" => $row['principal_id'],
|
||||
"relation_with_principal" => $row['relationship_with_principal'],
|
||||
"bpjs_class" => $row['bpjs_class'],
|
||||
"nric" => $row['nric'],
|
||||
"email" => $row['email'],
|
||||
"bank_info" => $row['banks_info'],
|
||||
"agent_code" => $row['agent_code'],
|
||||
"address1" => $row['address1'],
|
||||
"address2" => $row['address2'],
|
||||
"address3" => $row['address3'],
|
||||
"address4" => $row['address4'],
|
||||
"city" => $row['city'],
|
||||
"state" => $row['state'],
|
||||
"postal_code" => $row['post_code'],
|
||||
"passport_no" => $row['passport_number'],
|
||||
"passport_country" => $row['passport_country'],
|
||||
"identification_code" => $row['identification_code'],
|
||||
"pre_existing" => $row['pre_existing'],
|
||||
"bpjs_id" => $row['bpjs_id'],
|
||||
"endorsement_date" => $row['endorsement_date'],
|
||||
"remarks" => $row['remarks'],
|
||||
"policy_in_force" => $row['policy_in_force'],
|
||||
"start_no_claim" => $row['start_no_claim'],
|
||||
"end_no_claim" => $row['end_no_claim'],
|
||||
];
|
||||
|
||||
|
||||
if ($corporate->currentPolicy->code != $row['policy_number']) {
|
||||
throw new ImportRowException(__('enrollment.POLICY_NUMBER_NOT_MATCH', [
|
||||
'policy_id' => $row['policy_number']
|
||||
@@ -206,7 +226,8 @@ class MemberEnrollmentService
|
||||
'corporate_id' => $corporate->id,
|
||||
'branch_code' => $row['branch_code'],
|
||||
'division_id' => $division_id ?? null,
|
||||
'nik' => $row['nik']
|
||||
'nik' => $row['nik'],
|
||||
'status' => $row['employment_status']
|
||||
]);
|
||||
}
|
||||
DB::commit();
|
||||
@@ -295,7 +316,7 @@ class MemberEnrollmentService
|
||||
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_NO_CHANGE'), 0, null, $row);
|
||||
}
|
||||
|
||||
if (Carbon::parse(strtotime($row['member_effective_date'])) > Carbon::parse($row['end_date'])) {
|
||||
if (Carbon::parse(strtotime($row['member_effective_date'])) > Carbon::parse(strtotime($row['member_expiry_date']))) {
|
||||
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_INVALID'), 0, null, $row);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,29 @@ class Member extends Model
|
||||
"active",
|
||||
"created_by",
|
||||
"updated_by",
|
||||
"deleted_by"
|
||||
"deleted_by",
|
||||
|
||||
"nric",
|
||||
"email",
|
||||
"bank_info",
|
||||
"agent_code",
|
||||
"address1",
|
||||
"address2",
|
||||
"address3",
|
||||
"address4",
|
||||
"city",
|
||||
"state",
|
||||
"postal_code",
|
||||
"passport_no",
|
||||
"passport_country",
|
||||
"identification_code",
|
||||
"pre_existing",
|
||||
"bpjs_id",
|
||||
"endorsement_date",
|
||||
"remarks",
|
||||
"policy_in_force",
|
||||
"start_no_claim",
|
||||
"end_no_claim",
|
||||
];
|
||||
|
||||
public static $doc_headers_to_field_map = [
|
||||
@@ -109,6 +131,11 @@ class Member extends Model
|
||||
return $this->hasMany(MemberPolicy::class, 'member_id', 'member_id');
|
||||
}
|
||||
|
||||
public function currentPolicy()
|
||||
{
|
||||
return $this->hasOne(MemberPolicy::class, 'member_id', 'member_id')->where('status', 'active')->latestOfMany();
|
||||
}
|
||||
|
||||
public function scopeFilter($query, array $filters)
|
||||
{
|
||||
$query->when($filters['search'] ?? false, function ($query, $search) {
|
||||
|
||||
@@ -19,9 +19,9 @@ class MemberPolicy extends Model
|
||||
'end'
|
||||
];
|
||||
|
||||
public function policy()
|
||||
public function corporatePolicy()
|
||||
{
|
||||
return $this->belongsTo(Policy::class, 'policy_id', 'policy_id');
|
||||
return $this->belongsTo(CorporatePolicy::class, 'policy_id', 'code');
|
||||
}
|
||||
|
||||
public function member()
|
||||
|
||||
@@ -31,6 +31,29 @@ return new class extends Migration
|
||||
$table->string('principal_id')->nullable()->index();
|
||||
$table->string('relation_with_principal')->nullable();
|
||||
$table->string('bpjs_class')->nullable();
|
||||
|
||||
$table->string('nric')->nullable();
|
||||
$table->string('email')->nullable();
|
||||
$table->string('bank_info')->nullable();
|
||||
$table->string('agent_code')->nullable();
|
||||
$table->text('address1')->nullable();
|
||||
$table->text('address2')->nullable();
|
||||
$table->text('address3')->nullable();
|
||||
$table->text('address4')->nullable();
|
||||
$table->string('city')->nullable();
|
||||
$table->string('state')->nullable();
|
||||
$table->string('postal_code')->nullable();
|
||||
$table->string('passport_no')->nullable();
|
||||
$table->string('passport_country')->nullable();
|
||||
$table->string('identification_code')->nullable();
|
||||
$table->string('pre_existing')->nullable();
|
||||
$table->string('bpjs_id')->nullable();
|
||||
$table->string('endorsement_date')->nullable();
|
||||
$table->string('remarks')->nullable();
|
||||
$table->string('policy_in_force')->nullable();
|
||||
$table->string('start_no_claim')->nullable();
|
||||
$table->string('end_no_claim')->nullable();
|
||||
|
||||
$table->boolean('active')->default(true);
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
@@ -21,6 +21,9 @@ return new class extends Migration
|
||||
$table->foreignId('division_id')->nullable()->index();
|
||||
$table->string('nik')->nullable()->index();
|
||||
$table->string('status')->nullable();
|
||||
|
||||
$table->date('start')->nullable();
|
||||
$table->date('end')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
@@ -18,7 +18,7 @@ class DatabaseSeeder extends Seeder
|
||||
|
||||
$this->call([
|
||||
DummyMemberSeeder::class,
|
||||
DummyCorprateSeeder::class
|
||||
DummyCorporateSeeder::class
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,14 +208,14 @@ export default function CorporatePlanList() {
|
||||
{ id: 'member_id', label: 'MemberID', minWidth: 100, align: "left" },
|
||||
{ id: 'principal_id', label: 'Mapping ID', minWidth: 100, align: "left" },
|
||||
{ id: 'nik', label: 'NIK', minWidth: 100, align: "left" },
|
||||
{ id: 'policy_number', label: 'Policy Number', minWidth: 100, align: "left" },
|
||||
{ id: 'current_policy.policy_number', label: 'Policy Number', minWidth: 100, align: "left" },
|
||||
{ id: 'effective_date', label: 'Effective Date', minWidth: 100, align: "left" },
|
||||
{ id: 'name', label: 'Name', minWidth: 100, align: "left" },
|
||||
{ id: 'nric', label: 'NRIC', minWidth: 100, align: "left" },
|
||||
{ id: 'email', label: 'E-mail', minWidth: 100, align: "left" },
|
||||
{ id: 'plan_id', label: 'PlanID', minWidth: 100, align: "left" },
|
||||
{ id: 'termination_date', label: 'Termination Date', minWidth: 100, align: 'right' },
|
||||
{ id: 'activation_date', label: 'Activation Date', minWidth: 100, align: "right" },
|
||||
{ id: 'termination_date', label: 'Termination Date', minWidth: 100, align: 'right' },
|
||||
]);
|
||||
|
||||
// Generate the every row of the table
|
||||
@@ -235,9 +235,34 @@ export default function CorporatePlanList() {
|
||||
{open ? <KeyboardArrowDownIcon /> : <KeyboardArrowRightIcon />}
|
||||
</IconButton>
|
||||
</TableCell>
|
||||
{ columns.map((column, index) =>
|
||||
{/* { columns.map((column, index) =>
|
||||
<TableCell key={ index } align={ column.align } minwidth={ column.minWidth }>{ row[column.id] ?? '-' }</TableCell>
|
||||
) }
|
||||
) } */}
|
||||
{/* TODO FIX DISPLAY DATA FROM RELATION */}
|
||||
|
||||
{/* { id: 'member_id', label: 'MemberID', minWidth: 100, align: "left" },
|
||||
{ id: 'principal_id', label: 'Mapping ID', minWidth: 100, align: "left" },
|
||||
{ id: 'nik', label: 'NIK', minWidth: 100, align: "left" },
|
||||
{ id: 'current_policy.policy_number', label: 'Policy Number', minWidth: 100, align: "left" },
|
||||
{ id: 'effective_date', label: 'Effective Date', minWidth: 100, align: "left" },
|
||||
{ id: 'name', label: 'Name', minWidth: 100, align: "left" },
|
||||
{ id: 'nric', label: 'NRIC', minWidth: 100, align: "left" },
|
||||
{ id: 'email', label: 'E-mail', minWidth: 100, align: "left" },
|
||||
{ id: 'plan_id', label: 'PlanID', minWidth: 100, align: "left" },
|
||||
{ id: 'termination_date', label: 'Termination Date', minWidth: 100, align: 'right' },
|
||||
{ id: 'activation_date', label: 'Activation Date', minWidth: 100, align: "right" },
|
||||
*/}
|
||||
<TableCell align="left">{row.member_id}</TableCell>
|
||||
<TableCell align="left">{row.principal_id}</TableCell>
|
||||
<TableCell align="left">{row.employeds[0]?.nik}</TableCell>
|
||||
<TableCell align="left">{row.current_policy.policy_id}</TableCell>
|
||||
<TableCell align="left">{row.current_policy.start}</TableCell>
|
||||
<TableCell align="left">{row.name}</TableCell>
|
||||
<TableCell align="left">{row.nric}</TableCell>
|
||||
<TableCell align="left">{row.email}</TableCell>
|
||||
<TableCell align="left">{row.plan_id}</TableCell>
|
||||
<TableCell align="left">{row.current_policy.start}</TableCell>
|
||||
<TableCell align="left">{row.current_policy.end}</TableCell>
|
||||
<TableCell align="right"><Button variant="outlined" color="success" size="small">Active</Button></TableCell>
|
||||
{/* <TableCell align="right"><Button variant="outlined" color="success" size="small">Edit</Button></TableCell> */}
|
||||
</TableRow>
|
||||
|
||||
Reference in New Issue
Block a user