Project: PRJ741843

	Platform	Oracle	
	Database	PY801SXC	
	Version	82	
	Description	UPD741843	
	Comments	
		Payroll Tax Update 08-C for Release 8 SP1

PeopleCode (Record)
EARNINGS_SPCL.ERNCD.SaveEdit
EARNINGS_TBL.ERNCD.SaveEdit
STATE_TAX_TBL.SUPPL_CON_METHOD.SaveEdit

Message Catalog Entries
Payroll Messages 	2000, 726 (ENG)
Payroll Messages 	2000, 727 (ENG)
Payroll Messages 	2000, 728 (ENG)
Payroll Messages 	2000, 815 (ENG)

Message Catalog Detail

Message Catalog Entry: Payroll Messages 	2000, 726 (ENG)
	Severity	Error	
	Msg Text	A special accumulator for supplemental wages already exists.	
	Explanation	
		Only one special accumulator should be set up to track the taxable 
		gross of supplemental wages.  Either delete the special accumulator
		 or change the Effect on Special Balance to a value other than "T" 
		(adds taxable gross to special balance).

Message Catalog Entry: Payroll Messages 	2000, 727 (ENG)
	Severity	Warning	
	Msg Text	A non-supplemental earnings code is associated with a supplemental wages special accumulator.	
	Explanation	
		Only earnings codes that are set up with a tax method of supplement
		al or special supplemental should be attached to a special accumula
		tor where the Effect of Special Balance has been specified with a v
		alue of "T" (adds taxable gross to special balance).  Either delete
		 or change the special accumulator information.

Message Catalog Entry: Payroll Messages 	2000, 728 (ENG)
	Severity	Warning	
	Msg Text	A supplemental earnings code is not associated with the supplemental wages special accumulator.	
	Explanation	
		Earning codes that are set up with a tax method of supplemental or 
		special supplemental must be attached to a special accumulator that
		 tracks the taxable gross of supplemental wages.  Add your unique s
		upplemental wages special accumulator code and specify a value of "
		T" (adds taxable gross to special balance) in the Effect of Special
		 Balance field.

Message Catalog Entry: Payroll Messages 	2000, 815 (ENG)
	Severity	Error	
	Msg Text	Supplemental method only available for Deleware.	
	Explanation	
		The suppemental tax method of "Aggregate - No Annualize" is only av
		ailable for the state of Delware.

PeopleCode Detail

PeopleCode (Record): EARNINGS_SPCL.ERNCD.SaveEdit
Component boolean &erncd_changed;
Component boolean &erncd_tbl_changed;

Local Rowset &rs_Earnings_Spcl;
Local Row &row_Earnings_Spcl;
Local Record &rec_Earnings_Spcl;
Local string &RowHasT, &Erncd_Spcl, &Erncd_err;
Local number &OK, &I, &j;

&rs_Earnings_Spcl = GetRowset();
&row_Earnings_Spcl = &rs_Earnings_Spcl.GetRow(CurrentRowNumber());
&rec_Earnings_Spcl = &row_Earnings_Spcl.GetRecord(Record.EARNINGS_SPCL);
&RowHasT = "N";
&OK = 1;

For &I = 1 To &rs_Earnings_Spcl.RowCount;
   
   &row_Earnings_Spcl = &rs_Earnings_Spcl.GetRow(&I);
   &rec_Earnings_Spcl = &row_Earnings_Spcl.GetRecord(Record.EARNINGS_SPCL);
   
   If &rs_Earnings_Spcl(&I).IsNew Then
      &OK = 0;
   End-If;
   If &rs_Earnings_Spcl(&I).IsChanged Then
      &OK = 0;
   End-If;
   If &row_Earnings_Spcl.IsDeleted Then
      &OK = 0;
   End-If;
End-For;

If &OK = 0 Or
      &erncd_tbl_changed Then
   
   If EARNINGS_SPCL.SPCL_EFFECT = "T" Then
      &Erncd_Spcl = " ";
      SQLExec("select distinct A.ERNCD_SPCL from PS_EARNINGS_SPCL A  where SPCL_EFFECT = 'T' ", &Erncd_Spcl);
      If &Erncd_Spcl <> "" Then
         If EARNINGS_SPCL.ERNCD_SPCL <> &Erncd_Spcl Then
            Error MsgGet(2000, 726, "A special accumulator for supplemental wages already exists.");
         End-If;
      End-If;
      
      If EARNINGS_TBL.TAX_METHOD.Value <> "S" And
            EARNINGS_TBL.TAX_METHOD.Value <> "X" Then
         
         Warning MsgGet(2000, 727, "A non-supplemental earnings code is associated with a supplemental wages special accumulator.");
      End-If;
   Else
      
      If EARNINGS_TBL.TAX_METHOD.Value = "S" Or
            EARNINGS_TBL.TAX_METHOD.Value = "X" Then
         
         If CurrentRowNumber() = &rs_Earnings_Spcl.ActiveRowCount Then
            
            For &j = 1 To &rs_Earnings_Spcl.ActiveRowCount;
               &rec_Earnings_Spcl = &rs_Earnings_Spcl(&j).EARNINGS_SPCL;
               
               If &rs_Earnings_Spcl(&j).EARNINGS_SPCL.SPCL_EFFECT.Value = "T" Then
                  &RowHasT = "Y";
               End-If;
            End-For;
            
            If &RowHasT <> "Y" Then
               
               Warning MsgGet(2000, 728, "A supplemental earnings code is not associated with the supplemental wages special accumulator.");
               &Erncd_err = "Y";
            End-If;
         End-If;
      End-If;
   End-If;
End-If;

PeopleCode (Record): EARNINGS_TBL.ERNCD.SaveEdit
Component boolean &erncd_tbl_changed;

Local string &ERNCD, &TRCS, &EFDT;
Local number &I, &return, &msgtxt, &SYNCED_REC;
Local SQL &trcsql, &trcsql1;
Local date &EFFDT, &maxdt;
Local Rowset &ERNCD_DATA_ROWSET;
Local Row &ERNCD_DATA_ROW;
Local Record &ERNCD_DATA_REC;
PanelGroup string &MSG_DISPLAYED, &MSG_DISPLAYED_DEL;

&erncd_tbl_changed = Record.EARNINGS_TBL.IsChanged;

SQLExec("select TL from PS_INSTALLATION", &tl);
If &tl = "Y" Then
   &ERNCD_DATA_ROWSET = GetRowset();
   &ERNCD_DATA_ROW = &ERNCD_DATA_ROWSET.GetRow(CurrentRowNumber());
   &ERNCD_DATA_REC = &ERNCD_DATA_ROW.GetRecord(Record.EARNINGS_TBL);
   
   /* following code is to check if the row  was inactivated */
   
   If &ERNCD_DATA_REC.EFF_STATUS.Value = "I" And
         &MSG_DISPLAYED <> "Y" Then
      For &I = 1 To &ERNCD_DATA_ROWSET.ActiveRowCount
         &ERNCD_DATA_ROW = &ERNCD_DATA_ROWSET.GetRow(&I);
         &ERNCD_DATA_REC = &ERNCD_DATA_ROW.GetRecord(Record.EARNINGS_TBL);
         
         If &ERNCD_DATA_REC.EFF_STATUS.Value = "I" Then
            &ERNCD = &ERNCD_DATA_REC.ERNCD.Value;
            &EFFDT = &ERNCD_DATA_REC.EFFDT.Value;
            SQLExec("select %dateout(max(effdt)) from PS_EARNINGS_TBL where ERNCD = :1", &ERNCD, &maxdt);
            &SYNCED_REC = 0;
            SQLExec("SELECT COUNT(*) FROM PS_TL_TRC_TBL WHERE TL_COPY_FROM = :1", &ERNCD, &SYNCED_REC);
            
            If &EFFDT = &maxdt And
                  &SYNCED_REC <> 0 Then
               &trcsql1 = CreateSQL("select distinct A.TRC from PS_TL_TRC_TBL A, PS_TL_ERNCD_TBL B where A.TL_COPY_FROM = :1 AND A.TRC = B.TRC AND A.EFFDT = B.EFFDT AND B.PAY_SYSTEM = 'NA' AND B.EFF_STATUS = 'A' ", &ERNCD);
               While &trcsql1.Fetch(&TRC);
                  If All(&TRC) Then
                     &TRCS = &TRC | "," | &TRCS;
                     /*       &EFDT = &EFFDT | "," | &EFDT; */
                  End-If;
               End-While;
               If All(&TRCS) Then
                  /*                  &return = MessageBox(65, "", 13500, 150, "Selected Earnings Code Is In SYNC With The Following TRCs (%1)With Respective Effective Dates (%2).", &TRCS, &EFDT); */
                  
                  &return = MessageBox(65, "", 13500, 150, "Selected Earnings Code Is In SYNC With The Following TRCs (%1).", &TRCS);
                  If &return = 2 Then
                     Error (MsgGet(13500, 168, "User has requested to cancel the save."));
                  Else
                     /* setting the variable as we do not want to display the msg again */
                     &MSG_DISPLAYED = "Y";
                  End-If;
               End-If;
            Else
               If &MSG_DISPLAYED <> "Y" Then
                  &TRCS = " ";
                  &EFDT = " ";
                  &trcsql = CreateSQL("select distinct A.TRC from PS_TL_TRC_TBL A, PS_TL_ERNCD_TBL B where B.TL_ERNCD = :1 AND A.TRC = B.TRC AND A.EFFDT = B.EFFDT AND B.PAY_SYSTEM = 'NA' AND B.EFF_STATUS = 'A' AND B.EFFDT = %datein(:2)", &ERNCD, &EFFDT);
                  While &trcsql.Fetch(&TRC);
                     If All(&TRC) Then
                        &TRCS = &TRC | "," | &TRCS;
                        /*         &EFDT = &EFDT | "," | &EFFDT; */
                     End-If;
                  End-While;
                  If All(&TRCS) Then
                     &return = MessageBox(65, "", 13500, 169, "Selected Earnings Code Is Active With The Following TRCs, Do you wish to Inactivate TRCs now? ", &TRCS);
                     If &return = 2 Then
                        Error (MsgGet(13500, 168, "User has requested to cancel the save."));
                     Else
                        /* setting the variable as we do not want to display the msg again */
                        &MSG_DISPLAYED = "Y";
                     End-If;
                  End-If;
               End-If;
            End-If;
         End-If;
      End-For;
   End-If;

   
   /* Msg to be displayed when the user deletes the row */
   If &MSG_DISPLAYED_DEL <> "Y" Then
      For &J = 1 To &ERNCD_DATA_ROWSET.RowCount

         &ERNCD_DATA_ROW = &ERNCD_DATA_ROWSET.GetRow(&J);
         &ERNCD_DATA_REC = &ERNCD_DATA_ROW.GetRecord(Record.EARNINGS_TBL);
         If &ERNCD_DATA_ROW.IsDeleted Then
            &ERNCD = &ERNCD_DATA_REC.ERNCD.Value;
            &EFFDT = &ERNCD_DATA_REC.EFFDT.Value;
            &trcsql = CreateSQL("select distinct A.TRC from PS_TL_TRC_TBL A, PS_TL_ERNCD_TBL B where B.TL_ERNCD = :1 AND A.TRC = B.TRC AND A.EFFDT = B.EFFDT AND B.PAY_SYSTEM = 'NA' AND B.EFF_STATUS = 'A' AND B.EFFDT = %datein(:2)", &ERNCD, &EFFDT);
            While &trcsql.Fetch(&TRC);
               If All(&TRC) Then
                  &TRCS = &TRC | "," | &TRCS;
               End-If;
            End-While;
            If All(&TRCS) Then
               &MSG_DISPLAYED_DEL = "Y";
               Warning MsgGet(13500, 180, " row has been deleted re-sync it", &TRCS)
            End-If;
            
         End-If;
      End-For;
   End-If;
End-If;

PeopleCode (Record): STATE_TAX_TBL.SUPPL_CON_METHOD.SaveEdit
If (STATE_TAX_TBL.SUPPL_CON_METHOD = "D" Or
         STATE_TAX_TBL.SUPPL_SEP_METHOD = "D") And
      STATE_TAX_TBL.STATE <> "DE" Then
   Error MsgGet(2000, 815, "Supplemental method only available for Deleware.");
End-If