16-06-2020, 10:47 AM
(07-06-2020, 12:31 AM)larbiparadox كتب : وعليك السلام و رحمة الله و بركاته
بالنسبة لـ أكثر من 30.000 و أقل أو يساوي 35.000
كود :Function IRG2008(soumis:Real) : real; var TRS : array [0..5] of Real; Tax : array [0..5] of Real; Impan : array [0..5] of Real; brts,taux,tb,n,td,impota,impm,abat,ret,RTS1 :real; ill :integer; begin if soumis > 30000 then begin soumis := (Int(soumis / 10)) * 10; TRS[1] := 0; TRS[2] := 120000; TRS[3] := 360000; TRS[4] := 1440000; TRS[5] := 9999999; Tax[1] := 0; Tax[2] := 0; Tax[3] := 20; Tax[4] := 30; Tax[5] := 35; Impan[1] := 0; Impan[2] := 0; Impan[3] := 48000; Impan[4] := 372000; Impan[5] := 3367999.65; brts := soumis * 12; ill := 1; While (ill <= 5) and (brts >TRS[ill]) do ill := ill + 1; taux := Tax[ill]; ill := ill - 1; tb := TRS[ill]; td := Impan[ill]; n := brts - tb; impota := (n * taux / 100) + td; impm := impota / 12; abat := (40 * impm / 100); If abat < 1000 Then abat := 1000; If abat > 1500 Then abat := 1500; ret := impm - abat; If ret < 0 Then ret := 0; RTS1 := (ret * 10); RTS1 := Int(RTS1); RTS1 := RTS1 / 10; IRG2008 := RTS1; end else begin IRG2008 := 0; end; if (soumis > 30000) and (soumis <= 35000) then begin IRG2008 := ( (RTS1* 8) /3 ) - (20000 /3) ; end;
مثال : مثال مبلغ خاضع لضريبة 30.500 سابقا كان يخصم منه 2.650 أما الأن صيخصم منه 400 فقط
كصورة التالية
أما ذوي الاحتياجات الخاصة
كود :Function IRG2008(soumis:Real) : real; var TRS : array [0..5] of Real; Tax : array [0..5] of Real; Impan : array [0..5] of Real; brts,taux,tb,n,td,impota,impm,abat,ret,RTS1 :real; ill :integer; begin if soumis > 30000 then begin soumis := (Int(soumis / 10)) * 10; TRS[1] := 0; TRS[2] := 120000; TRS[3] := 360000; TRS[4] := 1440000; TRS[5] := 9999999; Tax[1] := 0; Tax[2] := 0; Tax[3] := 20; Tax[4] := 30; Tax[5] := 35; Impan[1] := 0; Impan[2] := 0; Impan[3] := 48000; Impan[4] := 372000; Impan[5] := 3367999.65; brts := soumis * 12; ill := 1; While (ill <= 5) and (brts >TRS[ill]) do ill := ill + 1; taux := Tax[ill]; ill := ill - 1; tb := TRS[ill]; td := Impan[ill]; n := brts - tb; impota := (n * taux / 100) + td; impm := impota / 12; abat := (40 * impm / 100); If abat < 1000 Then abat := 1000; If abat > 1500 Then abat := 1500; ret := impm - abat; If ret < 0 Then ret := 0; RTS1 := (ret * 10); RTS1 := Int(RTS1); RTS1 := RTS1 / 10; IRG2008 := RTS1; end else begin IRG2008 := 0; end; if (soumis > 30000) and (soumis <= 40000) then begin // if (soumis > 30000) and (soumis <= 35000) then begin //IRG2008 := ( (RTS1* 8) /3 ) - (20000 /3) ; IRG2008 := ( (RTS1* 5) /3 ) - (12500 /3) ; end; end;
السلام عليكم
يوجد خطأ بسيط في الخوارزمية السابقة حيث بعد تجريب الكود في حالة القيمة بين 30001 و 30009 تكون النتيجة خاطئة وهذا بسبب أن المتغير soumis قد تم تغيير قيمته الأصلية
إليكم الكود بعد التعديل
كود :
Function IRG2008(soumis:Real) : real;
var
TRS : array [0..5] of Real;
Tax : array [0..5] of Real;
Impan : array [0..5] of Real;
brts,taux,tb,n,td,impota,impm,abat,ret,RTS1, Imposable :real;
ill :integer;
begin
Imposable := soumis;
if soumis > 30000 then begin
soumis := (Int(soumis / 10)) * 10;
TRS[1] := 0;
TRS[2] := 120000;
TRS[3] := 360000;
TRS[4] := 1440000;
TRS[5] := 9999999;
Tax[1] := 0;
Tax[2] := 0;
Tax[3] := 20;
Tax[4] := 30;
Tax[5] := 35;
Impan[1] := 0;
Impan[2] := 0;
Impan[3] := 48000;
Impan[4] := 372000;
Impan[5] := 3367999.65;
brts := soumis * 12;
ill := 1;
While (ill <= 5) and (brts >TRS[ill]) do ill := ill + 1;
taux := Tax[ill];
ill := ill - 1;
tb := TRS[ill];
td := Impan[ill];
n := brts - tb;
impota := (n * taux / 100) + td;
impm := impota / 12;
abat := (40 * impm / 100);
If abat < 1000 Then abat := 1000;
If abat > 1500 Then abat := 1500;
ret := impm - abat;
If ret < 0 Then ret := 0;
RTS1 := (ret * 10);
RTS1 := Int(RTS1);
RTS1 := RTS1 / 10;
IRG2008 := RTS1;
end else begin
IRG2008 := 0;
end;
if (Imposable > 30000) and (Imposable <= 35000) then begin
IRG2008 := ( (RTS1* 8) /3 ) - (20000 /3) ;
end;
end;

![[صورة: 600123590.png]](https://www7.0zz0.com/2020/06/07/02/600123590.png)