How get Total Salary pre day on server script?

Leave Encashment is based on monthly salary, not a fixed amount from Salary Structure ( Leave Encashment Amount Per Day))

How do I take the total salary per day of the month, then multiply by the number of Encashment Days and put the total Encashment Amount?

@Maged_Bajandooh check this How to auto update/ calculate Leave Encashment Amount Per Day amount in salary structure after assigning base in Salary Structure Assignment you can take refrence from this link

What do you mean by monthly salary?
Please give an example, e.g.:
It is March 3rd, 2024.
the employee should receive 4 days worth of Encashment days and untill now s\he worked for three years.
the Encashment days’ worth is calculated by (let’s say):
Total salary of the past three years, devided by the number of months the employee is hired. Then devided by 31 (the number of days on the month March), or perhaps 21 (the number of business days on March 2024), etc.

Leave Encashment I want it to be calculated on the employee’s daily salary.
Let’s assume that the employee’s salary is 5400 S.R monthly, if per day ( 5400 S.R / 30 days = 180 S.R per day )

Leave Encashment = Leave Balance * Per day

Leave Encashment = 22.55 * 180 S.R = 4059 S.R