Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
3578 Ansichten

Hi I am currently stuck in an issue . I am trying to define a salary rule which will calculate the salary of employee on the base of date_to and date_from But in these object. I am only able get days. By using days i can get worked days from them. I am unable to get month year there.

datej = str(payslip.date_to)
datek = str(payslip.date_from)
dj = datej[-2:]
dk = datek[-2:]
working_days=dj-dk
one_daySalary=contract.wage/30
salary=working_days*one_daySalary
result = salary

I am only able to calculate the salary on bases of fixed 30 days month. If you have better idea about that then please help me. Thanks for your time.

Avatar
Verwerfen
Autor Beste Antwort

I had found the month in payslip.name .Then i simple tried that is month in that payslip name or not but in this solution we have to force user not to change payslip name pattern . I had changed the payslip name to read only to achieve this

     datej = str(payslip.date_to)
    datek = str(payslip.date_from)
    dj = int(datej[-2:])
    dk = int(datek[-2:])
    working_days=dj - dk
    month=0
    if "January" in payslip.name: month= 31
    if "February" in payslip.name: month= 28
    if "March" in payslip.name: month= 31
    if "April" in payslip.name: month= 30
    if "May" in payslip.name: month= 31
    if "June" in payslip.name: month= 30
    if "July" in payslip.name: month= 31
    if "August" in payslip.name: month= 31
    if "September" in payslip.name: month= 30
    if "October" in payslip.name: month= 31
    if "November" in payslip.name: month= 30
    if "December" in payslip.name: month= 31 
    one_daySalary=contract.wage/month
    salary=one_daySalary*working_days
     result = salary
Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Juli 24
14243
1
Juli 21
8447
0
Apr. 20
4955
1
Mai 18
3229
0
Apr. 18
3736