(v12) Leave Allocation: "Add unused leaves from previous allocations" does not respect used leaves

I just tried to allocate leaves for the new year to our employees.

When i check the box “Add unused leaves from previous allocations” the field “Unused leaves” gets populated with a value equal to “Total Leaves Allocated” from the last Leave Allocation. It does not respect the leaves which has allready been taken for this employee.

In addition the numbers on the the dashboard for a leave apllication are inconsitent.

In v12 a new doctype “Leave Ledger Entry” was introduced, and the new function “get_unused_leaves” does rely on this having the entrys of all used leaves (Approved Leave Applications). But in our case only allocations existed as entrys in this doctype.

I think this resulted from this doctype not beeing populated in the upgrade process from v11 to v12, since new Approved Leave Applications result in new Leave Ledger Entrys.

Seems like erpnext/patches/v12_0/generate_leave_ledger_entries.py should have created those, but somehow it didn`t.

Just leaving this here, maybe someone stumbles upon this also, while doing his first allocations after an upgrade to v12. If this is the case in oher installs too, we might could raise an issue.