الانتقال إلى المحتوى

إعادة المبلغ كتآآبة


ammar al_hada

Recommended Posts

السلام عليكم ورحمة الله وبركاتة 
كيف يمكن تحويل المبلغ المالي في التقرير من الأرقام إلى المبلغ كتآبة بالحروف ..اتمنى المساعدة

رابط هذا التعليق
شارك

هذه الفانكشن تفي بالغرض


  FUNCTION tafkeet (num char ) RETURN varchar2 IS 
    temp         varchar2(200);
    flipped     varchar2(9):= null;
    float       varchar2(3);
    sd3        varchar2(3) ; 
    nd3        varchar2(3) ; 
    rd3        varchar2(3) ;
    x        varchar2(9);
    I              NUMBER :=0;
BEGIN
  
temp := ' فقط ';
flipped := '';
float := mod( num, 1);
x := to_number(num) - to_number(float);

LOOP
FLIPPED := FLIPPED||SUBSTR(x,LENGTH(x)-I,1);
I := I +1;
IF LENGTH(x) = I  THEN
EXIT;
END IF;
END LOOP;
    
sd3    := substr(FLIPPED,1,3); 
Sd3 := substr(Sd3,3,1)  || substr(Sd3,2,1) || substr(Sd3,1,1) ;
    nd3    := substr(FLIPPED,4,3); 
ND3 := substr(ND3,3,1)  || substr(ND3,2,1) || substr(ND3,1,1) ;
    rd3    := substr(FLIPPED,7,3);
RD3 := substr(RD3,3,1)  || substr(RD3,2,1) || substr(RD3,1,1) ;

/*if substr(sd3,1,1)= 0 and nd3 = 0 then
sd3:= substr(sd3,2,2);
end if;*/

/*if substr(nd3,1,1)= 0 and rd3 = 0 then
nd3:= substr(nd3,2,2);
end if;*/

if substr(rd3,1,1)= 0 then  
rd3:= substr(rd3,2,2);
end if;

if to_number(rd3) <>0 then 
begin
if length(rd3) = 3   then
begin
Select
    temp || decode  (substr(Rd3,1,1),
            0,' ',
            1,' مـائـة ',
            2,' مـائتان ', 
            3,' ثلاثمـائـة ',
            4,' أربـعمـائـة ',
            5,' خـمـسمـائـة ',
            6,' ستمـائـة ',
            7,' سـبـعمـائـة ',
            8,' ثـمـانمـائـة  ',
            9,' تـسـعمـائـة ' , ' ') 
into 
    temp
from
        dual ;

end; 

if not(substr(rd3,2,1) = 1) and (to_number(substr(rd3,2,2))>0) then 
Begin 

select
temp   || decode(substr(rd3,3,1),
            1,' و واحد ',
            2,' و إثنان ', 
            3,' و ثلاثة ',
            4,' و أربعة ',
            5,' و خمسة ',
            6,' و ستة ',
            7,' و سبعة ',
            8,' و ثمانية ',
            9,' و تسعة ',' ') 

into 
    temp
from
        dual ;
end;

end if;


BEGIN 
select
    temp ||   decode (substr(Rd3,2,1),
             0,' ',
             1,DECODE(substr(Rd3,2,2),
             11,' و إحدى عشر ',
             12,' و إثنا عشر ',
             13,' و ثلاثة عشر ' ,
             14,' و أربعة عشر ' , 
             15,' و خمسة عشر ' ,
             16,' و ستة عشر ' ,
             17,' و سبعة عشر ',  
             18,' و ثمانية عشر ',
             19,' و تسعة عشر ',
             10,' و عشرة ')  ,
             2, ' و عشرون  ', 
             3, ' و ثلاثون ',
             4, ' و أربعون ', 
             5, ' و خمسون ',
             6, ' و ستون ', 
             7, ' و سبعون ',
             8, ' و ثمانون ',
             9, ' و تسعون ',' ') 
into 
    temp
from
        dual ;

END;

--end if; -- END OF LENGTH 3 (RD3)

--///////////////////////////////////////////////////////////////////////////////////////////
elsif  length(rd3) =2 then
if not(substr(rd3,1,1) = '1') then
begin
select
    temp||  decode ((substr(rd3,2,1)),
            1,' واحد و ',
            2,' إثنان و ', 
            3,' ثلاثة و ',
            4,' أربعة و ',
            5,' خمسة و ',
            6,' ستة و ',
            7,' سبعة و ',
            8,' ثمانية و ',
            9,' تسعة و ',' ') 

into 
    temp
from
        dual ;
end;

END IF ;

if (substr(Rd3,1,1) > 0) then 
BEGIN 
select
    temp ||  decode (substr(Rd3,1,1),
            0,' ',
            1,DECODE(substr(Rd3,1,2),
            11,' إحدى عشر ',
            12,' إثنا عشر ',
            13,' ثلاثة عشر ' ,
            14,' أربعة عشر ' , 
            15,' خمسة عشر ' ,
            16,' ستة عشر ' ,
            17,' سبعة عشر ',
            18,' ثمانية عشر ',
            19,' تسعة عشر ',
            10,' عشرة ')  ,
            2,' عشرون  ', 
            3,' ثلاثون ',
            4,' أربعون ', 
            5,' خمسون ',
            6,' ستون ',
            7,' سبعون ',
            8,' ثمانون ',
            9,' تسعون ',' ') 
into 
    temp
from
        dual ;
END;
end if ; 
--end if; -- length =2 true 

elsif ((length(rd3) =1 )or not(substr(rd3,1,1) = '1')) and not(length(rd3))>1  then
begin
    if (length(rd3) =1 ) then 
        null;
    else
        rd3 := substr(rd3,2,1) ;
    end if; 
select
         temp || decode (rd3
        ,'0',' '
        ,1,' '
        ,2,' إثنان '
        ,3,' ثلاثة '
        ,4,' أربعة '
        ,5,' خمسة '
        ,6,' ستة '
        ,7,' سبعة '
        ,8,' ثمانية '
        ,9,' تسعة '
        ,' ') 
into 
        temp
from
        dual ;
end;

end if;

temp := temp || ' مليون ';
IF LENGTH (ND3) > 0   and   to_number(ND3) <> 0 or to_number(sD3) <> 0  THEN 
TEMP := TEMP || ' و ' ;
END IF;
End ;
end if;

---******************************************** END OF MILL *************************************
if to_number(Nd3) <>0 then 
begin
if length(Nd3) = 3   then
begin
Select
    TEMP || decode  (substr(Nd3,1,1),
            0,' ',
            1,' مـائـة ',
            2,' مـائتان ', 
            3,' ثلاثمـائـة ',
            4,' أربـعمـائـة ',
            5,' خـمـسمـائـة ',
            6,' ستمـائـة ',
            7,' سـبـعمـائـة ',
            8,' ثـمـانمـائـة  ',
            9,' تـسـعمـائـة ' , ' ') 
into 
    temp
from
        dual ;


end; 

if substr(nd3,1,1) <> 0 and substr(nd3,2,1) <> 0 and substr(nd3,3,1) <> 0 then
temp :=temp || ' و ';
end if;
if substr(nd3,1,1) <> 0 and substr(nd3,2,1) <> 0 and  substr(nd3,3,1) = 0 then
temp :=temp ||  ' و ';
end if;
if substr(nd3,1,1) <> 0  and substr(nd3,2,1) = 0  and  substr(nd3,3,1) <> 0 then
temp :=temp || ' و ';
end if;


if not(substr(Nd3,2,1) = 1) and (to_number(substr(Nd3,2,2))>0) then 
Begin 

select
temp   || decode(substr(Nd3,3,1),
            0,' ' ,
            1,' واحد ',
            2,' إثنان ', 
            3,' ثلاثة ',
            4,' أربعة ',
            5,' خمسة ',
            6,' ستة ',
            7,' سبعة ',
            8,' ثمانية ',
            9,' تسعة ',' ') 

into 
    temp
from
        dual ;
end;


if substr(nd3,2,1) <> 0 and substr(nd3,3,1) <> 0 then
temp :=temp || ' و ';
end if;
end if;



BEGIN 
select
    temp ||   decode (substr(Nd3,2,1),
             0,' ',
             1,DECODE(substr(Nd3,2,2),
             11,' إحدى عشر ',
             12,' إثنا عشر ',
             13,' ثلاثة عشر ' ,
             14,' أربعة عشر ' , 
             15,' خمسة عشر ' ,
             16,' ستة عشر ' ,
             17,' سبعة عشر ',  
             18,' ثمانية عشر ',
             19,' تسعة عشر ',
             10,' عشرة ')  ,
             2, ' عشرون  ', 
             3, ' ثلاثون ',
             4, ' أربعون ', 
             5, ' خمسون ',
             6, ' ستون ', 
             7, ' سبعون ',
             8, ' ثمانون ',
             9, ' تسعون ',' ') 
into 
    temp
from
        dual ;

END;

--end if; -- END OF LENGTH 3 (ND3)

--///////////////////////////////////////////////////////////////////////////////////////////

elsif  length(Nd3) =2 then
if not(substr(Nd3,1,1) = '1') and not(substr(Nd3,2,1) = '0') then
begin
select
    temp||  decode ((substr(Nd3,2,1)),
            0,' ',
            1,' واحد و ',
            2,' إثنان و  ', 
            3,' ثلاثة و  ',
            4,' أربعة و ',
            5,' خمسة و ',
            6,' ستة و ',
            7,' سبعة و ',
            8,' ثمانية و ',
            9,' تسعة و ',' ') 

into 
    temp
from
        dual ;
end;

END IF ;
--not(substr(Nd3,1,1) = '1') and 
if (substr(Nd3,2,1) = '0') then
begin
select
    temp||  decode ((substr(Nd3,2,1)),
            0,' ' ,
            1,' واحد ',
            2,' إثنان ', 
            3,' ثلاثة  ',
            4,' أربعة ',
            5,' خمسة ',
            6,' ستة ',
            7,' سبعة ',
            8,' ثمانية ',
            9,' تسعة ',' ') 

into 
    temp
from
        dual ;
end;

END IF ;


if (substr(Nd3,1,1) > 0) then 
BEGIN 
select
    temp ||  decode (substr(Nd3,1,1),
            0,' ',
            1,DECODE(substr(Nd3,1,2),
            11,' إحدى عشر ',
            12,' اثنا عشر ',
            13,' ثلاثة عشر ' ,
            14,' أربعة عشر ' , 
            15,' خمسة عشر ' ,
            16,' ستة عشر ' ,
            17,' سبعة عشر ',
            18,' ثمانية عشر ',
            19,' تسعة عشر ',
            10,' عشرة ')  ,
            2,' عشرون ', 
            3,' ثلاثون ',
            4,' أربعون ', 
            5,' خمسون ',
            6,' ستون ',
            7,' سبعون ',
            8,' ثمانون ',
            9,' تسعون ',' ') 
into 
    temp
from
        dual ;
END;
end if ; 
end if; -- length =2 true 
if length(nd3) > 1 then
temp := temp || ' ألـف ';
end if;
if ((length(Nd3) =1 )or not(substr(Nd3,1,1) = '1')) and not(length(Nd3))>1  then
begin
    /*if (length(Nd3) =1 ) then 
        null;
    else
        Nd3 := substr(Nd3,2,1) ;
    end if; */
select
         temp || decode (Nd3
        ,'0',' '
        ,1,' ألف '
        ,2,' ألفان '
        ,3,' ثلاثة آلاف '
        ,4,' أربعة آلاف '
        ,5,' خمسة آلاف '
        ,6,' ستة آلاف '
        ,7,' سبعة آلاف '
        ,8,' ثمانية آلاف '
        ,9,' تسعة آلاف '
        ,' ') 
into 
        temp
from
        dual ;
end;

end if;

--temp := temp || ' ألـف ';
IF LENGTH (SD3) > 0  AND to_number(sd3) <> 0 and length(nD3) <> 0  THEN 
TEMP := TEMP || ' و ' ;
END IF;
End ;

end if;
--********************************************END OF ND3***************************************

if to_number(Sd3) <>0 then 
begin
if length(Sd3) = 3   then
begin
Select
    TEMP || decode  (substr(Sd3,1,1),
            0,' ',
            1,' مـائـة ',
            2,' مـائتان ', 
            3,' ثلاثمـائـة ',
            4,' أربـعمـائـة ',
            5,' خـمـسمـائـة ',
            6,' ستمـائـة ',
            7,' سـبـعمـائـة ',
            8,' ثـمـانمـائـة  ',
            9,' تـسـعمـائـة ' , ' ') 
into 
    temp
from
        dual ;


end; 

/*if to_number(rd3) <> 0 or length(nd3) <> 0 and substr(sd3,1,1) = 0 and substr(sd3,2,1) <> 0
  and substr(sd3,3,1) <> 0 then
       temp :=temp || ' و ';
end if;
*/
if substr(sd3,1,1) <> 0 and substr(sd3,2,1) <> 0 and substr(sd3,3,1) <> 0 then
    temp :=temp || ' و ';
end if;
if substr(sd3,1,1) <> 0 and substr(sd3,2,1) <> 0 and  substr(sd3,3,1) = 0 then
    temp :=temp ||  ' و ';
end if;
if substr(sd3,1,1) <> 0  and substr(sd3,2,1) = 0  and  substr(sd3,3,1) <> 0 then
    temp :=temp || ' و ';
end if;

if not(substr(Sd3,2,1) = 1) and (to_number(substr(Sd3,2,2))>0) then 
Begin 

select
temp   || decode(substr(Sd3,3,1),
            0,' ' ,
            1,'  واحد ',
            2,' إثنان ', 
            3,' ثلاثة ',
            4,' أربعة ',
            5,' خمسة ',
            6,' ستة ',
            7,' سبعة ',
            8,' ثمانية ',
            9,' تسعة ',' ') 

into 
    temp
from
        dual ;
end;

if  substr(sd3,2,1) <> 0  and substr(sd3,3,1)<>0 then
temp :=temp || ' و ';
end if;
end if;


BEGIN 
select
    temp ||   decode (substr(Sd3,2,1),
             0,' ',
             1,DECODE(substr(Sd3,2,2),
             11,' إحدى عشر ',
             12,' اثنا عشر ',
             13,' ثلاثة عشر ' ,
             14,' أربعة عشر ' , 
             15,' خمسة عشر ' ,
             16, ' ستة عشر ' ,
             17,' سبعة عشر ',  
             18,' ثمانية عشر ',
             19,' تسعة عشر ',
             10,' عشرة ')  ,
             2, ' عشرون  ', 
             3, ' ثلاثون ',
             4, ' أربعون ', 
             5, ' خمسون ',
             6, ' ستون ', 
             7, ' سبعون ',
             8, ' ثمانون ',
             9, ' تسعون ',' ') 
into 
    temp
from
        dual ;

END;

end if; -- END OF LENGTH 3 (SD3)

--///////////////////////////////////////////////////////////////////////////////////////////

if  length(Sd3) =2 then
if not(substr(Sd3,1,1) = '1') then
begin
select
    temp||  decode ((substr(Sd3,2,1)),
            1,' واحد و ',
            2,' إثنان و ', 
            3,' ثلاثة و ',
            4,' أربعة و ',
            5,' خمسة و ',
            6,' ستة و ',
            7,' سبعة و ',
            8,' ثمانية و ',
            9,' تسعة و ',' ') 

into 
    temp
from
        dual ;
end;

END IF ;

if (substr(Sd3,1,1) > 0) then 
BEGIN 
select
    temp ||  decode (substr(Sd3,1,1),
            0,' ',
            1,DECODE(substr(Sd3,1,2),
            11,' إحدى عشر ',
            12,' اثنا عشر ',
            13,'  ثلاثة عشر ' ,
            14,' أربعة عشر ' , 
            15,' خمسة عشر ' ,
            16,' ستة عشر ' ,
            17,' سبعة عشر ',
            18,' ثمانية عشر ',
            19,' تسعة عشر ',
            10,' عشرة ')  ,
            2,' عشرون ', 
            3,'  ثلاثون ',
            4,' أربعون ', 
            5,' خمسون ',
            6,' ستون ',
            7,' سبعون ',
            8,' ثمانون ',
            9,' تسعون ',' ') 
into 
    temp
from
        dual ;
END;
end if ; 
end if; -- length =2 true 

if ((length(Sd3) =1 )or not(substr(Sd3,1,1) = '1')) and not(length(Sd3))>1  then
begin
    if (length(Sd3) =1 ) then 
        null;
    else
        Sd3 := substr(Sd3,2,1) ;
    end if; 
select
         temp || decode (Sd3
        ,'0',' '
        ,1,' واحد '
        ,2,' إثنان '
        ,3,' ثلاثة '
        ,4,' أربعة '
        ,5,' خمسة '
        ,6,' ستة '
        ,7,' سبعة '
        ,8,' ثمانية '
        ,9,' تسعة '
        ,' ') 
into 
        temp
from
        dual ;
end;

end if;
End ;
end if;


if x = 0 or x is null then
temp := ' ' ;
else
temp := temp || ' ريال ';
end if;
IF LENGTH (float) > 0 AND float <> 00 and x <> 0 THEN 
TEMP := TEMP || ' و ' ;

END IF;
float:= replace(float,',');
float:= replace(float,'.');
--:float:= float || '000' ;
--:float := substr(:float,1,3) ;
-------------------------------------------------------------------------------------------------
if length(float) < 2 then
float := float || '0';
end if;  
if float <> 0 then
BEGIN 



if not(substr(float,1,1) = '1') and not(substr(float,1,1) = '0')then
begin
select
        temp  ||     decode ((substr(float,2,1)),
            1,' واحد و ',
            2,' اثنان و ', 
            3,' ثلاثة و ',
            4,' أربعة و ',
            5,' خمسة و ',
            6,' ستة و ',
            7,' سبعة و ',
            8,' ثمانية و ',
            9,' تسعة و ',' ') 
into 
        temp
from
        dual ;
end;
END IF ;
begin
select
        temp ||  decode (substr(float,1,1),
            0,' ',
            1, DECODE(substr(float,1,2),
            10,' عشرة ',
            11,' إحدى عشر ',
            12,' اثنا عشر ',
            13,' ثلاثة عشر ' ,
            14,' أربعة عشر ' , 
            15,' خمسة عشر ' ,
            16,' ستة عشر ' ,
            17,' سبعة عشر ',
            18,' ثمانية عشر ',
            19,' تسعة عشر ') ,
            2,' عشرون ', 
            3,' ثلاثون ',
            4,' أربعون ', 
            5,' خمسون ',
            6,' ستون ',
            7,' سبعون ',
            8,' ثمانون ',
            9,' تسعون ',' ') 
into 
        temp
from
        dual ;
end;
--end if;

if (substr(float,1,1) = '0') then 
begin
select
        temp  ||     decode ((substr(float,2,1)),
            1,' واحد ',
            2,' اثنان ', 
            3,' ثلاثة ',
            4,' أربعة ',
            5,' خمسة ',
            6,' ستة ',
            7,' سبعة ',
            8,' ثمانية ',
            9,' تسعة ',' ') 
into 
        temp
from
        dual ;
end;
end if;

END;
temp := temp || ' هللة ';
end if;

temp := temp || ' لا غير ';
return temp;

end;



رابط هذا التعليق
شارك

 

وين اكتبها طيب في التقارير

رابط هذا التعليق
شارك

جزاك الله كل خير بس وين اكتب هذي الفنكشن

رابط هذا التعليق
شارك

تقدر تنشأها على الداتابيز وتغير في الـ select statement بتاعت التقرير وتديها المبلغ كباراميتر , او

تقدر تعمل فورميولا بيها على التقرير , ويفضل طبعا على الداتابيز , لانك هتحتاج تعملها مرة واحدة بس , لكن لو في التقرير , يبقى كل تقرير هتعمله وتحتاجها فيه هتنشأها فيه .

رابط هذا التعليق
شارك

  • بعد 4 شهور...

جزالك الله كل خير 

طيب ممكن شرح مصور 

لاني مبتدئي ومحتاج اتعلم الشغل ده

رابط هذا التعليق
شارك

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   تمت استعادة المحتوى السابق الخاص بك.   مسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

جاري التحميل
×
×
  • أضف...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية