Skip to content
AbairTech Solution
  • Services
    • Chrome Extensions
  • Home
  • Live Demos
  • Mobile Apps
  • Business Software
  • Knowledge Center
  • Contact

HRMS Leave…

  • Home
  • Business Software Guides
  • Leave Management…

Leave Management in HRMS: Designing Accrual, Carry-Forward and Encashment Rules in Oracle

  • By Muhammad Abair Mutarraf
  • November 19, 2026November 23, 2026

How to design leave management in an Oracle-based HRMS: leave types and policies in tables, a leave ledger instead of a balance column, monthly accrual, proration for joiners, carry-forward caps, encashment, sandwich rules and year-end processing.

AbairTechSolutionDIGITAL SOLUTIONS FOR A SMARTER TOMORROW

Home

Services ▾
Oracle MigrationOracle APEXAPI IntegrationAll Services
Software ▾
Live DemosBusiness SoftwarePOSERPClinicHospitaleSign

Mobile AppsGuidesAboutContact

☰ Menu
Home

Services

Oracle MigrationOracle APEXAPI IntegrationAll Services

Software & Demos

Live DemosBusiness SoftwarePOSERPClinicHospitaleSign

Mobile AppsGuides & ArticlesInterview PrepAboutContact

Home › Knowledge Center

HRMS · Oracle PL/SQL

Leave Management in HRMS: Designing Accrual, Carry-Forward and Encashment Rules

By Muhammad Abair Mutarraf · Senior Oracle APEX & PL/SQL developer, 12 years’ experience · AbairTech Solution

Written by Muhammad Abair Mutarraf, Oracle Certified APEX Cloud Developer · Published November 2026 · Editorial policy

Leave looks like the simplest part of an HRMS: an employee has 20 days, takes 3, has 17 left. In practice, leave is where HR departments lose the most trust in their software. Balances do not match what employees expect, a new joiner gets a full year’s entitlement on day one, carry-forward is applied twice after a rerun, and nobody can explain how a balance of 11.5 was calculated.

Almost all of these problems come from one design decision: storing the leave balance as a single number that the system keeps updating. This guide shows a better structure – policies in tables and every movement in a ledger – with Oracle SQL and PL/SQL examples you can adapt to an APEX-based HR system.

1. Separate leave types, policies and employees

Different employee groups usually have different rules: staff and workers, permanent and contract, head office and factory. Keep the rules in a policy table instead of in code:

CREATE TABLE lv_type (
  leave_code     VARCHAR2(10) PRIMARY KEY,   -- ANNUAL, CASUAL, SICK
  leave_name     VARCHAR2(60) NOT NULL,
  paid_flag      CHAR(1) DEFAULT 'Y'
);

CREATE TABLE lv_policy (
  policy_code       VARCHAR2(20) NOT NULL,
  leave_code        VARCHAR2(10) NOT NULL REFERENCES lv_type,
  effective_from    DATE         NOT NULL,
  annual_days       NUMBER       NOT NULL,   -- e.g. 14
  accrual_method    VARCHAR2(10) NOT NULL
                    CHECK (accrual_method IN ('YEARLY','MONTHLY')),
  prorate_joiners   CHAR(1) DEFAULT 'Y',
  max_carry_forward NUMBER  DEFAULT 0,       -- days allowed into next year
  max_balance       NUMBER,                  -- optional cap
  encash_allowed    CHAR(1) DEFAULT 'N',
  min_service_days  NUMBER  DEFAULT 0,       -- e.g. eligible after probation
  count_holidays    CHAR(1) DEFAULT 'N',     -- sandwich rule
  CONSTRAINT lv_policy_pk PRIMARY KEY (policy_code, leave_code, effective_from)
);

Each employee is linked to a policy code. When the company changes its rules from next January, you add new policy rows with a new effective_from date – the old rules remain available for recalculating past years.

The numbers themselves – how many days, what carries forward, what can be encashed – must come from your company’s HR policy and the labour laws that apply to your workers. The software’s job is to apply those rules consistently, not to decide them.

2. Use a leave ledger, not a balance column

Instead of a balance column that is updated in place, record every movement as a row. The balance is simply the sum.

CREATE TABLE lv_ledger (
  ledger_id     NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  emp_id        NUMBER       NOT NULL,
  leave_code    VARCHAR2(10) NOT NULL,
  leave_year    NUMBER(4)    NOT NULL,
  txn_date      DATE         NOT NULL,
  txn_type      VARCHAR2(12) NOT NULL
                CHECK (txn_type IN ('OPENING','ACCRUAL','AVAILED','CARRY_FWD',
                                    'LAPSE','ENCASH','ADJUST')),
  days          NUMBER(6,2)  NOT NULL,   -- + adds, - deducts
  ref_id        NUMBER,                  -- leave application / run id
  remarks       VARCHAR2(200),
  created_by    VARCHAR2(60) DEFAULT USER,
  created_on    DATE DEFAULT SYSDATE
);

-- Current balance
SELECT emp_id, leave_code, SUM(days) AS balance
  FROM lv_ledger
 WHERE leave_year = :p_year
 GROUP BY emp_id, leave_code;

The ledger answers every question an employee or auditor will ask: when did I earn this, when did I use it, why was 2 days lapsed? It also makes reprocessing safe – you can delete the ledger rows of one type for one run (for example all ACCRUAL rows created by a monthly run) and post them again, without touching approved leave.

3. Accrual: yearly or monthly

With yearly accrual the full entitlement is credited at the start of the year. It is simple, but an employee who resigns in February may already have used leave they had not yet earned. With monthly accrual, one-twelfth is credited each month, so the balance always reflects service.

A monthly accrual run can be a single, re-runnable procedure:

CREATE OR REPLACE PROCEDURE lv_run_monthly_accrual (
  p_month_start IN DATE    -- first day of the month
) IS
  l_year NUMBER := EXTRACT(YEAR FROM p_month_start);
BEGIN
  -- make the run repeatable
  DELETE FROM lv_ledger
   WHERE txn_type = 'ACCRUAL'
     AND txn_date = p_month_start;

  INSERT INTO lv_ledger (emp_id, leave_code, leave_year, txn_date,
                         txn_type, days, remarks)
  SELECT e.emp_id,
         p.leave_code,
         l_year,
         p_month_start,
         'ACCRUAL',
         ROUND(p.annual_days / 12, 2),
         'Monthly accrual ' || TO_CHAR(p_month_start, 'Mon YYYY')
    FROM hr_employee e
    JOIN lv_policy  p ON p.policy_code = e.leave_policy
   WHERE p.accrual_method = 'MONTHLY'
     AND p.effective_from = (SELECT MAX(p2.effective_from)
                               FROM lv_policy p2
                              WHERE p2.policy_code = p.policy_code
                                AND p2.leave_code  = p.leave_code
                                AND p2.effective_from <= p_month_start)
     AND e.join_date <= LAST_DAY(p_month_start)
     AND (e.leaving_date IS NULL OR e.leaving_date >= p_month_start)
     AND p_month_start - e.join_date >= p.min_service_days;
END;

Rounding each month to two decimals can leave 13.92 instead of 14.00 at year end. A common fix is to credit the difference in December so the year totals exactly the annual entitlement – decide this rule with HR and apply it in the same procedure.

4. Joiners and leavers

For yearly accrual, prorate the opening credit for employees who join mid-year: entitlement × remaining days in the year ÷ days in the year, rounded according to policy (many companies round to the nearest half day). Store the result as an OPENING or ACCRUAL row with a clear remark such as “Prorated: joined 15 Aug, 139/365 days”.

For leavers, the final settlement must calculate the balance up to the leaving date. If leave was credited in advance (yearly method) and the employee used more than they earned, the final settlement may need a recovery. With a ledger, this calculation is one query; with a balance column it is guesswork.

5. Availing leave: working days, holidays and the sandwich rule

When an application is approved, post an AVAILED row with negative days. The number of days depends on two policy decisions:

  • Weekly offs and public holidays. Usually a leave from Thursday to Monday counts only the working days. This requires a holiday calendar table and each employee’s weekly off day – which may differ between office staff and shift workers.
  • Sandwich rule. Some companies count a holiday that falls between two leave days as leave. If your policy has this rule, make it a policy flag (count_holidays) rather than special code.

Half-day leave is simply 0.5 days in the ledger. Do not allow an approval that takes the balance below zero unless the policy explicitly allows negative balances, and check it in the database procedure, not only in the APEX screen.

6. Year-end: carry forward, lapse and encashment

Year-end processing turns the closing balance of one year into the opening of the next. Process each employee and leave type in this order:

  1. Calculate the closing balance for the year from the ledger.
  2. Carry forward up to max_carry_forward into the new year as a CARRY_FWD row.
  3. If encashment is allowed, encash the agreed portion of the remainder (an ENCASH row in the old year, and an earning element in payroll).
  4. Lapse whatever is left with a LAPSE row, so the old year closes at exactly zero.
SELECT emp_id, leave_code,
       closing,
       LEAST(closing, max_cf)                    AS carry_forward,
       GREATEST(closing - max_cf, 0)             AS excess   -- encash or lapse
  FROM (SELECT l.emp_id, l.leave_code,
               SUM(l.days)            AS closing,
               MAX(p.max_carry_forward) AS max_cf
          FROM lv_ledger l
          JOIN hr_employee e ON e.emp_id = l.emp_id
          JOIN lv_policy  p ON p.policy_code = e.leave_policy
                           AND p.leave_code  = l.leave_code
         WHERE l.leave_year = :p_year
         GROUP BY l.emp_id, l.leave_code)
 WHERE closing > 0;

Run year-end as a single, logged job and record the run id on every ledger row it creates. If something is wrong, you can reverse the whole run by deleting its rows and run it again – something that is almost impossible when balances are overwritten.

7. Connect leave to attendance and payroll

Leave is not isolated. Attendance processing should mark approved leave days as leave, not absent, and unpaid leave must feed payroll deductions. Keep the dependency in one direction: attendance and payroll read approved leave; they never change the leave ledger. See our guides on night-shift attendance and designing a payroll engine in PL/SQL.

8. Make balances easy to explain

Give employees and HR a leave statement page that lists ledger rows with dates and remarks, not just the final number. Most leave complaints end the moment the employee sees “Accrual Jan–Oct: 11.67, Availed: 4.0, Carried forward from 2025: 3.0”. Transparency is the best feature an HR system can have.

Quick checklist

  • Leave types and policy rules in tables, with effective dates
  • A ledger of movements instead of a single balance column
  • Accrual runs that can be repeated safely
  • Proration for joiners and correct settlement for leavers
  • Working-day counting using a holiday calendar and weekly offs
  • Negative-balance checks enforced in the database
  • Year-end carry forward, encashment and lapse posted as separate rows with a run id
  • Leave statement visible to employees and HR

Related: HRMS implementation checklist for textile mills, payroll software features checklist and our HRMS & payroll software with a live demo.

Building or fixing an HR system?

AbairTech builds HRMS and payroll on Oracle APEX and PL/SQL – leave, attendance, ZKTeco integration and payroll.

HRMS & Payroll DemoMore GuidesWhatsApp Us

Related implementation services

Need help applying these concepts in a business system? Explore Custom business software development or Oracle APEX development.

Knowledge Center · About · Contact · Privacy & Cookie Policy · Terms of Use · Advertising Disclosure · Editorial Standards

Muhammad Abair Mutarraf

Senior Oracle APEX, Oracle Forms and PL/SQL developer with 12 years of experience and founder of AbairTech Solution, Faisalabad. Oracle Certified APEX Cloud Developer who has led ERP and HRMS implementations and Oracle Forms to APEX modernization projects.

Search
Archives
  • November 2026
  • October 2026
  • September 2026
Opening Hours
Week Days 10:00 - 17:00
Saturday 10:00 - 15:00
Sunday Day Off
Contact us

Recent Posts

  • Oracle APEX Load Balancing: Step-by-Step Guide with ORDS, Nginx and High Availability
  • Oracle APEX Tips and Tricks + 40 Advanced MCQs with Answers (Developer Edition)
  • Inventory Valuation in ERP: FIFO vs Weighted Average Cost with Oracle SQL Examples
  • Leave Management in HRMS: Designing Accrual, Carry-Forward and Encashment Rules in Oracle
  • Oracle APEX Performance Tuning: How to Find and Fix Slow Pages

Recent Comments

  1. Shakir Hussain on Job Bank – Hire Developers & IT Students in Pakistan
  2. rabia naz on Job Bank – Hire Developers & IT Students in Pakistan

Popular Posts:

  • Oracle APEX Load Balancing: Step-by-Step Guide with ORDS, Nginx and High Availability
  • Oracle APEX Tips and Tricks + 40 Advanced MCQs with Answers (Developer Edition)
  • Inventory Valuation in ERP: FIFO vs Weighted Average Cost with Oracle SQL Examples
  • Leave Management in HRMS: Designing Accrual, Carry-Forward and Encashment Rules in Oracle
  • Oracle APEX Performance Tuning: How to Find and Fix Slow Pages

Categories:

  • API Integration
  • Business Software Guides
  • Jobs & Careers
  • Oracle APEX & Modernization
  • Oracle Database & PL/SQL
  • Technology Insights
  • Website Development

Popular Tags:

There’s no content to show here yet.

CONTACT US

Get in Touch With Us!

    Join us as we continue our mission to redefine digital standards and make a difference for businesses worldwide. Let’s work together to bring your digital dreams to life.

    Facebook-f Twitter Instagram

    Useful Links

    • Home
    • About
    • Services
    • Projects
    • Blog
    • Contact

    Our Services

    • Web Development
    • App Development
    • AI Development
    • Graphics Designing
    • SEO Service
    • Security Services

    Contact Info

    Faisalabad Pakistan

    support@abairtechsolution.com

    Call us now:

    +92 300 2005404

    Copyright © Abair Tech Solution 2024. All rights reserved

    We are using cookies to give you the best experience on our website.

    You can find out more about which cookies we are using or switch them off in .

    AbairTech Solution
    Powered by  GDPR Cookie Compliance
    Privacy Overview

    This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

    Strictly Necessary Cookies

    Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

    If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.