public void TestNoFees() { PawnLoan.CurrentPrincipalAmount = 80M; Assert.AreEqual(0, PfiPickupCalculator.ApplicableFees.Count); Assert.IsFalse(PfiPickupCalculator.HasPartialPayment); PfiPickupCalculator.Calculate(); Assert.IsFalse(PfiPickupCalculator.HasPartialPayment); Assert.AreEqual(80M, PfiPickupCalculator.PickupAmount); Assert.AreEqual(0, PfiPickupCalculator.ApplicableFees.Count); }
public void TestwithInterstStorage() { PawnLoan.CurrentPrincipalAmount = 80M; AddFee(PawnLoan, FeeTypes.INTEREST, FeeStates.ASSESSED, 5M, false); AddFee(PawnLoan, FeeTypes.STORAGE, FeeStates.ASSESSED, 4M, false); Assert.AreEqual(0, PfiPickupCalculator.ApplicableFees.Count); Assert.IsFalse(PfiPickupCalculator.HasPartialPayment); PfiPickupCalculator.Calculate(); Assert.IsFalse(PfiPickupCalculator.HasPartialPayment); Assert.AreEqual(87.75M, PfiPickupCalculator.PickupAmount); Assert.AreEqual(2, PfiPickupCalculator.ApplicableFees.Count); }
public void TestwithInterstStorageMailer() { PawnLoan.CurrentPrincipalAmount = 80M; PawnLoan.PickupLateFinAmount = 5M; PawnLoan.PickupLateServAmount = 5M; AddFee(PawnLoan, FeeTypes.INTEREST, FeeStates.ASSESSED, 5M, false); AddFee(PawnLoan, FeeTypes.STORAGE, FeeStates.ASSESSED, 4M, false); AddFee(PawnLoan, FeeTypes.LATE, FeeStates.ASSESSED, 10M, false); AddFee(PawnLoan, FeeTypes.MAILER_CHARGE, FeeStates.ASSESSED, 2M, false); Assert.AreEqual(0, PfiPickupCalculator.ApplicableFees.Count); Assert.IsFalse(PfiPickupCalculator.HasPartialPayment); PfiPickupCalculator.Calculate(); Assert.IsFalse(PfiPickupCalculator.HasPartialPayment); Assert.AreEqual(99.75M, PfiPickupCalculator.PickupAmount); Assert.AreEqual(4, PfiPickupCalculator.ApplicableFees.Count); }
public void TestTicket115417_2() { /**********************************************/ /*****SETUP OF LOAN****************************/ /*****NOT USING SAME LOAN AS OTHER TESTS*******/ /**********************************************/ PickupDate = new DateTime(2012, 3, 29); PawnLoan = new PawnLoan(); PawnLoan.InterestAmount = 4M; PawnLoan.ServiceCharge = 4M; PawnLoan.DateMade = new DateTime(2011, 12, 31); PawnLoan.DueDate = new DateTime(2012, 1, 31); PfiPickupCalculator = new PfiPickupCalculator(PawnLoan, TestSiteIds.Store00901, PickupDate); /**********************************************/ PawnLoan.CurrentPrincipalAmount = 80M; PawnLoan.PickupLateFinAmount = 4M; PawnLoan.PickupLateServAmount = 4M; AddFee(PawnLoan, FeeTypes.INTEREST, FeeStates.ASSESSED, 4M, false); AddFee(PawnLoan, FeeTypes.STORAGE, FeeStates.ASSESSED, 4M, false); AddFee(PawnLoan, FeeTypes.LATE, FeeStates.ASSESSED, 0M, false); PawnLoan.PartialPayments.Add(new PartialPayment { Date_Made = new DateTime(2012, 2, 14) }); Assert.AreEqual(0, PfiPickupCalculator.ApplicableFees.Count); PfiPickupCalculator.Calculate(); //WriteValues(); Assert.IsTrue(PfiPickupCalculator.HasPartialPayment); Assert.AreEqual(0, PfiPickupCalculator.MonthsAlreadyPaid); Assert.AreEqual(14, PfiPickupCalculator.DaysAlreadyPaid); Assert.AreEqual(1, PfiPickupCalculator.ApplicableFees.Count); Assert.AreEqual(88M, Math.Round(PfiPickupCalculator.PickupAmount, 2)); }
public void TestwithPartialPaymentBZ1494() { /**********************************************/ /*****SETUP OF LOAN****************************/ /*****NOT USING SAME LOAN AS OTHER TESTS*******/ /**********************************************/ PickupDate = new DateTime(2012, 3, 26); PawnLoan = new PawnLoan(); PawnLoan.InterestAmount = 14.48M; PawnLoan.ServiceCharge = 4M; PawnLoan.DateMade = new DateTime(2011, 10, 25); PawnLoan.DueDate = new DateTime(2012, 3, 25); PfiPickupCalculator = new PfiPickupCalculator(PawnLoan, TestSiteIds.Store00901, PickupDate); /**********************************************/ PawnLoan.CurrentPrincipalAmount = 289.5M; PawnLoan.PickupLateFinAmount = 30M; // not accurate values, but should sum correctly PawnLoan.PickupLateServAmount = 43.92M; // not accurate values, but should sum correctly AddFee(PawnLoan, FeeTypes.INTEREST, FeeStates.ASSESSED, 15M, false); AddFee(PawnLoan, FeeTypes.STORAGE, FeeStates.ASSESSED, 4M, false); AddFee(PawnLoan, FeeTypes.LATE, FeeStates.ASSESSED, 73.92M, false); PawnLoan.PartialPayments.Add(new PartialPayment { Date_Made = new DateTime(2011, 11, 9) }); Assert.AreEqual(0, PfiPickupCalculator.ApplicableFees.Count); PfiPickupCalculator.Calculate(); //WriteValues(); Assert.IsTrue(PfiPickupCalculator.HasPartialPayment); Assert.AreEqual(4, PfiPickupCalculator.MonthsToPay); Assert.AreEqual(15, PfiPickupCalculator.DaysToPay); Assert.AreEqual(3, PfiPickupCalculator.ApplicableFees.Count); Assert.AreEqual(372.66M, Math.Round(PfiPickupCalculator.PickupAmount, 2)); }
public void TestwithPartialPayment() { PawnLoan.CurrentPrincipalAmount = 80M; AddFee(PawnLoan, FeeTypes.INTEREST, FeeStates.ASSESSED, 5M, false); AddFee(PawnLoan, FeeTypes.STORAGE, FeeStates.ASSESSED, 4M, false); PawnLoan.PartialPayments.Add(new PartialPayment { Date_Made = new DateTime(2011, 9, 12) }); Assert.AreEqual(0, PfiPickupCalculator.ApplicableFees.Count); PfiPickupCalculator.Calculate(); //WriteValues(); Assert.IsTrue(PfiPickupCalculator.HasPartialPayment); Assert.AreEqual(0, PfiPickupCalculator.MonthsToPay); Assert.AreEqual(0, PfiPickupCalculator.DaysToPay); Assert.AreEqual(0, PfiPickupCalculator.ApplicableFees.Count); Assert.AreEqual(80M, Math.Round(PfiPickupCalculator.PickupAmount, 2)); }
private void LoadData() { var totalPickupAmt = 0.0M; PawnLoan pawnLoan = null; //If the loan is in service loan get the data from there else //get from pawnloans list var iDx = -1; var pawnloanToView = GlobalDataAccessor.Instance.DesktopSession.ServiceLoans; if (pawnloanToView.Count > 0) { iDx = pawnloanToView.FindIndex(pl => pl.TicketNumber == this._ticketNumber); } if (iDx < 0) { pawnloanToView = GlobalDataAccessor.Instance.DesktopSession.PawnLoans; iDx = GlobalDataAccessor.Instance.DesktopSession.PawnLoans.FindIndex(pl => pl.TicketNumber == this._ticketNumber); if (iDx < 0) { pawnloanToView = GlobalDataAccessor.Instance.DesktopSession.PawnLoans_Auxillary; iDx = GlobalDataAccessor.Instance.DesktopSession.PawnLoans_Auxillary.FindIndex( pl => pl.TicketNumber == this._ticketNumber); } } if (iDx >= 0) { pawnLoan = pawnloanToView[iDx]; } if (pawnLoan != null) { var pickupCalculator = new PfiPickupCalculator(pawnLoan, GlobalDataAccessor.Instance.DesktopSession.CurrentSiteId, ShopDateTime.Instance.FullShopDateTime); pickupCalculator.Calculate(); totalPickupAmt += pickupCalculator.PickupAmount; this.labelLoanNumber.Text = this._ticketNumber.ToString(); this.labelLoanAmount.Text = pawnLoan.Amount.ToString("c"); this.labelCurrentPrincipal.Text = pawnLoan.CurrentPrincipalAmount.ToString("c"); var currentRow = 0; CustomLabel feeName; CustomLabel feeValue; foreach (var feedata in pickupCalculator.ApplicableFees) { feeName = new CustomLabel(); feeValue = new CustomLabel(); if (feedata.FeeType == FeeTypes.LATE && feedata.Value < 0) { feeName.Text = "Refund:"; } else { feeName.Text = Commons.GetFeeName(feedata.FeeType) + ":"; } feeName.AutoSize = true; feeValue.AutoSize = true; feeName.Anchor = AnchorStyles.Right; feeValue.Anchor = AnchorStyles.Left; feeValue.Text = string.Format("{0:C}", feedata.Value); if (!string.IsNullOrEmpty(feeName.Text)) { this.tableLayoutPanelFees.Controls.Add(feeName, 0, currentRow); this.tableLayoutPanelFees.Controls.Add(feeValue, 1, currentRow); currentRow++; } } feeName = new CustomLabel(); feeValue = new CustomLabel(); feeName.AutoSize = true; feeValue.AutoSize = true; feeName.Anchor = AnchorStyles.Right; feeValue.Anchor = AnchorStyles.Left; feeName.Text = "Total Pickup Amount"; feeValue.Text = string.Format("{0:C}", totalPickupAmt); this.tableLayoutPanelFees.Controls.Add(feeName, 0, currentRow); this.tableLayoutPanelFees.Controls.Add(feeValue, 1, currentRow); } else { //no loan data to show Close(); } }
private void LoadData() { var totalPickupAmt = 0.0M; PawnLoan pawnLoan = null; //If the loan is in service loan get the data from there else //get from pawnloans list var iDx = -1; var pawnloanToView = GlobalDataAccessor.Instance.DesktopSession.ServiceLoans; if (pawnloanToView.Count > 0) { iDx = pawnloanToView.FindIndex(pl => pl.TicketNumber == this._ticketNumber); } if (iDx < 0) { pawnloanToView = GlobalDataAccessor.Instance.DesktopSession.PawnLoans; iDx = GlobalDataAccessor.Instance.DesktopSession.PawnLoans.FindIndex(pl => pl.TicketNumber == this._ticketNumber); if (iDx < 0) { pawnloanToView = GlobalDataAccessor.Instance.DesktopSession.PawnLoans_Auxillary; iDx = GlobalDataAccessor.Instance.DesktopSession.PawnLoans_Auxillary.FindIndex( pl => pl.TicketNumber == this._ticketNumber); } } if (iDx >= 0) { pawnLoan = pawnloanToView[iDx]; } if (pawnLoan != null) { var pickupCalculator = new PfiPickupCalculator(pawnLoan, GlobalDataAccessor.Instance.DesktopSession.CurrentSiteId, ShopDateTime.Instance.FullShopDateTime); pickupCalculator.Calculate(); totalPickupAmt += pickupCalculator.PickupAmount; this.labelLoanNumber.Text = this._ticketNumber.ToString(); this.labelLoanAmount.Text = pawnLoan.Amount.ToString("c"); //Don't show current principle if partial payments are not allowed. if (new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).IsPartialPaymentAllowed(GlobalDataAccessor.Instance.DesktopSession.CurrentSiteId)) { this.labelCurrentPrincipal.Text = pawnLoan.CurrentPrincipalAmount.ToString("c"); } else { //Hide the controls, remove the bottom row, and move the top alignment down for cosmetic purposes. var currentPrincipalRow = this.tableLayoutPanelPickupAmount.GetRow(this.labelCurrentPrincipalHeading); this.tableLayoutPanelPickupAmount.GetControlFromPosition(0, currentPrincipalRow).Visible = false; this.tableLayoutPanelPickupAmount.GetControlFromPosition(1, currentPrincipalRow).Visible = false; this.tableLayoutPanelPickupAmount.Top += 12; this.tableLayoutPanelPickupAmount.RowCount -= 1; } var currentRow = 0; CustomLabel feeName; CustomLabel feeValue; foreach (var feedata in pickupCalculator.ApplicableFees) { feeName = new CustomLabel(); feeValue = new CustomLabel(); if (feedata.FeeType == FeeTypes.LATE && feedata.Value < 0) { feeName.Text = "Refund:"; } else { feeName.Text = Commons.GetFeeName(feedata.FeeType) + ":"; } feeName.AutoSize = true; feeValue.AutoSize = true; feeName.Anchor = AnchorStyles.Right; feeValue.Anchor = AnchorStyles.Left; feeValue.Text = string.Format("{0:C}", feedata.Value); if (!string.IsNullOrEmpty(feeName.Text)) { this.tableLayoutPanelFees.Controls.Add(feeName, 0, currentRow); this.tableLayoutPanelFees.Controls.Add(feeValue, 1, currentRow); currentRow++; } } feeName = new CustomLabel(); feeValue = new CustomLabel(); feeName.AutoSize = true; feeValue.AutoSize = true; feeName.Anchor = AnchorStyles.Right; feeValue.Anchor = AnchorStyles.Left; feeName.Text = "Total Pickup Amount"; feeValue.Text = string.Format("{0:C}", totalPickupAmt); this.tableLayoutPanelFees.Controls.Add(feeName, 0, currentRow); this.tableLayoutPanelFees.Controls.Add(feeValue, 1, currentRow); } else { //no loan data to show Close(); } }