//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 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; } } }