Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
6856 Tampilan

Hi,


I have been struggling to find a solution to handle variable allowances and deductions in the payslip. One solution is to utilize the "Other Inputs" by creating a salary rule and then pick it while processing the payslip and input the amount manually. This approach working fine except when the defined rule is not selected (in case there is no allowance or deduction) I get an error.




The Python formula used in the salary rule :


1) Allowances: result = inputs.TA.amount

2) Deductions: 


result = -(inputs.TDS.amount)

The error that I'm getting when no deduction is selected:

Wrong python code defined for salary rule Deduction (TDS).

Error: <class 'AttributeError'>: "'float' object has no attribute 'amount'" while evaluating

'result = -(inputs.TDS.amount)'




And in case when no allowance is selected I'm getting this error:

Wrong python code defined for salary rule Allowance (TA).

Error: <class 'AttributeError'>: "'float' object has no attribute 'amount'" while evaluating

'result = inputs.TA.amount'



I need to modify the rule code to handle situations when no input is available. Could you please help me with this code?



Regards, 

Avatar
Buang

Hello,

Have you found a solution?

I am having the same error when no "Other inputs" entered.

If I enter some "other inputs" even with zero value, works fine.

If left Other inputs with no data, I get the same error.

Best regards

PM

Penulis

Yes dear, the solution was to handle the errors by:

1) Adding except to the condition so that the amount is not printed:

try:

result = inputs.MD.amount != 0

except:

result = False

2) Adding except on the formula:

try:

result = - (inputs.MD.amount)

except:

result = 0

Post Terkait Replies Tampilan Aktivitas
0
Okt 21
2427
0
Agu 25
67
1
Mei 25
1293
1
Mar 25
1289
0
Feb 25
1538