home *** CD-ROM | disk | FTP | other *** search
/ Software Du Jour / SoftwareDuJour.iso / BUSINESS / DBASE / DB3.ARC / PAYROLL.PRG < prev    next >
Encoding:
Text File  |  1984-10-25  |  14.0 KB  |  416 lines

  1.   **************  Payroll COMMAND FILE ******************
  2. * This command file generates payroll check stubs showing all deductions; gets
  3. * the next check number and writes a check in the Checkfil, showing the new
  4. * balance; and stores the individual salary payments and dedutions in a file
  5. * called Wages.  Summary information is stored in a database called Hold##.
  6. * This file is used to store the monthly, quarterly and annual FIT, FICA, SDI
  7. * and SIT deductions.  The deductions are not picked up from tax tables because
  8. * there are so few employees.  Instead, they are obtained from the individual
  9. * employee records in the Personnel database.
  10. *      Konstant.mem keeps track of the FICA and SDI percentages and their
  11. * maximums, as well as the the constant for ThisYear.  Changes can be thus
  12. * made in a single spot and will be correct in all the programs in the
  13. * accounting system.
  14. * The file is quite long, but breaks down into simpler modules:
  15. *     I: Get the date and End of Month, Quarter and Year flags.
  16. *    II: Compute all deductions and net pay for an individual employee, then
  17. *         place this in the employee record in Personne.dbf
  18. *   III: Print payroll stub.
  19. *    IV: Paycheck is written to the Checkfil and all amounts are placed into
  20. *         the Hold## summary file.
  21. *     V: When all individuals have been paid, the Hold## summary file is
  22. *         updated if it is the end of month, quarter or year.
  23. *    VI: Print out the summary file and data so that the physical checkbook
  24. *         can be updated (computer does not print our checks).
  25. *   VII: Delete transient constants, save others back to Konstant.MEM for
  26. *         system use.
  27. ***********************************************************************
  28. *****************************************************
  29. *********  I: Get date and pay period flags *********
  30. *
  31. SET MARGIN TO 0
  32. RESTORE FROM Konstant
  33. *
  34. *Selecting YTD file
  35. Header = 'Hold'+STR(ThisYear,2)
  36. SELECT 10
  37. USE &Header
  38. *Select file Personne.Dbf
  39. SELECT 5
  40. *
  41. *Payroll Transient Date Initialization
  42. TDate = DATE()
  43. *
  44. CLEAR
  45. STORE SPACE(1) TO Tproc,T_EOY,T_EOQ,T_EOM
  46. DO WHILE LEN(TProc) <> 0
  47.    @ 1,18 SAY 'PAYROLL PROCESSING'
  48.    @  4, 8 SAY 'Payroll DATE' GET TDate
  49.    @  4,35 SAY '(Press <Enter> if okay.)'
  50.    @  6, 8 SAY 'End of the YEAR?'
  51.    @  8, 8 SAY 'End of the QUARTER?'  
  52.    @ 10, 8 SAY 'End of the MONTH?' 
  53.    READ
  54.    @  4,35
  55.    @  6,28 GET T_EOY PICTURE '!'
  56.    @  6,30 SAY '(Y or N)'
  57.    READ
  58.    @ 6,28
  59.    IF T_EOY = 'Y'
  60.       STORE 'Y' TO T_EOQ, T_EOM
  61.       @ 6,28 GET T_EOY
  62.       @ 8,29 GET T_EOQ 
  63.       @ 10,27 GET T_EOM 
  64.       CLEAR GETS
  65.    ELSE
  66.       T_EOY = 'N'
  67.       @ 6,28 GET T_EOY
  68.       CLEAR GETS
  69.       @ 8,29 GET T_EOQ PICTURE '!'
  70.       @ 8,31 SAY '(Y or N)'
  71.       READ
  72.       @ 8,31
  73.       IF T_EOQ = 'Y'
  74.          T_EOM = 'Y'
  75.          @ 10,27 GET T_EOM 
  76.          CLEAR GETS
  77.       ELSE
  78.          T_EOQ = 'N'
  79.          @ 8,29 GET T_EOQ
  80.          CLEAR GETS
  81.          @ 10,27 GET T_EOM PICTURE '!'
  82.          @ 10,29 SAY '(Y or N)'
  83.          READ
  84.          @ 10,29
  85.          IF T_EOM <> 'Y'
  86.             T_EOM = 'N'
  87.             @ 10,27 GET T_EOM
  88.             CLEAR GETS
  89.          ENDIF
  90.       ENDIF quarter
  91.    ENDIF year
  92.    *
  93.    *** 2nd chance at date and flags
  94.    *
  95.    * Computer now does a date and flag check
  96.    @ 12,0 CLEAR
  97.    IF day(TDate) < 24 .AND. T_EOM = 'Y'
  98.          @ 12,8 SAY 'Warning:  End of the month selected but the'
  99.          @ 13,8 SAY 'date is '+DTOC(TDate)+'.'
  100.    ENDIF
  101.    IF T_EOY ='Y'
  102.       SELECT 10
  103.       IF .NOT. EOF()
  104.          GO BOTTOM          
  105.          IF Marker = 'Y'
  106.             @ 12,8 SAY 'Error: The end of the year has been done.'
  107.             SELECT 5
  108.             LOOP
  109.          ENDIF
  110.      ENDIF
  111.    ENDIF
  112.    @ 15,6 say 'The above information MUST be correct.     '
  113.    WAIT '      Press <ENTER> if O.K.' TO TProc
  114.    @ 15,0 CLEAR
  115. ENDDO TProc
  116. @ ROW(),0 SAY 'Payroll process working'
  117. *
  118. *****************************************************************************
  119. *********** II: Calculate deductions and net pay for each individual ********
  120. * Compute deductions.  Deductions for FICA, FIT, SDI and SIT are  kept in the
  121. * individual employee's Personnel record, rather than getting them from tax
  122. * tables, because there are so few employees.  (You have to decide what should
  123. * and should not be computerized.)  The 'YTDxxx' variables are the year-to-date
  124. * totals for these items.  Limits and percentages for FICA and SDI are obtained
  125. * from a file called Konstant.mem.  These are the variables FICACut, FICAMax,
  126. * FICAEnd, SDICut, SDIMax and SDIEnd.
  127. *
  128.   ************* This loop covers sections II, III and IV ****************
  129. *
  130. SELECT 5
  131. *
  132. REPLACE All FICA WITH (Pay_Rate*FICACUT + 0.005), SDI WITH (Pay_Rate*SDICUT;
  133.         + 0.005), Net_Pay WITH (Pay_Rate - FICA - FIT - SDI - SIT)
  134. *
  135. Where = 0
  136. GO TOP
  137. *
  138. DO WHILE .NOT. EOF()
  139.    IF .NOT. (Paid .OR. DELETED())
  140.       Where = Where + 1
  141.       *
  142.       *** Save the employee record in case the procedure is ended ***
  143.       T_Payee = STR(RECNO(),5)
  144.       COPY Record &T_Payee TO Bak
  145.       *
  146.       *** Deductions for partial salary based on number of days worked ***
  147.       *** Ratio is computed in Paymenu.prg
  148.       IF Ratio < 1.0000
  149.          REPLACE Pay_Rate WITH Pay_Rate*Ratio, FICA WITH FICA*Ratio,;
  150.            FIT WITH FIT*Ratio, SDI WITH SDI*Ratio, SIT WITH SIT*Ratio
  151.       ENDIF
  152.       *
  153.       * Deductions and totals are computed then stored in the employee record.
  154.       * FedTemp, Statemp and EmpTemp are used to carry forward values for
  155.       * salaries subject to FICA, SDI and state uenemployment insurance to
  156.       * Hold##, the summary file.
  157.       * 
  158.       IF YTDSAL > FICAEnd
  159.          FedTemp = 0
  160.          REPLACE FICA WITH 0
  161.       ELSE
  162.          IF (YTDSal + Pay_Rate) <= FICAEnd
  163.             REPLACE YTDFICA WITH (YTDFICA + FICA)
  164.             FedTemp = Pay_Rate
  165.          ELSE
  166.             REPLACE FICA WITH (MAXFICA - YTDFICA), YTDFICA WITH MAXFICA
  167.             FedTemp = (FICAEnd - YTDSal)
  168.          ENDIF
  169.       ENDIF
  170.       *
  171.       IF YTDSal > SDIEnd
  172.          StaTemp = 0
  173.          REPLACE SDI WITH 0
  174.       ELSE
  175.          IF (YTDSAL + Pay_Rate) <= SDIEnd
  176.             REPLACE YTDSDI WITH (YTDSDI + SDI)
  177.             StaTemp = Pay_Rate
  178.          ELSE
  179.             REPLACE SDI WITH (MAXSDI - YTDSDI), YTDSDI WITH MAXSDI
  180.             StaTemp = (SDIEnd-YTDSal)
  181.          ENDIF
  182.       ENDIF
  183.       *
  184.       * In California, the employer pays an Unemployment Insurance contribution
  185.       * on employee salary up to the amount of UIEnd.  There is nothing
  186.       * deducted from the employee salary for this, so we keep track only of
  187.       * the employer obligation as UISal.
  188.       *
  189.       IF YTDSal > UIEnd
  190.          EmpTemp = 0
  191.       ELSE
  192.          IF (YTDSal + Pay_Rate) <= UIEnd
  193.             EmpTemp = Pay_Rate
  194.          ELSE
  195.             EmpTemp = (UIEnd - YTDSal)
  196.          ENDIF
  197.       ENDIF
  198.       *
  199.       REPLACE Net_Pay WITH (Pay_Rate-FICA-FIT-SDI-SIT),YTDFIT WITH;
  200.               (YTDFIT + FIT),YTDSIT WITH (YTDSIT + SIT),QTDSal WITH;
  201.               (QTDSal + Pay_Rate),YTDSal WITH (YTDSal + Pay_Rate)
  202.       *
  203.       *************************************************************************
  204.       ************** III: Pay employee and print stub *************
  205.       *Select Wages.Dbf
  206.       SELECT 7
  207.       APPEND BLANK
  208.       REPLACE Check_Date WITH TDate,Check_Nmbr WITH NextCheck,Pay_Rate;
  209.               WITH E->Pay_Rate,Net_pay WITH E->Net_Pay, Emp_Nmbr WITH;
  210.               E->Emp_Nmbr,YTDSal WITH E->YTDSal, FICA WITH E->FICA
  211.       REPLACE FIT WITH E->FIT,SIT WITH E->SIT, SDI WITH E->SDI,;
  212.               Name with E->Name
  213.       *Select Checkfil.dbf
  214.       SELECT 6
  215.       APPEND BLANK
  216.       REPLACE Check_Nmbr WITH NextCheck, Check_Date WITH TDate, Name WITH;
  217.                E->Name, Amount WITH E->Net_Pay, Emp_Nmbr WITH E->Emp_Nmbr
  218.       REPLACE Client WITH 'OFC', Job_Nmbr WITH 31, Descrip WITH 'SALARY',;
  219.               Balance WITH (MBalance - Amount)
  220.       MBalance = MBalance - Amount
  221.       *
  222.       NextCheck = STR(VAL(NextCheck)+1,5)
  223.       Start = 1
  224.       DO WHILE Start < LEN(NextCheck) .AND. SUBSTR(NextCheck,Start,1)=' '
  225.          Start = Start + 1
  226.       ENDDO
  227.       NextCheck = SUBSTR(NextCheck,Start)
  228.       *
  229.       CLEAR
  230.       
  231.       SET PRINT ON
  232.       ? '         #'+TRIM(Check_Nmbr) + ': ', TDate, ': ' + Name + '   '
  233.       SELECT 5
  234.       ?? SUBSTR(SS_Nmbr,1,3)+'-'+SUBSTR(SS_Nmbr,4,2)+'-'+SUBSTR(SS_Nmbr,6,4)
  235.       ? '         GROSS PAY: $'+STR(Pay_Rate,7,2)+'    NET PAY: $';
  236.                                 +STR(Net_Pay,7,2)
  237.       ?
  238.       ? '                        FICA        FIT       SDI       SIT'
  239.       ? '         THIS CHECK:   '+STR(FICA,6,2)+'    '+STR(FIT,7,2);
  240.                           +'     '+STR(SDI,5,2)+'   ' +STR(SIT,7,2)
  241.       ? '          THIS YEAR:  '+STR(YTDFICA,7,2)+'   '+STR(YTDFIT,8,2);
  242.                          +'    '+STR(YTDSDI,6,2) +'   '+STR(YTDSIT,7,2)
  243.       ? '                     TOTAL SALARY THIS QUARTER: $'+STR(QTDSal,9,2)
  244.       ? '                        TOTAL SALARY THIS YEAR: $'+STR(YTDSal,9,2)
  245.       ?
  246.       ?
  247.       ?
  248.       SELECT 7
  249.       IF Where >= 4
  250.          ? CHR(12)
  251.          Where = 0
  252.       ENDIF
  253.       SET PRINT OFF
  254.       
  255.       *  
  256.       Paid = .T.
  257.       *
  258.       *************************************************************
  259.       ******* IV: Record paycheck in Hold## **********
  260.       *
  261.       CLEAR
  262.       @ 4,25 SAY '** DO NOT INTERRUPT **'
  263.       @ 5,25 SAY 'UPDATING MASTER RECORD'
  264.       * We keep an aggregate record of payroll and deductions.        The amounts
  265.       * for each employee are added to the amounts already in the last
  266.       * record in the file represented by 'Header'.  (This was set up at the
  267.       * start of the 'TProc' loop earlier, and has the name 'Hold84' or
  268.       * 'Hold85' or whatever 'ThisYear' is.)
  269.       *       This last record is either a blank (if this is the first
  270.       * payroll of the month), or has data from previous salary payments
  271.       * made during the current month.        At the end of the month, quarter and
  272.       * year, totals and a new blank record (except at the end of the year)
  273.       * are added.  This is done in the next loop.
  274.       * If this is a new year, there are no records in the file so we add a
  275.       * blank record.  Otherwise, we go to the last record in the file.
  276.       *
  277.       SELECT 10
  278.       *      
  279.       IF EOF()
  280.          APPEND BLANK
  281.       ELSE
  282.          GO BOTTOM
  283.       ENDIF
  284.       *
  285.       REPLACE Check_Date WITH SUBSTR(STR(YEAR(TDate),4),3,2) + STR(MONTH(TDate),2),;
  286.               Payroll WITH (Payroll + E->Pay_Rate),FICA WITH (FICA+E->FICA),;
  287.               FICASal WITH (FICASal + FedTemp)
  288.       REPLACE FIT WITH (FIT + E->FIT), SDI WITH (SDI+E->SDI);
  289.               SDISal WITH (SDISal + Statemp), SIT WITH (SIT + E->SIT);
  290.               UISal WITH (UISal + EmpTemp)
  291.       *
  292.       SELECT 5
  293.       *
  294.       *** Reset the employee record if paid for part time.         ***
  295.       *** The Bak file is not deleted here, as each copy command   ***
  296.       *** above wipes out the previous contents.                   ***
  297.       IF Ratio <> 1.0000
  298.          SELECT 9
  299.          USE Bak
  300.          SELECT 5
  301.          REPLACE Ratio WITH 1.0000
  302.          UPDATE FROM Bak ON Emp_Nmbr REPL Pay_Rate WITH I->Pay_Rate,;
  303.                 FICA WITH I->FICA,FIT WITH I->FIT,SDI WITH I->SDI,;
  304.                 SIT WITH I->SIT,Net_Pay WITH I->Net_Pay
  305.          SELECT 9
  306.          USE
  307.          SELECT 5
  308.       ENDIF
  309.    ENDIF
  310.    *
  311.    SKIP
  312.    IF Emp_Nmbr > MaxEmpl
  313.       IF .NOT. EOF()
  314.          GO BOTTOM
  315.       ENDIF
  316.       SKIP
  317.    ENDIF
  318.    *
  319. ENDDO personnel file
  320. *
  321. *********************************************************************
  322. ******* V: Personnel records are reset and Hold## is updated ********
  323. *
  324. REPLACE All Paid WITH .F.
  325. *
  326. IF T_EOQ = 'Y'
  327.    REPLACE All QTDSal WITH 0
  328. ENDIF
  329. *
  330. SELECT 10
  331. GO BOTTOM
  332. *
  333. * These variables must all be done before the payroll recap
  334. * PayRecap adds the blank record at the end of the Hold## file
  335. * besides the other stuff
  336. FedHit = (2*FICA + FIT)
  337. StateHit = (SDI + SIT)
  338. T_Old = VAL(SUBSTR(Check_Date,1,2))
  339. *
  340. DO PayRecap WITH T_EOY,T_EOM,T_EOQ,T_Old
  341. *
  342. ***********************************************************************
  343. ******** VI: Print payroll summary, transfer checks to costbase *******
  344. SELECT 6
  345. COUNT FOR .NOT. DELETED() TO Any
  346. CLEAR
  347. IF Any=0
  348.    ? '        No new checks written.'
  349.    ? '     <Return> to continue.'
  350.    WAIT
  351. ELSE
  352.    SELECT 10
  353.    CLEAR
  354.    SET PRINT ON
  355.    ? '             MASTER PAYROLL FILE SUMMARY:',TDate
  356.    ?
  357.    ?
  358.    ?'DATE     PAYROLL   FICA    FICASAL     FIT     SDI   SDISAL     '+;
  359.                 '  SIT   UISal'
  360.    ?
  361.    DO WHILE .NOT. EOF()
  362.       ?? Check_Date,Marker,Payroll,FICA,FICASal,FIT,SDI,SDISAL,SIT,UISAL
  363.       ?
  364.       SKIP
  365.    ENDDO
  366.    ?
  367.    ?
  368.    ?
  369.    IF T_EOM = 'Y'
  370.       ? 'SEND THE FOLLOWING PAYMENTS TODAY:'
  371.       ?
  372.       ? '              Federal withholding: $'+ STR(FedHit,9,2)
  373.       ?
  374.       ? '                State withholding:  $'+STR(StateHit,9,2)
  375.    ENDIF
  376.    *
  377.    ? CHR(12)
  378.    SET PRINT OFF
  379.    *
  380.    CLEAR
  381.    @ 3,25 SAY '*** DO NOT INTERRUPT ***'
  382.    @ 4,25 SAY ' UPDATING THE COSTBASE'
  383.    *
  384.    SELECT 6
  385.    GO TOP
  386.    DO WHILE .NOT. EOF()
  387.       IF .NOT. DELETED()
  388.          SELECT 3
  389.          APPEND BLANK
  390.          REPLACE Check_date WITH F->Check_date,Check_nmbr WITH;
  391.                  F->Check_nmbr,Client WITH F->Client,Job_nmbr;
  392.                  WITH F->Job_nmbr,Amount WITH F->Amount
  393.          REPLACE Name WITH F->Name,Descrip WITH F->Descrip,;
  394.                  Bill_nmbr WITH F->Bill_nmbr,Emp_nmbr WITH F->Emp_nmbr
  395.          SELECT 6
  396.       ENDIF
  397.       SKIP
  398.    ENDDO
  399.    *
  400.    DO Checkstu 
  401.    *
  402. ENDIF
  403. *
  404. *******************************************************************
  405. ****** VII: Dump transient variables, save necessary ones ********
  406. RELEASE T_Payee,T_Number,TDate,Ratio,Aborted,Printed,T_EOY,T_EOQ,T_EOM,Any,;
  407.         Header,Where,FedTemp,StaTemp,EmpTemp,Marker,Paying,Salaries;
  408.         StateHit,FedHit,Paid,T_Old,Year,Quarter,Month
  409. *
  410. SAVE TO Konstant
  411. ****** VIII; Close YTD file
  412. SELECT 10
  413. USE
  414. SET MARGIN TO 20
  415. RETURN
  416.