280 likes | 689 Views
Calc Codes for Beginners. Calc Codes for Beginners Kim Ste.Marie HR/Payroll Consultant. Calc Codes for Beginners. This session will cover the following Purpose of Calc Codes & Common Uses Parts of the Calc Code Calc Code Design Symbols, commands and syntax Editing Commands Example.
E N D
Calc Codes for Beginners Calc Codes for Beginners Kim Ste.Marie HR/Payroll Consultant
Calc Codes for Beginners This session will cover the following • Purpose of Calc Codes & Common Uses • Parts of the Calc Code • Calc Code Design • Symbols, commands and syntax • Editing Commands • Example
Calc Codes for Beginners Purpose: Calculation Codes may also be referred to as “calc codes” or “calculation formulas.” They are used in the Payroll system to add special processing rules when calculating contributions, deductions, and hours (CDH’s).
Calc Codes for Beginners Common Uses Calculating Deductions (Employee share) • Federal and State Taxes (FICA, Medicare, FIT, SIT, City Tax) • EFT (direct deposit) • Retirement (state specific and/or employer provided) Calculating Contributions (Employer share) • Federal and State Taxes • Insurance (Medical, Dental, Life) • Retirement Calculating Hours and/or Accruals (Earnings, Payments and/or Accruals) • Vacation Accrual • Sick Accrual • Comp Time • Longevity Pay
Calc Codes for Beginners The Calc Code Parts CDH Number 1 C Contribution (1001 FICA employer portion) 2 D Deduction (2001 FICA employee portion) 3 H Hour code (3025 Overtime) Clusters & Attributes • Clusters and Attributes are used in calc codes to uniquely identify specific data elements • Found in the Payroll Module. (NOT HR!!)
Calc Codes for Beginners Clusters Typically the same as screens or tables in a database Anything beginning with an “E” is EMPLOYEE INFO: ECNT: Refers to EMPLOYEE CONTRIBUTION SCREEN. EDED: Refers to EMPLOYEE DEDUCTION SCREEN. EMPM: Refers to EMPLOYEE MASTER SCREEN. Anything ending with a “D” is a DEFINITION: CNTD: Refers to a CONTRIBUTION DEFINITION. DEDD: Refers to a DEDUCTION DEFINITION. HRSD: Refers to an HOURS DEFINITION. NUCD: Refers to a COMMON CODE DEFINITIONS *See Clusters/Attribute HANDOUT
Calc Codes for Beginners Examples of Employee Assignment clusters: EMPM Employee Master PYPX Employee Pay Assignment EDED Employee Deduction Assignment CNTD Employee Contribution Assignment Examples of Payroll Definitions used in Calc Code DEDD Deduction Definition CNTD Contribution Definition NUCD Common Codes Other Important Information Needed for Calc Codes HBSX Hour Bases (Vacation, Sick, Personal leave balances) PBSX Pay Bases (Gross Pay, Tax Balances, Net Pay)
Calc Codes for Beginners Attributes are typically the same as fields. An example of a cluster and attribute is… EMPM.UNIT Employee Bargaining Unit PYPX.PAY Pay assignment Payclass ECNT.AMT Employee contribution amount EDED.AMT Employee deduction amount DEDD.ST Deduction Definition Status CNTD.BEG Contribution Definition begin date NUCD.CC Common Code /Code Category HBSX.CTD Hour Base Calendar to Date PBSX.PDT Pay Base Period To Date
Calc Codes for Beginners Locating Clusters & Attributes There are three methods of locating desired clusters and attributes in the payroll system: 1. Run a standard report (See handout) PYREFLAT - PY File Listing: Clusters and Attributes PYREFLCL - PY File Listing: Clusters • Access the System/Screen Help: Access help on any payroll field by placing a “?” in the desired field and looking at the end of the text. 3. Read the Payroll Users Guide: all field definitions in the payroll manual have the cluster.attribute specified at the end of the text paragraph.
Calc Code Design (PYUPCC, PYUPDD, PYUPHH) The calc code is located in the CDH definition If using 7i, calc codes can be designed/edited in WORDPAD and cut/paste directly into IFAS. Calc Codes for Beginners
Calc Codes for Beginners Recognized Symbols Syntax includes the use of logical operators for performing calculations on clusters and attributes, variables, and constants. Logical operators: All of the logical operators can be separated into the two groups of operators. Operators used in assignments: Operators used in comparisons: * Multiply. > Greater than. / Divide. < Less than. + Add. < > Not Equal To. - Subtract. <= Less than or Equal To := Assign To. >= Greater than or Equal To. = Equal To. = is used for comparing two values. It must be followed by an exact match and it is case sensitive. := is used to set one value to another
Calc Codes for Beginners Variables In addition to the clusters and attributes there are also miscellaneous character and numeric variables, which can be used to store data derived within calculation codes. NVAR0 – NVAR9 are misc. numeric values. CVAR0 – CVAR9 are misc. character values. Once the variable is assigned, we now refer to it as the variable rather than the cluster/attribute. Example: CVAR1 := EMPM.UNIT CVAR is assigned to Bargaining Unit NVAR2 := EDED.AMT * 2 NVAR2 is assigned to Employee Deduct Amount x 2.
Calc Codes for Beginners Final Variable “The Punchline” A punchline contains the result of the rest of the calculation. The Punchline is most often an amount. Every calc code must have a punchline. CNTX.AMT CONTRIBUTION DEDX.AMT DEDUCTION HRSX.AMT or HRSX.RATE HOUR Other Variables • PYPX: Contains pay assignment information used in a calc formula. PYPX clusters must be prefaced with a load statement. • MSCX: Contains miscellaneous values used in calculations. These calculations are done behind the scenes and do not appear on any screen. These are computed each time PY is calculated. However, you can still reference them.
Calc Codes for Beginners SYNTAX IF / ENDIF • The IF statement is a conditional statement. These key words are used when conditions need to be tested. • Each IF must be matched by an ENDIF, and they should be aligned. Example: IF EMPM.UNIT = “ADMN” DEDX.AMT := DEDD.VAL{1} ENDIF Translation: If Employee Bargaining Unit is ADMN then the deduction amount is the amount defined in PYUPDD Value 1.
Calc Codes for Beginners IF/ELSE/ENDIF • The IF statement is a conditional statement. These key words are used when conditions need to be tested. • Each IF must be matched by an ENDIF, and they should be aligned. • If ELSE is used, that should also be aligned. IF expression is true, do option one ELSE do the alternative ENDIF Example: IF EMPM.UNIT = “ADMN” DEDX.AMT := DEDD.VAL{1} ELSE DEDX.AMT := DEDD.VAL{2} ENDIF Translation: If Employee Bargaining Unit is ADMN then the deduction amount is the amount defined in PYUPDD Value 1. If the employee bargaining unit is not equal to ADMN then the deduction amount is the amount defined in PYUPDD Value 2.
Calc Codes for Beginners STOP Causes the execution of the calculation to be terminated. Execution is also terminated when the commands encompassed in the formula are completed. IF EMPM.TYPE <> ‘FT’ STOP ENDIF Translation: If Employee Type does not equal to FT, then STOP the calc code.
Calc Codes for Beginners AND and OR Used to perform logical tests that determine if specified conditions are met. Use AND if you want more than one condition to be met. IF EMPM.UNIT = ‘ADMN’ or EMPM.UNIT = ‘CERT’ DEDX.AMT := 10 ENDIF Translation: If employee bargaining unit is ADMN or employee bargaining unit is CERT then the deduction amount is 10. (result would be if either case were true) IF EMPM.UNIT = ‘ADMN’ and EMPM.TYPE = ‘FT’ DEDX.AMT := 20 ENDIF Translation: If employee bargaining unit is ADMN and Employee type is FT then the deduction amount is 20. (result would be if both cases are true)
Calc Codes for Beginners ROUNDING and TRUNCATING ROUND0 through ROUND5 This key word rounds to the nearest value of the operand given the number of decimal digits indicated by the command itself. The operand must be enclosed in parentheses. For Example: NVAR1 := 1.2367 ROUND2 (NVAR1) Result is NVAR1 equals 1.24 TRUNC0 through TRUNC5 This key word truncates the value of the operand to the number of decimal digits indicated by the command itself. The operand must be enclosed in a pair of parentheses. For Example: NVAR1 := 1.2367 RUNC2 (NVAR1) Result is NVAR1 equals 1.23
Calc Codes for Beginners OTHER SYNTAX Comments: Remarks may be inserted using the << >> signs. The calc code will ignore anything inside these brackets. Operand Separator: A comma (,) is used to separate various operands within an expression. For Example : CVAR0[5,2] := “PY” Brackets: These are used when extracting or assigning parts of a character variable. The first numeric start position and the second numeric refers to the length For Example: CVAR0 := 1234567 CVAR0[5,2] := “PY . Result: CVAR0 was originally 1234567 but now is 1234PY7 Parentheses: Used to group operands and to parenthesize arithmetic and relational statements. Braces: Subscripts {} are be used for attribute entries which have multiple values. For Example: CVAR0 := EDED.CD{1}
Calc Codes for Beginners WARN If turned on*, “WARN” statements appear with a CDH number when you run a force calculation, and can be useful for alerting payroll of potential problems and debugging calc codes. • To turn on*: Common code PYFG/PY200C “SHOWWARNS” • Messages of twenty spaces or less are permitted, and you can choose to have them printed on the WARN200 report when the calculation is processed. • The WARN200 report displays a summary of error messages that appear when you run a force calc. • The contents of the quotation marks will appear as the warn statement. • Warnings can include (separated by comma: Comments Clusters Variables Example: WARN (“Inactive Employee:”, EMPM.ID,NVAR1)
Calc Codes for Beginners LOAD The LOAD command will ‘load’ the cluster/attribute information into the calc code from an Hour Base, Pay Base, or another CDH For Example To Load the Vacation Balance (HB7) LOAD(HBSX.CLS,7) To Load the Gross Pay (PB2) LOAD(PBSX.CLS,2) To Load information from another CDH (3220) LOAD(HRSX.NO,220) Notes: • Two operands must be used when specifying the LOAD key word. • The first operand must be the name of the cluster and attribute to be loaded, and the second operand identifies which entry in the CLST.ATTRIB to load.
GOTO and LABEL The GOTO and LABEL key words may be used to skip the formula and go directly to a later section in the calc code. GOTO must be followed by a statement sequence number or the LABEL# key word. The execution of the calculation is transferred to the statement with the designated sequence or label number once the GOTO command is encountered. A GOTO will not process correctly if the line that the GOTO directs processing to does not contain a key word. For Example <<VACATION ACCRUAL>> IF EMPM.UNIT = “ADMN” NVAR0 := 12 GOTO LABEL1 ENDIF NVAR1 := MSCX.EMPMOS If NVAR1 >= 240 NVAR0 := 10 ELSE NVAR0 := 8 ENDIF LABEL1 HRSX.AMT := NVAR0 Translated: If employee’s bargaining unit is ADMN then accrual is 12. (IF ADMN then skip to the end of the calc code). Otherwise… If Service months greater than or equal to 240 months then accrual is 10 otherwise accrual is 8. Calc Codes for Beginners
DO and UNTIL Will cause processing to be repeated until the specified conditions are met. This is typically used when you need to add together pay assignments to get totals (e.g. Total Hours Per Day) Load the Employee’s pay assignments When done, then “Fail” or STOP Only look at pay assignments in payclass 200, 600 or 500 Add them up and get the total hours per day For Example: DO NVAR6 := NVAR6 + 1 LOAD(PYPX.CLS,NVAR6) IF MSCX.STATUS = "FAILED" GOTO LABEL3 ENDIF NVAR8 := PYPX.PAYNO IF NVAR8 = 200 OR NVAR8 = 600 OR NVAR8 = 500 NVAR7 := NVAR7 + PYPX.HRSDAY IF CVAR9 = "DEBUG" WARN (" HOURS PER DAY",NVAR7) ENDIF ENDIF LABEL3 UNTIL MSCX.STATUS = "FAILED" Calc Codes for Beginners
<<*************** FICA DEDUCTION *****************>> << Debug On/Off >> CVAR0 := " DEBUG" << Check if max has been exceeded >> IF DEDX.TTD >= DEDD.VAL {3} WARN ("MAX HAS BEEN EXCEEDED") DEDX.AMT := 0 STOP ENDIF LOAD(PBSX.CLS,6) << Compute deduction >> NVAR0 := PBSX.PTD * DEDD.VAL {1} << Check if computed amt puts ded > limit >> NVAR1 := DEDX.TTD + NVAR0 IF NVAR1 > DEDD.VAL {3} NVAR0 := DEDD.VAL {3} - DEDX.TTD ENDIF ROUND2(NVAR0) DEDX.AMT := NVAR0 << Debug Output >> IF CVAR0 = "DEBUG" WARN("FICA Wages: ",PBSX.PTD) WARN(" FICA Ded: ",DEDX.AMT) ENDIF TRANSLATION Assign variable to turn on DEBUG Load the “total to date” and compare to the amount on PYUPDD (CDH Master) Value 3. If greater than or equal to, then send a WARNING “MAX HAS BEEN EXCEEDED”) and set the deduction amount to 0.0. STOP the deduction. Load PB06 (FICA) Multiply the FICA gross Period to date X the amount in PYUPDD value 1. Take the deduction total to-date amount + the new calculated deduction amount. Compare the total to the maximum amount stored in PYUPDD value 3. If over the limit, only take the amount up to the limit. Round the end result to 2 decimals Set the deduction amount (“punchline”) DEBUG statement Display PB06 period to date Display deduction amount EXAMPLE: FICA Deduction
Calc Codes for Beginners QUESTIONS