How to do calculations in Model

28 views
Skip to first unread message

joji...@gmail.com

unread,
Sep 15, 2021, 12:10:00 PM9/15/21
to Django users
Hello there,
I am creating a salary & payroll application in Django. I need your guidance in calcuating the salary and insert to salarydetails table. I wanted to know how we can do the calculation using models. For example first we need to calculate the salary details for each salary head after deducting the LOP(Loss of Pay). Then we need to calculate Provident Fund(12 % of salary heads marked as IsConsiderforPF with a capping of Rs.15000). My question is whether all these complicated calculation can be achieved using models? Enclosed my Table structure.

Employee:
EmployeeId int,
EmployeeName Varchar(500),
Address Varchar(5000)

SalaryHead:
SalaryHeadId int,
SalaryHeadName varchar(1000),
IsLOPApplicable  boolean,
IsConsiderforPF boolean,
IsConsiderforPT boolean

SalaryMaster:
SalaryMasterId int,
EmployeeId int,
SalaryAmount Decimal(18,3)

MonthlySalaryHeader:
MonthlySalaryHeaderId int,
YearMonth int,
EmployeeId int,
TotalNoofDays int,
NoofDaysPresent int,
LOPDays int,

MonthlySalaryDetails:
MonthlySalaryDetailsid int,
MonthlySalaryHeaderId int,
SalaryHeadId int,
Amount Decimal(18,3)

Reply all
Reply to author
Forward
0 new messages