function TF_Musteri.VadeTarihiHesapla(Tarih : TDate ; Vade1,Vade2,Vade3 : Integer ) : TDateTime ;
var
D,A,Y : Word ;
Vade , Gun : Integer ;
tVadeTrh : TDateTime ;
begin
Gun := 0 ; Vade := 0 ;
if RG_TrhTip.ItemIndex = 1 then
begin
Tarih := Tarih - 1 ;
end ;
DecodeDate(Tarih,Y,A,D) ;
if (1 <= D) And (10 >= D ) then
begin
Gun := 10 ;
Vade := Vade1 ;
end ;
if (11 <= D) And (20 >= D ) then
begin
Gun := 20 ;
Vade := Vade2 ;
end ;
if (21 <= D) And (31 >= D ) then
begin
Gun := 31 ;
Vade := Vade3 ;
end ;
if Gun = 31 then
Gun := StrToInt(FormatDateTime('dd' , IncMonth(EncodeDate(Y, A , 1 ),1)-1)) ;
tVadeTrh := EncodeDate(Y,A,Gun) + Vade ;
if DayOfWeek(tVadeTrh) = 1 then tVadeTrh := tVadeTrh + 1 ;
if DayOfWeek(tVadeTrh) = 7 then tVadeTrh := tVadeTrh + 2 ;
Result := tVadeTrh ;
end;