partial void DeleteContributionSchedule(ContributionSchedule instance);
 partial void UpdateContributionSchedule(ContributionSchedule instance);
		private void detach_ContributionSchedules(ContributionSchedule entity)
		{
			this.SendPropertyChanging();
			entity.Investment = null;
		}
 partial void InsertContributionSchedule(ContributionSchedule instance);
示例#5
0
    public static void GenerateContributionSchedule(int months, RepaymentFrequency repaymentFrequency, Investment currentLoan)
    {
        using (FinanceManagerDataContext db = new FinanceManagerDataContext())
        {

            decimal repaymentIntervals = (decimal)(currentLoan.MaturityDate.Value.Date - currentLoan.InvestmentCalculationStartDate.Value).Days / (repaymentFrequency.ConversionUnit.Value * (decimal)months);
            DateTime tempScheduleDate = currentLoan.InvestmentCalculationStartDate.Value;
            DateTime tempDate = currentLoan.InvestmentCalculationStartDate.Value;
            CompanyProfile cProfile = db.CompanyProfiles.FirstOrDefault();
            decimal balance = 0;
            for (decimal i = 0; i < Math.Round((currentLoan.MaturityDate.Value - currentLoan.InvestmentCalculationStartDate.Value).Days / repaymentIntervals, MidpointRounding.AwayFromZero); i++)
            {
                tempScheduleDate = tempDate = tempDate.AddDays((int)repaymentIntervals);
                if (tempScheduleDate.DayOfWeek == DayOfWeek.Sunday)
                {
                    tempScheduleDate = tempScheduleDate.AddDays(1);
                }
                else if (tempScheduleDate.DayOfWeek == DayOfWeek.Saturday)
                {
                    tempScheduleDate = tempScheduleDate.AddDays(2);
                }

                //decimal totalAmountContributed = db.Contributions.Where<Contribution>(cont => cont.InvestmentId == currentLoan.InvestmentID).Sum<Contribution>(c => c.ContributionAmount).Value;

                //update balance
                balance += currentLoan.ContributionFreqAmount.Value;

                var _contributionSchedule = new ContributionSchedule()
                {
                    IsContributionMade = false,
                    ExpectedContributionAmount = currentLoan.ContributionFreqAmount,
                    InvestmentId = currentLoan.InvestmentID,
                    ContributionDate = tempScheduleDate,
                    Balance = balance
                };

                db.SubmitChanges();
                db.ContributionSchedules.InsertOnSubmit(_contributionSchedule);

                //audit
                Utils.logAction("Insert", _contributionSchedule);
            }

            //DateTime.Now.Month

        }
    }