...
IF TimeActivity."Use Accruals" THEN BEGIN
...
IF EmplAbsenceEntry2.FINDSET THEN
REPEAT
EmplAbsenceEntry2.CALCFIELDS("Used Calendar Days");
RemainingDays := EmplAbsenceEntry2."Calendar Days" - EmplAbsenceEntry2."Used Calendar Days";
IF RemainingDays >= DaysToUse THEN BEGIN
...
END;
UNTIL (EmplAbsenceEntry2.NEXT = 0) OR (DaysToUse = 0);
END ELSE
InsertEmplAbsenceEntry(AbsenceLine,AbsenceLine."Calendar Days",AbsenceLine."Working Days",0);
...
...
IF TimeActivity."Use Accruals" THEN BEGIN
...
IF EmplAbsenceEntry2.FINDSET THEN BEGIN // modify this line
REPEAT
EmplAbsenceEntry2.CALCFIELDS("Used Calendar Days");
RemainingDays := EmplAbsenceEntry2."Calendar Days" - EmplAbsenceEntry2."Used Calendar Days";
// Add the following line.
IF RemainingDays <> 0 THEN
// End of the added line.
IF RemainingDays >= DaysToUse THEN BEGIN
...
END;
UNTIL (EmplAbsenceEntry2.NEXT = 0) OR (DaysToUse = 0);
// Add the following lines.
IF DaysToUse <> 0 THEN
REPEAT
IF EmplAbsenceEntry2.GET(InsertVacationAccrual(AbsenceLine)) THEN BEGIN
EmplAbsenceEntry2.CALCFIELDS("Used Calendar Days");
RemainingDays := EmplAbsenceEntry2."Calendar Days" - EmplAbsenceEntry2."Used Calendar Days";
IF RemainingDays >= DaysToUse THEN BEGIN
InsertEmplAbsenceEntry(AbsenceLine,DaysToUse,0,EmplAbsenceEntry2."Entry No.");
DaysToUse := 0;
END ELSE BEGIN
InsertEmplAbsenceEntry(AbsenceLine,RemainingDays,0,EmplAbsenceEntry2."Entry No.");
DaysToUse := DaysToUse - RemainingDays;
END;
END;
UNTIL DaysToUse = 0;
END;
// End of the added lines.
END ELSE
InsertEmplAbsenceEntry(AbsenceLine,AbsenceLine."Calendar Days",AbsenceLine."Working Days",0);
...