public void TestRescheduleOUT() { const int loanID = 6; //4182; // 1718; // 4439; //3534; Loan loan = new Loan(); ReschedulingArgument reModel = new ReschedulingArgument(); reModel.LoanType = loan.GetType() .AssemblyQualifiedName; reModel.LoanID = loanID; reModel.ReschedulingDate = DateTime.UtcNow.Date.AddDays(0); //new DateTime(2015, 10, 02); //reModel.ReschedulingRepaymentIntervalType = RepaymentIntervalTypes.Month; reModel.SaveToDB = false; reModel.RescheduleIn = false; reModel.PaymentPerInterval = 180m; reModel.StopFutureInterest = false; var s1 = new RescheduleLoan <Loan>(loan, reModel); s1.Context.UserID = 357; //25852; try { s1.Execute(); this.m_oLog.Debug("RESULT FOR OUT" + s1.Result.ToString()); // ReSharper disable once CatchAllClause } catch (Exception e) { Console.WriteLine(e); } }
public RescheduleLoanIN(ReschedulingArgument reschedulingArgument) { this.ReschedulingArguments = reschedulingArgument; this.Result = new ReschedulingResult(); this.Result.LoanID = this.ReschedulingArguments.LoanID; this.Result.ReschedulingRepaymentIntervalType = this.ReschedulingArguments.ReschedulingRepaymentIntervalType; this.Result.BlockAction = false; // used in client's calendar for re-date selecting and in strategy for validations this.Result.ReschedulingIntervalStart = DateTime.UtcNow.Date.AddDays(1); if (this.ReschedulingArguments.RescheduleIn) { this.Result.ReschedulingIntervalEnd = this.Result.ReschedulingIntervalStart.AddDays(30); } // if today date sent - set re-date to tomorrow, otherwise set the date that sent this.Result.FirstItemDate = (this.ReschedulingArguments.ReschedulingDate.Date == DateTime.UtcNow.Date) ? this.Result.ReschedulingIntervalStart : this.ReschedulingArguments.ReschedulingDate.Date; this.cultureInfo = new CultureInfo("en-GB"); this.emailToAddress = CurrentValues.Instance.EzbobTechMailTo; this.emailFromAddress = CurrentValues.Instance.MailSenderEmail; this.emailFromName = CurrentValues.Instance.MailSenderName; this.sendDebugMail = CurrentValues.Instance.ReschedulingDebugMail; this.toAddressDebugMail = CurrentValues.Instance.ReschedulingDebugMailAddress; }
} // AddLoanOptions public ReschedulingActionResult RescheduleLoan(int userID, int customerID, ReschedulingArgument reAgrs) { Type t; try { t = Type.GetType(reAgrs.LoanType); } catch (Exception e) { Log.Alert("Fail to get type from the argument {0}. ReschedulingArgument: {1}; error: {2}", reAgrs.LoanType, reAgrs, e); return(null); } // try if (t == null) { Log.Alert("Type t (of loan) not found"); return(null); } // if //Log.Debug("t is {0}, t.Name={1}", t, t.Name); ReschedulingResult result = new ReschedulingResult(); try { if (t.Name == "Loan") { RescheduleLoan <Loan> strategy; var amd = ExecuteSync(out strategy, customerID, userID, new Loan(), reAgrs); return(new ReschedulingActionResult { MetaData = amd, Value = strategy.Result }); } // if if (t.Name == "NL_Model") { //RescheduleLoan<NL_Model> strategy; // TODO } // if } catch (Exception e) { Log.Alert("Reschedule; exception: ", e.Message); result.Error = "InternalServerError"; } // try return(new ReschedulingActionResult { Value = result }); } // RescheduleLoan
public RescheduleLoan9Feb2016(T t, ReschedulingArgument reschedulingArgument) { this.ReschedulingArguments = reschedulingArgument; if (t.GetType() == typeof(Loan)) { this.tLoan = t as Loan; this.tNLLoan = null; this.loanRep = ObjectFactory.GetInstance <LoanRepository>(); this.loanRep.Clear(); } else if (t.GetType() == typeof(NL_Model)) { this.tNLLoan = t as NL_Model; this.tLoan = null; } this.Result = new ReschedulingResult(); this.Result.LoanID = this.ReschedulingArguments.LoanID; this.Result.ReschedulingRepaymentIntervalType = this.ReschedulingArguments.ReschedulingRepaymentIntervalType; this.Result.BlockAction = false; // used in client's calendar for re-date selecting and in strategy for validations this.Result.ReschedulingIntervalStart = DateTime.UtcNow.Date.AddDays(1); if (this.ReschedulingArguments.RescheduleIn) { this.Result.ReschedulingIntervalEnd = this.Result.ReschedulingIntervalStart.AddDays(30); } // if today date sent - set re-date to tomorrow, otherwise set the date that sent this.Result.FirstItemDate = (this.ReschedulingArguments.ReschedulingDate.Date == DateTime.UtcNow.Date) ? this.Result.ReschedulingIntervalStart : this.ReschedulingArguments.ReschedulingDate.Date; this.cultureInfo = new CultureInfo("en-GB"); this.emailToAddress = CurrentValues.Instance.EzbobTechMailTo; this.emailFromAddress = CurrentValues.Instance.MailSenderEmail; this.emailFromName = CurrentValues.Instance.MailSenderName; this.sendDebugMail = CurrentValues.Instance.ReschedulingDebugMail; this.toAddressDebugMail = CurrentValues.Instance.ReschedulingDebugMailAddress; }
public JsonResult RescheduleLoan(int loanID, DbConstants.RepaymentIntervalTypes?intervalType, // month/week decimal?AmountPerInterval, // for "out" reschedule bool?rescheduleIn, DateTime reschedulingDate, bool save = false, bool stopFutureInterest = false) { ReschedulingActionResult result = null; try { Loan loan = this._loans.Get(loanID); if (rescheduleIn != null) { ReschedulingArgument reModel = new ReschedulingArgument(); reModel.LoanType = loan.GetType().AssemblyQualifiedName; reModel.LoanID = loanID; reModel.SaveToDB = save; reModel.ReschedulingDate = reschedulingDate; if (intervalType != null) { reModel.ReschedulingRepaymentIntervalType = (DbConstants.RepaymentIntervalTypes)intervalType; } reModel.RescheduleIn = (bool)rescheduleIn; reModel.StopFutureInterest = stopFutureInterest; if (reModel.RescheduleIn == false) // "out" { reModel.PaymentPerInterval = AmountPerInterval; } // re strategy result = this.serviceClient.Instance.RescheduleLoan(this._context.User.Id, loan.Customer.Id, reModel); Log.Debug(string.Format("RescheduleLoanSubmitted: {0}, {1}", reModel, result.Value)); } } catch (Exception editex) { Log.Error("rescheduling editor EXCEPTION: " + editex); } return(result == null ? null : Json(result.Value)); }
private void RescheduleSetmodel(int loanID, EditLoanDetailsModel model) { var loan = this._loans.Get(loanID); model.Id = loanID; model.Options = this.loanOptionsRepository.GetByLoanId(model.Id) ?? LoanOptions.GetDefault(model.Id); Log.DebugFormat("RescheduleSetmodel: loanID: {2} model {0}, loan: {1}", model, loan, loanID); ReschedulingArgument renewModel = new ReschedulingArgument(); renewModel.LoanType = loan.GetType().AssemblyQualifiedName; renewModel.LoanID = loanID; renewModel.SaveToDB = false; renewModel.ReschedulingDate = DateTime.UtcNow; renewModel.ReschedulingRepaymentIntervalType = DbConstants.RepaymentIntervalTypes.Month; renewModel.RescheduleIn = true; try { ReschedulingActionResult result = this.serviceClient.Instance.RescheduleLoan(this._context.User.Id, loan.Customer.Id, renewModel); model.ReResultIn = result.Value; //Log.Debug(string.Format("IN=={0}, {1}", renewModel, result.Value)); // ReSharper disable once CatchAllClause } catch (Exception editex) { Log.Error(editex); } renewModel.RescheduleIn = false; renewModel.PaymentPerInterval = 0m; try { ReschedulingActionResult result = this.serviceClient.Instance.RescheduleLoan(this._context.User.Id, loan.Customer.Id, renewModel); model.ReResultOut = result.Value; //Log.Debug(string.Format("OUT=={0}, {1}", renewModel, result.Value)); // ReSharper disable once CatchAllClause } catch (Exception editex) { Log.Error(editex); } }
public void TestRescheduleIN() { const int loanID = 11; Loan loan = new Loan(); ReschedulingArgument reModel = new ReschedulingArgument(); reModel.LoanType = loan.GetType() .AssemblyQualifiedName; reModel.LoanID = loanID; reModel.ReschedulingDate = DateTime.UtcNow.Date.AddDays(5); //reModel.ReschedulingRepaymentIntervalType = RepaymentIntervalTypes.Month; reModel.RescheduleIn = true; reModel.SaveToDB = false; reModel.StopFutureInterest = true; try { var s = new RescheduleLoan <Loan>(loan, reModel); s.Context.UserID = 357; // 25852 s.Execute(); this.m_oLog.Debug("RESULT FOR IN" + s.Result.ToString()); // ReSharper disable once CatchAllClause } catch (Exception e) { Console.WriteLine(e); } }
public RescheduleLoanWithN(T t, ReschedulingArgument reschedulingArgument) : base(T t, ReschedulingArgument reschedulingArgument)
public void TestMultipleRescheduling() { /*var loans = new[] { * 18,19,20,22,29,30,31,32,33,34,36,37,38, 35, 4439, 3534, 1846, 2662, 1721,1758,1718,1764,1781,1795,1808,1810,1825,1831,1838,1841,1847,1856,1895,1903,1904, * 3456,3462,3476,3478,3509,3510,3513,3521,3533,3535,3538,3539,3547,3583,3593,3607,3651,3670,3700,3710,3711,3714,3754,3827,3860,3917,3946,4081,4139,4174,4183,4192, * 2990,2996,3003,3007,3032,3038,3083,3084,3094,3096,3113,3118,3141,3142,3166,3196,3208,3236,3275,3285,3302 * }; * // select top 10 * from [dbo].[Loan] l left join [dbo].[LoanScheduleDeleted] d on l.Id=d.LoanId where d.Id IS NULL and l.Status <> 'PaidOff' and YEAR(l.Date) = 2015 and DateClosed is null * foreach (var loanID in loans) { * try { * ReschedulingArgument reModel = new ReschedulingArgument(); * Loan loan = new Loan(); * reModel.LoanType = loan.GetType().AssemblyQualifiedName; * reModel.LoanID = loanID; * reModel.RescheduleIn = false; * reModel.SaveToDB = false; * reModel.ReschedulingDate = DateTime.UtcNow; * reModel.ReschedulingRepaymentIntervalType = RepaymentIntervalTypes.Month; * if (reModel.RescheduleIn == false) { * reModel.PaymentPerInterval = 900m; * } * var s = new RescheduleLoan<Loan>(loan, reModel); * s.Context.UserID = 25852; * s.Execute(); * m_oLog.Debug(s.Result.ToString()); * } catch (Exception e) { * Console.WriteLine(e); * } * }*/ Loan loan = new Loan(); this.m_oDB.ForEachRowSafe((sr) => { try { int loanid = sr["Id"]; // IN /* ReschedulingArgument reModel = new ReschedulingArgument(); * reModel.LoanID = loanid; * reModel.LoanType = loan.GetType().AssemblyQualifiedName; * reModel.RescheduleIn = true; * reModel.SaveToDB = false; * reModel.ReschedulingDate = DateTime.UtcNow.Date.AddDays(15); * reModel.ReschedulingRepaymentIntervalType = RepaymentIntervalTypes.Month; * var s = new RescheduleLoan<Loan>(loan, reModel); * s.Context.UserID = 357; //25852; * s.Execute(); * this.m_oLog.Debug(s.Result.ToString()); * this.m_oLog.Debug("IN_RESULT: {0}", s.Result.ToString());*/ // OUT ReschedulingArgument reModel1 = new ReschedulingArgument(); Loan loan1 = new Loan(); reModel1.LoanID = loanid; reModel1.LoanType = loan1.GetType() .AssemblyQualifiedName; reModel1.RescheduleIn = false; reModel1.SaveToDB = false; reModel1.ReschedulingDate = DateTime.UtcNow.Date.AddDays(44); reModel1.ReschedulingRepaymentIntervalType = RepaymentIntervalTypes.Month; reModel1.PaymentPerInterval = 90m; reModel1.StopFutureInterest = true; var s1 = new RescheduleLoan <Loan>(loan1, reModel1); s1.Context.UserID = 357; //25852; s1.Execute(); this.m_oLog.Debug("OUT_RESULT: {0}", s1.Result.ToString()); } catch (Exception e) { Console.WriteLine(e); } }, "select top 100 l.Id from [dbo].[Loan] l left join [dbo].[LoanScheduleDeleted] d on l.Id=d.LoanId where d.Id IS NULL and l.Status <> 'PaidOff' and DateClosed is null", // order by l.Id desc", // "select top 10 * from [dbo].[Loan] l left join [dbo].[LoanScheduleDeleted] d on l.Id=d.LoanId where d.Id IS NULL and l.Status <> 'PaidOff' and YEAR(l.Date) = 2015 and DateClosed is null order ", CommandSpecies.Text); //top 100 }