How does leave balance calculation works?

How does leave balance calculation works?