
Hi all,
I'm building leave tracking App. I don't know how to calculate balance because it includes the carry forward amount from the previous year. The first year, there is no carry forward amount allowed, from the second year, the carry forward amount will be max 6 of the ending balance of the previous year. The result I wanted should be as the table below.
| Year | Cary Forward Amount | Amount granted for the year | Total opening balance | Amount Used | Ending balance |
| 2019 | 0 | 18 | 18 | 16 | 2 |
| 2020 | 2 | 18 | 20 | 12 | 8 |
| 2021 | 6 | 18 | 24 | 20 | 4 |
| 2022 | 4 | 18 | 22 | 10 | 12 |
How can I achieve this?
Appreciate for your help!
Thanks,