///// <summary>
        ///// Handles U043 exceptions
        ///// Deals with either Invoices, RRs, or POs depending on data
        ///// If notes.returnVal2 does not contain "DUPLICATE", it adds a notification and transhist record
        ///// Clears V299 exceptions for invoices
        ///// Sets the PegasysInvoice, PegasysRR_frm or PegasysPO_frm records to "REJECT"
        ///// </summary>
        ///// <param name="exception"></param>
        //public void ExceptionU043(EXCEPTION exception, AddressValuesModel Search, AddressValuesModel Address, PEGASYSRR_FRM RRFrmQuery, PEGASYSPO_FRM POFrmQuery)
        //{
        //    DateTime? Ex_Date = exception.EX_DATE;
        //    Report_ID = "";
        //    ReportForm = "";
        //    Pegasys = false;
        //    PDocNo = "";

        //    if (!String.IsNullOrWhiteSpace(exception.INV_KEY_ID))
        //    {
        //        HandleInvoice(Search, Address);

        //    }
        //    else if (String.IsNullOrWhiteSpace(exception.RR_ID))
        //    {
        //        HandleRR(Search, Address, RRFrmQuery);
        //    }
        //    else if (!String.IsNullOrWhiteSpace(exception.PO_ID))
        //    {
        //        HandlePO(Search, Address, POFrmQuery);

        //    }
        //}

        public void HandlePO(AddressValuesModel Search, AddressValuesModel Address, PEGASYSPO_FRM POFrmQuery, string thismemo)
        {
            NewNotes();

            //Need to have access to the POQuery List
            var DateQueued = DateTime.Now;

            if (!String.IsNullOrWhiteSpace(POFrmQuery.MODNO))
            {
                Report_ID  = "F06";
                ReportForm = "Mod Reject";
            }
            else
            {
                Report_ID  = "F03";
                ReportForm = "PO Reject";
            }

            if (!notes.returnVal2.Contains("DUPLICATE"))
            {
                if (thismemo == "CANCEL")
                {
                    //DisplayMessage("Only Notification cancelled - PO will still be rejected!", 0, "Nothing");
                }
                else
                {
                    var properties = new List <string>
                    {
                        "FAXNOTES"
                    };
                    exception.FAXNOTES = thismemo; //objmemo.p_thismemo;
                    UpdateException(exception, properties);

                    if (!CheckNotificationExists())
                    {
                        Status = "Pending";
                        InsertNotification();
                    }
                }
                var S_Note = "Yes";

                NewNote = "Reject PO/Mod " + "\r\n" + "Send Notification " + S_Note + " " + ReportForm + "\r\n" + NewNote;
                var strCuffMemo = "'Reject - " + "\r\n" + "Send Notification " + S_Note + ": " +
                                  Report_ID + " - " + ReportForm + "\r" + NewNote;
                InsertTranshist(exception, "X", strCuffMemo, "", PrepCode);
            }

            var rtnPO = GetPegasysPOFrmByKey(exception.PO_ID);

            UpdatePegasysPOToReject(rtnPO);
        }
        public bool FinishCode(PEGASYSPO_FRM POFrmQuery)
        {
            //Moved the cmdChange.click code to
            //the Click event of the cmdExceptionBase
            var ResponseNotes = NewNote;

            UpdateException(exception, "C", notes.returnVal7, notes.returnVal3, exception.RESPONSENOTES + "\r\n" + NewNote, "");

            // Not necessary, per Ron Sele's findings.
            //var success = UpdatePegasysPOToKeyed(exception.PO_ID);
            //if (!success) return false;

            if (exception.ERR_CODE.Right(3) == "200")
            {
                ExceptionU200(exception, POFrmQuery);
            }

            return(true);
        }
Esempio n. 3
0
 protected string GetPOStatus(PEGASYSPO_FRM rtnPO)
 {
     if (rtnPO.DATAENTRY_FL == "T" && rtnPO.PREVALIDATION_FL == "T" && rtnPO.VALIDATION_FL == "T" && rtnPO.VENDORMATCH_FL == "T" && rtnPO.OFFICEMATCH_FL == "T")
     {
         return("PREOUT");
     }
     else if (rtnPO.DATAENTRY_FL == "T" && rtnPO.PREVALIDATION_FL == "T" && rtnPO.VALIDATION_FL == "T" && rtnPO.VENDORMATCH_FL == "T" && rtnPO.OFFICEMATCH_FL == "F")
     {
         return("NEEDOFFC");
     }
     else if (rtnPO.DATAENTRY_FL == "T" && rtnPO.PREVALIDATION_FL == "T" && rtnPO.VALIDATION_FL == "F" && rtnPO.VENDORMATCH_FL == "T")
     {
         return("NEEDVAL");
     }
     else if (rtnPO.DATAENTRY_FL == "T" && rtnPO.PREVALIDATION_FL == "T" && rtnPO.VALIDATION_FL == "T" && rtnPO.VENDORMATCH_FL == "F")
     {
         return("NEEDVEND");
     }
     else if (rtnPO.DATAENTRY_FL == "T" && rtnPO.PREVALIDATION_FL == "T" && rtnPO.VALIDATION_FL == "F" && rtnPO.VENDORMATCH_FL == "F")
     {
         return("VVREADY");
     }
     else if (rtnPO.DATAENTRY_FL == "T" && rtnPO.PREVALIDATION_FL == "F" && !String.IsNullOrWhiteSpace(rtnPO.MODNO))
     {
         return("MODREADY");
     }
     else if (rtnPO.DATAENTRY_FL == "T" && rtnPO.PREVALIDATION_FL == "F")
     {
         return("KEYED");
     }
     else if (rtnPO.DATAENTRY_FL == "F" && rtnPO.PREVALIDATION_FL == "F")
     {
         return("KEYREADY");
     }
     return("");
 }
Esempio n. 4
0
        public void FinishCode(PEGASYSINVOICE InvQuery, PEGASYSPO_FRM POFrmQuery, AddressValuesModel Search, string sNotesType, bool POExists, bool InvExists, bool RRExists)
        {
            NewNotes();

            var cImageID = "";

            switch (exception.ERR_CODE)
            {
            case "P060":
            case "P061":
            case "P005":
                cImageID = InvQuery.IMAGEID;
                break;

            case "V216":
                if (!String.IsNullOrWhiteSpace(exception.INV_KEY_ID))
                {
                    cImageID = InvQuery.IMAGEID;
                }
                else if (!String.IsNullOrWhiteSpace(exception.PO_ID))
                {
                    cImageID = POFrmQuery.IMAGEID;
                }
                break;

            default:
                if (POFrmQuery != null)
                {
                    cImageID = POFrmQuery.IMAGEID;
                }

                break;
            }

            if (!String.IsNullOrWhiteSpace(cImageID))
            {
                string cVendName = "";
                if (String.IsNullOrWhiteSpace(exception.VENDNAME.Trim()))
                {
                    if (!String.IsNullOrWhiteSpace(Search.VENDORNAME))
                    {
                        cVendName = Search.VENDORNAME;
                    }
                }
                else
                {
                    cVendName = exception.VENDNAME.Trim();
                }
            }

            if (exception.ERR_CODE.Right(3) == "230")
            {
                if (exception.ERR_CODE.Left(1) == "P")
                {
                    U048table = "PEGINV";
                }

                CreateExceptionU048(InvQuery, POFrmQuery);
            }
            else if (exception.ERR_CODE == "D062")
            {
                notes.returnVal3 = "D062";
                U048table        = notes.returnValZ;
                CreateExceptionU048(InvQuery, POFrmQuery);
            }
            else if (exception.ERR_CODE.Left(1) == "V")
            {
                //generate U048 & blank out the PO.last_status
                if (!String.IsNullOrWhiteSpace(exception.INV_KEY_ID))
                {
                    U048table = "PEGINV";
                }
                else if (String.IsNullOrWhiteSpace(exception.PO_ID))
                {
                    U048table = "PEGPO";
                }
                CreateExceptionU048(InvQuery, POFrmQuery);
            }
            else if (exception.ERR_CODE == "U043" || exception.ERR_CODE == "U044")
            {
                ExceptionU043(sNotesType, POExists, InvExists, RRExists);
            }
            else if (exception.ERR_CODE == "U049")
            {
                ExceptionU049(sNotesType);
            }
            else if (exception.ERR_CODE == "P060" || exception.ERR_CODE == "P061" || exception.ERR_CODE == "P005")
            {
                string responsenotes = exception.RESPONSENOTES + "\r\n" + NewNote;
                UpdateException(exception, "Q", notes.returnVal7, notes.returnVal3, responsenotes, "");

                UpdatePegasysInvoiceStatusById("MATCHREADY");

                //Disabled because it doesn't update the Oracle tables
                //SET CLASS TO exceptions ADDITIVE
                //objChg = CREATE("InterestCorrectDE")

                //objChg.r_act = THISFORM.r_act

                //objChg.r_rr_id = THISFORM.r_rr_id

                //objChg.r_inv_key_id = THISFORM.r_inv_key_id

                //objChg.r_pegasys = THISFORM.r_pegasys

                //objChg.SHOW
            }
            else
            {
                var responsenotes = exception.RESPONSENOTES + "\r\n" + NewNote;
                UpdateException(exception, "Q", notes.returnVal7, notes.returnVal3, responsenotes, "");
            }
        }
Esempio n. 5
0
        protected void CreateExceptionU048(PEGASYSINVOICE InvQuery, PEGASYSPO_FRM POFrmQuery)
        {
            U048table = U048table.ToUpper();
            var lGoU048 = true;

            if (U048table == "PEGINV")
            {
                //Updating PegasysInvoice ...
                var rtnInv         = GetPegasysInvoiceByKey(exception.INV_KEY_ID);
                var fieldsToUpdate = new List <string>
                {
                    "ERR_CODE"
                };
                rtnInv.ERR_CODE = "U048";
                UpdatePegasysInvoice(rtnInv, fieldsToUpdate);
            }
            else if (U048table == "PEGPO")
            {
                //Updating Pegasyspo_frm ...
                var rtnPO          = GetPegasysPOFrmByKey(exception.PO_ID);
                var fieldsToUpdate = new List <string>
                {
                    "ERR_CODE"
                };

                UpdatePegasysPO(rtnPO, fieldsToUpdate);
            }
            else if (U048table == "PEGRR")
            {
                //Updating Pegasysrr_frm ...
                var rtnRR          = GetPegasysRRByKey(exception.RR_ID);
                var fieldsToUpdate = new List <string>
                {
                    "ERR_CODE"
                };

                UpdatePegasysRR(rtnRR, fieldsToUpdate);
            }

            if (lGoU048 == true)
            {
                //Generating U048...
                var objException = new VITAPExceptions();

                objException.ActNum = exception.ACT;

                if (U048table.InList("PEGPO,PO"))
                {
                    objException.Po_id = exception.PO_ID;

                    objException.Updpostatus = "T";
                }

                if (U048table.InList("PEGRR,RR"))
                {
                    objException.Rr_id = exception.RR_ID;

                    objException.Updrrstatus = "T";
                }

                if (U048table.InList("PEGINV,INVOICE"))
                {
                    objException.Inv_key_id   = exception.INV_KEY_ID;
                    objException.Updinvstatus = "T";
                }

                if (U048table == "EXPENSEACCRUAL")
                {
                    objException.Ae_id       = exception.AE_ID;
                    objException.Updaestatus = "T";
                }

                if (U048table.InList("PEGINV,PEGPO,PEGRR"))
                {
                    objException.Ex_fund  = exception.EX_FUND;
                    objException.Vendname = exception.VENDNAME;

                    if (U048table == "PEGINV" && InvQuery.AMOUNT != null)
                    {
                        objException.Poamount = (double)InvQuery.AMOUNT;
                    }
                    else if (U048table == "PEGPO" && POFrmQuery.AMOUNT != null)
                    {
                        objException.Poamount = (double)POFrmQuery.AMOUNT;
                    }
                }

                objException.Ex_memo  = notes.returnVal3;
                objException.Err_code = "U048";
                objException.PrepCode = PrepCode;

                objException.AddException();

                var responsenotes = exception.RESPONSENOTES + "\r\n" + NewNote;
                UpdateException(exception, "Q", notes.returnVal7, notes.returnVal3, responsenotes, "");
            }
        }
        public void FinishCode(string NewAct, string NewPDocNo, string Vcpo, DateTime?StartDate, PEGASYSPO_FRM vpo)
        {
            if (!String.IsNullOrEmpty(NewAct) && NewAct.Length > 8 && NewAct.StartsWith("1B") && NewAct.EndsWith("C"))
            {
                NewAct = NewAct.Substring(NewAct.Length - 8);
            }
            else if (!String.IsNullOrEmpty(NewAct) && NewAct.Length > 8)
            {
                NewAct = "";
            }


            //string Act = "";
            bool bChangeAct = false, bChangePdocno = false;

            if (String.IsNullOrWhiteSpace(exception.ACT) && !String.IsNullOrWhiteSpace(NewAct))
            {
                bChangeAct = true;
                //Act = "";
            }
            else
            {
                if (exception.ACT != NewAct)
                {
                    bChangeAct = true;
                }
            }

            if (String.IsNullOrWhiteSpace(PDocNo))
            {
                bChangePdocno = true;
                PDocNo        = "";
            }
            else
            {
                if (PDocNo != NewPDocNo)
                {
                    bChangePdocno = true;
                }
            }

            UpdateExceptionNewValues(bChangeAct, bChangePdocno, NewAct, NewPDocNo);

            if (!String.IsNullOrWhiteSpace(exception.PO_ID))
            {
                UpdatePOFrmData(NewPDocNo, NewAct, Vcpo, vpo);
            }

            if (!String.IsNullOrWhiteSpace(exception.INV_KEY_ID))
            {
                UpdateInvData(NewAct, NewPDocNo, StartDate);
            }
            else if (!String.IsNullOrWhiteSpace(exception.AE_ID))
            {
                UpdateAERecord(NewAct, NewPDocNo);
            }
            else if (!String.IsNullOrWhiteSpace(exception.RR_ID))
            {
                UpdateRRRecord(NewAct, NewPDocNo);
            }
        }
        private void UpdatePOFrmData(string newPDocNo, string newAct, string Vcpo, PEGASYSPO_FRM vpo)
        {
            //Update PO Frm data
            var PO_Status = "MODREADY";

            if (Status == "VITAP")
            {
                PO_Status = "WAITONPO";
            }
            var rtnPO = GetPegasysPOFrmByKey(exception.PO_ID);

            string modNo = "";

            if (vpo != null)
            {
                modNo = vpo.MODNO;
            }

            var newPoId = newPDocNo.Trim();

            if (!String.IsNullOrWhiteSpace(modNo))
            {
                newPoId = newPoId + "&" + modNo;
            }

            var fieldsToUpdate = new List <string>
            {
                "ACT",
                "PO_ID",
                "PDONO",
                "ERR_CODE",
                "PO_STATUS",
                "DATAENTRY_FL",
                "PREVALIDATION_FL",
                "VCPO"
            };

            if (rtnPO != null)
            {
                rtnPO.ACT              = newAct;
                rtnPO.PO_ID            = newPoId;
                rtnPO.PDOCNO           = newPDocNo;
                rtnPO.ERR_CODE         = null;
                rtnPO.PO_STATUS        = PO_Status;
                rtnPO.DATAENTRY_FL     = "T";
                rtnPO.PREVALIDATION_FL = "F";
                rtnPO.VCPO             = Vcpo;
                UpdatePegasysPO(rtnPO, fieldsToUpdate);
            }


            //Update Accounting Line data
            var rtnPOAcct = GetPegasysPOAcctsFrmByKey(exception.PO_ID);

            fieldsToUpdate = new List <string>
            {
                "PO_ID",
                "PO_ACCT_ID"
            };

            foreach (var row in rtnPOAcct)
            {
                row.PO_ID      = newPoId;
                row.PO_ACCT_ID = newPoId + row.PO_ACCT_ID.Substring(row.PO_ACCT_ID.IndexOf('&'));
                UpdatePegasysPOAcctFrm(row, fieldsToUpdate);
            }

            //Update Office data
            var rtnPOOffc = GetPegasysPOOffcsByKey(exception.PO_ID);

            fieldsToUpdate = new List <string>
            {
                "PO_ID",
                "PO_OFFC_ID"
            };

            foreach (var row in rtnPOOffc)
            {
                row.PO_ID      = newPoId;
                row.PO_OFFC_ID = newPoId + row.PO_OFFC_ID.Substring(row.PO_OFFC_ID.IndexOf('&'));
                UpdatePegasysPOOffc(row, fieldsToUpdate);
            }

            //Update Transhist data
            UpdateTranshistByPO(exception.PO_ID, newPoId, newAct);

            //Update Exception data
            var rtnExc = GetExceptionsByPOID(exception.PO_ID);

            fieldsToUpdate = new List <string>
            {
                "PO_ID",
                "PDOCNO",
                "ACT"
            };

            foreach (var row in rtnExc)
            {
                row.PO_ID  = newPoId;
                row.PDOCNO = newPoId;
                row.ACT    = newAct;
                UpdateException(row, fieldsToUpdate);
            }

            //Update Exception History data
            UpdateExceptionHistByPO(exception.PO_ID, newPoId, newAct);

            //Update Notification data
            var rtnNot = GetNotificationsByPOID(exception.PO_ID);

            fieldsToUpdate = new List <string>
            {
                "PO_ID",
                "ACT"
            };

            foreach (var row in rtnNot)
            {
                row.PO_ID = newPoId;
                row.ACT   = newAct;
                UpdateNotification(row, fieldsToUpdate);
            }

            var PO_ID = newPoId;
        }
        protected void ExceptionU200(EXCEPTION exception, PEGASYSPO_FRM POFrmQuery)
        {
            //Need to get the NewAct from the screen
            var strNewAct     = "";
            var strNewPdocno  = "";
            var ChangeField   = "";
            var Change_Act    = false;
            var Change_Pdocno = false;

            if (String.IsNullOrWhiteSpace(exception.ACT))
            {
                Change_Act = true;
            }
            else
            {
                if (exception.ACT != strNewAct)
                {
                    Change_Act = true;
                }
            }
            if (String.IsNullOrWhiteSpace(exception.PDOCNO))
            {
                Change_Pdocno = true;
                PDocNo        = "";
            }
            else
            {
                if (exception.PDOCNO != strNewPdocno)
                {
                    Change_Pdocno = true;
                }
            }

            ChangeField = "";
            if (Change_Act && Change_Pdocno)
            {
                ChangeField = "ACT changed from " + exception.ACT + " to " + strNewAct + "\r\n" +
                              "PDOCNO changed from " + exception.PDOCNO + " to " + strNewPdocno;

                exception.PDOCNO = strNewPdocno;
            }
            else
            {
                if (Change_Act)
                {
                    ChangeField = "ACT changed from " + exception.ACT + " to " + strNewAct;
                }

                if (Change_Pdocno)
                {
                    ChangeField      = "PDOCNO changed from " + exception.PDOCNO + " to " + strNewPdocno;
                    exception.PDOCNO = strNewPdocno;
                }
            }

            if (!String.IsNullOrWhiteSpace(exception.PO_ID))
            {
                string strNewPO_ID = strNewPdocno + "&" + POFrmQuery.MODNO.Trim();
                UpdatePegasysPOToModReady(exception.PO_ID, strNewPdocno, strNewPO_ID, strNewAct);
                UpdatePegasysPOAcctFrm(exception.PO_ID, strNewPdocno);
                UpdatePegasysPOOffcFrm(exception.PO_ID, strNewPO_ID);
                UpdateTranshistByPO(exception.PO_ID, strNewPO_ID, strNewAct);
                UpdateExceptionByPO(exception.PO_ID, strNewPO_ID, strNewAct);
                UpdateNotificationByPO(exception.PO_ID, strNewPO_ID, strNewAct);

                exception.PO_ID = strNewPO_ID;
            }
            else if (!String.IsNullOrWhiteSpace(exception.INV_KEY_ID))
            {
                UpdatePegasysInvoiceToReVerify(exception.INV_KEY_ID, strNewPdocno, strNewAct);
            }
            else if (!String.IsNullOrWhiteSpace(exception.RR_ID))
            {
                UpdatePegasysRRToReVerify(exception.RR_ID, strNewPdocno, strNewAct);
            }
            else if (!String.IsNullOrWhiteSpace(exception.AE_ID))
            {
                UpdatePegasysAEToReVerify(exception.AE_ID, strNewPdocno, strNewAct);
            }
        }
        /// <summary>
        /// Handls U049 exceptions
        /// Deals with either Invoices, RRs, or POs depending on data
        /// If notes.returnVal2 does not contain "DUPLICATE", it adds a notification and transhist record
        /// Clears V299 exceptions for invoices
        /// Sets the PegasysInvoice, PegasysRR_frm or PegasysPO_frm records to "REJECT"
        /// Users the RRQuery.RR_ID and POQuery.MODNO values, so those need to be passed in
        /// </summary>
        /// <param name="exception"></param>
        public void ExceptionU049(EXCEPTION exception, AddressValuesModel Search, AddressValuesModel Address,
                                  PEGASYSRR_FRM RRFrmQuery, PEGASYSPO_FRM POFrmQuery, string thismemo)
        {
            var Ex_Date = exception.EX_DATE;

            Report_ID = "";
            string S_Note = "No";

            ReportForm       = "";
            exception.PDOCNO = "";
            string strCuffMemo = "";

            Status = "Pending";

            if (!String.IsNullOrWhiteSpace(exception.INV_KEY_ID))
            {
                var DateQueued = DateTime.Now;
                Report_ID = "P08";

                Pegasys         = true;
                ReportForm      = "PegInvReject";
                exception.PO_ID = String.IsNullOrWhiteSpace(exception.PDOCNO) ? exception.PO_ID : exception.PDOCNO;

                // Not sending Notification if its a DUPLICATE Invoice
                if (!notes.returnVal2.Contains("DUPLICATE"))
                {
                    //Open MandMemo screen to get user input
                    if (thismemo == "CANCEL")
                    {
                        //DisplayMessage("Only Notification cancelled - Invoice will still be rejected!", 0, "Nothing");
                    }
                    else
                    {
                        exception.FAXNOTES = thismemo;


                        if (!CheckNotificationExists())
                        {
                            InsertNotification();
                        }
                    }

                    S_Note  = "Yes";
                    NewNote = "Reject Invoice " + "\r\n" + "Send Notification " + S_Note + " " + ReportForm + "\r\n" + NewNote;

                    strCuffMemo = "Reject - " + "\r\n" + "Send Notification " + S_Note + ": " +
                                  Report_ID + " - " + ReportForm + "\r" + NewNote;
                    InsertTranshist(exception, "X", strCuffMemo, "Reject Notification", PrepCode);
                }

                //Updating Invoice Table to Reject the Invoice

                var rtnInv = GetPegasysInvoiceByKey(exception.INV_KEY_ID);
                //Doesn't set lasttime to 0
                UpdatePegasysInvoiceToReject(rtnInv);

                // Just in case there is a V299 on Hold
                var rtnExc = GetExceptionV299();
                if (rtnExc != null)
                {
                    UpdateExceptionV299(exception.INV_KEY_ID);
                }

                // Creating a Custom TransHist Entry
                strCuffMemo = "U044 Invoice Number Changed Not Approved, Rejected back to Vendor";
                InsertTranshist(exception, "X", strCuffMemo, "Rejected by Manager", PrepCode);
            }
            else if (!String.IsNullOrWhiteSpace(exception.RR_ID))
            {
                //F05
                var DateQueued = DateTime.Now;
                Report_ID       = "F05";
                ReportForm      = "RR Reject";
                exception.RR_ID = RRFrmQuery.RR_ID;

                if (!notes.returnVal2.Contains("DUPLICATE"))
                {
                    if (String.IsNullOrWhiteSpace(exception.FAXNOTES))
                    {
                        if (thismemo == "CANCEL")
                        {
                            //DisplayMessage("Only Notification cancelled - RR will still be rejected!", 0, "Nothing");
                        }
                        else
                        {
                            exception.FAXNOTES = thismemo;

                            if (!CheckNotificationExists())
                            {
                                InsertNotification();
                            }
                        }
                    }

                    S_Note      = "Yes";
                    NewNote     = "Reject RR " + "\r\n" + "Send Notification " + S_Note + " " + ReportForm + "\r\n" + NewNote;
                    strCuffMemo = "Reject - " + "\r\n" + "Send Notification " + S_Note + ": " +
                                  Report_ID + " - " + ReportForm + "\r" + NewNote;
                    InsertTranshist(exception, "X", strCuffMemo, "Reject Notification", PrepCode);
                }

                var rtnRR = GetPegasysRRByKey(exception.RR_ID);

                UpdatePegasysRRToReject(rtnRR);
            }

            else if (!String.IsNullOrWhiteSpace(exception.PO_ID))
            {
                var DateQueued = DateTime.Now;
                ReportForm = "";

                if (!String.IsNullOrWhiteSpace(POFrmQuery.MODNO))
                {
                    Report_ID  = "F06";
                    ReportForm = "Mod Reject";
                }
                else
                {
                    Report_ID  = "F03";
                    ReportForm = "PO Reject";
                }

                if (!notes.returnVal2.Contains("DUPLICATE"))
                {
                    if (String.IsNullOrWhiteSpace(exception.FAXNOTES))
                    {
                        if (thismemo == "CANCEL")
                        {
                            //DisplayMessage("Only Notification cancelled - PO will still be rejected!", 0, "Nothing");
                        }
                        else
                        {
                            exception.FAXNOTES = thismemo;

                            if (!CheckNotificationExists())
                            {
                                InsertNotification();
                            }
                        }
                    }

                    S_Note  = "Yes";
                    NewNote = "Reject PO/Mod " + "\r\n" + "Send Notification " + S_Note + " " + ReportForm + "\r\n" + NewNote;

                    strCuffMemo = "Reject - " + "\r\n" + "Send Notification " + S_Note + ": " + Report_ID + " - " + ReportForm + "\r" + NewNote;
                    InsertTranshist(exception, "X", strCuffMemo, "Reject Notification", PrepCode);
                }

                var rtnPO = GetPegasysPOFrmByKey(exception.PO_ID);
                //Doesn't update lasttime
                UpdatePegasysPOToReject(rtnPO);
            }
            else
            {
                //Need to do error handling here
                //DisplayMessage("Unexpected Branching of code..Needs Investigation..Contact Helpdesk..", 64, "Unexpected Outcome!!");
            }
        }
        /// <summary>
        /// Calls the various Error Code methods
        /// Need to handle adding an exception under P041
        /// U084 was in the case statement twice, so the second one was removed
        /// Z234, Z237, and Z310 has been removed
        /// </summary>
        /// <param name="exception"></param>
        public void FinishCode(EXCEPTION exception, AddressValuesModel Search, AddressValuesModel Address,
                               PEGASYSINVOICE InvQuery, PEGASYSRR_FRM RRFrmQuery, PEGASYSPO_FRM POFrmQuery, String PrepCode)
        {
            //string _sEx_Memo2_Prefix = "";
            //The following needs to be handled..It was being set in each method, but not necessary if we can do it once here.
            NewNotes();
            var FaxNotes = notes.returnVal2 + notes.returnVal7;

            if (!String.IsNullOrWhiteSpace(FaxNotes))
            {
                exception.FAXNOTES = FaxNotes;
                notes.FaxNotes     = FaxNotes;
            }

            exception.FAXNOTES = exception.FAXNOTES.ReplaceNull("").ReplaceApostrophes();
            NewNote            = NewNote.ReplaceApostrophes();

            if (exception.ERR_CODE.Right(3).InList("029,009,037"))
            {
                Exception_029_009_037(exception, Search, Address);
            }
            else if (exception.ERR_CODE.Right(3) == "036")
            {
                Exception_036(PrepCode);
            }
            else if (exception.ERR_CODE.Right(3).InList("230,232,234"))
            {
                Exception230(Search, Address, InvQuery, RRFrmQuery, POFrmQuery);
            }
            else if (exception.ERR_CODE.Right(3) == "046")
            {
                Exception046(exception, Search, Address);
            }
            else if (exception.ERR_CODE.Right(3) == "200")
            {
                ExceptionU200(Search, Address);
            }
            else
            {
                switch (exception.ERR_CODE)
                {
                //case "C500":
                //case "C520":
                //    ExceptionC500(exception);
                //    break;

                case "D062":
                case "M303":
                case "M224":
                case "M237":
                    ExceptionM237(exception);
                    break;

                case "P060":
                    ExceptionD062(Search, Address);
                    break;

                case "P001":
                case "P002":
                case "P004":
                case "P024":
                case "P008":
                    ExceptionP002(exception, Search, Address);
                    break;

                case "P041":
                    if (Caption == "FINISH")
                    {
                        Exception046(exception, Search, Address);

                        //Add the Exception E052 here
                        AddException("", exception.ERR_CODE, PrepCode);
                    }
                    break;

                case "P140":
                case "P039":
                    ExceptionP140(exception, Search, Address);
                    break;

                case "P201":
                    ExceptionU200(Search, Address);
                    break;


                case "P231":
                    Exception230(Search, Address, InvQuery, RRFrmQuery, POFrmQuery);
                    break;

                case "V299":
                case "V216":
                case "V300":
                case "V215":
                    ExceptionV299(Search, Address, InvQuery, POFrmQuery);
                    break;

                case "A224":
                    ExceptionA224(exception, Search, Address, RRFrmQuery);
                    break;

                case "A226":
                    ExceptionA226(exception, Search, Address);
                    break;

                case "A237":
                    ExceptionA237(exception, Search, Address);
                    break;

                default:
                    break;
                }
            }



            //Update the exception
            string responseNotes = exception.RESPONSENOTES + "\r\n" + NewNote;

            UpdateException(exception, "X", notes.returnVal7, notes.returnVal3, responseNotes, "REJECT");
        }
        /// <summary>
        /// Handles 230 exceptions
        /// Uses InvQuery.PDOCNOPO & POFrmQuery.PDOCNO values, so those need to be passed in
        /// Sets PegasysInvoice to REJECT, Adds a Notification, and a Transhist record
        /// </summary>
        private void Exception230(AddressValuesModel Search, AddressValuesModel Address, PEGASYSINVOICE InvQuery, PEGASYSRR_FRM RRFrmQuery, PEGASYSPO_FRM POFrmQuery)
        {
            if (!String.IsNullOrWhiteSpace(exception.INV_KEY_ID) && InvQuery != null) // && USED("invquery"))
            {
                PDocNo = InvQuery.PDOCNOPO;
            }
            else if (!String.IsNullOrWhiteSpace(exception.PO_ID) && POFrmQuery != null) // && USED("pofrmquery"))
            {
                PDocNo = POFrmQuery.PDOCNO;
            }
            else
            {
                PDocNo = "";
            }

            if (exception.ERR_CODE.Left(1) == "P")
            {
                NewNote = "Reject Invoice - " + NewNote;

                var rtnInv = GetPegasysInvoiceByKey(exception.INV_KEY_ID);
                if (rtnInv != null)
                {
                    UpdatePegasysInvoiceToReject(rtnInv);
                }
            }
            else if (exception.ERR_CODE.Left(1) == "A")
            {
                NewNote = "Reject RR - " + NewNote;

                var rtnRR = GetPegasysRRByKey(exception.RR_ID);
                if (rtnRR != null)
                {
                    UpdatePegasysRRToReject(rtnRR);
                }
            }
            else if (exception.ERR_CODE.Left(1) == "M")
            {
                NewNote = "Reject AE - " + NewNote;

                var rtnAE = GetPegasysAEByKey(exception.AE_ID);
                if (rtnAE != null)
                {
                    UpdatePegasysAEToReject(rtnAE);
                }

                // Do not send Rejection Notification Letter for EA's.
                return;
            }

            if (notes.returnVal2 == null || !notes.returnVal2.Contains("DUPLICATE"))
            {
                if (exception.ERR_CODE.Left(1) == "P")
                {
                    Report_ID  = "P08";
                    ReportForm = "PegInvReject";
                }
                else if (exception.ERR_CODE.Left(1) == "A")
                {
                    Report_ID  = "F05";
                    ReportForm = "PegRRReject";
                }

                //Do not send Rejection Notification Letter for EA's.

                if (!CheckNotificationExists())
                {
                    Status = "Pending";
                    InsertNotification();
                }

                var strCuffMemo = "Send Notification " + Report_ID + ": " + ReportForm;
                InsertTranshist(exception, "X", strCuffMemo, "Reject Notification", PrepCode);
            }
        }
        /// <summary>
        /// Handles V299 exceptions
        /// Deals with either Invoices or POs
        /// Sets PegasysInvoice or PegasysPO_frm record to "REJECT"
        /// Adds notification and transhist records
        /// Did update C500 or C520 exceptions, but no longer needed
        /// Uses InvQuery.PDOCNOPO, POFrmQuery.PDOCNO, and GetEx.EX_DATE values so those need to be passed in
        ///
        /// </summary>
        private void ExceptionV299(AddressValuesModel Search, AddressValuesModel Address, PEGASYSINVOICE InvQuery, PEGASYSPO_FRM POFrmQuery)
        {
            //For Both Pegasys Vendor Exceptions V299 and V216
            if (!String.IsNullOrWhiteSpace(exception.INV_KEY_ID))
            {
                if (InvQuery != null)
                {
                    PDocNo = InvQuery.PDOCNOPO.ReplaceNull("");
                    var Po_Id = InvQuery.PDOCNOPO.ReplaceNull("");
                }
                else
                {
                    PDocNo = "";
                }

                //Update Pegasysinvoice table

                var rtnInv = GetPegasysInvoiceByKey(exception.INV_KEY_ID);
                if (rtnInv != null)
                {
                    UpdatePegasysInvoiceToReject(rtnInv);
                }


                NewNote = "Reject Invoice - " + NewNote;
            }
            else if (!String.IsNullOrWhiteSpace(exception.PO_ID))
            {
                PDocNo = POFrmQuery.PDOCNO.ReplaceNull("");
                //Update Pegasyspo_frm table

                var rtnPO = GetPegasysPOFrmByKey(exception.PO_ID);
                UpdatePegasysPOToReject(rtnPO);
            }


            //Create Notification V08
            exception.PO_ID = String.IsNullOrWhiteSpace(exception.PDOCNO) ? exception.PO_ID : exception.PDOCNO;
            var FaxNotes   = notes.returnVal7;
            var DateQueued = DateTime.Now;
            //exception.PREPCODE = objapp.prepcode;
            var strPegasys = "";

            if (!String.IsNullOrWhiteSpace(exception.INV_KEY_ID) && exception.ERR_CODE.InList("V299,V300"))
            {
                Report_ID  = "V08";
                strPegasys = "PegInvReject-Vendor";
            }
            else if (!String.IsNullOrWhiteSpace(exception.PO_ID))
            {
                Report_ID  = "F03";
                strPegasys = "PegPOReject";
            }

            Pegasys = true;

            if (notes.returnVal2 != null && !notes.returnVal2.Contains("DUPLICATE"))
            {
                if (!CheckNotificationExists())
                {
                    Status = "Pending";
                    InsertNotification();
                }

                var s_Note = "Yes";

                var strDate = ((DateTime)exception.EX_DATE).ToShortDateString();

                var strCuffMemo = "Reject Document - " + "\r\n" + "Send Notification " + s_Note + ": " +
                                  Report_ID + " - " + strPegasys + "\r" + NewNote;
                InsertTranshist(exception, "X", strCuffMemo, "Reject Notification", PrepCode);
            }
        }