Leavemgt in al(calculate accumulatedleavedays)

Hey,kindly need some help here:i need to come up with a way to calculate accumulated annual leaves so every employee is subjected to 1.75 leave day per month the fiscal year starts from July nad ends in June,once june ends and the perosn hasnt taken the leaves let them be carried to july nad once july closes off the carried off leave days field should be reset to zero
this is my code
local procedure ManageAccumulatedLeaveDays()
var
CurrentDate: Date;
FiscalYearStart: Date;
FiscalYearEnd: Date;
AccountingPeriod: Record “Accounting Period”;
HRSetup: Record “Human Resources Setup”;
MonthsWorked: Integer;
IsSecondMonth: Boolean;
AnnualLeavePerMonth: Decimal;
AccumulatedLeaveDays: Decimal;
FiscalYearMonth: Integer;
Employee: Record Employee;
IsJune: Boolean;
IsJuly: Boolean;
begin
CurrentDate := WorkDate();

// Find the accounting period that includes the current date
if not AccountingPeriod.FindSet() then
    Error('No accounting periods found.');

// Identify the start and end dates of the fiscal year
repeat
    if (AccountingPeriod."Starting Date" <= CurrentDate) then begin
        FiscalYearStart := AccountingPeriod."Starting Date";
        AccountingPeriod.Next();
        FiscalYearEnd := AccountingPeriod."Starting Date" - 1;
        break;
    end;
until AccountingPeriod.Next() = 0;

if FiscalYearStart = 0D then
    Error('No accounting period found for the current date.');

// Fetch HR setup values
if not HRSetup.Get() then
    Error('HR Setup record not found.');

AnnualLeavePerMonth := HRSetup."Leave Liability"; // Assuming this is the field for the default value

// Determine the fiscal year month relative to the fiscal year start date
FiscalYearMonth := Date2DMY(CurrentDate, 2) - Date2DMY(FiscalYearStart, 2) + 1;
if FiscalYearMonth <= 0 then
    FiscalYearMonth := FiscalYearMonth + 12;

IsJune := (Date2DMY(CurrentDate, 2) = 6);
IsJuly := (Date2DMY(CurrentDate, 2) = 7);

// Handle end of June logic
if IsJune then begin
    // Reset available leave days to 1.75 and move accumulated leave to carried over
    if Employee.FindSet() then begin
        repeat
            Employee."AvailableAnnualLeaveDays" := 1.75;
            Employee."CarriedB/F" := Employee."AccumulatedAnnualLeaveDays"; // Move accumulated to carried over
            Employee."AccumulatedAnnualLeaveDays" := 0; // Reset accumulated to zero
            Employee.Modify(true); // Save changes
        until Employee.Next() = 0;
    end;
end;

// Handle end of July logic
if IsJuly then begin
    if Employee.FindSet() then begin
        repeat
            if Employee."CarriedB/F" > 0 then begin
                Employee."CarriedB/F" := 0; // Reset carried over leave if not taken
            end;
            Employee."AvailableAnnualLeaveDays" := 1.75; // Set available leave days to 1.75
            Employee.Modify(true); // Save changes
        until Employee.Next() = 0;
    end;
end;

// Check if the current date is in the second month of the fiscal year
IsSecondMonth := (FiscalYearMonth = 2); // Second month (1-based index)

if IsSecondMonth then begin
    // Reset leave days to the value specified in HR Setup at the start of the second month
    Rec."AccumulatedAnnualLeaveDays" := AnnualLeavePerMonth;
end;

// Calculate accumulated leave days from the second month of the fiscal year to the current date
if FiscalYearMonth > 2 then
    MonthsWorked := FiscalYearMonth - 2
else if FiscalYearMonth = 1 then
    MonthsWorked := 11 // Covers case when we are in the first month of the new fiscal year
else
    MonthsWorked := 0;

AccumulatedLeaveDays := MonthsWorked * AnnualLeavePerMonth;
Rec."AccumulatedAnnualLeaveDays" := Rec."AccumulatedAnnualLeaveDays" + AccumulatedLeaveDays;

// Ensure record is modified
Rec.Modify(true); // Use true to trigger OnModify trigger if needed

end; Any one to help me please
NB:this is my second month in AL am trying to learn the language please dont laugh at my code