//Calculate the days to extend, new due date and the last day to pickup
        //using the amount to extend
        private void CalculateDataFromAmountToExtend()
        {
            var pfiDateAdjusted = false;

            customTextBoxNumDaystoExtend.Text = ServiceLoanProcedures.GetNumberOfExtendDaysFromExtensionAmount(GetAmountToExtendFromUI(), dailyAmount);
            var daysToAdd = GetDaysToExtendFromUI() * ServiceLoanProcedures.GetNumberOfDaysToExtendBy(_extensionType);

            labelAdjustedDueDate.Text =
                new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetValidDueDate(
                    Utilities.GetDateTimeValue(labelCurrDueDate.Text).AddDays(
                        daysToAdd), siteID);

            /* dateCalendarLastPickupDate.SelectedDate =
             *   BusinessRulesProcedures.GetValidPFIDateWithWaitdays(
             *       Utilities.GetDateTimeValue(labelAdjustedDueDate.Text),
             *       siteID, ref pfiDateAdjusted);*/
            dateCalendarLastPickupDate.SelectedDate =
                new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetValidPFIDate(
                    currentPFIDate.AddDays(daysToAdd),
                    siteID, ref pfiDateAdjusted);

            if (pfiDateAdjusted)
            {
                MessageBox.Show(Commons.GetMessageString("ExtendDateAdjustedMessage"));
            }

            checkAmtToExtend();
            daysToExtend  = GetDaysToExtendFromUI();
            AmtToExtend   = GetAmountToExtendFromUI();
            newPickupDate = dateCalendarLastPickupDate.SelectedDate;
        }
        private void buttonContinue_Click(object sender, EventArgs e)
        {
            try
            {
                if (_numberOfSelections > 0)
                {
                    getSelectedTransactions();
                    string strUserId = GlobalDataAccessor.Instance.DesktopSession.UserName;
                    bool   retVal    = ServiceLoanProcedures.CheckCurrentTempStatus(ref _selectedTransactions, strUserId, ServiceTypes.CUSTHOLD);
                    if (_selectedTransactions.Count == 0)
                    {
                        return;
                    }
                    GlobalDataAccessor.Instance.DesktopSession.HoldsData = _selectedTransactions;

                    if (retVal)
                    {
                        this.NavControlBox.Action = NavBox.NavAction.BACKANDSUBMIT;
                    }
                    else
                    {
                        throw new Exception("Error when trying to update temp status on selected loans");
                    }
                }
            }
            catch (Exception ex)
            {
                BasicExceptionHandler.Instance.AddException("Error when trying to put hold on selected transactions", new ApplicationException(ex.Message));
                this.NavControlBox.Action = NavBox.NavAction.CANCEL;
            }
        }
        private void buttonReleaseHold_Click(object sender, EventArgs e)
        {
            if (_numberOfSelections > 0)
            {
                try
                {
                    GetSelectedTransactions();
                    string strUserId = GlobalDataAccessor.Instance.DesktopSession.UserName;
                    bool   retVal    = ServiceLoanProcedures.CheckCurrentTempStatus(ref _selectedTransactions, strUserId, ServiceTypes.CUSTHOLD);
                    if (_selectedTransactions.Count == 0)
                    {
                        return;
                    }
                    GlobalDataAccessor.Instance.DesktopSession.HoldsData = _selectedTransactions;


                    if (retVal)
                    {
                        bool containsJewelry = false;
                        foreach (HoldData holdData in GlobalDataAccessor.Instance.DesktopSession.HoldsData)
                        {
                            Item itemi = holdData.Items.Find(item => item.IsJewelry);
                            if (itemi != null)
                            {
                                if (itemi.ItemStatus == ProductStatus.PFI)
                                {
                                    containsJewelry = true;
                                    break;
                                }
                            }
                        }
                        if (containsJewelry)
                        {
                            MultiJewelryCaseNumber multiJcase = new MultiJewelryCaseNumber();
                            multiJcase.ShowDialog();
                        }
                        this.NavControlBox.IsCustom     = true;
                        this.NavControlBox.CustomDetail = "HoldReleaseInfo";
                        this.NavControlBox.Action       = NavBox.NavAction.BACKANDSUBMIT;
                    }
                    else
                    {
                        throw new Exception("Error when trying to update temp status on selected loans");
                    }
                }
                catch (Exception ex)
                {
                    BasicExceptionHandler.Instance.AddException("Error when trying to put hold on selected transactions", new ApplicationException(ex.Message));
                    this.NavControlBox.Action = NavBox.NavAction.CANCEL;
                }
            }
            else
            {
                MessageBox.Show("No transactions selected for update.");
                return;
            }
        }
        //Calculate the number of days to extend, new due date
        //and the amount to extend based on the last day to pickup
        private void CalculateDataFromLastDayToPickup()
        {
            var pfiDateAdjusted = false;
            //DateTime originalPfiDate = Utilities.GetDateTimeValue(dateCalendarLastPickupDate.SelectedDate);
            var originalPfiDate = currentPFIDate;

            dateCalendarLastPickupDate.SelectedDate =
                new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetValidPFIDate(
                    Utilities.GetDateTimeValue(dateCalendarLastPickupDate.SelectedDate), siteID,
                    ref pfiDateAdjusted);
            var newPFiDate    = Utilities.GetDateTimeValue(dateCalendarLastPickupDate.SelectedDate);
            var extensionDays = Utilities.GetIntegerValue((newPFiDate - originalPfiDate).TotalDays);

            labelAdjustedDueDate.Text =
                new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetValidDueDate(
                    Utilities.GetDateTimeValue(labelCurrDueDate.Text).AddDays(
                        extensionDays), siteID);
            if (_extensionType == ExtensionTerms.DAILY)
            {
                customTextBoxNumDaystoExtend.Text = (Utilities.GetDateTimeValue(labelAdjustedDueDate.Text) -
                                                     Utilities.GetDateTimeValue(labelCurrDueDate.Text)).TotalDays.ToString();
            }
            else
            {
                customTextBoxNumDaystoExtend.Text =
                    Math.Round((Utilities.GetDateTimeValue(labelAdjustedDueDate.Text) -
                                Utilities.GetDateTimeValue(labelCurrDueDate.Text)).TotalDays / 30, 0).ToString();
            }

            SetAmountToExtendToUI(ServiceLoanProcedures.GetAmountToExtend(GetDaysToExtendFromUI(), dailyAmount));
            if (pfiDateAdjusted)
            {
                MessageBox.Show(Commons.GetMessageString("ExtendDateAdjustedMessage"));
            }
            daysToExtend  = GetDaysToExtendFromUI();
            AmtToExtend   = GetAmountToExtendFromUI();
            newPickupDate = dateCalendarLastPickupDate.SelectedDate;
            checkAmtToExtend();
        }
        private void customButtonSubmit_Click(object sender, EventArgs e)
        {
            decimal principalAmt = Utilities.GetDecimalValue(customTextBoxPrincipal.Text, 0);
            decimal subTotal     = Math.Round(principalAmt + interestAmt + storageFee + lateFeeFin - refundAmt, 2);

            if (customButtonSubmit.Text == "Calculate")
            {
                if (string.IsNullOrEmpty(customTextBoxPrincipal.Text))
                {
                    MessageBox.Show("Please enter a principal reduction amount");
                    return;
                }
                if (principalAmt >= currentPrincipal)
                {
                    MessageBox.Show("Principal reduction cannot be more or equal to the current principal");
                    return;
                }
                //CHeck that the amount entered satisfies the minimum that is allowed
                decimal minPartialPmt = new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetPartialPaymentMinAmount(GlobalDataAccessor.Instance.DesktopSession.CurrentSiteId);

                if (principalAmt < minPartialPmt)
                {
                    MessageBox.Show("Payment minimum amount of $" + minPartialPmt + " has not been met. Please enter sufficient amount");
                    return;
                }
                decimal newAmount = currentPrincipal - principalAmt;
                newPrincipalAmount.Text        = newAmount.ToString("f2");
                totalDueAmount.Text            = String.Format("{0:C}", subTotal);
                customButtonSubmit.Text        = "Submit";
                customTextBoxPrincipal.Enabled = false;
            }
            else
            {
                this.DialogResult = DialogResult.OK;
                SiteId siteId = Utilities.CloneObject(GlobalDataAccessor.Instance.CurrentSiteId);
                siteId.Date = ShopDateTime.Instance.ShopDate;

                siteId.LoanAmount = currentPrincipal - principalAmt;
                var newPawnLoan = Utilities.CloneObject(pawnLoan);
                siteId.Date        = ShopDateTime.Instance.ShopDate;
                newPawnLoan.Amount = currentPrincipal - principalAmt;
                decimal lateFeeAmount = lateFeeFin - refundAmt;
                UnderwritePawnLoanVO uwVO;
                newPawnLoan = ServiceLoanProcedures.GetLoanFees(GlobalDataAccessor.Instance.CurrentSiteId,
                                                                ServiceTypes.PARTIALPAYMENT,
                                                                0, 0, lateFeeAmount, 0,
                                                                newPawnLoan,
                                                                out uwVO);
                decimal lastInterestAmount = originalInterestAmount;

                if (pawnLoan.PartialPaymentPaid)
                {
                    lastInterestAmount = (from ppmt in pawnLoan.PartialPayments
                                          where ppmt.Time_Made == pawnLoan.LastPartialPaymentDate
                                          select ppmt.CUR_FIN_CHG).FirstOrDefault();
                }
                decimal totalIntAmt = Math.Round(interestAmt + lateInterest - (lastInterestAmount * extensionsPaid), 2);
                //decimal totalServAmt = Math.Round(storageFee + lateService - (originalServiceAmount * extensionsPaid), 2);
                decimal totalServAmt      = Math.Round(subTotal - (principalAmt + totalIntAmt), 2);
                decimal storageFeeAllowed = new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetStorageFee(GlobalDataAccessor.Instance.CurrentSiteId);
                Common.Libraries.Objects.Pawn.PartialPayment pPmnt = new Common.Libraries.Objects.Pawn.PartialPayment();
                pPmnt.PMT_AMOUNT   = subTotal;
                pPmnt.PMT_INT_AMT  = totalIntAmt;
                pPmnt.PMT_PRIN_AMT = principalAmt;
                pPmnt.PMT_SERV_AMT = totalServAmt;
                pPmnt.CUR_AMOUNT   = currentPrincipal - principalAmt;
                pPmnt.CUR_FIN_CHG  = Math.Round(uwVO.totalFinanceCharge, 2);
                pPmnt.Cur_Int_Pct  = Math.Round(uwVO.APR, 2);
                if (storageFeeAllowed != 0)
                {
                    pPmnt.Cur_Srv_Chg = (from newFee in newPawnLoan.Fees
                                         where newFee.FeeType == FeeTypes.STORAGE
                                         select newFee).FirstOrDefault().Value;
                }
                else
                {
                    pPmnt.Cur_Srv_Chg = Math.Round((pPmnt.CUR_AMOUNT * uwVO.feeDictionary["CL_PWN_0010_SVCCHRGRATE"]) / 100, 2);
                }
                pPmnt.Cur_Term_Fin = Utilities.GetIntegerValue(Math.Floor(100 * uwVO.totalFinanceCharge));
                pPmnt.Status_cde   = "New";
                pawnLoan.PartialPayments.Add(pPmnt);
                pawnLoan.Fees.Clear();


                if (totalIntAmt != 0)
                {
                    Fee interestAmtFee = new Fee()
                    {
                        FeeType        = FeeTypes.INTEREST,
                        Value          = totalIntAmt,
                        OriginalAmount = totalIntAmt,
                        FeeState       = FeeStates.ASSESSED,
                        FeeDate        = ShopDateTime.Instance.ShopDate,
                        CanBeProrated  = false,
                        CanBeWaived    = false
                    };
                    pawnLoan.Fees.Add(interestAmtFee);
                }
                if (totalServAmt != 0)
                {
                    Fee storageAmtFee = new Fee()
                    {
                        FeeType        = storageFeeAllowed == 0?FeeTypes.SERVICE:FeeTypes.STORAGE,
                        Value          = totalServAmt,
                        OriginalAmount = totalServAmt,
                        FeeState       = FeeStates.ASSESSED,
                        FeeDate        = ShopDateTime.Instance.ShopDate,
                        CanBeProrated  = false,
                        CanBeWaived    = false
                    };
                    pawnLoan.Fees.Add(storageAmtFee);
                }



                this.Close();
            }
        }
示例#6
0
        private void CalculateRolloverAmount()
        {
            SiteId siteId = Utilities.CloneObject(GlobalDataAccessor.Instance.CurrentSiteId);
            UnderwritePawnLoanVO underwritePawnLoanVO;

            decimal       totalFinCharge = 0.0M;
            decimal       totSrvCharge   = 0.0M;
            decimal       newLoanFee     = 0.0M;
            const decimal dLateFee       = 0.00M;
            decimal       apr            = 0.0M;
            DateTime      dueDate        = DateTime.MaxValue;
            DateTime      pfiDate        = DateTime.MaxValue;

            //If renewal is the action
            if (radRenew.Checked)
            {
                //Compute renewal amount
                decimal renAmt = this.pawnLoanRenewalAllowed ?
                                 this.pawnLoan.PickupAmount - this.pawnLoan.Amount
                                            : 0.0M;


                decimal renewedLoanAmt = pawnLoan.PickupAmount - renAmt;
                siteId.Date = ShopDateTime.Instance.ShopDate;

                siteId.LoanAmount = renewedLoanAmt;

                // Call Business Rules for Fees
                PawnLoan newloan = Utilities.CloneObject(this.pawnLoan);
                newloan.Amount = renewedLoanAmt;


                this.newPawnLoan = ServiceLoanProcedures.GetLoanFees(
                    siteId,
                    ServiceTypes.RENEW,
                    0, 0, 0, 0,
                    newloan,
                    out underwritePawnLoanVO);
                this.newPawnLoan.OriginalFees = Utilities.CloneObject(newloan.Fees);
                this.newPawnLoan.ObjectUnderwritePawnLoanVO = underwritePawnLoanVO;

                this.newPawnLoan.RenewalAmount = renAmt;
                this.newPawnLoan.Amount        = renewedLoanAmt;

                //Calculate the fees for the new loan which should
                //not include the interest or gun lock fee
                //TO do: Figure out how to determine which fees need
                //to be used for renew from the database and use that

                newLoanFee = (from ploan in newPawnLoan.Fees
                              where ploan.FeeType != FeeTypes.INTEREST &&
                              ploan.FeeType != FeeTypes.GUN_LOCK
                              select ploan).Sum(s => s.Value);

                totalFinCharge = underwritePawnLoanVO.totalFinanceCharge;
                totSrvCharge   = underwritePawnLoanVO.totalServiceCharge;
                dueDate        = underwritePawnLoanVO.DueDate;
                pfiDate        = underwritePawnLoanVO.PFIDate;
                apr            = underwritePawnLoanVO.APR;

                this.newPawnLoan.PickupAmount = this.newPawnLoan.Amount
                                                + underwritePawnLoanVO.totalFinanceCharge
                                                + newLoanFee;
                this.newPawnLoan.DueDate        = underwritePawnLoanVO.DueDate;
                this.newPawnLoan.PfiNote        = underwritePawnLoanVO.PFINotifyDate;
                this.newPawnLoan.PfiEligible    = underwritePawnLoanVO.PFIDate;
                this.newPawnLoan.DateMade       = underwritePawnLoanVO.MadeDate;
                this.newPawnLoan.InterestAmount = Math.Round(totalFinCharge, 2);
                this.newPawnLoan.InterestRate   = Math.Round(apr, 2);

                //Enable submit button
                this.submitButton.Enabled    = true;
                this.calculateButton.Enabled = false;
            }
            else if (radPaydown.Checked)
            {
                this.submitButton.Enabled    = false;
                this.calculateButton.Enabled = true;
                siteId.Date = ShopDateTime.Instance.ShopDate;
                decimal paydownLoanAmount = this.pawnLoan.PickupAmount - this.customerPaydownAmount;

                siteId.LoanAmount = paydownLoanAmount;
                PawnLoan newloan = Utilities.CloneObject(this.pawnLoan);
                newloan.Amount = paydownLoanAmount;

                this.newPawnLoan = ServiceLoanProcedures.GetLoanFees(
                    siteId,
                    ServiceTypes.PAYDOWN,
                    0, 0, 0, 0,
                    newloan,
                    out underwritePawnLoanVO);

                this.newPawnLoan.OriginalFees = Utilities.CloneObject(this.pawnLoan.Fees);
                this.newPawnLoan.ObjectUnderwritePawnLoanVO = underwritePawnLoanVO;

                //Calculate the fees for the new loan which should
                //not include the interest
                //TO do: Figure out how to determine which fees need
                //to be used for paydown from the database and use that
                newLoanFee = (from ploan in newPawnLoan.Fees
                              where ploan.FeeType != FeeTypes.INTEREST
                              select ploan).Sum(s => s.Value);

                this.newPawnLoan.Amount = paydownLoanAmount;
                //Verify new loan renewal amount against min state loan amount
                if (this.newPawnLoan.Amount < MinLoanAmt)
                {
                    MessageBox.Show(
                        "The new loan amount for this transaction is less than the minimum amount required for a new loan. " +
                        "Please adjust the terms of the paydown to continue.",
                        "Paydown Loan Validation",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information);
                    rolloverError = true;
                    return;
                }
                //Compute pickup amount, required for determining rollover amounts
                totalFinCharge = underwritePawnLoanVO.totalFinanceCharge;
                totSrvCharge   = underwritePawnLoanVO.totalServiceCharge;
                dueDate        = underwritePawnLoanVO.DueDate;
                pfiDate        = underwritePawnLoanVO.PFIDate;
                apr            = underwritePawnLoanVO.APR;

                this.newPawnLoan.PaydownAmount = this.customerPaydownAmount;
                this.newPawnLoan.PickupAmount  = this.newPawnLoan.Amount
                                                 + underwritePawnLoanVO.totalFinanceCharge
                                                 + newLoanFee;

                this.newPawnLoan.DueDate        = underwritePawnLoanVO.DueDate;
                this.newPawnLoan.PfiNote        = underwritePawnLoanVO.PFINotifyDate;
                this.newPawnLoan.PfiEligible    = underwritePawnLoanVO.PFIDate;
                this.newPawnLoan.DateMade       = underwritePawnLoanVO.MadeDate;
                this.newPawnLoan.InterestAmount = Math.Round(totalFinCharge, 2);
                this.newPawnLoan.InterestRate   = Math.Round(apr, 2);

                this.submitButton.Enabled = true;
            }
            //Set previous ticket number attribute
            this.newPawnLoan.PrevTicketNumber = this.pawnLoan.TicketNumber;
            this.newPawnLoan.OrigTicketNumber = this.pawnLoan.OrigTicketNumber;

            //****End Section



            // populate form fields
            this.ButtonVisible(true);

            this.amountFinanced_NewLoan.Text = String.Format("{0:C}", this.newPawnLoan.Amount);
            this.interest_NewLoan.Text       = String.Format("{0:C}", totalFinCharge);
            this.service_NewLoan.Text        = String.Format("{0:C}", totSrvCharge);
            this.fee_NewLoan.Text            = String.Format("{0:C}", newLoanFee);
            this.pickupAmount_NewLoan.Text   = String.Format("{0:C}", this.newPawnLoan.PickupAmount);
            this.apr_NewLoan.Text            = CashlinxDesktopSession.Instance.CurrentSiteId.Alias == "OK" ? String.Format("{0:N2}%", apr) : String.Format("{0}%", apr);
            this.dueDate_NewLoan.Text        = dueDate.ToShortDateString();
            this.lastDatePickup_NewLoan.Text = pfiDate.ToShortDateString();
            this.renewalAmountValue.Text     = String.Format("{0:C}", this.newPawnLoan.RenewalAmount);
            this.Update();
        }
        //Calculate the Amount to extend, new due date and last day to pickup
        //using the number of days to extend
        private void CalculateDataFromNumberOfDaysToExtend()
        {
            var     numDaysToExtend = GetDaysToExtendFromUI();
            var     pfiDateAdjusted = false;
            decimal amountToExtend;
            int     monthsToExtendBy;

            if (partialPaymentAllowed)
            {
                if (_extensionType == ExtensionTerms.MONTHLY)
                {
                    if (selectedLoans[currIndex].PartialPaymentPaid)
                    {
                        monthsToExtendBy = GetDaysToExtendFromUI() - 1;

                        amountToExtend = (monthsToExtendBy * dailyAmount) + (daysToPay * interestAmount / 30) + (daysToPay * serviceAmount / 30);
                    }
                    else
                    {
                        monthsToExtendBy = GetDaysToExtendFromUI();
                        amountToExtend   = monthsToExtendBy * dailyAmount;
                    }
                }
                else
                {
                    //amountToExtend = (numDaysToExtend * dailyAmount) + (daysToPay * interestAmount / 30) + (daysToPay * serviceAmount / 30);
                    amountToExtend = numDaysToExtend * dailyAmount;
                }
            }
            else
            {
                amountToExtend = numDaysToExtend * dailyAmount;
            }
            SetAmountToExtendToUI(amountToExtend.ToString("f2"));
            var daysToAdd = numDaysToExtend * ServiceLoanProcedures.GetNumberOfDaysToExtendBy(_extensionType);

            if (_extensionType == ExtensionTerms.DAILY)
            {
                labelAdjustedDueDate.Text =
                    new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetValidDueDate(
                        Utilities.GetDateTimeValue(labelCurrDueDate.Text).AddDays(daysToAdd), siteID);
                dateCalendarLastPickupDate.SelectedDate =
                    new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetValidPFIDate(
                        currentPFIDate.AddDays(daysToAdd),
                        siteID, ref pfiDateAdjusted);
            }
            else
            {
                labelAdjustedDueDate.Text =
                    new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetValidDueDate(
                        Utilities.GetDateTimeValue(labelCurrDueDate.Text).AddMonths(numDaysToExtend), siteID);
                dateCalendarLastPickupDate.SelectedDate =
                    new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetValidPFIDate(
                        currentPFIDate.AddMonths(numDaysToExtend),
                        siteID, ref pfiDateAdjusted);
            }

            /* dateCalendarLastPickupDate.SelectedDate =
             *   BusinessRulesProcedures.GetValidPFIDateWithWaitdays(
             *       Utilities.GetDateTimeValue(labelAdjustedDueDate.Text),
             *       siteID, ref pfiDateAdjusted);*/
            if (pfiDateAdjusted)
            {
                MessageBox.Show(Commons.GetMessageString("ExtendDateAdjustedMessage"));
            }
            checkAmtToExtend();
            daysToExtend  = GetDaysToExtendFromUI();
            AmtToExtend   = GetAmountToExtendFromUI();
            newPickupDate = dateCalendarLastPickupDate.SelectedDate;
        }
        private void showPawnLoanData()
        {
            if (currIndex >= 0)
            {
                var pl = selectedLoans[currIndex];

                siteID = new SiteId
                {
                    Alias       = GlobalDataAccessor.Instance.CurrentSiteId.Alias,
                    Company     = GlobalDataAccessor.Instance.CurrentSiteId.Company,
                    Date        = ShopDateTime.Instance.ShopDate,
                    LoanAmount  = pl.Amount,
                    State       = pl.OrgShopState,
                    StoreNumber = pl.OrgShopNumber,
                    TerminalId  = GlobalDataAccessor.Instance.CurrentSiteId.TerminalId
                };

                var businessRulesProcedures = new BusinessRulesProcedures(DS);
                partialPaymentAllowed = businessRulesProcedures.IsPartialPaymentAllowed(siteID);
                var partialPaymentInLastMonth   = pl.PartialPayments.Any(pp => pp.Date_Made > pl.PfiNote && pp.Date_Made < pl.PfiEligible);
                var allowFutureInterestPayments = businessRulesProcedures.AllowFutureInterestPayments(siteID);
                var storageFee = businessRulesProcedures.GetStorageFee(siteID);

                labelLoanNumber.Text  = pl.TicketNumber.ToString();
                labelCurrDueDate.Text = pl.DueDate.FormatDate();

                DateTime PartialPmtDate = DateTime.MaxValue;


                if (pl.PartialPaymentPaid)
                {
                    Common.Libraries.Objects.Pawn.PartialPayment pmt = pl.PartialPayments.OrderByDescending(pp => pp.Time_Made).FirstOrDefault();
                    PartialPmtDate = pmt.Date_Made;
                    interestAmount = pmt.CUR_FIN_CHG;
                    serviceAmount  = pmt.Cur_Srv_Chg;
                }
                else
                {
                    interestAmount = pl.InterestAmount;
                    serviceAmount  = pl.ServiceCharge;
                }
                if (partialPaymentAllowed && _extensionType != ExtensionTerms.DAILY)
                {
                    ExtensionProcedures.GetExtensionPeriod(PartialPmtDate,
                                                           pl.DateMade,
                                                           ShopDateTime.Instance.ShopDate,
                                                           pl.DueDate,
                                                           pl.PfiNote,
                                                           pl.PfiEligible,
                                                           pl.ExtensionType,
                                                           out daysToPay,
                                                           out monthsToPay,
                                                           out LastCycleEnd);
                }
                else
                {
                    pl.ExtensionType = _extensionType;
                    //daysToPay = 30;
                }

                int     daysToAdd;
                decimal amountToExtend;

                dailyAmount = ServiceLoanProcedures.GetDailyAmount(pl.ExtensionType, interestAmount, serviceAmount);
                if (pl.ExtensionType == ExtensionTerms.MONTHLY)
                {
                    customTextBoxNumDaystoExtend.Visible = false;
                    ddlNumDaystoExtend.Visible           = true;
                    suppressDaysChangedEvent             = true;
                    for (int i = 1; i <= monthsToPay; i++)
                    {
                        ddlNumDaystoExtend.Items.Add(i.ToString());
                    }
                    if (ddlNumDaystoExtend.Items.Count > 0)
                    {
                        ddlNumDaystoExtend.SelectedIndex = 0;
                    }
                    suppressDaysChangedEvent = false;

                    customTextBoxAmtToExtend.Visible = false;
                    lblAmtToExtend.Visible           = true;
                    int monthsToExtendBy = 1;
                    if (partialPaymentAllowed && pl.PartialPaymentPaid)
                    {
                        monthsToExtendBy = GetDaysToExtendFromUI() - 1;

                        amountToExtend = (monthsToExtendBy * dailyAmount) + (daysToPay * interestAmount / 30) + (daysToPay * serviceAmount / 30);
                    }
                    else
                    {
                        monthsToExtendBy = GetDaysToExtendFromUI();
                        amountToExtend   = monthsToExtendBy * dailyAmount;
                    }
                    lblAmtToExtend.Text = amountToExtend.ToString("f2");
                    this.ActiveControl  = this.ddlNumDaystoExtend;

                    var pfiDateAdjusted = false;
                    labelAdjustedDueDate.Text =
                        new BusinessRulesProcedures(DS).GetValidDueDate(pl.DueDate.AddMonths(Utilities.GetIntegerValue(ddlNumDaystoExtend.Text, 1)), siteID);
                    dateCalendarLastPickupDate.SelectedDate =
                        new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetValidPFIDate(
                            pl.PfiEligible.AddMonths(Utilities.GetIntegerValue(ddlNumDaystoExtend.Text, 1)),
                            siteID, ref pfiDateAdjusted);
                    dateCalendarLastPickupDate.Enabled = false;
                }
                else
                {
                    customTextBoxNumDaystoExtend.Visible = true;
                    ddlNumDaystoExtend.Visible           = false;
                    customTextBoxNumDaystoExtend.Text    = "30";
                    labelNumDaysToExtendHeading.Visible  = true;
                    customTextBoxAmtToExtend.Visible     = true;
                    lblAmtToExtend.Visible = false;
                    SetAmountToExtendToUI(ServiceLoanProcedures.GetAmountToExtend(GetDaysToExtendFromUI(), dailyAmount));
                    daysToAdd          = GetDaysToExtendFromUI();
                    this.ActiveControl = this.customTextBoxNumDaystoExtend;
                    var pfiDateAdjusted = false;
                    labelDailyAmtHeading.Text = "Daily Amount:";
                    if (partialPaymentAllowed && pl.PartialPaymentPaid && !allowFutureInterestPayments)
                    {
                        labelNumDaysToExtendHeading.Text = "One Month's Full Charge";
                        //customTextBoxNumDaystoExtend.Visible = false;
                        ddlNumDaystoExtend.Visible = false;
                        lblNumDaysToExtend.Visible = true;
                        //customTextBoxAmtToExtend.Visible = false;
                        lblAmtToExtend.Visible = false;
                        //lblNumDaysToExtend.Text = fullMonth;
                        customTextBoxAmtToExtend.Visible  = true;
                        customTextBoxAmtToExtend.Text     = (daysToPay * dailyAmount).ToString("f2");
                        customTextBoxNumDaystoExtend.Text = (interestAmount + serviceAmount).ToString("f2");
                        labelAdjustedDueDate.Text         =
                            new BusinessRulesProcedures(DS).GetValidDueDate(LastCycleEnd.AddMonths(1), siteID);
                        dateCalendarLastPickupDate.SelectedDate =
                            new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetValidPFIDate(
                                pl.PfiEligible.AddMonths(1),
                                siteID, ref pfiDateAdjusted);
                        dateCalendarLastPickupDate.Enabled   = false;
                        customTextBoxAmtToExtend.Enabled     = false;
                        customTextBoxNumDaystoExtend.Enabled = false;
                    }
                    else
                    {
                        labelAdjustedDueDate.Text =
                            new BusinessRulesProcedures(DS).GetValidDueDate(pl.DueDate.AddDays(daysToAdd), siteID);
                        dateCalendarLastPickupDate.SelectedDate =
                            new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetValidPFIDate(
                                pl.PfiEligible.AddDays(daysToAdd),
                                siteID, ref pfiDateAdjusted);
                    }
                }

                lblNumDaysToExtend.Visible = false;

                labelDailyAmount.Text = String.Format("{0:0.0000}", dailyAmount);

                daysToExtend            = GetDaysToExtendFromUI();
                AmtToExtend             = GetAmountToExtendFromUI();
                newPickupDate           = dateCalendarLastPickupDate.SelectedDate;
                labelLoanSelection.Text = (this.currIndex + 1) + " of " + this.numberOfLoansToExtend;
                //}

                currentPFIDate = pl.PfiEligible;

                //Show the selection for printing memo of extension in single page
                //if this is the last loan to be processed
                if (currIndex + 1 == numberOfLoansToExtend)
                {
                    //Check if there are any service loans set for extension already
                    var idx = GlobalDataAccessor.Instance.DesktopSession.ServiceLoans.FindIndex(ploan => ploan.TempStatus == StateStatus.E);

                    if (new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).PrintMultipleMemoOfExtension(siteID) && (numberOfLoansToExtend > 1 || idx >= 0) &&
                        !GlobalDataAccessor.Instance.DesktopSession.PrintSingleMemoOfExtension)
                    {
                        this.checkBoxPrintSingleMemoForExtn.Visible = true;
                    }
                    this.customButtonContinue.Text = "Submit";
                }
                if (numberOfLoansToExtend == 1)
                {
                    this.customButtonSkip.Visible = false;
                }
            }
        }