Leave policy assignment based on joining date only considering past 12 months period

I tested Leave policy assignment based on joinong date for an Employee who’s joining date was more then 3 years ago (40 months), but months_passed calculated were only 5 months. Because of this line:

This simply should be difference months between from_date (joining_date) and to_date (effective_to)

I tested in ERPNext v13.21.1 but this bug is also present in version-14-beta, and i assume its also in v13.21.1 prior versions too.

Github Issue: