From c37b72639df294d2020d971a8a13dfca048fba30 Mon Sep 17 00:00:00 2001 From: Maud Royer Date: Fri, 29 Nov 2024 16:12:17 +0100 Subject: [PATCH] feat: price with pharmacy fee Signed-off-by: Maud Royer --- src/components/PresentationsList.tsx | 9 +++++++-- src/db/pdbmMySQL/types.ts | 12 +++++------- src/db/utils.ts | 15 ++------------- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/components/PresentationsList.tsx b/src/components/PresentationsList.tsx index 99f5884..9837966 100644 --- a/src/components/PresentationsList.tsx +++ b/src/components/PresentationsList.tsx @@ -70,9 +70,14 @@ export function PresentationsList(props: { {(p.details && presentationDetailName(p.details)) || p.PresNom01} {" "} -{" "} - {p.Prix && p.Taux ? ( + {p.PPF && p.TauxPriseEnCharge ? ( <> - Prix {p.Prix} € - remboursé à {p.Taux} + Prix{" "} + {Intl.NumberFormat("fr-FR", { + style: "currency", + currency: "EUR", + }).format(p.PPF)}{" "} + - remboursé à {p.TauxPriseEnCharge} ) : ( <>Prix libre - non remboursable diff --git a/src/db/pdbmMySQL/types.ts b/src/db/pdbmMySQL/types.ts index 8edee11..86c58e6 100644 --- a/src/db/pdbmMySQL/types.ts +++ b/src/db/pdbmMySQL/types.ts @@ -6,7 +6,7 @@ export interface PdbmMySQL { Composant: SpecComposantTable; Subs_Nom: Subs_NomTable; Presentation: PresentationTable; - CNAM_InfoTarif: InfoTarifTable; + CEPS_Prix: CEPSPrixTable; Spec_Delivrance: SpecDelivranceTable; DicoDelivrance: DicoDelivranceTable; StatutComm: StatutCommTable; @@ -79,12 +79,10 @@ interface PresentationTable { codeCIP13: string; } -interface InfoTarifTable { +interface CEPSPrixTable { Cip13: string; - Taux: string; - Prix: string; - DateEffet: Date; - IndicRestreinte: string; + TauxPriseEnCharge: string; + PPF: number; } interface SpecDelivranceTable { @@ -139,7 +137,7 @@ export type SpecElement = Selectable; export type SpecComposant = Selectable; export type SubstanceNom = Selectable; export type Presentation = Selectable; -export type PresInfoTarif = Selectable; +export type PresInfoTarif = Selectable; export type SpecDelivrance = Selectable & Selectable; export type Patho = Selectable; diff --git a/src/db/utils.ts b/src/db/utils.ts index a6810e7..1afaa68 100644 --- a/src/db/utils.ts +++ b/src/db/utils.ts @@ -57,22 +57,11 @@ export const getPresentations = cache( .selectFrom("Presentation") .where("SpecId", "=", CIS) .where(presentationIsComm()) - .leftJoin( - "CNAM_InfoTarif", - "Presentation.codeCIP13", - "CNAM_InfoTarif.Cip13", - ) + .leftJoin("CEPS_Prix", "Presentation.codeCIP13", "CEPS_Prix.Cip13") .selectAll() .execute() ).sort((a, b) => - a.Prix && b.Prix - ? parseFloat(a.Prix.replace(",", ".")) - - parseFloat(b.Prix.replace(",", ".")) - : a.Prix - ? -1 - : b.Prix - ? 1 - : 0, + a.PPF && b.PPF ? a.PPF - b.PPF : a.PPF ? -1 : b.PPF ? 1 : 0, ); }, );