Need pseudo code checked for me
Hey people, i wrote a code for a payroll system in Microsoft Access 2010(SQL). It works fine but i was told to write it in Pseudo code. The thing is i never write in pseudo code (yes, it is kind of a bad habit) and so i had a go. So i was just wondering if someone can check what I've done out for me.
have i used to right wording?
would you be able to code it without any other information?
any help would be appreciated.
Code:
Private Sub cmdPayroll_Click()
Dim PRDate As Date 'Date pay goes into bank
Dim PRMonth As String 'Payroll Month
Dim db As DAO.Database
Dim rsAgents As DAO.Recordset
Dim rsMonthly As DAO.Recordset
Dim rsSales As DAO.Recordset
Dim AgentsID As String
Dim ComTotal As Double
Dim Gross As Double
Dim Tax As Double
Dim NI As Double
Dim Net As Double
For PRMonth "Enter the Payroll Month, eg. 112012 is November 2012"
For PRDate "Enter the Date Of Pay, eg dd/mm/year"
Set the db as CurrentDb()
Set rsAgents equal to db.OpenRecordset("Select * from Agents", dbOpenSnapshot)
Set rsMonthly equal to db.OpenRecordset("Select * from [Monthly Pay]", dbOpenDynaset)
Set rsSales equal to db.OpenRecordset("Select * from Sales", dbOpenDynaset)
rsAgents.MoveFirst
Do Until rsAgents.EOF
The AgentsID is equal to rsAgents![AgentID]
Set ComTotal equal to 0
Move onto the first record in rsSales
Do Until rsSales.EOF
If the [Commission Paid] text in rsSales! is equal to No And AgentsID is equal to rsSales![AgentID] Then
The ComTotal is equal to ComTotal plus the data entered into rsSales![Commission]
Edit rsSalesEdit
Set rsSales![Commission Paid] equal to True
Update rsSales
End If
Move onto the next record in rsSales
Loop
Add new data into rsMonthly
rsMonthly![Agent ID] is equal to rsAgents![AgentID]
rsMonthly![PayMonth] is equal to PRMonth
rsMonthly![Date Of Pay] is equal to PRDate
rsMonthly![Gross (Salary)] is equal to rsAgents![Annual Salary] divided by 12
rsMonthly![Gross (Commission)] is equal to ComTotal
Gross is equal to rsMonthly![Gross (Salary)] plus rsMonthly![Gross (Commission)]
rsMonthly![Gross] is equal to Gross
Tax is equal to CalcTax(Gross, rsAgents![Personal Allowance])
NI is equal to CalcNI(Gross)
Net is equal to the Gross minus NI minus Tax
rsMonthly![Tax] equal to Tax
rsMonthly![NI] equal to NI
rsMonthly![Net] equal to Net
Update rsMonthly
Move onto Next record in rsAgent
Dim Tax As Single
Dim TIncome As Single
Dim AnnualIncome As Single
AnnualIncome is equal to MonthlyIncome multiplied by 12
TIncome is equal to AnnualIncome minus personal allowance
If TIncome is greater than 150000 Then
Tax is equal to 0.5 multiplied by (TIncome minus 150000) plus 0.4 multiplied by by (150000 minus 34371) plus (0.2 multiplied by 34370)
ElseIf TIncome is greater than 34371 then
Tax is equal to 0.4 multiplied by (TIncome minus 34370) plus (0.2 multiplied by 34370)
ElseIf TIncome is greater than 0 Then
Tax is equal to TIncome multiplied by 0.2
Else
Tax is equal to 0
End If
CalcTax is equal to Tax divided by 12
End Function
Public Function CalcNI(MonthlyIncome As Double) As Double
Dim NI As Single
Dim ww As Single
AnnualIncome is equal to MonthlyIncome multiplied by 12
ww is equal to AnnualIncome divided by 52
If ww is greater than 817 Then
NI is equal to ((817 minus 146) multiplied 0.12) plus ((ww minus 817) multiplied by 0.02)
ElseIf ww is greater than 146 Then
NI is equal to ((ww - 146) multiplied by 0.12)
Else
NI is equal to 0
End If
CalcNI is equal to (NI multiplied by 52) divided by 12
End Function
Algorithm for Calculating Commission
Private Sub cmdCalcComm_Click()
Data in [Commission] is equal to the data in [Price Paid] multiplied by 0.02
End Sub
p.s I'm sorry if this is the wrong place to post, its been a while since I've been on here.