Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        private void populateVoidTreeView()
        {
            //Call to clear and ready tree
            this.voidTreeView.BeginUpdate();
            this.voidTreeView.Nodes.Clear();

            //Compute date prior to which is beyond
            //the max void days
            var curShopDate = ShopDateTime.Instance.ShopDate;

            this.maxVoidShopDate = curShopDate.AddDays(-maxVoidDays).Date;

            //Clear loan records
            if (this.Loans == null)
            {
                this.Loans = new Dictionary <string, List <LoanVoidDetails> >();
            }
            this.Loans.Clear();

            //Pull rows out of data table
            for (int j = 0; j < this.LoanChainData.Rows.Count; ++j)
            {
                DataRow dR = this.LoanChainData.Rows[j];
                if (dR == null)
                {
                    continue;
                }

                LoanVoidDetails lvd;
                if (!this.retrieveLoanRowDetails(dR, out lvd))
                {
                    continue;
                }
                if ((this.LoanChainData.Rows.Count - 1) == j)
                {
                    lvd.CanVoid        = true;
                    lvd.CantVoidReason = "";
                }
                else
                {
                    if (lvd.CanVoid)
                    {
                        lvd.CanVoid        = false;
                        lvd.CantVoidReason = "This is not the last transaction in the loan chain.";
                    }
                }

                if (lvd.CanVoid && lvd.OpCode == "New")
                {
                    var mask = ResourceSecurityMask.NONE;
                    lvd.CanVoid = Common.Controllers.Database.Procedures.SecurityProfileProcedures.GetUserResourceAccess("NEWPAWNLOAN", CashlinxDesktopSession.Instance.LoggedInUserSecurityProfile, CashlinxDesktopSession.Instance, out mask);

                    if (!lvd.CanVoid || (lvd.CanVoid && mask == ResourceSecurityMask.NONE))
                    {
                        lvd.CanVoid        = false;
                        lvd.CantVoidReason = "User does not have permissions to void new loan.";
                    }
                    else
                    {
                        lvd.CanVoid = true;
                    }
                }

                List <LoanVoidDetails> curList;
                if (CollectionUtilities.isNotEmptyContainsKey(this.Loans, lvd.TickNum))
                {
                    curList = this.Loans[lvd.TickNum];
                    curList.Add(lvd);
                    this.Loans[lvd.TickNum] = curList;
                }
                else
                {
                    curList = new List <LoanVoidDetails>(1)
                    {
                        lvd
                    };
                    this.Loans.Add(lvd.TickNum, curList);
                }
            }

            LoanVoidDetails rollOverPrev = null;

            foreach (string curLoanNum in this.Loans.Keys)
            {
                List <LoanVoidDetails> curLoans = this.Loans[curLoanNum];
                //If current loan number is not valid (no tree started) or the loan number is
                //different from the
                TreeNode tParNode  = null;
                TreeNode childNode = null;
                foreach (LoanVoidDetails curLvd in curLoans)
                {
                    if (curLvd == null)
                    {
                        continue;
                    }
                    childNode = null;
                    //If we have a loan that is either new or after a rollover,
                    //create a new parent tree node
                    if ((curLvd.OpRefIsLoan && !curLvd.OpRefIsRollover) ||
                        (rollOverPrev != null))
                    {
                        if (rollOverPrev == null)
                        {
                            //Create parent node for loan
                            tParNode = new TreeNode(
                                curLvd.OpCode + " #" +
                                curLvd.TickNum + " " +
                                curLvd.OpDate.FormatDate() + " " +
                                curLvd.Amount.ToString("C") + " (" +
                                curLvd.RecId + ")");
                        }
                        else
                        {
                            tParNode = new TreeNode(
                                rollOverPrev.OpCode + " New #" +
                                curLvd.TickNum + " " +
                                curLvd.OpDate.FormatDate() + " (" +
                                curLvd.RecId + ")");
                            curLvd.Amount = rollOverPrev.Amount;
                            rollOverPrev  = null;
                        }
                    }
                    else if (curLvd.OpRefIsLoan && curLvd.OpRefIsRollover)
                    {
                        rollOverPrev = curLvd;
                        continue;
                    }
                    else if (!curLvd.OpRefIsLoan)
                    {
                        childNode = new TreeNode(
                            curLvd.OpCode + " " +
                            curLvd.OpDate.FormatDate() + " " +
                            curLvd.Amount.ToString("C") + " (" +
                            curLvd.RecId + ")");
                    }

                    if (curLvd.GreyedOut)
                    {
                        if (tParNode != null && childNode == null)
                        {
                            curLvd.NodeTag     = MAXVOID_TAG;
                            tParNode.Tag       = curLvd;
                            tParNode.BackColor = Color.Gray;
                            this.voidTreeView.Nodes.Add(tParNode);
                        }
                        else if (tParNode != null)
                        {
                            curLvd.NodeTag      = MAXVOID_TAG;
                            childNode.Tag       = curLvd;
                            childNode.BackColor = Color.Gray;
                            tParNode.Nodes.Add(childNode);
                        }
                    }
                    else
                    {
                        if (!curStoreNumber.Equals(curLvd.StoreNum, StringComparison.OrdinalIgnoreCase))
                        {
                            if (tParNode != null && childNode == null)
                            {
                                curLvd.NodeTag        = BADSTORE_TAG;
                                curLvd.GreyedOut      = true;
                                curLvd.CanVoid        = false;
                                curLvd.CantVoidReason = "Cannot void a transaction in a non originating store.";
                                tParNode.Tag          = curLvd;
                                tParNode.BackColor    = Color.Red;
                                tParNode.ForeColor    = Color.White;
                                this.voidTreeView.Nodes.Add(tParNode);
                            }
                            else if (tParNode != null)
                            {
                                curLvd.NodeTag        = BADSTORE_TAG;
                                curLvd.GreyedOut      = true;
                                curLvd.CanVoid        = false;
                                curLvd.CantVoidReason = "Cannot void a transaction in a non originating store.";
                                childNode.Tag         = curLvd;
                                childNode.BackColor   = Color.Red;
                                childNode.ForeColor   = Color.White;
                                tParNode.Nodes.Add(childNode);
                            }
                        }
                        else
                        {
                            if (curLvd.CanVoid)
                            {
                                if (tParNode != null && childNode == null)
                                {
                                    curLvd.NodeTag     = VALID_TAG;
                                    tParNode.Tag       = curLvd;
                                    tParNode.BackColor = Color.WhiteSmoke;
                                    tParNode.ForeColor = Color.Black;
                                    this.voidTreeView.Nodes.Add(tParNode);
                                }
                                else if (tParNode != null)
                                {
                                    curLvd.NodeTag      = VALID_TAG;
                                    childNode.Tag       = curLvd;
                                    childNode.BackColor = Color.WhiteSmoke;
                                    childNode.ForeColor = Color.Black;
                                    tParNode.Nodes.Add(childNode);
                                }
                            }
                            else
                            {
                                if (tParNode != null && childNode == null)
                                {
                                    curLvd.NodeTag        = NOVOID_TAG;
                                    curLvd.CanVoid        = false;
                                    curLvd.CantVoidReason = "You cannot void this transaction.";
                                    tParNode.Tag          = curLvd;
                                    tParNode.BackColor    = Color.Gray;
                                    this.voidTreeView.Nodes.Add(tParNode);
                                }
                                else if (tParNode != null)
                                {
                                    curLvd.NodeTag        = NOVOID_TAG;
                                    curLvd.CanVoid        = false;
                                    curLvd.CantVoidReason = "You cannot void this transaction.";
                                    childNode.Tag         = curLvd;
                                    childNode.BackColor   = Color.Gray;
                                    tParNode.Nodes.Add(childNode);
                                }
                            }
                        }
                    }
                }
            }


            this.voidTreeView.EndUpdate();
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dR"></param>
        /// <param name="lvd"></param>
        /// <returns></returns>
        private bool retrieveLoanRowDetails(DataRow dR, out LoanVoidDetails lvd)
        {
            lvd = new LoanVoidDetails
            {
                TkNum         = dR["ticket_number"],
                StNum         = dR["ref_store"],
                OpRf          = dR["ref_number"],
                OpCd          = dR["ref_event"],
                OpDt          = dR["ref_date"],
                OpTim         = dR["ref_time"],
                Amt           = dR["ref_amt"],
                DtMd          = dR["date_made"],
                TmMd          = dR["time_made"],
                HType         = dR["hold_type"],
                RcId          = dR["receiptdetail_number"],
                PfiElig       = dR["pfi_elig"],
                CreatedByData = dR["createdby"]
            };

            lvd.TickNum     = Utilities.GetStringValue(lvd.TkNum, string.Empty);
            lvd.StoreNum    = Utilities.GetStringValue(lvd.StNum, string.Empty);
            lvd.OpRef       = Utilities.GetStringValue(lvd.OpRf, string.Empty);
            lvd.OpCode      = Utilities.GetStringValue(lvd.OpCd, string.Empty);
            lvd.Amount      = Utilities.GetDecimalValue(lvd.Amt, 0.0M);
            lvd.HoldType    = Utilities.GetStringValue(lvd.HType, string.Empty);
            lvd.RecId       = Utilities.GetLongValue(lvd.RcId, 0L);
            lvd.PfiEligDate = Utilities.GetDateTimeValue(lvd.PfiElig, DateTime.MaxValue);
            lvd.CreatedBy   = Utilities.GetStringValue(lvd.CreatedByData, string.Empty);


            if (lvd.OpDt == null || lvd.OpTim == null || string.IsNullOrEmpty(lvd.TickNum) ||
                string.IsNullOrEmpty(lvd.StoreNum) || string.IsNullOrEmpty(lvd.OpRef) ||
                string.IsNullOrEmpty(lvd.OpCode) || lvd.RecId == 0L)
            {
                lvd.CanVoid        = false;
                lvd.CantVoidReason = "Invalid loan transaction data";
                return(false);
            }

            //If op code is new loan, renewal, or paydown, fetch the date made
            //and time made columns
            bool opRfRoll;

            lvd.OpRefIsLoan     = this.isOpCodeRolloverOrNew(lvd.OpCode, out opRfRoll);
            lvd.OpRefIsRollover = opRfRoll;
            lvd.CanVoid         = true;
            lvd.MarkedForVoid   = false;

            //Get op date and time
            lvd.OpDate = (DateTime)lvd.OpDt;
            if (lvd.OpTim.ToString() != string.Empty)
            {
                lvd.OpTime = (DateTime)lvd.OpTim;
            }

            if (lvd.OpRefIsLoan)
            {
                //Check for hold
                if (!string.IsNullOrEmpty(lvd.HoldType))
                {
                    if (!(lvd.HoldType.Equals("CUSTHOLD", StringComparison.OrdinalIgnoreCase) ||
                          lvd.HoldType.Equals("BKHOLD", StringComparison.OrdinalIgnoreCase)))
                    {
                        lvd.CanVoid        = false;
                        lvd.GreyedOut      = true;
                        lvd.CantVoidReason = "Loan is in void restricted hold status of " +
                                             lvd.HoldType;
                        return(false);
                    }
                }
                //Pull date_made and time_made
                // if (lvd.DtMd != null && lvd.TmMd != null)
                //{
                lvd.DateMd           = (DateTime)lvd.DtMd;
                lvd.TimeMd           = (DateTime)lvd.TmMd;
                lvd.LoanSpecificTime = true;
                lvd.GreyedOut        = lvd.OpDate.Date <= this.maxVoidShopDate;
                if (lvd.OpCode.ToString() == "PFI" || lvd.OpCode.ToString() == "PARTP")
                {
                    lvd.GreyedOut = lvd.OpDate.Date != ShopDateTime.Instance.ShopDate;
                }
                lvd.CanVoid = lvd.GreyedOut == false;
                if (!lvd.CanVoid)
                {
                    lvd.CantVoidReason = "Loan exceeds maximum days to void boundary.";
                }

                /*  }
                 * else
                 * {
                 *    lvd.LoanSpecificTime = false;
                 *    lvd.GreyedOut = lvd.OpDate.Date <= this.maxVoidShopDate;
                 *    lvd.CanVoid = lvd.GreyedOut == false;
                 *    if (!lvd.CanVoid)
                 *    {
                 *        lvd.CantVoidReason = "Loan exceeds maximum days to void boundary.";
                 *    }
                 * }*/
            }
            else
            {
                lvd.LoanSpecificTime = false;
                lvd.GreyedOut        = lvd.OpDate.Date <= this.maxVoidShopDate;
                if (lvd.OpCode.ToString() == "PFI" || lvd.OpCode.ToString() == "PARTP")
                {
                    lvd.GreyedOut = lvd.OpDate.Date != ShopDateTime.Instance.ShopDate;
                }

                lvd.CanVoid = lvd.GreyedOut == false;
                if (!lvd.CanVoid)
                {
                    lvd.CantVoidReason = "Loan exceeds maximum days to void boundary.";
                }
            }
            //SR 5/18/2010 Gray out converted loans
            //Check if this is a converted loan

            if (lvd.CreatedBy == "CONV")
            {
                lvd.GreyedOut      = true;
                lvd.CanVoid        = false;
                lvd.CantVoidReason = "Converted Loans cannot be voided.";
            }

            return(true);
        }