FUNCTION Function_Traduction_Mnt(Xxcpr_Amount IN NUMBER,
Xxcpr_Currency_Code IN VARCHAR2,
Xxcpr_Country IN VARCHAR2)
RETURN VARCHAR2 IS
Vl_Precision NUMBER;
Vl_Entier NUMBER;
Vl_Decimal NUMBER;
Vl_Seg_Milliard VARCHAR2(3);
Vl_Seg_Million VARCHAR2(3);
Vl_Seg_Millier VARCHAR2(3);
Vl_Seg_Cdu VARCHAR2(3);
Vl_Mnt_Traduit VARCHAR2(5000) := '';
Vl_Tmp_Amount NUMBER;
CURSOR Xxcpr_Cur_Precision IS
SELECT PRECISION
FROM Fnd_Currencies
WHERE Currency_Code = Xxcpr_Currency_Code;
CURSOR Xxcpr_Cur_Lib_Mnt IS
SELECT ' ' || Xlm0.Valeur || ' ' Milliard,
' ' || Xlm1.Valeur || ' ' Million,
' ' || Xlm2.Valeur || ' ' Millier,
' ' || Xld.Valeur_Unites || ' ' Unite_Devise,
' ' || Xlm10.Valeur || ' ' Milliard_Plur,
' ' || Xlm11.Valeur || ' ' Million_Plur,
' ' || Xlm12.Valeur || ' ' Millier_Plur,
Xlm3.Valeur Seg_Milliard,
Xlm4.Valeur Seg_Million,
Xlm5.Valeur Seg_Millier,
Xlm6.Valeur Seg_Cdu
FROM Xxrfr_Lib_Mnt Xlm0,
Xxrfr_Lib_Mnt Xlm1,
Xxrfr_Lib_Mnt Xlm2,
Xxrfr_Lib_Mnt Xlm3,
Xxrfr_Lib_Dev Xld,
Xxrfr_Lib_Mnt Xlm4,
Xxrfr_Lib_Mnt Xlm5,
Xxrfr_Lib_Mnt Xlm6,
Xxrfr_Lib_Mnt Xlm10,
Xxrfr_Lib_Mnt Xlm11,
Xxrfr_Lib_Mnt Xlm12
WHERE Xlm0.Code = 'MILLIARD'
AND Xlm1.Code = 'MILLION'
AND Xlm2.Code = 'MILLIER'
AND Xld.Code_Dev = Xxcpr_Currency_Code
AND Xlm3.Code = Vl_Seg_Milliard
AND Xlm4.Code = Vl_Seg_Million
AND Xlm5.Code = Vl_Seg_Millier
AND Xlm6.Code = Vl_Seg_Cdu
AND Xlm10.Code = 'MILLIARDS'
AND Xlm11.Code = 'MILLIONS'
AND Xlm12.Code = 'MILLIERS'
AND Xlm0.Pays = Xxcpr_Country
AND Xlm1.Pays = Xxcpr_Country
AND Xlm2.Pays = Xxcpr_Country
AND Xlm3.Pays = Xxcpr_Country
AND Xld.Pays = Xxcpr_Country
AND Xlm4.Pays = Xxcpr_Country
AND Xlm5.Pays = Xxcpr_Country
AND Xlm6.Pays = Xxcpr_Country
AND Xlm10.Pays = Xxcpr_Country
AND Xlm11.Pays = Xxcpr_Country
AND Xlm12.Pays = Xxcpr_Country;
Vl_Rec_Lib_Mnt Xxcpr_Cur_Lib_Mnt%ROWTYPE;
CURSOR Xxcpr_Cur_Lib_Mnt_Dec IS
SELECT ' ' || Xld.Valeur_Decimales || ' ' Decimal_Devise,
Xlm8.Valeur Mnt_Partie_Decimale
FROM Xxrfr_Lib_Dev Xld,
Xxrfr_Lib_Mnt Xlm8
WHERE Xld.Code_Dev = Xxcpr_Currency_Code
AND Xlm8.Code = To_Char(Vl_Decimal)
AND Xld.Pays = Xxcpr_Country
AND Xlm8.Pays = Xxcpr_Country;
Vl_Rec_Lib_Mnt_Dec Xxcpr_Cur_Lib_Mnt_Dec%ROWTYPE;
BEGIN
OPEN Xxcpr_Cur_Precision;
FETCH Xxcpr_Cur_Precision
INTO Vl_Precision;
IF Xxcpr_Cur_Precision%NOTFOUND THEN
Vl_Precision := 0;
END IF;
CLOSE Xxcpr_Cur_Precision;
Vl_Entier := Trunc(Xxcpr_Amount);
Vl_Decimal := (Xxcpr_Amount - Vl_Entier) *
Power(10,
Vl_Precision);
IF Xxcpr_Amount > 999999999999.99 THEN
RETURN NULL;
END IF;
Vl_Seg_Milliard := To_Char(Trunc(Xxcpr_Amount / Power(10,
9)));
Vl_Seg_Million := Substr(To_Char(Trunc(Xxcpr_Amount /
Power(10,
6))),
Length(To_Char(Trunc(Xxcpr_Amount /
Power(10,
6)))) - 2,
3);
Vl_Seg_Million := To_Char(To_Number(Vl_Seg_Million));
Vl_Tmp_Amount := Vl_Entier - (Trunc(Vl_Entier / Power(10,
6)) *
Power(10,
6));
Vl_Seg_Millier := To_Char(Trunc(Vl_Tmp_Amount /
Power(10,
3)));
Vl_Seg_Cdu := To_Char(MOD(Vl_Tmp_Amount,
Power(10,
3)));
OPEN Xxcpr_Cur_Lib_Mnt;
FETCH Xxcpr_Cur_Lib_Mnt
INTO Vl_Rec_Lib_Mnt;
IF Xxcpr_Cur_Lib_Mnt%NOTFOUND THEN
CLOSE Xxcpr_Cur_Lib_Mnt;
RETURN(NULL);
END IF;
IF Vl_Seg_Milliard = 0 THEN
Vl_Mnt_Traduit := Vl_Mnt_Traduit;
ELSIF Vl_Seg_Milliard = 1 THEN
Vl_Mnt_Traduit := Vl_Mnt_Traduit || Vl_Rec_Lib_Mnt.Seg_Milliard ||
Vl_Rec_Lib_Mnt.Milliard;
ELSIF Vl_Seg_Milliard > 1 THEN
Vl_Mnt_Traduit := Vl_Mnt_Traduit || Vl_Rec_Lib_Mnt.Seg_Milliard ||
Vl_Rec_Lib_Mnt.Milliard_Plur;
END IF;
IF Vl_Seg_Million = 0 THEN
Vl_Mnt_Traduit := Vl_Mnt_Traduit;
ELSIF Vl_Seg_Million = 1 THEN
Vl_Mnt_Traduit := Vl_Mnt_Traduit || Vl_Rec_Lib_Mnt.Seg_Million ||
Vl_Rec_Lib_Mnt.Million;
ELSIF Vl_Seg_Million > 1 THEN
Vl_Mnt_Traduit := Vl_Mnt_Traduit || Vl_Rec_Lib_Mnt.Seg_Million ||
Vl_Rec_Lib_Mnt.Million_Plur;
END IF;
IF Vl_Seg_Millier = 0 THEN
Vl_Mnt_Traduit := Vl_Mnt_Traduit;
ELSIF Vl_Seg_Millier = 1 THEN
IF Xxcpr_Country = 'PT' THEN
Vl_Mnt_Traduit := Vl_Mnt_Traduit || Ltrim(Vl_Rec_Lib_Mnt.Millier);
ELSE
Vl_Mnt_Traduit := Vl_Mnt_Traduit || Vl_Rec_Lib_Mnt.Seg_Millier ||
Vl_Rec_Lib_Mnt.Millier;
END IF;
ELSIF Vl_Seg_Millier > 1 THEN
Vl_Mnt_Traduit := Vl_Mnt_Traduit || Vl_Rec_Lib_Mnt.Seg_Millier ||
Vl_Rec_Lib_Mnt.Millier_Plur;
END IF;
IF Vl_Seg_Cdu = 0 THEN
IF Vl_Mnt_Traduit IS NULL THEN
Vl_Mnt_Traduit := Vl_Mnt_Traduit;
ELSE
Vl_Mnt_Traduit := Vl_Mnt_Traduit ||
Ltrim(Vl_Rec_Lib_Mnt.Unite_Devise);
END IF;
ELSE
Vl_Mnt_Traduit := Vl_Mnt_Traduit || Vl_Rec_Lib_Mnt.Seg_Cdu ||
Vl_Rec_Lib_Mnt.Unite_Devise;
END IF;
CLOSE Xxcpr_Cur_Lib_Mnt;
IF Vl_Decimal <> 0 THEN
OPEN Xxcpr_Cur_Lib_Mnt_Dec;
FETCH Xxcpr_Cur_Lib_Mnt_Dec
INTO Vl_Rec_Lib_Mnt_Dec;
IF Xxcpr_Cur_Lib_Mnt_Dec%NOTFOUND THEN
CLOSE Xxcpr_Cur_Lib_Mnt_Dec;
RETURN(NULL);
END IF;
Vl_Mnt_Traduit := Vl_Mnt_Traduit ||
Vl_Rec_Lib_Mnt_Dec.Mnt_Partie_Decimale ||
Vl_Rec_Lib_Mnt_Dec.Decimal_Devise;
CLOSE Xxcpr_Cur_Lib_Mnt_Dec;
ELSIF Vl_Mnt_Traduit IS NULL THEN
Vl_Mnt_Traduit := Vl_Rec_Lib_Mnt.Seg_Cdu ||
Vl_Rec_Lib_Mnt.Unite_Devise;
END IF;
Vl_Mnt_Traduit := Upper(Rtrim(Vl_Mnt_Traduit));
RETURN(Vl_Mnt_Traduit);
END Function_Traduction_Mnt; |