public void TestProcessTransaction() { var account = new Account(); var client = AccountFactory.CreateTransactionClient(Utility.CreateSavingsAccountType(), account); client.ProcessTransaction(new Transaction { TransactionType = "Deposit", Amount = 100 }); var currentPosition = client.Positions.FirstOrDefault(b => b.PositionType == "Current"); Assert.AreEqual(100, currentPosition.Value); }
public void TestTransactions() { var account = new Account(); var client = AccountFactory.CreateTransactionClient(Utility.CreateLoanGivenAccountType(), account); client.ProcessTransaction(new Transaction { TransactionType = "Advance", Amount = 100 }); var currentPosition = client.Positions.FirstOrDefault(b => b.PositionType == "Principal"); Assert.AreEqual(100, currentPosition.Value); }
public void TestOptions() { DateTime startDate = new DateTime(2013, 3, 8); DateTime endDate = startDate.AddYears(25); var account = CreateLoanGivenAccount(startDate, endDate, Utility.CreateEuroZoneCalendar()); var client = AccountFactory.CreateTransactionClient(Utility.CreateLoanGivenAccountType(), account); client.Initialize(); var accrualOption = account.GetOption("AccrualOption"); Assert.AreEqual(4, accrualOption.OptionValues.Count()); Assert.AreEqual("Actual", accrualOption.OptionValues.First()); Assert.AreEqual("30/360", accrualOption.OptionValues.Last()); }
public void TestPaymentCalc() { DateTime startDate = new DateTime(2013, 3, 8); DateTime endDate = startDate.AddYears(25); Calendar calendar = Utility.CreateEuroZoneCalendar(); SessionState.Current.ValueDate = startDate; var account = CreateLoanGivenAccount(startDate, endDate, calendar); var client = AccountFactory.CreateTransactionClient(Utility.CreateLoanGivenAccountType(), account); //var client = new TransactRules.Runtime.LoanGiven { Account = account }; client.Initialize(); var accrualSchedule = account.GetSchedule("AccrualSchedule"); var interestSchedule = account.GetSchedule("InterestSchedule"); var redemptionSchedule = account.GetSchedule("RedemptionSchedule"); DateTime interestStart = new DateTime(2013, 3, 31); interestSchedule.StartDate = interestStart; interestSchedule.EndDate = endDate; interestSchedule.IncludeDates.Add(new ScheduleDate { Value = endDate }); redemptionSchedule.StartDate = interestStart; redemptionSchedule.EndDate = endDate; redemptionSchedule.IncludeDates.Add(new ScheduleDate { Value = endDate }); var accrualOption = account.GetOption("AccrualOption"); accrualOption.Value = "365"; client.CalculateInstaments(); var instalments = account.GetInstalments("Redemptions"); Assert.IsTrue(Math.Abs((decimal)2964.37 - instalments.First().Amount) < (decimal)0.01); Assert.IsTrue(Math.Abs((decimal)2964.37 - instalments.Last().Amount) < (decimal)0.01); }
public void TestSchedules() { DateTime startDate = new DateTime(2013, 3, 8); DateTime endDate = startDate.AddYears(25); Calendar calendar = Utility.CreateEuroZoneCalendar(); var account = CreateLoanGivenAccount(startDate, endDate, calendar); var client = AccountFactory.CreateTransactionClient(Utility.CreateLoanGivenAccountType(), account); client.Initialize(); var accrualSchedule = account.GetSchedule("AccrualSchedule"); var interestSchedule = account.GetSchedule("InterestSchedule"); DateTime interestStart = new DateTime(2013, 3, 31); interestSchedule.StartDate = interestStart; interestSchedule.EndDate = endDate; interestSchedule.IncludeDates.Add(new ScheduleDate { Value = endDate }); var accrualDates = accrualSchedule.GetAllDates(endDate); Assert.AreEqual(startDate, accrualDates.First()); Assert.AreEqual(endDate, accrualDates.Last()); Assert.AreEqual(endDate.Subtract(startDate).Days + 1, accrualDates.Count()); var interestDates = interestSchedule.GetAllDates(endDate); Assert.AreEqual(interestStart, interestDates.First()); Assert.AreEqual(new DateTime(2013, 4, 30), interestDates.Skip(1).First()); Assert.AreEqual(new DateTime(2013, 5, 31), interestDates.Skip(2).First()); Assert.AreEqual(new DateTime(2014, 2, 28), interestDates.Skip(11).First()); Assert.AreEqual(endDate, interestDates.Last()); }
public void TestForecast() { DateTime startDate = new DateTime(2013, 3, 8); DateTime endDate = startDate.AddYears(25); Calendar calendar = Utility.CreateEuroZoneCalendar(); SessionState.Current.ValueDate = startDate; var account = CreateLoanGivenAccount(startDate, endDate, calendar); var client = AccountFactory.CreateTransactionClient(Utility.CreateLoanGivenAccountType(), account); //var client = new TransactRules.Runtime.LoanGiven { Account = account }; client.Initialize(); var accrualSchedule = account.GetSchedule("AccrualSchedule"); var interestSchedule = account.GetSchedule("InterestSchedule"); DateTime interestStart = new DateTime(2013, 3, 31); interestSchedule.StartDate = interestStart; interestSchedule.EndDate = endDate; interestSchedule.IncludeDates.Add(new ScheduleDate { Value = endDate }); var accrualOption = account.GetOption("AccrualOption"); accrualOption.Value = "365"; client.Forecast(endDate); Assert.AreEqual((decimal)1333778.93, account.GetPosition("Principal").Value); Assert.IsTrue(account.GetPosition("InterestAccrued").Value < (decimal)0.005); Assert.AreEqual((decimal)709778.93, account.GetPosition("InterestCapitalized").Value); }