public void AddInstallments(string installedBy, params Installment[] installments) { if (string.IsNullOrEmpty(installedBy)) { throw new ApplicationException("MISSING_UPDATE_BY"); } if (installments == null || installments.Length < 1) { throw new ApplicationException("AT_LEAST_ONE_ITEM_REQUIRED"); } UpdatedBy = installedBy; UpdatedDate = DateTime.Now; foreach (var installment in installments) { Installments.Add(installment); var remaining = RemainingAmount(); if (remaining == 0) { Status = PaymentStatusEnum.PAID.ToString(); } else if (remaining <= 0) { Status = PaymentStatusEnum.OVERPAID.ToString(); installment.CustomerCredits.Add(new CustomerCredit("System", Math.Abs(remaining), installment.Id, CustomerIdmPartyId, CustomerName, CustomerAddress)); } } }
// First Installment always occurs on PaymentPlan creation date private void InitializeInstallments() { for (int interval = 0; interval < InstallmentCount; interval++) { Installments.Add(new Installment(OriginationDate.AddDays(interval * InstallmentIntervalDays), InstallmentAmount)); } Installments.OrderBy(i => i.Date); }
public IList <Installment> PendingInstallments() { var intervals = InstallmentIntervalOfDays; for (int i = 1; i < CountOfInstallations; i++) { var pendingInstallment = new Installment() { Id = Install.Id, Amount = Install.Amount * 1 / CountOfInstallations, Date = Install.Date.AddDays(intervals) }; Installments.Add(pendingInstallment); intervals = intervals + InstallmentIntervalOfDays; } return(Installments); }
// First Installment always occurs on PaymentPlan creation date private void InitializeInstallments() { var paymentAmountPerInstallment = TotalAmountDue / NumberOfInstallments; //initialize with first payment var initialPayment = new Installment(paymentAmountPerInstallment, OriginationDate); Installments.Add(initialPayment); var paymentDate = OriginationDate; //rest of the payments for (var i = 1; i < NumberOfInstallments; i++) { paymentDate = paymentDate.AddDays(InstallmentIntervalDays); var installmentPayment = new Installment(paymentAmountPerInstallment, paymentDate); Installments.Add(installmentPayment); } }
/// <summary> /// Read a direct payment session request result /// </summary> /// <param name="streamReader"></param> /// <param name="installments"></param> internal static void Read(XmlReader reader, Installments installments) { if (reader.IsEmptyElement) { XMLParserUtils.SkipNode(reader); return; } reader.ReadStartElement(SerializerHelper.Installments); reader.MoveToContent(); while (!reader.EOF) { if (XMLParserUtils.IsEndElement(reader, SerializerHelper.Installments)) { XMLParserUtils.SkipNode(reader); break; } if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case SerializerHelper.Installment: Installment installment = new Installment(); InstallmentSerializer.Read(reader, installment); installments.Add(installment); break; default: XMLParserUtils.SkipElement(reader); break; } } else { XMLParserUtils.SkipNode(reader); } } }
public Installment FirstInstallment() { if (Install.Amount < 0 || CountOfInstallations < 1) { throw new ArgumentException(); } var firstInstall = new Installment() { Id = Install.Id, Amount = Install.Amount * 1 / CountOfInstallations, Date = Install.Date }; if (Install.IsPending) { Install.IsPending = false; Installments.Add(firstInstall); PendingInstallments(); } return(firstInstall); }