本文整理匯總了C#中OpenCBS.CoreDomain.Contracts.Loans.Loan.CalculateDuePenaltiesForInstallment方法的典型用法代碼示例。如果您正苦於以下問題:C# Loan.CalculateDuePenaltiesForInstallment方法的具體用法?C# Loan.CalculateDuePenaltiesForInstallment怎麽用?C# Loan.CalculateDuePenaltiesForInstallment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OpenCBS.CoreDomain.Contracts.Loans.Loan
的用法示例。
在下文中一共展示了Loan.CalculateDuePenaltiesForInstallment方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: lvContracts_SubItemEndEditing
private void lvContracts_SubItemEndEditing(object sender, UserControl.SubItemEndEditingEventArgs e)
{
if (4 == e.SubItem && e.Item.Tag != null)
{
e.Item.SubItems[e.SubItem].Tag = (OCurrency)decimal.Parse(e.DisplayText);
e.Item.SubItems[e.SubItem].Text = e.DisplayText;
}
if (5 == e.SubItem && e.Item.Tag != null)
{
e.Item.SubItems[e.SubItem].Tag = (OCurrency)decimal.Parse(e.DisplayText);
e.Item.SubItems[e.SubItem].Text = e.DisplayText;
}
var loan = new Loan();
if (4 == e.SubItem || 5 == e.SubItem || 9 == e.SubItem && e.Item.Tag != null)
{
loan = e.Item.Tag as Loan;
}
if (loan != null && loan.Id != 0)
{
Installment i = loan.GetFirstUnpaidInstallment();
bool disableFees = false;
var result = new KeyValuePair<Loan, RepaymentEvent>();
OCurrency penalties = (OCurrency)e.Item.SubItems[4].Tag;
OCurrency principal = result.Value == null ? i.PrincipalHasToPay : result.Value.Principal;
OCurrency interest = result.Value == null ? i.InterestHasToPay : result.Value.InterestPrepayment;
OCurrency total;
if (penalties != loan.CalculateDuePenaltiesForInstallment(i.Number, TimeProvider.Today))
disableFees = true;
total = (OCurrency)e.Item.SubItems[5].Tag;
if (e.SubItem == 5)
{
if (total < 0)
throw new ArithmeticException("Total cannot be negative.");
if (total > penalties)
{
OCurrency remainder = total - penalties;
if (remainder > interest)
{
remainder -= interest;
principal = remainder > principal ? principal : remainder;
remainder -= principal;
total = principal + interest + penalties + remainder;
}
else
{
interest = remainder;
principal = 0;
}
}
else
{
penalties = total;
principal = 0;
interest = 0;
}
}
e.Item.SubItems[2].Text = principal.GetFormatedValue(loan.UseCents);
e.Item.SubItems[2].Tag = principal;
e.Item.SubItems[3].Text = interest.GetFormatedValue(loan.UseCents);
e.Item.SubItems[3].Tag = interest;
e.Item.SubItems[4].Text = penalties.GetFormatedValue(loan.UseCents);
e.Item.SubItems[4].Tag = penalties;
e.Item.SubItems[5].Text = total.GetFormatedValue(loan.UseCents);
e.Item.SubItems[5].Tag = total;
if (e.Item.SubItems.Count > 9)
e.Item.SubItems[9].Tag = cbItem.SelectedItem;
if (5 == e.SubItem)
e.DisplayText = total.GetFormatedValue(loan.UseCents);
if (9 == e.SubItem)
e.DisplayText = cbItem.SelectedItem.ToString();
if (10 == e.SubItem)
e.Item.SubItems[10].Text = e.DisplayText;
int paymentOption = cbItem.SelectedIndex + 1;
KeyValuePair<Loan, RepaymentEvent> keyValuePair = CalculatePrincipalAndInterest(loan,
total.Value,
disableFees,
penalties.Value,
paymentOption);
if (keyValuePair.Value != null)
{
e.Item.SubItems[2].Text =
keyValuePair.Value.Principal.GetFormatedValue(loan.Product.UseCents);
e.Item.SubItems[2].Tag = keyValuePair.Value.Principal;
e.Item.SubItems[3].Text =
keyValuePair.Value.Interests.GetFormatedValue(loan.Product.UseCents);
e.Item.SubItems[3].Tag = keyValuePair.Value.Interests;
e.Item.SubItems[4].Text =
keyValuePair.Value.Penalties.GetFormatedValue(loan.Product.UseCents);
//.........這裏部分代碼省略.........