本文整理汇总了C#中OpenCBS.CoreDomain.Contracts.Loans.Loan.CalculateActualOlb方法的典型用法代码示例。如果您正苦于以下问题:C# Loan.CalculateActualOlb方法的具体用法?C# Loan.CalculateActualOlb怎么用?C# Loan.CalculateActualOlb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenCBS.CoreDomain.Contracts.Loans.Loan
的用法示例。
在下文中一共展示了Loan.CalculateActualOlb方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MembersOfGroup
public MembersOfGroup(List<Member> pMembers, Loan pLoan, DateTime pDate)
{
InitializeComponent();
_loan = pLoan;
_paymentDate = pDate;
OCurrency olb = _loan.CalculateActualOlb();
Member leader = null;
int roundTo = _loan.UseCents ? 2 : 0;
OCurrency loanAmount =
_loan.Events.GetLoanRepaymentEvents().Where(
rpe => rpe.RepaymentType == OPaymentType.PersonTotalPayment && !rpe.Deleted).Aggregate(
_loan.Amount, (current, rpe) => current - rpe.Principal);
foreach (Member person in pMembers)
{
OCurrency olbByPerson = 0;
OCurrency actualOlb = _loan.CalculateActualOlb();
foreach (LoanShare loanShare in _loan.LoanShares)
{
if (loanShare.PersonId == person.Tiers.Id && person.CurrentlyIn)
{
olbByPerson = actualOlb*loanShare.Amount/loanAmount;
}
}
olb -= Math.Round(olbByPerson.Value, roundTo);
// Define the list items
if (!person.IsLeader)
{
Color color = person.CurrentlyIn ? Color.Black : Color.Silver;
ListViewItem lvi = new ListViewItem {Tag = person, Text = ((Person) person.Tiers).Name};
lvi.UseItemStyleForSubItems = false;
lvi.ForeColor = color;
lvi.SubItems.Add(olbByPerson.GetFormatedValue(_loan.UseCents));
listViewMembers.Items.Add(lvi);
}
else
{
leader = person;
leader.LoanShareAmount = olbByPerson;
}
}
if (leader != null)
{
leader.LoanShareAmount += olb;
Color color = leader.CurrentlyIn ? Color.Red : Color.Silver;
ListViewItem lvi = new ListViewItem { Tag = leader, Text = ((Person)leader.Tiers).Name };
lvi.UseItemStyleForSubItems = false;
lvi.ForeColor = color;
lvi.SubItems.Add(leader.LoanShareAmount.GetFormatedValue(_loan.UseCents));
listViewMembers.Items.Add(lvi);
}
}
示例2: TestOLBCorrectlyCalculated
public void TestOLBCorrectlyCalculated()
{
LoanProduct package = new LoanProduct
{
InstallmentType = new InstallmentType(1, "Monthly", 0, 1),
LoanType = OLoanTypes.Flat,
ChargeInterestWithinGracePeriod = true,
Currency = new Currency {Id = 1},
KeepExpectedInstallment = false
};
Loan myContract = new Loan(package,1000,0.03m,6,2,new DateTime(2006,1,1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User()));
Assert.AreEqual(1000m,myContract.CalculateActualOlb().Value);
myContract.Repay(1,new DateTime(2006,2,1),30,true,false);
Assert.AreEqual(1000m,myContract.CalculateActualOlb().Value);
myContract.Repay(2,new DateTime(2006,3,1),30,true,false);
Assert.AreEqual(1000m,myContract.CalculateActualOlb().Value);
myContract.Repay(3,new DateTime(2006,4,3),280,true,false);
Assert.AreEqual(750m,myContract.CalculateActualOlb().Value);
}
示例3: SimulateRescheduling
public Loan SimulateRescheduling(Loan loan, ScheduleConfiguration rescheduleConfiguration)
{
var copyOfLoan = loan.Copy();
var scheduleConfiguration = _configurationFactory
.Init()
.WithLoan(copyOfLoan)
.Finish()
.GetConfiguration();
var schedule = Mapper.Map<IEnumerable<Installment>, IEnumerable<IInstallment>>(copyOfLoan.InstallmentList);
var scheduleBuilder = new ScheduleBuilder();
var rescheduleAssembler = new RescheduleAssembler();
var copyOfRescheduleConfiguration = (IScheduleConfiguration) rescheduleConfiguration.Clone();
copyOfRescheduleConfiguration.InterestRate *=
(decimal) scheduleConfiguration.PeriodPolicy.GetNumberOfPeriodsInYear(
copyOfRescheduleConfiguration.StartDate,
scheduleConfiguration.YearPolicy);
schedule = rescheduleAssembler.AssembleRescheduling(
schedule,
scheduleConfiguration,
copyOfRescheduleConfiguration,
scheduleBuilder,
loan.CalculateActualOlb().Value);
var newSchedule = Mapper.Map<IEnumerable<IInstallment>, List<Installment>>(schedule);
copyOfLoan.InstallmentList = newSchedule;
copyOfLoan.NbOfInstallments = newSchedule.Count();
return copyOfLoan;
}
示例4: AssembleRescheduling
private List<Installment> AssembleRescheduling(Loan loan, ScheduleConfiguration rescheduleConfiguration, IScheduleConfiguration scheduleConfiguration)
{
var copyOfLoan = loan.Copy();;
var schedule = copyOfLoan.InstallmentList;
// Build a new combined schedule
// 1. To close all active installments before date of rescheduling.
// Get the part of the schedule that comes before the rescheduling date...
var newSchedule =
from installment in schedule
where installment.ExpectedDate <= rescheduleConfiguration.StartDate
select installment;
// Get overpaid principal = sum of paid principal after the rescheduling date...
var overpaidPrincipal = (
from installment in schedule
where installment.PaidDate > rescheduleConfiguration.StartDate
select installment
).Sum(installment => installment.PaidCapital.Value);
//Add overpaid principal to paid principal of the last installment before the rescheduling
if (newSchedule.Any())
newSchedule.Last().PaidCapital += overpaidPrincipal;
// Close all active installments before date of rescheduling
var olbDifference = 0m;
foreach (var installment in newSchedule)
{
installment.OLB += olbDifference;
olbDifference += installment.CapitalRepayment.Value - installment.PaidCapital.Value;
installment.CapitalRepayment = installment.PaidCapital;
installment.InterestsRepayment = installment.PaidInterests;
}
// 2. To store amounts of interest paid, those for installments after date of rescheduling.
var overpaidInterest = (
from installment in schedule
where installment.ExpectedDate > rescheduleConfiguration.StartDate
select installment
).Sum(installment => installment.PaidInterests.Value);
// 3. To get total of first calculated interest. It will be interest between last closed installment and date of rescheduling
// plus interest between date of rescheduling and first repayment date
// To calculate extra interest for used days.
// For the case when date of rescheduling < date of first installment
var currentOlb = loan.CalculateActualOlb().Value;
var usedDays = 0;
if (newSchedule.Any())
{
usedDays = (rescheduleConfiguration.StartDate - newSchedule.Last().ExpectedDate).Days;
}
var daysInYear = scheduleConfiguration.YearPolicy.GetNumberOfDays(rescheduleConfiguration.StartDate);
var extraInterest = currentOlb * scheduleConfiguration.InterestRate / 100 * usedDays / daysInYear;
// To calculate interest between date of rescheduling and first repayment date.
var daysTillRepayment =
(rescheduleConfiguration.PreferredFirstInstallmentDate - rescheduleConfiguration.StartDate).Days;
decimal firstInterest = 0;
if (rescheduleConfiguration.GracePeriod == 0 || rescheduleConfiguration.ChargeInterestDuringGracePeriod)
firstInterest = currentOlb*rescheduleConfiguration.InterestRate/100*daysTillRepayment/
scheduleConfiguration.PeriodPolicy.GetNumberOfDays(
rescheduleConfiguration.PreferredFirstInstallmentDate);
copyOfLoan.Amount = currentOlb;
copyOfLoan.InterestRate = rescheduleConfiguration.InterestRate/100;
copyOfLoan.NbOfInstallments = rescheduleConfiguration.NumberOfInstallments;
copyOfLoan.GracePeriod = rescheduleConfiguration.GracePeriod;
copyOfLoan.StartDate = rescheduleConfiguration.StartDate;
copyOfLoan.FirstInstallmentDate = rescheduleConfiguration.PreferredFirstInstallmentDate;
copyOfLoan.Product.ChargeInterestWithinGracePeriod = rescheduleConfiguration.ChargeInterestDuringGracePeriod;
rescheduleConfiguration.RoundingPolicy = scheduleConfiguration.RoundingPolicy;
var rescheduled = SimulateScheduleCreation(copyOfLoan);
// Adjust the new schedule's installment numbers
var increment = newSchedule.Count();
foreach (var installment in rescheduled)
{
installment.Number += increment;
}
// Distribute the extra and overpaid interest
if (rescheduleConfiguration.GracePeriod > 0 && !rescheduleConfiguration.ChargeInterestDuringGracePeriod)
rescheduled[rescheduleConfiguration.GracePeriod].InterestsRepayment +=
rescheduleConfiguration.RoundingPolicy.Round(extraInterest);
else
rescheduled.First().InterestsRepayment =
rescheduleConfiguration.RoundingPolicy.Round(firstInterest + extraInterest);
foreach (var installment in rescheduled)
{
if (installment.InterestsRepayment < overpaidInterest)
{
installment.PaidInterests = installment.InterestsRepayment;
overpaidInterest -= installment.InterestsRepayment.Value;
}
else
{
installment.PaidInterests = overpaidInterest;
break;
//.........这里部分代码省略.........
示例5: SimulateRescheduling
public Loan SimulateRescheduling(Loan loan, ScheduleConfiguration rescheduleConfiguration)
{
var copyOfLoan = loan.Copy();
var scheduleConfiguration = _configurationFactory
.Init()
.WithLoan(copyOfLoan)
.Finish()
.GetConfiguration();
var schedule = copyOfLoan.InstallmentList;
var scheduleBuilder = new ScheduleBuilder();
var rescheduleAssembler = new RescheduleAssembler();
var copyOfRescheduleConfiguration = (IScheduleConfiguration)rescheduleConfiguration.Clone();
if (loan.Product.ScriptName == null)
schedule = rescheduleAssembler.AssembleRescheduling(
schedule,
scheduleConfiguration,
copyOfRescheduleConfiguration,
scheduleBuilder,
loan.CalculateActualOlb().Value).ToList();
else
schedule = AssembleRescheduling(loan, rescheduleConfiguration, scheduleConfiguration);
copyOfLoan.InstallmentList = schedule;
copyOfLoan.NbOfInstallments = schedule.Count();
return copyOfLoan;
}
示例6: Reschedule
public RescheduleLoanEvent Reschedule(ReschedulingOptions ro, Loan contract, NonWorkingDateSingleton nwdS, ApplicationSettings applicationSettings)
{
_contract = contract;
_nwdS = nwdS;
_generalSettings = applicationSettings;
switch (contract.Product.LoanType)
{
case OLoanTypes.Flat:
_Reschedule_Flat(ro);
break;
case OLoanTypes.DecliningFixedPrincipal:
_Reschedule_FixedPrincipal(ro);
break;
case OLoanTypes.DecliningFixedInstallments:
_Reschedule_DecliningFixedInstallments(ro);
break;
}
_Reschedule_AdjustOverpaid();
RescheduleLoanEvent rSe = new RescheduleLoanEvent
{
Date = ro.ReschedulingDate,
Amount = contract.CalculateActualOlb(),
Interest = contract.GetTotalInterestDue(),
ClientType = contract.ClientType,
BadLoan = contract.BadLoan,
NbOfMaturity = ro.NewInstallments,
DateOffset = ro.RepaymentDateOffset,
GracePeriod = ro.GracePeriod,
ChargeInterestDuringShift = ro.ChargeInterestDuringShift,
ChargeInterestDuringGracePeriod = ro.ChargeInterestDuringGracePeriod,
InstallmentNumber =
contract.GetLastFullyRepaidInstallment() == null
? 1
: contract.GetLastFullyRepaidInstallment().Number + 1
};
_contract.CalculateStartDates();
return rSe;
}
示例7: ShowLoanInListView
private void ShowLoanInListView(VillageMember member, Loan loan)
{
Person person = (Person)member.Tiers;
ApplicationSettings dataParam = ApplicationSettings.GetInstance(string.Empty);
int decimalPlaces = dataParam.InterestRateDecimalPlaces;
ListViewItem item = new ListViewItem(person.Name) { Tag = member };
if (loan == null || _village.EstablishmentDate==null) return;
if (loan.CreationDate.Date >= _village.EstablishmentDate.Value.Date && _village.Id == loan.NsgID)
{
item.SubItems.Add(loan.ProductName);
item.SubItems.Add(loan.Code);
item.SubItems.Add(MultiLanguageStrings.GetString(Ressource.ClientForm, loan.ContractStatus + ".Text"));
item.SubItems.Add(loan.Amount.GetFormatedValue(loan.UseCents));
item.SubItems.Add(
loan.CalculateActualOlb().GetFormatedValue(loan.UseCents));
item.SubItems.Add(loan.Product.Currency.Name);
item.SubItems.Add(Math.Round(loan.InterestRate*100m, decimalPlaces).ToString());
item.SubItems.Add(loan.InstallmentType.Name);
item.SubItems.Add(loan.NbOfInstallments.ToString());
item.SubItems.Add(loan.AlignDisbursementDate.ToShortDateString());
if (loan.GetLastNonDeletedEvent() != null) item.SubItems.Add(loan.GetLastNonDeletedEvent().Date.ToShortDateString());
else item.SubItems.Add("-");
if (loan.NextInstallment != null)
{
item.SubItems.Add(loan.NextInstallment.ExpectedDate.ToShortDateString());
item.SubItems.Add(
ServicesHelper.ConvertDecimalToString(loan.NextInstallment.Amount.Value));
}
else
{
item.SubItems.Add("-");
item.SubItems.Add("-");
}
item.SubItems.Add(loan.CloseDate.ToShortDateString());
if (member.LeftDate != null)
item.BackColor = Color.Red;
listViewLoans.Items.Add(item);
}
}