From a0858d891da2dee1e6f10a0f1cda6c6b98fbb457 Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Thu, 17 Feb 2022 15:05:47 +0100 Subject: [PATCH] Implements insurance coverage amount limit --- app/Console/Kernel.php | 4 +- .../Controllers/HealthCareSheetController.php | 111 +++++++++++++++--- app/Http/Controllers/InsuranceController.php | 7 ++ app/Http/Controllers/InvoiceController.php | 10 +- app/Models/NhHavingRight.php | 2 + app/Models/NhHealthCareSheet.php | 8 +- app/Models/NhInsurance.php | 2 + app/Models/NhNetworksConfig.php | 3 + app/Traits/Helper.php | 69 +++++------ ...d_insurance_coverage_amount_to_insured.php | 42 +++++++ ...overage_sharing_to_nh_networks_configs.php | 33 ++++++ ...amounts_to_nh_health_care_sheets_table.php | 35 ++++++ ...date_nh_infos_health_care_sheets_view4.php | 54 +++++++++ ...suranceAmountInNhHealthCareSheetsTable.php | 25 ++++ resources/views/emails/invoice.blade.php | 4 +- 15 files changed, 346 insertions(+), 63 deletions(-) create mode 100644 database/migrations/2022_02_16_143251_add_insurance_coverage_amount_to_insured.php create mode 100644 database/migrations/2022_02_16_153852_add_family_coverage_sharing_to_nh_networks_configs.php create mode 100644 database/migrations/2022_02_17_120927_add_insurances_amounts_to_nh_health_care_sheets_table.php create mode 100644 database/migrations/2022_02_17_130356_update_nh_infos_health_care_sheets_view4.php create mode 100644 database/seeders/FixNullableInsuranceAmountInNhHealthCareSheetsTable.php diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 430f0bf..9f763f0 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -94,10 +94,8 @@ class Kernel extends ConsoleKernel } foreach ($sheets as $sheet) { - $this->fetchHealthCareSheetAmounts($sheet); - $totalInsuredAmount += $sheet->insured_amount; - $totalInsurerAmount += $sheet->insurer_amount; + $totalInsurerAmount += $sheet->insurance_amount; $sheet->date = $sheet->created_at->format('d/m/Y'); } diff --git a/app/Http/Controllers/HealthCareSheetController.php b/app/Http/Controllers/HealthCareSheetController.php index 4b7d4fb..5264fd8 100755 --- a/app/Http/Controllers/HealthCareSheetController.php +++ b/app/Http/Controllers/HealthCareSheetController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Events\InsuredConsultation; +use App\Exceptions\AppException; use App\HealthCareSheetType; use App\InsuranceState; use App\InsuranceSubscriptionState; @@ -12,6 +13,7 @@ use App\Models\NhAct; use App\Models\NhAuthorizationOfCareRequest; use App\Models\NhDrugsAndDevice; use App\Models\NhExam; +use App\Models\NhHavingRight; use App\Models\NhHealthCareSheet; use App\Models\NhHealthCareSheetsExam; use App\Models\NhHealthCareSheetsHistory; @@ -642,7 +644,6 @@ class HealthCareSheetController extends Controller } $parts = $this->getConfigInsuranceParts($nhConfig, $request->input('care_condition')); - try { DB::beginTransaction(); @@ -694,6 +695,11 @@ class HealthCareSheetController extends Controller $this->useAuthorizationRequest($p['act_id'], $insurance->id, $beneficiary_id, $healthCareSheet->id, $datetime); } + // Calculer les parts de l'assurance et l'assuré pour cette feuille de soins + $this->calculateInsuranceAmounts($healthCareSheet); + // Verification de la limite de couverture + $this->verifyInsuranceCoverageAmount($nhConfig, $insurance, $healthCareSheet, $beneficiary ?? null); + foreach ($request->input('prescriptions', []) as $p) { $prescription = NhMedicalPrescription::create($p); $prescription->created_at = $prescription->updated_at = $datetime; @@ -741,6 +747,8 @@ class HealthCareSheetController extends Controller DB::commit(); return $this->successResponse(trans('messages.consultation_or_prescription_carried_out')); + } catch (AppException $e) { + return $this->errorResponse($e->getMessage(), $e->getCode()); } catch (Throwable $e) { Log::error($e->getMessage() . '\n' . $e->getTraceAsString()); DB::rollBack(); @@ -748,6 +756,34 @@ class HealthCareSheetController extends Controller } } + + /** + * @throws AppException + */ + // Verification de la limite de couverture + private function verifyInsuranceCoverageAmount(NhNetworksConfig $nhConfig, NhInsurance $insurance, NhHealthCareSheet $sheet, NhHavingRight $beneficiary = null) + { + $insurance_coverage_amount = isset($beneficiary) ? $beneficiary->insurance_coverage_amount : $insurance->insurance_coverage_amount; + $insurance_amount = $sheet->insurance_amount; + + if (!$nhConfig->family_coverage_sharing) { + $total_insurance_amount = $insurance_coverage_amount + $insurance_amount; + if ($total_insurance_amount > $nhConfig->coverage_limit_per_insured_per_year) { + DB::rollBack(); + throw new AppException("La limite de couverture a été atteinte pour cet assuré"); + } + } else { + $total_insurance_amount = $insurance_amount + $insurance->insurance_coverage_amount; + foreach ($insurance->beneficiaries as $b) { + $total_insurance_amount += $b->insurance_coverage_amount; + } + if ($total_insurance_amount > ($nhConfig->coverage_limit_per_insured_per_year * ($insurance->number_of_beneficiaries + 1))) { + DB::rollBack(); + throw new AppException("La mutualisation familiale a été atteinte pour cet assuré"); + } + } + } + private function useAuthorizationRequest($act_id, $insurance_id, $beneficiary_id, $sheet_id, $datetime): void { $authorization_request = NhAuthorizationOfCareRequest::where('act_id', $act_id)->where('insurance_id', $insurance_id); @@ -990,6 +1026,12 @@ class HealthCareSheetController extends Controller } } + // Calculer les parts de l'assurance et l'assuré pour cette feuille de soins + $this->calculateInsuranceAmounts($healthCareSheet); + // Verification de la limite de couverture + $this->verifyInsuranceCoverageAmount($nhConfig, $sheet->insurance, $healthCareSheet, $sheet->beneficiary); + + #Clone pivots // $performances = NhHealthCareSheetsPerformance::where('sheet_id', $sheet->id)->get(); // foreach ($performances as $pf) { @@ -1016,6 +1058,8 @@ class HealthCareSheetController extends Controller DB::commit(); return $this->successResponse(trans('messages.execution_carried_out')); + } catch (AppException $e) { + return $this->errorResponse($e->getMessage(), $e->getCode()); } catch (Throwable $e) { Log::error($e->getMessage() . '\n' . $e->getTraceAsString()); DB::rollBack(); @@ -1386,20 +1430,38 @@ class HealthCareSheetController extends Controller $datetime = $this->getCurrentTimeByCountryCode($sheet->insurance->network->country->code_country); - if ($action == 'ACCEPT') { - $sheet->state = InsuranceSubscriptionState::ACCEPTED; - $message = trans('messages.care_sheet_accepted'); - } else if ($action == 'REJECT') { - $sheet->state = InsuranceSubscriptionState::REJECTED; - $message = trans('messages.care_sheet_rejected'); - } else { - $sheet->state = InsuranceSubscriptionState::UNDER_VALIDATION; - $sheet->created_at = $datetime; - $message = trans('messages.care_sheet_resubmitted'); + try { + DB::beginTransaction(); + if ($action == 'ACCEPT') { + $sheet->state = InsuranceSubscriptionState::ACCEPTED; + $message = trans('messages.care_sheet_accepted'); + // Mettre à jour lq couverture d'assurance de chaque assuré + $sheet->insurance_consumed_at = $datetime; + if (!empty($sheet->beneficiary)) { + $sheet->beneficiary->insurance_coverage_amount += $sheet->insurance_amount; + $sheet->beneficiary->save(); + } else { + $sheet->insurance->insurance_coverage_amount += $sheet->insurance_amount; + $sheet->insurance->save(); + } + } else if ($action == 'REJECT') { + $sheet->state = InsuranceSubscriptionState::REJECTED; + $message = trans('messages.care_sheet_rejected'); + } else { + $sheet->state = InsuranceSubscriptionState::UNDER_VALIDATION; + $sheet->created_at = $datetime; + $message = trans('messages.care_sheet_resubmitted'); + } + $sheet->updated_at = $datetime; + $sheet->save(); + DB::commit(); + return $this->successResponse($message); + + } catch (Throwable $e) { + Log::error($e->getMessage() . '\n' . $e->getTraceAsString()); + DB::rollBack(); + return $this->errorResponse(trans('errors.unexpected_error'), 500); } - $sheet->updated_at = $datetime; - $sheet->save(); - return $this->successResponse($message); } private function getConfigInsuranceParts(NhNetworksConfig $nhConfig, $care_condition): stdClass @@ -1773,8 +1835,15 @@ class HealthCareSheetController extends Controller ]); } } + + // Calculer les parts de l'assurance et l'assuré pour cette feuille de soins + $this->calculateInsuranceAmounts($sheet); + // Verification de la limite de couverture + $this->verifyInsuranceCoverageAmount($nhConfig, $sheet->insurance, $sheet, $beneficiary ?? null); + } + $_prescriptions = []; foreach ($request->input('prescriptions', []) as $p) { if (!empty($p['to_delete'])) { NhMedicalPrescription::find($p['id'])->delete(); @@ -1806,6 +1875,7 @@ class HealthCareSheetController extends Controller } $prescription->updated_at = $datetime; $prescription->save(); + $_prescriptions[] = $prescription; if (empty($p['id'])) { NhHealthCareSheetsPrescription::create([ @@ -1857,10 +1927,19 @@ class HealthCareSheetController extends Controller } } + if ($sheet->type == HealthCareSheetType::EXECUTION) { + // Calculer les parts de l'assurance et l'assuré pour cette feuille de soins + $this->calculateInsuranceAmounts($sheet); + // Verification de la limite de couverture + $this->verifyInsuranceCoverageAmount($nhConfig, $sheet->insurance, $sheet, $sheet->beneficiary); + } + $sheet->save(); DB::commit(); return $this->successResponse(trans('messages.consultation_or_prescription_updated')); + } catch (AppException $e) { + return $this->errorResponse($e->getMessage(), $e->getCode()); } catch (Throwable $e) { Log::error($e->getMessage() . '\n' . $e->getTraceAsString()); DB::rollBack(); @@ -1887,10 +1966,8 @@ class HealthCareSheetController extends Controller $sheet->patient_situation = trans('states.' . $sheet->patient_situation); $sheet->_care_condition = $sheet->care_condition; $sheet->care_condition = trans('states.' . $sheet->care_condition); - $this->fetchHealthCareSheetAmounts($sheet); - $sheet->insurance_amount = $this->toMoneyWithCurrencyCode($sheet->insurer_amount, $sheet->currency_code); + $sheet->insurance_amount = $this->toMoneyWithCurrencyCode($sheet->insurance_amount, $sheet->currency_code); $sheet->insured_amount = $this->toMoneyWithCurrencyCode($sheet->insured_amount, $sheet->currency_code); - unset($sheet->insurer_amount); foreach ($sheet->performances as $p) { $p->amount_formatted = $this->toMoneyWithCurrencyCode($p->amount, $sheet->currency_code); $p->moderator_ticket_formatted = $this->toMoneyWithCurrencyCode($p->moderator_ticket, $sheet->currency_code); diff --git a/app/Http/Controllers/InsuranceController.php b/app/Http/Controllers/InsuranceController.php index 390b5b1..aea4a84 100644 --- a/app/Http/Controllers/InsuranceController.php +++ b/app/Http/Controllers/InsuranceController.php @@ -204,8 +204,10 @@ class InsuranceController extends Controller $insurance->state = trans($insurance->state); $insurance->bonus_amount = $this->toMoneyWithCurrencyCode($insurance->bonus_amount, $currency_code); $insurance->total_bonus_amount = $this->toMoneyWithCurrencyCode($insurance->total_bonus_amount, $currency_code); + $insurance->insurance_coverage_amount = $this->toMoneyWithCurrencyCode($insurance->insurance_coverage_amount, $currency_code); foreach ($insurance->beneficiaries as $b) { $b->bonus_amount = $this->toMoneyWithCurrencyCode($b->bonus_amount, $currency_code); + $b->insurance_coverage_amount = $this->toMoneyWithCurrencyCode($b->insurance_coverage_amount, $currency_code); } } @@ -654,11 +656,16 @@ class InsuranceController extends Controller 'number_of_beneficiaries' => sizeof($insurance->beneficiaries), 'total_bonus_amount' => $amountToPaid, 'bonus_amount' => $bonus_amount, + 'insurance_coverage_amount' => 0, 'updated_at' => $datetime, 'state' => InsuranceState::PAID, 'start_at' => $datetime, 'end_at' => DateTime::createFromFormat('Y-m-d H:i:s', $datetime)->modify('+' . $insurance->number_of_months . 'months') ]); + // Reinitialiser les montants de couvertures de l'assurance + $insurance->beneficiaries->each->update([ + 'insurance_coverage_amount' => 0 + ]); NhInsurancesPayment::create([ 'insured_id' => $insurance->insured_id, diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index cde01c5..6b182da 100755 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -99,10 +99,8 @@ class InvoiceController extends Controller } foreach ($sheets as $sheet) { - $this->fetchHealthCareSheetAmounts($sheet); - $totalInsuredAmount += $sheet->insured_amount; - $totalInsurerAmount += $sheet->insurer_amount; + $totalInsurerAmount += $sheet->insurance_amount; $sheet->date = $sheet->created_at->format('d/m/Y'); } @@ -262,10 +260,8 @@ class InvoiceController extends Controller foreach ($i->health_care_sheets as $sheet) { - $this->fetchHealthCareSheetAmounts($sheet); - - $sheet->amount = $this->toMoneyWithCurrencyCode($sheet->insured_amount + $sheet->insurer_amount, $i->currency_code); - $sheet->insurerAmount = $this->toMoneyWithCurrencyCode($sheet->insurer_amount, $i->currency_code); + $sheet->amount = $this->toMoneyWithCurrencyCode($sheet->insured_amount + $sheet->insurance_amount, $i->currency_code); + $sheet->insurerAmount = $this->toMoneyWithCurrencyCode($sheet->insurance_amount, $i->currency_code); $sheet->insuredAmount = $this->toMoneyWithCurrencyCode($sheet->insured_amount, $i->currency_code); } diff --git a/app/Models/NhHavingRight.php b/app/Models/NhHavingRight.php index 67e6bc7..db6271c 100644 --- a/app/Models/NhHavingRight.php +++ b/app/Models/NhHavingRight.php @@ -20,6 +20,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property Carbon $birthdate * @property string $affiliation * @property float $bonus_amount + * @property float $insurance_coverage_amount * @property string|null $birthdate_proof * @property string|null $birthdate_proof_doc * @property string|null $justice_doc @@ -49,6 +50,7 @@ class NhHavingRight extends Model 'birthdate', 'affiliation', 'bonus_amount', + 'insurance_coverage_amount', 'birthdate_proof', 'birthdate_proof_doc', 'justice_doc', diff --git a/app/Models/NhHealthCareSheet.php b/app/Models/NhHealthCareSheet.php index 9783be8..30f19e6 100644 --- a/app/Models/NhHealthCareSheet.php +++ b/app/Models/NhHealthCareSheet.php @@ -31,6 +31,9 @@ use Illuminate\Database\Eloquent\Model; * @property string $state * @property int $prescription_sheet_id * @property int $invoice_id + * @property float $insurance_amount + * @property float $insured_amount + * @property float $insurance_consumed_at * @property Carbon $created_at * @property Carbon $updated_at * @@ -71,7 +74,10 @@ class NhHealthCareSheet extends Model 'type', 'state', 'prescription_sheet_id', - 'invoice_id' + 'invoice_id', + 'insurance_amount', + 'insured_amount', + 'insurance_consumed_at' ]; public function institution() diff --git a/app/Models/NhInsurance.php b/app/Models/NhInsurance.php index 1075ecd..a696551 100644 --- a/app/Models/NhInsurance.php +++ b/app/Models/NhInsurance.php @@ -20,6 +20,7 @@ use Illuminate\Database\Eloquent\Model; * @property float $bonus_amount * @property int $number_of_beneficiaries * @property float $total_bonus_amount + * @property float $insurance_coverage_amount * @property Carbon|null $start_at * @property Carbon|null $end_at * @property string $state @@ -43,6 +44,7 @@ class NhInsurance extends Model 'insured_id', 'number_of_months', 'total_bonus_amount', + 'insurance_coverage_amount', 'number_of_beneficiaries', 'bonus_amount', 'start_at', diff --git a/app/Models/NhNetworksConfig.php b/app/Models/NhNetworksConfig.php index 731cbdc..015ceff 100644 --- a/app/Models/NhNetworksConfig.php +++ b/app/Models/NhNetworksConfig.php @@ -19,6 +19,7 @@ use Illuminate\Database\Eloquent\Model; * @property int $age_limit_of_child_beneficiary * @property int $age_limit_of_insured_and_spouse * @property float $coverage_limit_per_insured_per_year + * @property boolean $family_coverage_sharing * @property float $current_affection_percentage_insurer * @property float $current_affection_percentage_insured * @property float $long_term_affection_percentage_insurer @@ -40,6 +41,7 @@ class NhNetworksConfig extends Model 'age_limit_of_insured_and_spouse' => 'int', 'age_limit_of_child_beneficiary' => 'int', 'coverage_limit_per_insured_per_year' => 'float', + 'family_coverage_sharing' => 'boolean', 'current_affection_percentage_insurer' => 'float', 'current_affection_percentage_insured' => 'float', 'long_term_affection_percentage_insurer' => 'float', @@ -55,6 +57,7 @@ class NhNetworksConfig extends Model 'age_limit_of_insured_and_spouse', 'age_limit_of_child_beneficiary', 'coverage_limit_per_insured_per_year', + 'family_coverage_sharing', 'current_affection_percentage_insurer', 'current_affection_percentage_insured', 'long_term_affection_percentage_insurer', diff --git a/app/Traits/Helper.php b/app/Traits/Helper.php index ecff006..272d406 100644 --- a/app/Traits/Helper.php +++ b/app/Traits/Helper.php @@ -19,6 +19,7 @@ use App\Models\NhInsurance; use App\Models\NhInsurancesHavingRight; use App\Models\NhInsurancesSubscription; use App\Models\NhMonthsPricesGrid; +use App\Models\NhNetworksConfig; use App\Models\User; use Brick\Money\Context\AutoContext; use Brick\Money\Money; @@ -32,6 +33,7 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; +use stdClass; trait Helper { @@ -171,39 +173,6 @@ trait Helper return date('d') . '/' . date('m') . '/' . date('Y') . '/' . $agent_code; } - public function fetchHealthCareSheetAmounts($sheet) - { - $insurerAmount = 0; - $insuredAmount = 0; - - if ($sheet->type == HealthCareSheetType::CONSULTATION) { - $sum = current(DB::select("SELECT SUM(moderator_ticket) as moderator_ticket , SUM(insurance_amount) as insurance_amount FROM nh_performances p INNER JOIN - nh_health_care_sheets_performances hp ON p.id = hp.performance_id WHERE hp.sheet_id = :sheet_id LIMIT 1", ['sheet_id' => $sheet->id])); - if (isset($sum)) { - $insuredAmount += $sum->moderator_ticket; - $insurerAmount += $sum->insurance_amount; - } - } else { - $sum = current(DB::select("SELECT SUM(insured_paid_amount) as insured_paid_amount , SUM(insurer_paid_amount) as insurer_paid_amount FROM nh_medical_prescriptions p INNER JOIN - nh_health_care_sheets_prescriptions hp ON p.id = hp.prescription_id WHERE hp.sheet_id = :sheet_id LIMIT 1", ['sheet_id' => $sheet->id])); - if (isset($sum)) { - $insuredAmount += $sum->insured_paid_amount; - $insurerAmount += $sum->insurer_paid_amount; - } - - - $sum = current(DB::select("SELECT SUM(insured_paid_amount) as insured_paid_amount , SUM(insurer_paid_amount) as insurer_paid_amount FROM nh_exams e INNER JOIN - nh_health_care_sheets_exams he ON e.id = he.exam_id WHERE he.sheet_id = :sheet_id LIMIT 1", ['sheet_id' => $sheet->id])); - if (isset($sum)) { - $insuredAmount += $sum->insured_paid_amount; - $insurerAmount += $sum->insurer_paid_amount; - } - } - - $sheet->insurer_amount = $insurerAmount; - $sheet->insured_amount = $insuredAmount; - } - /** * @throws AppException */ @@ -248,4 +217,38 @@ trait Helper if (!checkPassword($password, $agent->encrypted_password, $agent->salt)) throw new AppException(trans('messages.incorrect_user_password')); } + + public function calculateInsuranceAmounts(NhHealthCareSheet $sheet) + { + $insuranceAmount = 0; + $insuredAmount = 0; + + if ($sheet->type == HealthCareSheetType::CONSULTATION) { + $sum = current(DB::select("SELECT SUM(moderator_ticket) as moderator_ticket , SUM(insurance_amount) as insurance_amount FROM nh_performances p INNER JOIN + nh_health_care_sheets_performances hp ON p.id = hp.performance_id WHERE hp.sheet_id = :sheet_id LIMIT 1", ['sheet_id' => $sheet->id])); + if (isset($sum)) { + $insuredAmount += $sum->moderator_ticket; + $insuranceAmount += $sum->insurance_amount; + } + } else { + $sum = current(DB::select("SELECT SUM(insured_paid_amount) as insured_paid_amount , SUM(insurer_paid_amount) as insurer_paid_amount FROM nh_medical_prescriptions p INNER JOIN + nh_health_care_sheets_prescriptions hp ON p.id = hp.prescription_id WHERE hp.sheet_id = :sheet_id LIMIT 1", ['sheet_id' => $sheet->id])); + if (isset($sum)) { + $insuredAmount += $sum->insured_paid_amount; + $insuranceAmount += $sum->insurer_paid_amount; + } + + + $sum = current(DB::select("SELECT SUM(insured_paid_amount) as insured_paid_amount , SUM(insurer_paid_amount) as insurer_paid_amount FROM nh_exams e INNER JOIN + nh_health_care_sheets_exams he ON e.id = he.exam_id WHERE he.sheet_id = :sheet_id LIMIT 1", ['sheet_id' => $sheet->id])); + if (isset($sum)) { + $insuredAmount += $sum->insured_paid_amount; + $insuranceAmount += $sum->insurer_paid_amount; + } + } + + $sheet->insurance_amount = $insuranceAmount; + $sheet->insured_amount = $insuredAmount; + $sheet->save(); + } } diff --git a/database/migrations/2022_02_16_143251_add_insurance_coverage_amount_to_insured.php b/database/migrations/2022_02_16_143251_add_insurance_coverage_amount_to_insured.php new file mode 100644 index 0000000..c5181d1 --- /dev/null +++ b/database/migrations/2022_02_16_143251_add_insurance_coverage_amount_to_insured.php @@ -0,0 +1,42 @@ +decimal('insurance_coverage_amount', 10, 2)->default(0)->after('bonus_amount') + ->comment("Montant de la couverture de l'assurance de l'ayant droit, deja utilisé"); + }); + + Schema::table('nh_insurances', function (Blueprint $table) { + $table->decimal('insurance_coverage_amount', 10, 2)->default(0)->after('total_bonus_amount') + ->comment("Montant de la couverture de l'assurance de l'assuré principal, deja utilisé"); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('nh_having_rights', function (Blueprint $table) { + $table->dropColumn(['insurance_coverage_amount']); + }); + + Schema::table('nh_insurances', function (Blueprint $table) { + $table->dropColumn(['insurance_coverage_amount']); + }); + } +} diff --git a/database/migrations/2022_02_16_153852_add_family_coverage_sharing_to_nh_networks_configs.php b/database/migrations/2022_02_16_153852_add_family_coverage_sharing_to_nh_networks_configs.php new file mode 100644 index 0000000..b66ffc8 --- /dev/null +++ b/database/migrations/2022_02_16_153852_add_family_coverage_sharing_to_nh_networks_configs.php @@ -0,0 +1,33 @@ +boolean('family_coverage_sharing')->default(0)->after('coverage_limit_per_insured_per_year') + ->comment("Mutualisation ou partage de couverture familiale"); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('nh_networks_configs', function (Blueprint $table) { + $table->dropColumn(['family_coverage_sharing']); + }); + } +} diff --git a/database/migrations/2022_02_17_120927_add_insurances_amounts_to_nh_health_care_sheets_table.php b/database/migrations/2022_02_17_120927_add_insurances_amounts_to_nh_health_care_sheets_table.php new file mode 100644 index 0000000..28cc582 --- /dev/null +++ b/database/migrations/2022_02_17_120927_add_insurances_amounts_to_nh_health_care_sheets_table.php @@ -0,0 +1,35 @@ +decimal('insurance_amount', 10)->nullable()->after('invoice_id'); + $table->decimal('insured_amount', 10)->nullable()->after('insurance_amount'); + $table->dateTime('insurance_consumed_at')->nullable()->after('insured_amount') + ->comment("Date de consommation de la couverture d'assurance"); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('nh_health_care_sheets', function (Blueprint $table) { + $table->dropColumn(['insurance_amount', 'insured_amount', 'insurance_consumed_at']); + }); + } +} diff --git a/database/migrations/2022_02_17_130356_update_nh_infos_health_care_sheets_view4.php b/database/migrations/2022_02_17_130356_update_nh_infos_health_care_sheets_view4.php new file mode 100644 index 0000000..d2e781e --- /dev/null +++ b/database/migrations/2022_02_17_130356_update_nh_infos_health_care_sheets_view4.php @@ -0,0 +1,54 @@ +get(); + foreach ($sheets as $sheet) { + $this->calculateInsuranceAmounts($sheet); + } + } +} diff --git a/resources/views/emails/invoice.blade.php b/resources/views/emails/invoice.blade.php index 9b97d7b..41d5a97 100755 --- a/resources/views/emails/invoice.blade.php +++ b/resources/views/emails/invoice.blade.php @@ -357,7 +357,7 @@ color:black;margin-left: 45px;'>-------------------

none;border-bottom:solid #BFBFBF 1.0pt;border-right:solid #BFBFBF 1.0pt; background:#F2F2F2;padding:0in 5.4pt 0in 5.4pt'>

{{$fmt->format($sheet->insured_amount + $sheet->insurer_amount)}} + style='font-size:9.0pt;font-family:"Garamond",serif;color:black'>{{$fmt->format($sheet->insured_amount + $sheet->insurance_amount)}}

-------------------

none;border-bottom:solid #BFBFBF 1.0pt;border-right:solid #BFBFBF 1.0pt; background:#F2F2F2;padding:0in 5.4pt 0in 5.4pt'>

{{$fmt->format($sheet->insurer_amount)}} + style='font-size:9.0pt;font-family:"Garamond",serif;color:black'>{{$fmt->format($sheet->insurance_amount)}}