Add insurance months prices grid while fetch stopped insurance
This commit is contained in:
parent
a259cc654b
commit
06402e1cae
|
@ -100,7 +100,7 @@ class InsuranceController extends Controller
|
||||||
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')]);
|
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 $network) {
|
foreach ($insurances as $network) {
|
||||||
$this->formatInsuranceNetwork($network);
|
$network->months_prices = $this->fetchInsuranceNetworkMonthsAndYearsPrices($network->nhc_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->successResponse($insurances);
|
return $this->successResponse($insurances);
|
||||||
|
@ -148,18 +148,18 @@ class InsuranceController extends Controller
|
||||||
if (!$insurance_network)
|
if (!$insurance_network)
|
||||||
return $this->errorResponse(trans('errors.network_not_found'));
|
return $this->errorResponse(trans('errors.network_not_found'));
|
||||||
|
|
||||||
$this->formatInsuranceNetwork($insurance_network);
|
$insurance_network->months_prices = $this->fetchInsuranceNetworkMonthsAndYearsPrices($insurance_network->nhc_id);
|
||||||
return $this->successResponse($insurance_network);
|
return $this->successResponse($insurance_network);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function formatInsuranceNetwork($insurance_network): void
|
private function fetchInsuranceNetworkMonthsAndYearsPrices($nh_network_config_id)
|
||||||
{
|
{
|
||||||
$months_prices = DB::select("SELECT id , number_of_months , min_amount , max_insurance_coverage_amount, waiting_period_days, payment_period , number_of_fractions FROM nh_months_prices_grid
|
$months_prices = DB::select("SELECT id , 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 ORDER BY number_of_fractions ASC",
|
WHERE nh_network_config_id = :nhc_id ORDER BY number_of_fractions ASC",
|
||||||
['nhc_id' => $insurance_network->nhc_id]);
|
['nhc_id' => $nh_network_config_id]);
|
||||||
|
|
||||||
$years_prices = DB::select("SELECT min_age , max_age , markup_percentage FROM nh_years_prices_grid WHERE nh_network_config_id = :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_network->nhc_id]);
|
['nhc_id' => $nh_network_config_id]);
|
||||||
|
|
||||||
foreach ($months_prices as $mp) {
|
foreach ($months_prices as $mp) {
|
||||||
foreach ($years_prices as $cp) {
|
foreach ($years_prices as $cp) {
|
||||||
|
@ -178,9 +178,7 @@ class InsuranceController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$insurance_network->months_prices = $months_prices;
|
return $months_prices;
|
||||||
|
|
||||||
unset($insurance_network->nhc_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -323,6 +321,10 @@ class InsuranceController extends Controller
|
||||||
$b->insurance_remaining_amount = $this->toMoneyWithCurrencyCode(($monthPrice->max_insurance_coverage_amount ?? 0) - $b->insurance_coverage_amount, $currency_code);
|
$b->insurance_remaining_amount = $this->toMoneyWithCurrencyCode(($monthPrice->max_insurance_coverage_amount ?? 0) - $b->insurance_coverage_amount, $currency_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($type == 'STOPPED') {
|
||||||
|
$insurance->months_prices = $this->fetchInsuranceNetworkMonthsAndYearsPrices($insurance->nhNetworkConfig->id);
|
||||||
|
}
|
||||||
|
|
||||||
unset($insurance->nhNetworkConfig);
|
unset($insurance->nhNetworkConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -707,9 +709,9 @@ class InsuranceController extends Controller
|
||||||
* ),
|
* ),
|
||||||
* @OA\Property(
|
* @OA\Property(
|
||||||
* property="month_price_id",
|
* property="month_price_id",
|
||||||
* description = "Mot de passe",
|
* description = "ID du type de paiement",
|
||||||
* type="string",
|
* type="integer",
|
||||||
* example= "12345"
|
* example= 12
|
||||||
* ),
|
* ),
|
||||||
* ),
|
* ),
|
||||||
* ),
|
* ),
|
||||||
|
|
Loading…
Reference in New Issue