public void Calculate() { ApplicableFees.Clear(); PickupAmount = PawnLoan.CurrentPrincipalAmount; DeterminePartialPaymentInfo(); refundAmount = 0; if (PawnLoan.IsExtended && PawnLoan.PartialPaymentPaid) { var extnReceipts = (from r in PawnLoan.Receipts where r.Event == ReceiptEventTypes.Extend.ToString() && r.RefTime > PawnLoan.LastPartialPaymentDate select r).Except(from r in PawnLoan.Receipts where r.Event == ReceiptEventTypes.VEX.ToString() && r.RefTime > PawnLoan.LastPartialPaymentDate select r); refundAmount = (from rcpt in extnReceipts select rcpt.Amount).Sum(); } else if (PawnLoan.IsExtended) { refundAmount = PawnLoan.ExtensionAmount; } foreach (var fee in PawnLoan.OriginalFees) { if (fee.Waived || fee.FeeState == FeeStates.VOID) { continue; } var feeValue = GetFeeValue(fee); if (feeValue != 0) { this.ApplicableFees.Add(new Fee { FeeType = fee.FeeType, CanBeProrated = fee.CanBeProrated, CanBeWaived = fee.CanBeWaived, FeeDate = fee.FeeDate, FeeRef = fee.FeeRef, FeeRefType = fee.FeeRefType, FeeState = fee.FeeState, OriginalAmount = fee.OriginalAmount, Prorated = fee.Prorated, Tag = fee.Tag, Value = feeValue, Waived = fee.Waived }); } this.PickupAmount += feeValue; } }
public void Calculate() { ApplicableFees.Clear(); PickupAmount = PawnLoan.CurrentPrincipalAmount; DeterminePartialPaymentInfo(); refundAmount = 0; if (PawnLoan.IsExtended && PawnLoan.PartialPaymentPaid) { var extnReceipts = (from r in PawnLoan.Receipts where r.Event == ReceiptEventTypes.Extend.ToString() && r.RefTime > PawnLoan.LastPartialPaymentDate select r); var voidExtnReceipts = (from r in PawnLoan.Receipts where r.Event == ReceiptEventTypes.VEX.ToString() && r.RefTime > PawnLoan.LastPartialPaymentDate select r); decimal extensionAmount = (from rcpt in extnReceipts select rcpt.Amount).Sum(); decimal voidExtensionAmount = (from rcpt in voidExtnReceipts select rcpt.Amount).Sum(); refundAmount = extensionAmount - voidExtensionAmount; } else if (PawnLoan.IsExtended) { refundAmount = PawnLoan.ExtensionAmount; } Fee lateFee = (from f in PawnLoan.OriginalFees where f.FeeType == FeeTypes.LATE select f).FirstOrDefault(); if (lateFee.FeeRef == 0 && lateFee.OriginalAmount == 0 && refundAmount > 0) { PawnLoan.OriginalFees.Add(new Fee { FeeType = FeeTypes.LATE, FeeDate = ShopDateTime.Instance.ShopDate, FeeRef = PawnLoan.TicketNumber, FeeRefType = FeeRefTypes.PAWN, FeeState = FeeStates.ASSESSED, OriginalAmount = refundAmount, Value = refundAmount }); } foreach (var fee in PawnLoan.OriginalFees) { if (fee.Waived || fee.FeeState == FeeStates.VOID) { continue; } var feeValue = GetFeeValue(fee); if (feeValue != 0) { this.ApplicableFees.Add(new Fee { FeeType = fee.FeeType, CanBeProrated = fee.CanBeProrated, CanBeWaived = fee.CanBeWaived, FeeDate = fee.FeeDate, FeeRef = fee.FeeRef, FeeRefType = fee.FeeRefType, FeeState = fee.FeeState, OriginalAmount = fee.OriginalAmount, Prorated = fee.Prorated, Tag = fee.Tag, Value = Math.Round(feeValue, 2), Waived = fee.Waived }); } this.PickupAmount += feeValue; } }