home *** CD-ROM | disk | FTP | other *** search
- ************** Payroll COMMAND FILE ******************
- * This command file generates payroll check stubs showing all deductions; gets
- * the next check number and writes a check in the Checkfil, showing the new
- * balance; and stores the individual salary payments and dedutions in a file
- * called Wages. Summary information is stored in a database called Hold##.
- * This file is used to store the monthly, quarterly and annual FIT, FICA, SDI
- * and SIT deductions. The deductions are not picked up from tax tables because
- * there are so few employees. Instead, they are obtained from the individual
- * employee records in the Personnel database.
- * Konstant.mem keeps track of the FICA and SDI percentages and their
- * maximums, as well as the the constant for ThisYear. Changes can be thus
- * made in a single spot and will be correct in all the programs in the
- * accounting system.
- * The file is quite long, but breaks down into simpler modules:
- * I: Get the date and End of Month, Quarter and Year flags.
- * II: Compute all deductions and net pay for an individual employee, then
- * place this in the employee record in Personne.dbf
- * III: Print payroll stub.
- * IV: Paycheck is written to the Checkfil and all amounts are placed into
- * the Hold## summary file.
- * V: When all individuals have been paid, the Hold## summary file is
- * updated if it is the end of month, quarter or year.
- * VI: Print out the summary file and data so that the physical checkbook
- * can be updated (computer does not print our checks).
- * VII: Delete transient constants, save others back to Konstant.MEM for
- * system use.
- ***********************************************************************
- *****************************************************
- ********* I: Get date and pay period flags *********
- *
- SET MARGIN TO 0
- RESTORE FROM Konstant
- *
- *Selecting YTD file
- Header = 'Hold'+STR(ThisYear,2)
- SELECT 10
- USE &Header
- *Select file Personne.Dbf
- SELECT 5
- *
- *Payroll Transient Date Initialization
- TDate = DATE()
- *
- CLEAR
- STORE SPACE(1) TO Tproc,T_EOY,T_EOQ,T_EOM
- DO WHILE LEN(TProc) <> 0
- @ 1,18 SAY 'PAYROLL PROCESSING'
- @ 4, 8 SAY 'Payroll DATE' GET TDate
- @ 4,35 SAY '(Press <Enter> if okay.)'
- @ 6, 8 SAY 'End of the YEAR?'
- @ 8, 8 SAY 'End of the QUARTER?'
- @ 10, 8 SAY 'End of the MONTH?'
- READ
- @ 4,35
- @ 6,28 GET T_EOY PICTURE '!'
- @ 6,30 SAY '(Y or N)'
- READ
- @ 6,28
- IF T_EOY = 'Y'
- STORE 'Y' TO T_EOQ, T_EOM
- @ 6,28 GET T_EOY
- @ 8,29 GET T_EOQ
- @ 10,27 GET T_EOM
- CLEAR GETS
- ELSE
- T_EOY = 'N'
- @ 6,28 GET T_EOY
- CLEAR GETS
- @ 8,29 GET T_EOQ PICTURE '!'
- @ 8,31 SAY '(Y or N)'
- READ
- @ 8,31
- IF T_EOQ = 'Y'
- T_EOM = 'Y'
- @ 10,27 GET T_EOM
- CLEAR GETS
- ELSE
- T_EOQ = 'N'
- @ 8,29 GET T_EOQ
- CLEAR GETS
- @ 10,27 GET T_EOM PICTURE '!'
- @ 10,29 SAY '(Y or N)'
- READ
- @ 10,29
- IF T_EOM <> 'Y'
- T_EOM = 'N'
- @ 10,27 GET T_EOM
- CLEAR GETS
- ENDIF
- ENDIF quarter
- ENDIF year
- *
- *** 2nd chance at date and flags
- *
- * Computer now does a date and flag check
- @ 12,0 CLEAR
- IF day(TDate) < 24 .AND. T_EOM = 'Y'
- @ 12,8 SAY 'Warning: End of the month selected but the'
- @ 13,8 SAY 'date is '+DTOC(TDate)+'.'
- ENDIF
- IF T_EOY ='Y'
- SELECT 10
- IF .NOT. EOF()
- GO BOTTOM
- IF Marker = 'Y'
- @ 12,8 SAY 'Error: The end of the year has been done.'
- SELECT 5
- LOOP
- ENDIF
- ENDIF
- ENDIF
- @ 15,6 say 'The above information MUST be correct. '
- WAIT ' Press <ENTER> if O.K.' TO TProc
- @ 15,0 CLEAR
- ENDDO TProc
- @ ROW(),0 SAY 'Payroll process working'
- *
- *****************************************************************************
- *********** II: Calculate deductions and net pay for each individual ********
- * Compute deductions. Deductions for FICA, FIT, SDI and SIT are kept in the
- * individual employee's Personnel record, rather than getting them from tax
- * tables, because there are so few employees. (You have to decide what should
- * and should not be computerized.) The 'YTDxxx' variables are the year-to-date
- * totals for these items. Limits and percentages for FICA and SDI are obtained
- * from a file called Konstant.mem. These are the variables FICACut, FICAMax,
- * FICAEnd, SDICut, SDIMax and SDIEnd.
- *
- ************* This loop covers sections II, III and IV ****************
- *
- SELECT 5
- *
- REPLACE All FICA WITH (Pay_Rate*FICACUT + 0.005), SDI WITH (Pay_Rate*SDICUT;
- + 0.005), Net_Pay WITH (Pay_Rate - FICA - FIT - SDI - SIT)
- *
- Where = 0
- GO TOP
- *
- DO WHILE .NOT. EOF()
- IF .NOT. (Paid .OR. DELETED())
- Where = Where + 1
- *
- *** Save the employee record in case the procedure is ended ***
- T_Payee = STR(RECNO(),5)
- COPY Record &T_Payee TO Bak
- *
- *** Deductions for partial salary based on number of days worked ***
- *** Ratio is computed in Paymenu.prg
- IF Ratio < 1.0000
- REPLACE Pay_Rate WITH Pay_Rate*Ratio, FICA WITH FICA*Ratio,;
- FIT WITH FIT*Ratio, SDI WITH SDI*Ratio, SIT WITH SIT*Ratio
- ENDIF
- *
- * Deductions and totals are computed then stored in the employee record.
- * FedTemp, Statemp and EmpTemp are used to carry forward values for
- * salaries subject to FICA, SDI and state uenemployment insurance to
- * Hold##, the summary file.
- *
- IF YTDSAL > FICAEnd
- FedTemp = 0
- REPLACE FICA WITH 0
- ELSE
- IF (YTDSal + Pay_Rate) <= FICAEnd
- REPLACE YTDFICA WITH (YTDFICA + FICA)
- FedTemp = Pay_Rate
- ELSE
- REPLACE FICA WITH (MAXFICA - YTDFICA), YTDFICA WITH MAXFICA
- FedTemp = (FICAEnd - YTDSal)
- ENDIF
- ENDIF
- *
- IF YTDSal > SDIEnd
- StaTemp = 0
- REPLACE SDI WITH 0
- ELSE
- IF (YTDSAL + Pay_Rate) <= SDIEnd
- REPLACE YTDSDI WITH (YTDSDI + SDI)
- StaTemp = Pay_Rate
- ELSE
- REPLACE SDI WITH (MAXSDI - YTDSDI), YTDSDI WITH MAXSDI
- StaTemp = (SDIEnd-YTDSal)
- ENDIF
- ENDIF
- *
- * In California, the employer pays an Unemployment Insurance contribution
- * on employee salary up to the amount of UIEnd. There is nothing
- * deducted from the employee salary for this, so we keep track only of
- * the employer obligation as UISal.
- *
- IF YTDSal > UIEnd
- EmpTemp = 0
- ELSE
- IF (YTDSal + Pay_Rate) <= UIEnd
- EmpTemp = Pay_Rate
- ELSE
- EmpTemp = (UIEnd - YTDSal)
- ENDIF
- ENDIF
- *
- REPLACE Net_Pay WITH (Pay_Rate-FICA-FIT-SDI-SIT),YTDFIT WITH;
- (YTDFIT + FIT),YTDSIT WITH (YTDSIT + SIT),QTDSal WITH;
- (QTDSal + Pay_Rate),YTDSal WITH (YTDSal + Pay_Rate)
- *
- *************************************************************************
- ************** III: Pay employee and print stub *************
- *Select Wages.Dbf
- SELECT 7
- APPEND BLANK
- REPLACE Check_Date WITH TDate,Check_Nmbr WITH NextCheck,Pay_Rate;
- WITH E->Pay_Rate,Net_pay WITH E->Net_Pay, Emp_Nmbr WITH;
- E->Emp_Nmbr,YTDSal WITH E->YTDSal, FICA WITH E->FICA
- REPLACE FIT WITH E->FIT,SIT WITH E->SIT, SDI WITH E->SDI,;
- Name with E->Name
- *Select Checkfil.dbf
- SELECT 6
- APPEND BLANK
- REPLACE Check_Nmbr WITH NextCheck, Check_Date WITH TDate, Name WITH;
- E->Name, Amount WITH E->Net_Pay, Emp_Nmbr WITH E->Emp_Nmbr
- REPLACE Client WITH 'OFC', Job_Nmbr WITH 31, Descrip WITH 'SALARY',;
- Balance WITH (MBalance - Amount)
- MBalance = MBalance - Amount
- *
- NextCheck = STR(VAL(NextCheck)+1,5)
- Start = 1
- DO WHILE Start < LEN(NextCheck) .AND. SUBSTR(NextCheck,Start,1)=' '
- Start = Start + 1
- ENDDO
- NextCheck = SUBSTR(NextCheck,Start)
- *
- CLEAR
-
- SET PRINT ON
- ? ' #'+TRIM(Check_Nmbr) + ': ', TDate, ': ' + Name + ' '
- SELECT 5
- ?? SUBSTR(SS_Nmbr,1,3)+'-'+SUBSTR(SS_Nmbr,4,2)+'-'+SUBSTR(SS_Nmbr,6,4)
- ? ' GROSS PAY: $'+STR(Pay_Rate,7,2)+' NET PAY: $';
- +STR(Net_Pay,7,2)
- ?
- ? ' FICA FIT SDI SIT'
- ? ' THIS CHECK: '+STR(FICA,6,2)+' '+STR(FIT,7,2);
- +' '+STR(SDI,5,2)+' ' +STR(SIT,7,2)
- ? ' THIS YEAR: '+STR(YTDFICA,7,2)+' '+STR(YTDFIT,8,2);
- +' '+STR(YTDSDI,6,2) +' '+STR(YTDSIT,7,2)
- ? ' TOTAL SALARY THIS QUARTER: $'+STR(QTDSal,9,2)
- ? ' TOTAL SALARY THIS YEAR: $'+STR(YTDSal,9,2)
- ?
- ?
- ?
- SELECT 7
- IF Where >= 4
- ? CHR(12)
- Where = 0
- ENDIF
- SET PRINT OFF
-
- *
- Paid = .T.
- *
- *************************************************************
- ******* IV: Record paycheck in Hold## **********
- *
- CLEAR
- @ 4,25 SAY '** DO NOT INTERRUPT **'
- @ 5,25 SAY 'UPDATING MASTER RECORD'
- * We keep an aggregate record of payroll and deductions. The amounts
- * for each employee are added to the amounts already in the last
- * record in the file represented by 'Header'. (This was set up at the
- * start of the 'TProc' loop earlier, and has the name 'Hold84' or
- * 'Hold85' or whatever 'ThisYear' is.)
- * This last record is either a blank (if this is the first
- * payroll of the month), or has data from previous salary payments
- * made during the current month. At the end of the month, quarter and
- * year, totals and a new blank record (except at the end of the year)
- * are added. This is done in the next loop.
- * If this is a new year, there are no records in the file so we add a
- * blank record. Otherwise, we go to the last record in the file.
- *
- SELECT 10
- *
- IF EOF()
- APPEND BLANK
- ELSE
- GO BOTTOM
- ENDIF
- *
- REPLACE Check_Date WITH SUBSTR(STR(YEAR(TDate),4),3,2) + STR(MONTH(TDate),2),;
- Payroll WITH (Payroll + E->Pay_Rate),FICA WITH (FICA+E->FICA),;
- FICASal WITH (FICASal + FedTemp)
- REPLACE FIT WITH (FIT + E->FIT), SDI WITH (SDI+E->SDI);
- SDISal WITH (SDISal + Statemp), SIT WITH (SIT + E->SIT);
- UISal WITH (UISal + EmpTemp)
- *
- SELECT 5
- *
- *** Reset the employee record if paid for part time. ***
- *** The Bak file is not deleted here, as each copy command ***
- *** above wipes out the previous contents. ***
- IF Ratio <> 1.0000
- SELECT 9
- USE Bak
- SELECT 5
- REPLACE Ratio WITH 1.0000
- UPDATE FROM Bak ON Emp_Nmbr REPL Pay_Rate WITH I->Pay_Rate,;
- FICA WITH I->FICA,FIT WITH I->FIT,SDI WITH I->SDI,;
- SIT WITH I->SIT,Net_Pay WITH I->Net_Pay
- SELECT 9
- USE
- SELECT 5
- ENDIF
- ENDIF
- *
- SKIP
- IF Emp_Nmbr > MaxEmpl
- IF .NOT. EOF()
- GO BOTTOM
- ENDIF
- SKIP
- ENDIF
- *
- ENDDO personnel file
- *
- *********************************************************************
- ******* V: Personnel records are reset and Hold## is updated ********
- *
- REPLACE All Paid WITH .F.
- *
- IF T_EOQ = 'Y'
- REPLACE All QTDSal WITH 0
- ENDIF
- *
- SELECT 10
- GO BOTTOM
- *
- * These variables must all be done before the payroll recap
- * PayRecap adds the blank record at the end of the Hold## file
- * besides the other stuff
- FedHit = (2*FICA + FIT)
- StateHit = (SDI + SIT)
- T_Old = VAL(SUBSTR(Check_Date,1,2))
- *
- DO PayRecap WITH T_EOY,T_EOM,T_EOQ,T_Old
- *
- ***********************************************************************
- ******** VI: Print payroll summary, transfer checks to costbase *******
- SELECT 6
- COUNT FOR .NOT. DELETED() TO Any
- CLEAR
- IF Any=0
- ? ' No new checks written.'
- ? ' <Return> to continue.'
- WAIT
- ELSE
- SELECT 10
- CLEAR
- SET PRINT ON
- ? ' MASTER PAYROLL FILE SUMMARY:',TDate
- ?
- ?
- ?'DATE PAYROLL FICA FICASAL FIT SDI SDISAL '+;
- ' SIT UISal'
- ?
- DO WHILE .NOT. EOF()
- ?? Check_Date,Marker,Payroll,FICA,FICASal,FIT,SDI,SDISAL,SIT,UISAL
- ?
- SKIP
- ENDDO
- ?
- ?
- ?
- IF T_EOM = 'Y'
- ? 'SEND THE FOLLOWING PAYMENTS TODAY:'
- ?
- ? ' Federal withholding: $'+ STR(FedHit,9,2)
- ?
- ? ' State withholding: $'+STR(StateHit,9,2)
- ENDIF
- *
- ? CHR(12)
- SET PRINT OFF
- *
- CLEAR
- @ 3,25 SAY '*** DO NOT INTERRUPT ***'
- @ 4,25 SAY ' UPDATING THE COSTBASE'
- *
- SELECT 6
- GO TOP
- DO WHILE .NOT. EOF()
- IF .NOT. DELETED()
- SELECT 3
- APPEND BLANK
- REPLACE Check_date WITH F->Check_date,Check_nmbr WITH;
- F->Check_nmbr,Client WITH F->Client,Job_nmbr;
- WITH F->Job_nmbr,Amount WITH F->Amount
- REPLACE Name WITH F->Name,Descrip WITH F->Descrip,;
- Bill_nmbr WITH F->Bill_nmbr,Emp_nmbr WITH F->Emp_nmbr
- SELECT 6
- ENDIF
- SKIP
- ENDDO
- *
- DO Checkstu
- *
- ENDIF
- *
- *******************************************************************
- ****** VII: Dump transient variables, save necessary ones ********
- RELEASE T_Payee,T_Number,TDate,Ratio,Aborted,Printed,T_EOY,T_EOQ,T_EOM,Any,;
- Header,Where,FedTemp,StaTemp,EmpTemp,Marker,Paying,Salaries;
- StateHit,FedHit,Paid,T_Old,Year,Quarter,Month
- *
- SAVE TO Konstant
- ****** VIII; Close YTD file
- SELECT 10
- USE
- SET MARGIN TO 20
- RETURN