home *** CD-ROM | disk | FTP | other *** search
/ Software Du Jour / SoftwareDuJour.iso / BUSINESS / DBASE / DBASEACC.ARC / PAYROLL.PRG < prev    next >
Text File  |  1979-12-31  |  12KB  |  383 lines

  1.  
  2. *PAYROLL.CMD
  3. * This command file generates payroll check stubs showing all deductions; gets
  4. * the next check number and writes a check in the CheckFile, showing the new
  5. * balance; and stores the salaries and deductions in a database called Hold82.
  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. *   Constants.MEM keeps track of the FICA and SDI percentages and their
  11. * maximums, as well as 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. Operator verifies deductions and payroll stub is printed.
  19. *  IV. Paycheck is written to the Checkfil and all amounts are placed into the
  20. * Hold82 summary file.
  21. *   V. When all individuals have been paid, the Hold 82 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 Constant.MEM for
  26. * system use.
  27.  
  28. ******I.  Get date and pay period flags******
  29.  
  30. RESTORE FROM Constant
  31. DO GetDate
  32.  
  33. STORE 'Y' TO GetWhen
  34. DO WHILE !(GetWhen) = 'Y'
  35.     ERASE
  36.     @ 1,18 SAY "PAYROLL PROCESSING"
  37.     STORE " " TO EOY
  38.     @ 4,8 SAY 'Want to change the date?' GET Date
  39.     @ 5,8 SAY '(Press <Return> if okay.)'
  40.     READ
  41.     @ 7,6 SAY "Is it the end of the YEAR?" GET EOY
  42.     @ 7,35 SAY "(Y or N)"
  43.     ? CHR(7)
  44.     READ
  45.     STORE !(EOY) TO EOY
  46.     IF EOY = "Y"
  47.  STORE "Y" TO EOQ
  48.  STORE "Y" TO EOM
  49.     ELSE
  50.  STORE "N" to EOY
  51.  STORE " " TO EOQ
  52.  @ 8,3 SAY "Is it the end of the QUARTER?"  GET EOQ
  53.  @ 8,35 SAY "(Y or N)"
  54.  ? CHR(7)
  55.  READ
  56.  STORE !(EOQ) TO EOQ
  57.  IF EOQ = "Y"
  58.      STORE "Y" TO EOM
  59.  ELSE
  60.      STORE "N" TO EOQ
  61.      STORE " " TO EOM
  62.      @ 9,5, SAY "Is it the end of the MONTH?"  GET EOM
  63.      @ 9,35 SAY "(Y or N)"
  64.      ? CHR(7)
  65.      READ
  66.      STORE !(EOM) TO EOM
  67.      IF EOM <> "Y"
  68.   STORE "N" TO EOM
  69.      ENDIF
  70.  ENDIF quarter
  71.     ENDIF year
  72.  
  73.     ERASE
  74.     @ 4,25 SAY $(Date,1,2)+'/'+$(Date,3,2)+'/'+$(Date,5,2)
  75.     @ 6,0 SAY "End of Year:  "+EOY+"   End of QUARTER: "+EOQ+;
  76.        "   End of MONTH:  "+EOM
  77.     STORE " " TO GetWhen
  78.     ?
  79.     ? '                                                   '
  80.     @ 8,6, say 'The above information MUST be correct.    '
  81.     ? CHR(7)
  82.     * 2nd chance at date and flags
  83.     ACCEPT '            Any CHANGES (Y or N)?' TO GetWhen
  84.  
  85.     STORE 'Hold'+STR(ThisYear,2) TO Header
  86.     * Computer now does a date and flag check
  87.     IF !(GetWhen) <> 'Y'
  88.  IF $(Date,5,2)<'26' .AND. EOM = 'Y'
  89.      ?
  90.      ?
  91.      ?"CHECK THE INFO AGAIN.  It's the end of the month, but the"
  92.      ?'date is '+Date-'.  Do you want to make changes (Y or N)?'
  93.      ? CHR(7)
  94.      WAIT TO GetWhen
  95.  ENDIF
  96.  IF EOY = 'Y'
  97.      SELECT SECONDARY
  98.      USE &Header
  99.      GO BOTTOM
  100.      IF Marker = 'Y'
  101.   ? CHR(7)
  102.   ? 'You blew it--the end of the year has been done!'
  103.   WAIT
  104.   RELEASE All
  105.   STORE T TO Paying
  106.   RETURN
  107.      ENDIF
  108.  ENDIF
  109.     ENDIF
  110. ENDDO GetWhen
  111. RELEASE GetWhen
  112.  
  113.  
  114. ****** II.  Calculate decutions and net pay for each individual *****
  115. * Compute deductions.  Decutions for FICA, FIT, SDI and SIT are kept in the
  116. * individual employee's Personnel record, rather than getting them from tax
  117. * tables, because there are so few employees.  (You have to decide what should
  118. * and should not be computerized.)  The "YTDxxx" variables are the year-to-date
  119. * totals for these items.  Limits and percentages for FICA and SDI are obtained
  120. * from a file called Constant.MEM.  These are the variables FICACut, FICAMax,
  121. * FICAEnd, SDICut, SDIMax and SDIEnd.
  122.  
  123. SELECT PRIMARY
  124.  
  125. USE Personne
  126. REPLACE ALL FICA WITH (Pay:Rate*FICACUT+0.005);
  127.      SDI WITH (Pay:Rate*SDICUT+0.005)
  128.  
  129. STORE 0 TO Count
  130. GO TOP
  131. DO WHILE .NOT. EOF
  132.     IF Paid .OR. *
  133.  SKIP
  134.     ELSE
  135.  STORE Count + 1 TO Count
  136.  
  137.  ** Save the employee record in case the procedure is ended ***
  138.  STORE STR(#,5) TO Payee
  139.  COPY Record &Payee TO Bak
  140.  
  141.  ** Deductions for partial salary based on number of days worked ***
  142.  ** Ratio is computed in PayMenu.CMD
  143.  IF Ratio < 1.000
  144.      REPLACE Pay:Rate WITH Pay:Rate*Ratio, FICA WITH FICA*Ratio,FIT;
  145.              WITH FIT*Ratio, SDI WITH SDI*Ratio, SIT WITH SIT*Ratio
  146.  ENDIF
  147.  * Deductions and totals are computed then stored in the employee
  148.  * record FedTemp, Statemp and EmpTemp are used to carry forward values
  149.  * for salaries subject to FICA, SDI and stateme unemployment insurance
  150.  * to Hold82, the summary file.
  151.  
  152.  IF YTDSAL > FICAEnd
  153.      STORE 0 TO FedTemp
  154.      REPLACE FICA WITH 0
  155.  ELSE
  156.      IF (YTDSal + Pay:Rate) <= FICAEnd
  157.   REPLACE YTDFICA WITH (YTDFICA + FICA)
  158.   STORE Pay:Rate TO FedTemp
  159.      ELSE
  160.   REPLACE FICA WITH (MAXFICA - YTDFICA), YTDFICA WITH MAXFICA
  161.   STORE (FICAEnd - YTDSal) TO FedTemp
  162.      ENDIF
  163.  ENDIF
  164.  
  165.  IF YTDSal > SDIEnd
  166.      STORE 0 TO StaTemp
  167.      REPLACE SDI WITH 0
  168.  ELSE
  169.      IF (YTDSAL + Pay:Rate) <= SDIEnd
  170.   REPLACE YTDSDI WITH (YTDSDI + SDI)
  171.   STORE Pay:Rate TO StaTemp
  172.      ELSE
  173.   REPLACE SDI WITH (MAXSDI - YTDSDI), YDSDI WITH MAXSDI
  174.   STORE (SDIEnd-YTDSal) TO StaTemp
  175.      ENDIF
  176.  ENDIF
  177.  
  178.     * In California, the employer pays an Unemployment Ins. contribution
  179.     * on employee salary up to the amount of UIEnd.  There is nothing
  180.     * deducted from the employee salary for this, so we keep track only of
  181.     * the employer obligation as UISal.
  182.     IF YTDSal > UIEnd
  183.  STORE 0 TO EmpTemp
  184.     ELSE
  185.  IF (YTDSal + Pay:Rate) <= UIEND
  186.      STORE Pay:Rate TO EmpTemp
  187.  ELSE
  188.      STORE (UIEnd - YTDSal) TO EmpTemp
  189.  ENDIF
  190.     ENDIF
  191.     REPLACE Net:Pay WITH (Pay:Rate-FICA-FIT-SDI-SIT)
  192.     REPLACE YTDFIT WITH (YTDFIT + FIT)
  193.     REPLACE YTDSIT WITH (YTDSIT + SIT)
  194.     REPLACE QTDSal WITH (QTDSal + Pay:Rate)
  195.     REPLACE YTDSal WITH (YTDSal + Pay:Rate)
  196.  
  197. *****  III.  Print employee stub ****
  198. ERASE
  199. SET PRINT ON
  200. ? '         '+$(Date,3,2)+'/'+$(Date,5,2)+'/'+$(Date,1,2)+': '+Name;
  201.       +'    '+$(SS:Nmbr,1,3)+'-'+$(SS:Nmbr,4,2)+'-'+$(SS:Nmbr,6,4)
  202. ? '          GROSS PAY* $'-STR(Pay:Rate,7,2)+'   NET PAY: $';
  203.                           -STR(Net:Pay,7,2)
  204. ?
  205. ? '                       FICA        FIT        SDI        SIT'
  206. ? '       THIS CHECK:   '+STR(FICA,6,2)+'   '+STR(FIT,7,2);
  207.                   +'    '+STR(SDI,5,2)+'   '+STR(SIT,7,2)
  208. ? '       THIS YEAR:    '+STR(YTDFICA,7,2)+'   '+STR(YTDFIT,8,2);
  209.                 +'    '+STR(YTDSDI,6,2)+'   '+STR(YTDSIT,7,2)
  210. ? '                  TOTAL SALARY THIS QUARTER: $'-STR(QTDSal,9,2)
  211. ? '                     TOTAL SALARY THIS YEAR: $'-STR(YTDSal,9,2)
  212. ?
  213. ?
  214. ?
  215. *Pagefeed after every six employee stubs
  216. IF Count >= 6
  217.     ? CHR(12)
  218.     STORE 0 TO Count
  219. ENDIF
  220. SET PRINT OFF
  221.  
  222. IF EOQ = 'Y' .AND. Paid
  223.     REPLACE QTDSal WITH 0
  224. ENDIF
  225.  
  226. ***** IV. Record paycheck in Checkfile and Hold82 ****
  227. * Now a check is "written" in the CheckFil.
  228. SELECT SECONDARY
  229. USE Checkfil
  230. APPEND BLANK
  231. REPLACE Check:Nmbr WITH NextCheck, Check:Date WITH Date,;
  232.  Name WITH P.Name, Amount WITH Net:Pay, Emp:Nmbr;
  233.  WITH P.Emp:Nmbr, Client WITH 'OFC', Job:Nmbr WITH 31,;
  234.  Descrip WITH 'SALARY', Balance WITH (MBalance - Amount)
  235. STORE (MBalance - Amount) TO MBalance
  236. STORE STR(VAL(NextCheck)+1,4) TO NextCheck
  237.  
  238. ERASE
  239. @ 3,25 SAY "**DO NOT INTERRUPT**"
  240. @ 5,25 SAY "UPDATING MASTER RECORD"
  241. ? CHR(7)
  242. * We keep an aggregate record of payroll and deductions.  The amounts
  243. * for each employee are added to the amounts already in the last
  244. * record in the file represented by "Header".  (This was set up at the
  245. * start of the "GetWhen" loop earlier, and has the name "Hold82" or
  246. * "Hold--" or whatever "ThisYear" is.)
  247. *   This last record is either a blank (if this is the first payroll
  248. * of the month), or has data from previous salary payments
  249. * made during the current month.  At the end of the month, quarter and
  250. * year, totals and a new blank record )except at the end of the year)
  251. * are added.  This is done in the next loop.
  252.  
  253. USE &Header
  254.  
  255. * If this is a new year, there are no records in the file so we add a
  256. * blank record.  Otherwise, we go to the last record in the file.
  257. IF EOF
  258.     APPEND BLANK
  259. ELSE
  260.     GO BOTTOM
  261. ENDIF
  262.  
  263. REPLACE Check:Date WITH Date, Payroll WITH (Payroll+Pay:Rate),;
  264.     FICA WITH (FICA+P.FICA), FICASal WITH (FICASal + FedTemp),;
  265.     FIT WITH (FIT + P.FIT), SDI WITH (SDI+P.SDI),;
  266.     SDISal WITH (SDISal + Statemp), SIT WITH (SIT + P.SIT),;
  267.     UISal WITH (UISal + EmpTemp)
  268. SELECT PRIMARY
  269.  
  270. **Reset the employee record if he was paid for part time. **
  271. **The Bak file is not deleted here, as each copy command **
  272. **above wipes out the previous contents.
  273. IF Ratio <> 1.000
  274.     REPLACE Ratio WITH 1.000
  275.     UPDA FROM Bak ON Emp:Nmbr REPL Pay:Rate,FICA,FIT,SDI,SIT,Net:Pay
  276. ENDIF
  277. ENDIF
  278.  
  279. SKIP
  280. ENDDO personnel file
  281.  
  282. ************
  283. *** V: Personnel records are reset and Holdxx is updated ***
  284. STORE ' ' TO Completed
  285. REPLACE All Paid WITH F
  286.  
  287. USE &Header
  288. GO Bottom
  289. IF EOM = 'Y'
  290.     REPLACE Marker WITH 'M'
  291.  
  292. * If it's the end of the quarter, we total the amounts for the previous
  293. * three months to a new record and mark it with a 'Q'.
  294.     IF EOQ = 'Y'
  295.  STORE STR(#,5) TO Number
  296.  TOTAL ON Marker TO Quarter FOR # >= (VAL(Number)-2)
  297.  APPEND FROM Quarter
  298.  DELETE FILE Quarter
  299.  
  300.  IF $(Date,3,2) = '03'
  301.      REPLACE Check:Date WITH '1st'
  302.  ELSE
  303.      IF $(Date,3,2) = '06'
  304.   REPLACE CHeck:Date WITH '2ND'
  305.      ELSE
  306.   IF $(Date,3,2) = '9'
  307.       REPLACE Check:Date WITH '3RD'
  308.   ELSE
  309.       IF $(Date,3,2) = '12'
  310.    REPLACE Check:Date WITH '4TH'
  311.   ENDIF
  312.      ENDIF
  313.  ENDIF
  314.     ENDIF
  315.  
  316.     REPLACE Marker WITH 'Q'
  317.  
  318.     * If it's the end of the year, we total all the quarterly amounts to
  319.     * a new record and mark it with a 'Y'.
  320.     IF EOY = 'Y'
  321.  TOTAL ON Marker TO Annual FOR Marker = 'Q'
  322.  APPEND FROM Annual
  323.  REPLACE Marker WITH 'Y', Check:Date WITH 'END'
  324.  DELETE FILE Annual
  325.     ENDIF
  326.     ENDIF
  327.  
  328.     * If it's the end of a month but not the end of the year, we add a new
  329.     * blank record for next month's payroll records.
  330.     IF EOY <> 'Y'
  331.  APPEND BLANK
  332.     ENDIF
  333. ENDIF
  334.  
  335. ****** VI: Print payroll summary, transfer checks to costbase *****
  336. USE CheckFil
  337. COUNT FOR .NOT. * TO Any
  338. IF Any=0
  339.     ? '       No new checks written.'
  340.     ? '   <Return> to continue.'
  341.     WAIT
  342. ELSE
  343.     USE &Header
  344.     ERASE
  345.     @ 12,25 SAY "CHECK THE PRINTER, THEN PRESS <RETURN>."
  346.     ? CHR(7)
  347.     WAIT
  348.     ERASE
  349.     SET PRINT ON
  350.     SET MARGIN TO 45
  351.     ? '          MASTER PAYROLL FILE SUMMARY: '+$(Date,3,2) +'/';
  352.        +$(Date,5,2)+'/'+$(Date,1,2)
  353.     ?
  354.     ?
  355.     ?'DATE  PAYROLL  FICA   FICASAL   FIT    SDI     SDISAL     '+;
  356.   'SIT     UISal'
  357.     ?
  358.     LIST OFF
  359.     SET MARGIN TO 38
  360.     ? CHR(12)
  361.     SET PRINT OFF
  362.  
  363.     ERASE
  364.     @ 3,25 SAY "*** DO NOT INTERRUPT ***"
  365.     @ 5,25 SAY " UPDATING THE COSTBASE "
  366.     ? CHR(7)
  367.  
  368.     USE CostBase INDEX $Supp
  369.     APPEND FROM Checkfil
  370.  
  371.     DO CheckStu
  372. ENDIF
  373.  
  374. ***VII* Dump transient variables, save necessary ones***
  375. RELEASE Payee,Number,Date,Ratio,Aborted,Printed,EOY,EOQ,EOM,Any,Header,;
  376.  Count,FedTemp,StaTemp,EmpTemp,Marker,Paaying,Salaries
  377. SAVE TO Constant
  378.  
  379. USE
  380. RELEASE All
  381. DELETE FILE Bak
  382. RETURN
  383.