private List <DebtInfo> GetDebtInfo(QueryExpression qe) { using (FBCommonBLL bll = new FBCommonBLL()) { List <DebtInfo> result = new List <DebtInfo>(); qe.Include = new string[] { typeof(T_FB_BORROWAPPLYDETAIL).Name }; qe.OrderBy = new string[] { "PLANREPAYDATE" }; List <T_FB_BORROWAPPLYMASTER> list = bll.GetEntities <T_FB_BORROWAPPLYMASTER>(qe); list = list.OrderBy(item => item.PLANREPAYDATE).ToList(); result = list.CreateList(item => { DebtInfo debtInfo = new DebtInfo(); decimal?deblt = item.T_FB_BORROWAPPLYDETAIL.Sum(detail => { return(detail.UNREPAYMONEY); }); debtInfo.Debt = deblt == null ? 0 : deblt.Value; debtInfo.EmployeeID = item.OWNERID; debtInfo.OrderType = "T_FB_BORROWAPPLYMASTER"; debtInfo.OrderCode = item.BORROWAPPLYMASTERCODE; return(debtInfo); }); return(result); } }
private void btnAddNewDebtor_Click(object sender, RoutedEventArgs e) { using (ApplicationDBContext context = new ApplicationDBContext()) { var v = (from a in context.DebtInfos where a.FIO == txtFIO.Text select a).FirstOrDefault(); if (v == null) { DebtInfo d = new DebtInfo() { FIO = txtFIO.Text, Address = txtAddress.Text, Phone = txtTel.Text }; context.DebtInfos.Add(d); context.SaveChanges(); txtFIO.Text = txtAddress.Text = txtTel.Text = ""; txtFIO_Qarzdor.Text = d.FIO; Refresh_DG(); } else { MessageBox.Show("Этот человек зарегистрирован"); } } }
private void DG_AllDebtor_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { if (DG_AllDebtor.SelectedCells.Count > 0 && DG_AllDebtor.SelectedCells[0].IsValid) { DebtInfo pDebtInfo = new DebtInfo(); pDebtInfo = DG_AllDebtor.SelectedValue as DebtInfo; using (ApplicationDBContext context = new ApplicationDBContext()) { DebtInfo v = (from a in context.DebtInfos where a.FIO == pDebtInfo.FIO select a).FirstOrDefault(); if (v != null) { txtFIO_Qarzdor.Text = v.FIO; } else { MessageBox.Show("Ошибка!!!"); } } } } catch (Exception err) { MessageBox.Show(err.Message); } }
public void Create_PayoffNumberDays(string name, double balance, double min, double rate, int expected) { var i = new DebtInfo(name, (decimal)balance, (decimal)rate, (decimal)min); i.Should().NotBeNull(); i.PayoffDays.Should().Be(expected); }
public void Create_Percent(string name, double balance, double min, double rate) { var i = new DebtInfo(name, (decimal)balance, (decimal)rate, (decimal)min); i.Should().NotBeNull(); i.MinimumPercent.Should().Be((decimal)min / (decimal)balance); }
public async Task <IActionResult> CreateAsync([FromBody] DebtInfo debtInfo) { var next = debtInfo.ToDebt(); if (next == null) { return(BadRequest(new { message = "Информация о задолженности не передана." })); } var current = await _debtService.GetDebtByFieldsAsync(next); if (current == null) { // Добавляем новую запись await _debtService.CreateDebtAsync(next); return(Ok(next.Id)); } if (!next.Equals(current)) { // Изменяем либо перезаписываем запись, созданную не нами await _debtService.UpdateDebtAsync(current, next); return(Ok(next.Id)); } return(Ok(next.Id)); }
public void Create_PaymentReduction(string name, double balance, double min, double rate) { var i = new DebtInfo(name, (decimal)balance, (decimal)rate, (decimal)min); i.Should().NotBeNull(); i.CurrentPaymentReduction.Should().Be(i.CurrentPayment - i.AverageMonthlyInterest); }
public void Create_Payment(string name, double balance, double min, double rate) { var i = new DebtInfo(name, (decimal)balance, (decimal)rate, (decimal)min); i.Should().NotBeNull(); i.CurrentPayment.Should().Be(i.Balance > 0 ? i.Minimum + i.AdditionalPayment : 0); }
public DebtAmortizationItem(DebtInfo debt) { debtInfo = debt; Payment = debt.CurrentPayment; CurrentBalance = debt.Balance; MonthlyRate = Payment >= CurrentBalance ? 0 : debt.AverageMonthyPr; debtInfo = new DebtInfo(Name, RemainingBalance, debt.Rate, Payment); }
public void Create_PayoffMonths(string name, double balance, double min, double rate) { var i = new DebtInfo(name, (decimal)balance, (decimal)rate, (decimal)min); i.Should().NotBeNull(); i.PayoffMonths.Should() .Be(i.Balance > 0 ? (int)Math.Ceiling(i.Balance / i.CurrentPaymentReduction) : 0); }
public void Create_Balance(string name, double balance, double min, double rate) { var i = new DebtInfo(name, (decimal)balance, (decimal)rate, (decimal)min); i.Should().NotBeNull(); var newBalance = i.Balance - i.CurrentPaymentReduction; i.ApplyPayment(); i.Balance.Should().Be(DebtInfo.RoundUp(newBalance, 2)); }
public void GetAmortization(string name, double balance, double min, double rate, int expected) { var i = new DebtInfo(name, (decimal)balance, (decimal)rate, (decimal)min); var list = i.GetAmortization(); list.Count.Should().BeGreaterThan(0); Console.WriteLine(i); Console.WriteLine( $"\n{"Payment".PadRight(10)} | {"Interest".PadRight(8)} | {"Applied".PadRight(10)} | Remaining" + "\n-------------------------------------------------"); list.ForEach(Console.WriteLine); }
public static Debt ToDebt(this DebtInfo debtInfo) { var debt = new Debt { Id = debtInfo.Id, DebtorKey = debtInfo.DebtorId, DebtTypeKey = debtInfo.DebtTypeId, Year = debtInfo.Year, Month = debtInfo.Month, Count = debtInfo.Count, Cost = debtInfo.Cost, Description = debtInfo.Description, EditorKey = debtInfo.EditorId }; return(debt); }
//TODO:CR:B:2 Rewrite to use Entity Framework private static void UpdateDatabase(SqlConnection connection, string codeBase, DebtInfo info) { string sql = "INSERT INTO CodeDebt (CodeBase, SourcePath, SourceFile, Type, Initials, Criticality, Estimate, Comment, LineNumber, LineCount)" + " VALUES (@CodeBase, @SourcePath, @SourceFile, @Type, @Initials, @Criticality, @Estimate, @Comment, @LineNumber, @LineCount)"; using (SqlCommand cmd = new SqlCommand(sql, connection)) { cmd.Parameters.Add(new SqlParameter("@CodeBase", codeBase)); cmd.Parameters.Add(new SqlParameter("@SourcePath", info.SourcePath)); cmd.Parameters.Add(new SqlParameter("@SourceFile", info.SourceFile)); cmd.Parameters.Add(new SqlParameter("@Type", info.DebtType)); cmd.Parameters.Add(new SqlParameter("@Initials", info.Initials)); cmd.Parameters.Add(new SqlParameter("@Criticality", info.Criticality)); cmd.Parameters.Add(new SqlParameter("@Estimate", info.Estimate)); cmd.Parameters.Add(new SqlParameter("@Comment", info.Comments)); cmd.Parameters.Add(new SqlParameter("@LineNumber", info.LineNumber)); cmd.Parameters.Add(new SqlParameter("@LineCount", info.LineCount)); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); } }