update import request log

This commit is contained in:
Linksehat Staging Server
2024-01-12 15:23:32 +07:00
parent 13699a3f03
commit 118aae8e6d

View File

@@ -177,8 +177,6 @@ class RequestLogService
$serviceCode = 'Unk';
}
$benefit = Benefit::where('code', $row['benefit_id'])->first();
$requestLog = RequestLog::updateOrCreate(
[
'code' => $code
@@ -190,7 +188,7 @@ class RequestLogService
'discharge_date' => $row['submission_date'],
'payment_type' => 'cashless',
'status' => $status,
'status_final_log' => $status,
'status_final_log' => $row['status_final_log'] == 'Y' ? 1 : 0,
'final_log' =>$row['status_final_log'] == 'Y' ? 1 : 0,
'import_system' =>TRUE,
'catatan' => $row['catatan'],
@@ -200,20 +198,24 @@ class RequestLogService
'approved_final_log_at' => $row['approved_final_log_at'],
]);
$requestLogBenefit = RequestLogBenefit::updateOrCreate(
[
'request_log_id' => $requestLog->id,
],
[
'request_log_id' => $requestLog->id,
'benefit_id' => $benefit->id,
'amount_incurred' => $row['total_billing'],
'amount_approved' => $row['amount_approval'],
'amount_not_approved' => $row['amount_not_approval'],
'excess_paid' => $row['amount_not_approval'],
'created_by' => auth()->user()->id,
$benefit = Benefit::where('code', $row['benefit_id'])->first();
if ($benefit) { // jika tidak ada benefit nya maka belum ngisi benefit nya
RequestLogBenefit::updateOrCreate(
[
'request_log_id' => $requestLog->id,
],
[
'request_log_id' => $requestLog->id,
'benefit_id' => $benefit->id,
'amount_incurred' => $row['total_billing'],
'amount_approved' => $row['amount_approval'],
'amount_not_approved' => $row['amount_not_approval'],
'excess_paid' => $row['amount_not_approval'],
'created_by' => auth()->user()->id,
]);
}
]);
// Commit transaksi
DB::commit();