 # Depends on Payment Days is not working in formula calculation

Github Issue: https://github.com/frappe/erpnext/issues/19413

When using a variable whose value is affected by “Depends on Payment Days (DPD)” in the formula of any other component, it takes the total value and not the value affected by “Depends on Payment Days”.

Output of bench version
erpnext 12.1.7
frappe 12.0.17

Steps to reproduce the issue

1. Create a new Salary Structure
2. Add a new Salary Component for example Basic Salary (`BS`) with a formula value as: `base`, and set Depends on Payment Days (DPD) as enabled.
3. Add a new Salary Component for example Basic Salary Two (`BS2`) with a formula value as: `BS`, and with Depends on Payment Days (DPD) disabled.
4. Test the Salary Structure with an employee that has less Payment Days than Working Days

Example configuration

Working Days: 30
Payment Days: 15
`base`: 1.000

Basic Salary (`BS`) = `base`
Basic Salary Two (`BS2`) = `BS`

Observed result
`BS` = 500 (Correct as it’s affected by DPD, he only worked half month)
`BS2` = 1.000 (Incorrect as `BS` has a value of 500, it should be also 500)

Expected result
`BS` = 500
`BS2` = 500

My scenario is as follows:

I need to calculate other components, taking into account the `BS` (affected by DPD), but adding another variable that should not be affected by DPD, example:

`BS` = `base` = 1.000 = (with DPD) = 500
`X` = 5.000 (Fixed value that should not be affected by DPD)
`BS2`= `BS` + `X` = 5.500 (But right know it displays 6.000 incorrectly as it takes BS as 1.000)

1 Like

I have a few questions too

1. What counted in “Payment days” ?
2. Does ERPNext count days since the Join date if an employee join in middle of month? (right now it is not when I set base salary component as Depends on Payment days)
3. Will date marked as Absent (in Attendance tool) be excluded from “Payment days” or still be included ?

Hi cospin18,

You have to enable DEPEND ON PAYMENT DAYS for BS2 to get the desired output.
Now, what the system is doing is
IF " Depend on payment days " is checked, it will calculate according to the payment days ( present days)
IF " Depend on payment days " is not checked, it will calculate according to the payment_days = total working days and not present days.

Working days : 30
Payment days : 15
base = 1000 rs

So, For BS it calculates as :
1000 / 30 = 33.33 rs per day
AS, depend on payment days is enabled.
Base will be - 33.33 * 15 ( payment days ) = 500 rs
BS = base = 500 rs

Now for BS2,
As, depend on payment days is disabled.
So, here base will be 33.33 * 30 = 1000 rs.
Here it will consider the payment_days = 30 because depend on payment days in unchecked.
SO BS2= BS and here BS will be = (( 1000/30 )* 30 ) = 1000 .

I hope you got their logic .
This basic functionality is still working after 1 year 