From 89f4a8946e5dcdcb082057513a2f5000d5216d18 Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Mon, 31 Jan 2022 12:49:10 +0100 Subject: [PATCH] Add total_price of acts while get health care sheets details --- app/Http/Controllers/HealthCareSheetController.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/HealthCareSheetController.php b/app/Http/Controllers/HealthCareSheetController.php index e6b2f30..24bdbc5 100755 --- a/app/Http/Controllers/HealthCareSheetController.php +++ b/app/Http/Controllers/HealthCareSheetController.php @@ -581,12 +581,13 @@ class HealthCareSheetController extends Controller $datetime = $this->getCurrentTimeByCountryCode($insurance->network->country->code_country); + $beneficiary_id = $request->input('beneficiary_id'); $accident_date = $request->input('accident_date'); $pregnancy_start_at = $request->input('pregnancy_start_at'); $pregnancy_end_at = $request->input('pregnancy_end_at'); $healthCareSheet = NhHealthCareSheet::create([ 'health_care_sheet_id' => $this->generateSheetID(), - 'beneficiary_id' => $request->input('beneficiary_id'), + 'beneficiary_id' => !empty($beneficiary_id) ? $beneficiary_id : null, 'network_agent_id' => $request->input('network_agent_id'), 'care_condition' => $request->input('care_condition'), 'practitioner_lastname' => $request->input('practitioner_lastname'), @@ -1201,7 +1202,13 @@ class HealthCareSheetController extends Controller private function formatExamAndPrescriptionAmounts($e, $sheet): void { - $e->unit_price_formatted = isset($e->unit_price) ? $this->toMoneyWithCurrencyCode($e->unit_price, $sheet->currency_code) : null; + if (isset($e->unit_price)) { + $e->total_price = $this->toMoneyWithCurrencyCode($e->unit_price * $e->quantity, $sheet->currency_code); + $e->unit_price_formatted = isset($e->unit_price) ? $this->toMoneyWithCurrencyCode($e->unit_price, $sheet->currency_code) : null; + } else { + $e->total_price = null; + $e->unit_price_formatted = null; + } $e->insured_paid_amount_formatted = isset($e->insured_paid_amount) ? $this->toMoneyWithCurrencyCode($e->insured_paid_amount, $sheet->currency_code) : null; $e->insurer_paid_amount_formatted = isset($e->insurer_paid_amount) ? $this->toMoneyWithCurrencyCode($e->insurer_paid_amount, $sheet->currency_code) : null; }