I have an access database I was asked to modify to have the calculations generate correctly. I did not create the database and the person who did is no longer working at the institution. Here goes
The database calculates deductions for overtime pay producing the overall time pay.
NIS: National Insurance Scheme
PAYE: Pay as you earn
A temporary employee is charged 10.1% NIS on gross pay
An appointed employee is 8.8%
Maximum salary for which NIS is charged is $4090.00 so therefore anyone earning more than $4090.00 is not charged NIS
PAYE is charged to salaries over $4100.00 at a rate of 20% and above $4100.00 35%
Below is the code which is in the database but the calculations are incorrect.
A copy of the database is also attached the calculation is found in the pay transaction table under the hour event procedure.
Private Sub hours_AfterUpdate()
'Calculates Pay For Employee
Dim rsPay As Recordset, strSQl As String
Dim rsSettings As Recordset, TotalPay As Currency, nPay As Currency
Dim qDef As QueryDef, nTaxable As Currency, nMonthLim As Currency
Dim nSalary As Currency
Set rsSettings = CurrentDb.OpenRecordset("Payroll Settings", dbOpenDynaset)
Set qDef = CurrentDb.QueryDefs("Salary Info Query")
qDef.Parameters(0) = Me.natregno
Set rsPay = qDef.OpenRecordset
If Not rsPay.EOF Then
Me.pay = Me.hours * Nz(rsPay("rate"), 1)
TotalPay = Nz(rsPay("Allowance"), 0) + Nz(rsPay("salary"), 0) + Nz(Me.pay, 0)
nPay = Nz(rsPay("Allowance"), 0) + Nz(rsPay("salary"), 0)
If nPay >= rsSettings("NISLimit") Then
Me.nis = 0
Else
nPay = Abs(rsSettings("NISlimit") - rsPay("salary"))
If nPay > Me.pay Then
Me.nis = Me.pay * IIf(rsPay("emp_code") = "E", rsSettings("nisrateP"), rsSettings("nisrateT"))
Else
Me.nis = nPay * IIf(rsPay("emp_code") = "E", rsSettings("nisrateP"), rsSettings("nisrateT"))
End If
End If
If ((TotalPay * 12) - rsPay("persallow")) > rsSettings("PAYELimit") Then
nSalary = (((Nz(rsPay("Allowance"), 0) + Nz(rsPay("salary"), 0)) * 12) - rsPay("persallow")) / 12
nMonthLim = rsSettings("PAYELimit") / 12
If nSalary < nMonthLim Then
nTaxable = nMonthLim - nSalary
Me.tax = (nTaxable * rsSettings("paye1")) + ((Me.pay - nTaxable) * rsSettings("paye2"))
Else
Me.tax = Me.pay * rsSettings("paye2")
End If
Else
Me.tax = Me.pay * rsSettings("paye1")
End If
Me.netpay = Me.pay - Me.nis - Me.tax
Else
MsgBox "Officer Number Not Found!!", vbInformation + vbOKOnly, cCaption
End If
Set rsPay = Nothing
Set rsSettings = Nothing
Set qDef = Nothing
Me.Refresh
End Sub
Private Sub natregno_BeforeUpdate(Cancel As Integer)
Dim strSQl As String, db As Database, rs As Recordset, lError As Boolean
lError = False
Set db = CurrentDb
Set rs = db.OpenRecordset("Names", dbOpenDynaset)
rs.FindFirst "emp_id = '" & Trim(Me.natregno) & "'"
If rs.NoMatch Then
MsgBox "National Registration Number Not Found!!", vbInformation + vbOKOnly, cCaption
Cancel = True
lError = True
End If
Set rs = Nothing
db.Close
Set db = Nothing
If lError Then
Exit Sub
End If
Me.RecordsetClone.FindFirst "natregno = '" & Me.natregno & "' AND pay_pd_id = " & _
[Forms]![pay transactions]![cmb_periods]
If Not Me.RecordsetClone.NoMatch Then
MsgBox "This officer already has hours entered for this period.", vbInformation + vbOKOnly, cCaption
Cancel = True
End If
End Sub
Public Sub Calc_Pay()
End Sub