From c4b833a59fd47da1ef3d5059b96b9084b42c88da Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Fri, 1 Apr 2022 10:35:08 +0100 Subject: [PATCH] Update response palyoad while fetch insurance networks --- app/Http/Controllers/InsuranceController.php | 26 +++++++++++++++++--- resources/lang/fr/states.php | 4 +-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/InsuranceController.php b/app/Http/Controllers/InsuranceController.php index 2084e49..0571aa1 100644 --- a/app/Http/Controllers/InsuranceController.php +++ b/app/Http/Controllers/InsuranceController.php @@ -61,7 +61,7 @@ class InsuranceController extends Controller * name="user_id", * description="ID de l'utilisateur", * in="query", - * required=true, + * required=false, * @OA\Schema( * type="integer", * ) @@ -96,18 +96,38 @@ class InsuranceController extends Controller } else { $country = CountriesCurrency::findOrFail($request->input('country_id')); - $insurances = DB::select("SELECT n.id , n.name , nhc.age_limit_of_insured_and_spouse, nhc.age_limit_of_child_beneficiary, nhc.max_number_of_beneficiaries, nhc.id as nhc_id + $insurances = DB::select("SELECT n.id , n.name , nhc.age_limit_of_insured_and_spouse, nhc.age_limit_of_child_beneficiary, nhc.max_number_of_beneficiaries, nhc.family_coverage_sharing, nhc.id as nhc_id FROM networks n JOIN configWallet cw ON cw.id_network = n.id JOIN nh_networks_configs nhc ON nhc.network_id = n.id WHERE n.country_id = :countryId AND cw.type = 'ilink_sante' AND n.status = 1", ['countryId' => $request->input('country_id')]); foreach ($insurances as $insurance) { - $months_prices = DB::select("SELECT id, number_of_months , min_amount FROM nh_months_prices_grid WHERE nh_network_config_id = :nhc_id", + $months_prices = DB::select("SELECT number_of_months , min_amount , max_insurance_coverage_amount, waiting_period_days, payment_period , number_of_fractions FROM nh_months_prices_grid WHERE nh_network_config_id = :nhc_id", + ['nhc_id' => $insurance->nhc_id]); + + $years_prices = DB::select("SELECT min_age , max_age , markup_percentage FROM nh_years_prices_grid WHERE nh_network_config_id = :nhc_id", ['nhc_id' => $insurance->nhc_id]); foreach ($months_prices as $mp) { + foreach ($years_prices as $cp) { + $cp->amount = $this->toMoneyWithCurrencyCode(round((100 + $cp->markup_percentage) * $mp->min_amount / 100), $country->currency_code ?? 'XAF'); + } + $mp->min_amount = $this->toMoneyWithCurrencyCode($mp->min_amount, $country->currency_code ?? 'XAF'); + $mp->max_insurance_coverage_amount = $this->toMoneyWithCurrencyCode($mp->max_insurance_coverage_amount, $country->currency_code ?? 'XAF'); + $mp->payment_period = trans('states.' . $mp->payment_period); + + + $mp->child_prices = $years_prices; } + + foreach ($months_prices as $mp) { + foreach ($mp->child_prices as $cp) { + unset($cp->markup_percentage); + } + } + $insurance->months_prices = $months_prices; + unset($insurance->nhc_id); } } diff --git a/resources/lang/fr/states.php b/resources/lang/fr/states.php index 7bd3744..a97422f 100755 --- a/resources/lang/fr/states.php +++ b/resources/lang/fr/states.php @@ -33,6 +33,6 @@ return [ "PARTIALLY_PAID" => "PARTIELLEMENT PAYÉE", "SUSPENDED" => "SUSPENDUE", "ONE_TIME" => "UNE SEULE FOIS", - "DAILY" => "JOURNELLEMENT", - "MONTHLY" => "MENSUELLEMENT" + "DAILY" => "JOURNALIER", + "MONTHLY" => "MENSUEL" ];