コード例 #1
0
        public async Task DeleteCreditAsyncShouldDeletePendingCredit(CreditStatus creditStatus, CreditStatus expected)
        {
            var options = new DbContextOptionsBuilder <PhotoparallelDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;
            var dbContext = new PhotoparallelDbContext(options);

            var credit = new CreditContract {
                CreditStatus = creditStatus
            };

            dbContext.CreditContracts.Add(credit);

            var order = new Order {
                OrderStatus = OrderStatus.Pending
            };

            dbContext.Orders.Add(order);

            credit.Order = order;

            await dbContext.SaveChangesAsync();

            var ordersService = new Mock <IOrdersService>();

            var creditsService = new CreditsService(dbContext, ordersService.Object);

            await creditsService.DeleteCreditAsync(credit.Id);

            Assert.Equal(expected, credit.CreditStatus);
        }
コード例 #2
0
        public async Task FinishCreditAsync(CreditContract credit)
        {
            credit.IssuedOn     = DateTime.UtcNow.AddHours(GlobalConstants.BulgarianHoursFromUtcNow);
            credit.ActiveUntil  = DateTime.UtcNow.AddHours(GlobalConstants.BulgarianHoursFromUtcNow).AddMonths(credit.Months);
            credit.CreditStatus = CreditStatus.Pending;

            this.context.Update(credit);
            await this.context.SaveChangesAsync();
        }
コード例 #3
0
ファイル: CreditController.cs プロジェクト: GoldKolt/prs
        // GET: Credit/Delete/5
        public async Task <IActionResult> Delete(int id)
        {
            CreditContract contract = await _context.CreditContracts.Include(c => c.Accounts).Include(c => c.User).FirstAsync(c => c.Id == id);

            CreditContractViewModel vm             = _mapper.Map <CreditContractViewModel>(contract);
            CreditAccount           account        = contract.Accounts.FirstOrDefault(a => !a.IsForPercents);
            CreditAccount           percentAccount = contract.Accounts.FirstOrDefault(a => a.IsForPercents);

            vm.CreditAmount  = account?.Credit.ToString("F");
            vm.CreditPercent = percentAccount?.Saldo.ToString("F");
            vm.UserName      = string.Format("{0} {1} {2}", contract.User.Surname, contract.User.FirstName, contract.User.SecondName);
            return(View(vm));
        }
コード例 #4
0
ファイル: CreditController.cs プロジェクト: GoldKolt/prs
        public async Task <IActionResult> Pay(int id)
        {
            try
            {
                CreditContract contract = await _context.CreditContracts
                                          .Include(c => c.Credit).FirstOrDefaultAsync(c => c.Id == id);

                if (contract == null)
                {
                    return(RedirectToAction("Details", new { id }));
                }
                Account frbAccount = await _context.Accounts.FirstAsync(a => a.Name == "frb");

                Account cashRegisterAccount = await _context.Accounts.FirstAsync(a => a.Name == "cash");

                IEnumerable <CreditAccount> accounts = await _context.CreditAccounts.Where(da => da.CreditContractId == contract.Id).ToListAsync();

                CreditAccount account        = accounts.First(a => !a.IsForPercents);
                CreditAccount percentAccount = accounts.First(a => a.IsForPercents);

                decimal sum = 0;
                if (contract.Credit.HasAnnuityPayments)
                {
                    double i = (double)contract.Credit.Rate / 12;
                    double k = (i * Math.Pow(i + 1, contract.Credit.Term)) / (Math.Pow(i + 1, contract.Credit.Term) - 1);
                    sum = (decimal)k * contract.CreditAmount - percentAccount.Saldo;
                }
                else
                {
                    decimal osn  = contract.CreditAmount / contract.Credit.Term;
                    decimal proc = (2 * contract.CreditAmount - account.Debet) * contract.Credit.Rate / 365 * 30;
                    sum = osn + proc - percentAccount.Saldo;
                }

                PaymentForCredit(ref cashRegisterAccount, ref account, sum);
                PaymentForPercents(ref cashRegisterAccount, ref percentAccount, percentAccount.Saldo);

                _context.Accounts.Update(account);
                _context.Accounts.Update(percentAccount);
                _context.Accounts.Update(frbAccount);
                _context.Accounts.Update(cashRegisterAccount);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
コード例 #5
0
        public async Task SetCreditDetailsAsync(CreditContract creditContract, Order order, string address, CreditCompany creditCompany, decimal salary, int months, string ucn, string idNumber)
        {
            creditContract.CreditCompany = creditCompany;
            creditContract.Address       = address;
            creditContract.Months        = months;
            creditContract.PricePerMonth = Math.Round(order.TotalPrice / months, 2) + Math.Round((order.TotalPrice * (creditCompany.Interest / GlobalConstants.HundredPercent)) / GlobalConstants.MonthsInYear, 2);
            creditContract.TotalAmount   = months * creditContract.PricePerMonth;
            creditContract.ActiveUntil   = DateTime.UtcNow.AddHours(GlobalConstants.BulgarianHoursFromUtcNow).AddMonths(months);
            creditContract.Customer      = order.Customer;
            creditContract.Order         = order;
            creditContract.Salary        = salary;
            creditContract.Ucn           = ucn;
            creditContract.IdNumber      = idNumber;

            this.context.Update(creditContract);
            await this.context.SaveChangesAsync();
        }
コード例 #6
0
        public async Task <CreditContract> GetOpenCreditsByUserIdAsync(string customerId)
        {
            var openCredit = await this.context.CreditContracts
                             .SingleOrDefaultAsync(x => x.CustomerId == customerId && x.CreditStatus == CreditStatus.Open);

            if (openCredit == null)
            {
                openCredit = new CreditContract()
                {
                    CustomerId = customerId,
                };

                this.context.Add(openCredit);
                await this.context.SaveChangesAsync();
            }

            return(openCredit);
        }
コード例 #7
0
ファイル: CreditController.cs プロジェクト: GoldKolt/prs
        public async Task <IActionResult> Delete(int id, IFormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
                CreditContract contract = await _context.CreditContracts.Include(c => c.Accounts).FirstAsync(c => c.Id == id);

                _context.CreditAccounts.RemoveRange(contract.Accounts);
                _context.CreditContracts.Remove(contract);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
コード例 #8
0
        public async Task GetCreditByIdAsyncShouldNotReturnOpenCredit()
        {
            var options = new DbContextOptionsBuilder <PhotoparallelDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;
            var dbContext = new PhotoparallelDbContext(options);

            var credit = new CreditContract {
                CreditStatus = CreditStatus.Open,
            };

            dbContext.CreditContracts.Add(credit);
            await dbContext.SaveChangesAsync();

            var ordersService = new Mock <IOrdersService>();

            var creditsService = new CreditsService(dbContext, ordersService.Object);

            var searchedCredit = await creditsService.GetCreditByIdAsync(credit.Id);

            Assert.Null(searchedCredit);
        }
コード例 #9
0
        public async Task FinishCreditAsyncShouldChangeCreditStatusToPending()
        {
            var options = new DbContextOptionsBuilder <PhotoparallelDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;
            var dbContext = new PhotoparallelDbContext(options);

            var credit = new CreditContract {
                CreditStatus = CreditStatus.Open, Months = 12
            };

            dbContext.CreditContracts.Add(credit);
            await dbContext.SaveChangesAsync();

            var ordersService = new Mock <IOrdersService>();

            var creditsService = new CreditsService(dbContext, ordersService.Object);

            await creditsService.FinishCreditAsync(credit);

            Assert.Equal(CreditStatus.Pending, credit.CreditStatus);
            Assert.Equal(DateTime.UtcNow.ToString("dd/MM/YYYY"), credit.IssuedOn.ToString("dd/MM/YYYY"));
            Assert.Equal(DateTime.UtcNow.AddMonths(credit.Months).ToString("dd/MM/YYYY"), credit.ActiveUntil.ToString("dd/MM/YYYY"));
        }
コード例 #10
0
ファイル: CreditController.cs プロジェクト: GoldKolt/prs
        public async Task <IActionResult> Create(CreditContractViewModel vm)
        {
            try
            {
                decimal amount = decimal.Parse(vm.CreditAmount);
                if (amount > 1000000 || amount < 10)
                {
                    return(View("Error"));
                }
                CreditContract contract = _mapper.Map <CreditContract>(vm);
                Credit         credit   = _context.Credits.Find(vm.CreditId);
                User           user     = await _context.Users.FindAsync(contract.UserId);

                int count = await _context.Accounts.Where(a => a.UserId == user.Id).CountAsync();

                contract.EndDate = contract.BeginDate.AddMonths(credit.Term);
                await _context.CreditContracts.AddAsync(contract);

                await _context.SaveChangesAsync();

                Account cashRegisterAccount = await _context.Accounts.FirstOrDefaultAsync(a => a.Name == "cash");

                Account frbAccount = await _context.Accounts.FirstOrDefaultAsync(a => a.Name == "frb");

                CreditAccount account = new CreditAccount()
                {
                    IsActive         = false,
                    CreditContractId = contract.Id,
                    Credit           = 0,
                    Debet            = 0,
                    Saldo            = 0,
                    IsForPercents    = false,
                    UserId           = user.Id,
                    Number           = "2400" + user.Id.ToString("00000") + (count + 1).ToString("000") + '1',
                    Name             = user.Surname + " " + user.FirstName + " " + user.SecondName
                };
                CreditAccount percentAccount = new CreditAccount()
                {
                    IsActive         = false,
                    CreditContractId = contract.Id,
                    Credit           = 0,
                    Debet            = 0,
                    Saldo            = 0,
                    IsForPercents    = true,
                    UserId           = user.Id,
                    Number           = "2470" + user.Id.ToString("00000") + (count + 2).ToString("000") + '2',
                    Name             = user.Surname + " " + user.FirstName + " " + user.SecondName
                };
                GiveCreditToClient(ref frbAccount, ref account, amount);
                Card card = new Card()
                {
                    Account = account,
                    Pin     = Math.Abs(account.Number.GetHashCode()).ToString("0000").Substring(0, 4),
                    Number  = "9112" + Math.Abs(contract.Number.GetHashCode()).ToString("00000000").Substring(0, 8),
                    Balance = amount
                };
                await _context.CreditAccounts.AddAsync(account);

                await _context.CreditAccounts.AddAsync(percentAccount);

                _context.Accounts.Update(frbAccount);
                _context.Accounts.Update(cashRegisterAccount);
                await _context.Cards.AddAsync(card);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View(vm));
            }
        }
コード例 #11
0
        private IActionResult Edited(Credit credit)
        {
            using (var transaction = _context.Database.BeginTransaction())
            {
                CreditCalculate           calculate     = new CreditCalculate();
                CreditContract            contract      = new CreditContract();
                List <CreditContractItem> contractItems = new List <CreditContractItem>();

                try
                {
                    calculate     = credit.creditCalculate;
                    contract      = credit.creditContract;
                    contractItems = credit.creditContactItem.ToList();

                    // Calculate
                    calculate.UpdateDate = DateTime.Now;
                    _context.Update(calculate);
                    _context.SaveChanges();

                    // Contract
                    contract.UpdateDate = DateTime.Now;
                    _context.Update(contract);
                    _context.SaveChanges();

                    // ContractItem
                    var contItem = _context.CreditContractItem.Where(o => o.ContractId == contract.ContractId).ToList();
                    _context.RemoveRange(contItem);
                    _context.SaveChanges();

                    foreach (var item in contractItems)
                    {
                        item.ContractId = contract.ContractId;
                        item.RefNo      = contract.RefNo;

                        //item.PayPrice = item.Balance;
                        //item.PayVatPrice = item.BalanceVatPrice;
                        //item.PayNetPrice = item.BalanceNetPrice;
                        // สถานะยังไม่ชำระ
                        item.Status = 13;

                        item.CreateBy   = contract.CreateBy;
                        item.CreateDate = DateTime.Now;
                        item.UpdateBy   = contract.UpdateBy;
                        item.UpdateDate = DateTime.Now;
                    }

                    _context.CreditContractItem.AddRange(contractItems);
                    _context.SaveChanges();


                    transaction.Commit();

                    var obj = new Dictionary <string, object>
                    {
                        { "contractId", contract.ContractId }
                    };

                    return(Ok(obj));
                } catch (Exception ex) {
                    transaction.Rollback();
                    return(StatusCode(500, ex.Message));
                }
            }
        }
コード例 #12
0
        private IActionResult Reviced(Credit credit)
        {
            using (var transaction = _context.Database.BeginTransaction())
            {
                CreditCalculate           calculate     = new CreditCalculate();
                CreditContract            contract      = new CreditContract();
                List <CreditContractItem> contractItems = new List <CreditContractItem>();
                Models.Booking            booking       = new Models.Booking();

                try
                {
                    calculate     = credit.creditCalculate;
                    contract      = credit.creditContract;
                    contractItems = credit.creditContactItem.ToList();
                    booking       = _context.Booking.FirstOrDefault(b => b.BookingId == contract.BookingId);

                    // Calculate
                    calculate.UpdateDate = DateTime.Now;
                    _context.CreditCalculate.Update(calculate);
                    _context.SaveChanges();

                    // Contract
                    contract.UpdateDate = DateTime.Now;
                    contract.RefNo      = GenerateReferenceContract(contract.ContractId);
                    _context.CreditContract.Update(contract);
                    _context.SaveChanges();

                    // ContractItem
                    foreach (var item in contractItems)
                    {
                        item.ContractId = contract.ContractId;
                        item.RefNo      = contract.RefNo;

                        //item.PayPrice = item.Balance;
                        //item.PayVatPrice = item.BalanceVatPrice;
                        //item.PayNetPrice = item.BalanceNetPrice;
                        // สถานะยังไม่ชำระ
                        item.Status = 13;

                        item.CreateBy   = contract.CreateBy;
                        item.CreateDate = DateTime.Now;
                        item.UpdateBy   = contract.UpdateBy;
                        item.UpdateDate = DateTime.Now;
                    }

                    _context.CreditContractItem.AddRange(contractItems);
                    _context.SaveChanges();

                    // ค้นห่อผู้เช่าซื้อด้วยรหัส
                    var __branch = _context.Branch.SingleOrDefault(x => x.BranchId == 1);

                    var __company = _context.Company.FirstOrDefault(x => x.ComId == 1);

                    // Booking
                    if (booking.SellDate == null)
                    {
                        booking.SellDate = DateTime.Now;
                    }

                    booking.ReturnDepostit = calculate.ReturnDeposit;
                    // กรณีมีการคืนเงินมัดจำ
                    if (calculate.ReturnDeposit == 1 && booking.ReturnDepostit == 0)
                    {
                        booking.ReturnDepositPrice = calculate.ReturnDepositPrice;
                        booking.ReturnDepNo        = iSysParamService.GeerateeReturnDepositNo((int)contract.BranchId);
                        booking.ReturnDepBy        = contract.CreateBy;
                        booking.ReturnDepDate      = DateTime.Now;
                    }
                    else if (calculate.ReturnDeposit == 0)
                    {
                        booking.ReturnDepositPrice = 0;
                    }

                    booking.BookingStatus      = 2; // สถานะขาย
                    booking.PaymentPrice       = calculate.DepositPrice;
                    booking.PaymentType        = booking.BookingDepositType;
                    booking.CusSellName        = __company.ComName;
                    booking.CusTaxNo           = __branch.BranchRegisterNo;
                    booking.SellBy             = contract.CreateBy;
                    booking.LStartDate         = calculate.FirstPayment.ToString("yyyy-MM-dd");
                    booking.LPayDay            = calculate.DueDate;
                    booking.LTerm              = calculate.InstalmentEnd;
                    booking.LInterest          = calculate.Interest;
                    booking.LPriceTerm         = calculate.InstalmentPrice;
                    booking.ReturnDepositPrice = calculate.ReturnDeposit;

                    // กรณีมีการคืนเงินมัดจำ
                    if (calculate.ReturnDeposit == 1 && booking.ReturnDepostit == 0)
                    {
                        booking.ReturnDepositPrice = calculate.ReturnDepositPrice;
                        booking.ReturnDepNo        = iSysParamService.GeerateeReturnDepositNo((int)contract.BranchId);
                        booking.ReturnDepBy        = contract.CreateBy;
                        booking.ReturnDepDate      = DateTime.Now;
                    }

                    _context.Booking.Update(booking);
                    _context.SaveChanges();

                    transaction.Commit();

                    var obj = new Dictionary <string, object>
                    {
                        { "contractId", contract.ContractId }
                    };

                    return(Ok(obj));
                } catch (Exception ex) {
                    transaction.Rollback();
                    return(StatusCode(500, ex.Message));
                }
            }
        }
コード例 #13
0
        private IActionResult Created(Credit credit)
        {
            using (var transaction = _context.Database.BeginTransaction())
            {
                CreditCalculate           calculate     = new CreditCalculate();
                CreditContract            contract      = new CreditContract();
                List <CreditContractItem> contractItems = new List <CreditContractItem>();

                try{
                    calculate     = credit.creditCalculate;
                    contract      = credit.creditContract;
                    contractItems = credit.creditContactItem.ToList();

                    // Calculate
                    calculate.CreateDate = DateTime.Now;
                    _context.CreditCalculate.Add(calculate);
                    _context.SaveChanges();

                    // Contract
                    contract.CalculateId = calculate.CalculateId;
                    contract.RefNo       = GenerateReferenceContract(null);
                    contract.ContractNo  = iSysParamService.GenerateContractNo((int)contract.BranchId);
                    contract.CreateDate  = DateTime.Now;
                    _context.CreditContract.Add(contract);
                    _context.SaveChanges();

                    // ContractItem
                    foreach (var item in contractItems)
                    {
                        item.ContractId = contract.ContractId;
                        item.RefNo      = contract.RefNo;

                        item.PayPrice    = item.Balance;
                        item.PayVatPrice = item.BalanceVatPrice;
                        item.PayNetPrice = item.BalanceNetPrice;

                        item.Status = 13; // สถานะยังไม่ชำระ

                        item.CreateBy   = contract.CreateBy;
                        item.CreateDate = DateTime.Now;
                    }

                    _context.CreditContractItem.AddRange(contractItems);
                    _context.SaveChanges();

                    // หลังจากเลือกรายการที่ค้นหาแล้วให้เอา log_id ที่ได้มาเก็บตอนทำการขาย
                    // มีเงื่อนไขโดย itemDetailType==1(สินค้าประเภทรถ)
                    var bookItem = _context.BookingItem.FirstOrDefault(x => x.BookingId == contract.BookingId && x.ItemDetailType == 1);
                    if (bookItem != null)
                    {
                        bookItem.LogReceiveId = calculate.LogReceiveId;
                        _context.BookingItem.Update(bookItem);
                        _context.SaveChanges();
                    }

                    var stockReceive = _context.StockReceive.FirstOrDefault(x => x.LogId == calculate.LogReceiveId);
                    if (stockReceive != null)
                    {
                        stockReceive.BalanceQty = stockReceive.BalanceQty - 1;
                        _context.StockReceive.Update(stockReceive);
                        _context.SaveChanges();
                    }

                    transaction.Commit();

                    var obj = new Dictionary <string, object>
                    {
                        { "contractId", contract.ContractId }
                    };

                    return(Ok(obj));
                } catch (Exception ex) {
                    transaction.Rollback();

                    return(StatusCode(500, ex.Message));
                }
            }
        }
コード例 #14
0
        public IActionResult Detail(int contractId)
        {
            try
            {
                var detail = (from db in ctx.CreditContract

                              join _branch in ctx.Branch on db.BranchId equals _branch.BranchId into a1
                              from branch in a1.DefaultIfEmpty()

                              join _contractType in ctx.MContractType on db.ContractType equals _contractType.TypeCode into a2
                              from contractType in a2.DefaultIfEmpty()

                              join _areaPayment in ctx.Branch on db.AreaPayment equals _areaPayment.BranchId into a3
                              from areaPayment in a3.DefaultIfEmpty()

                              join _contractGroup in ctx.MContractGroup on db.ContractGroup equals _contractGroup.GroupCode into a4
                              from contractGroup in a4.DefaultIfEmpty()

                              join _status in ctx.MStatus on db.ContractStatus equals _status.Id into a5
                              from status in a5.DefaultIfEmpty()

                              join _contractPoint in ctx.Zone on db.ContractPoint equals _contractPoint.ZoneId into a6
                              from contractPoint in a6.DefaultIfEmpty()

                              join _contrachHire in ctx.MCustomer on db.ContractHire equals _contrachHire.CustomerCode into a7
                              from contrachHire in a7.DefaultIfEmpty()

                              join _contractMate in ctx.MCustomer on db.ContractMate equals _contractMate.CustomerCode into a8
                              from contractMate in a8.DefaultIfEmpty()

                              join _contractBooking in ctx.MCustomer on db.ContractBooking equals _contractBooking.CustomerCode into a9
                              from contractBooking in a9.DefaultIfEmpty()

                              join _gurantor1 in ctx.MCustomer on db.ContractGurantor1 equals _gurantor1.CustomerCode into a10
                              from gurantor1 in a10.DefaultIfEmpty()

                              join _gurantor2 in ctx.MCustomer on db.ContractGurantor2 equals _gurantor2.CustomerCode into a11
                              from gurantor2 in a11.DefaultIfEmpty()

                              join _relation1 in ctx.MRelation on db.GurantorRelation1 equals _relation1.Id into a12
                              from relation1 in a12.DefaultIfEmpty()

                              join _relation2 in ctx.MRelation on db.GurantorRelation2 equals _relation2.Id into a13
                              from relation2 in a13.DefaultIfEmpty()

                              join _created in ctx.User on db.CreatedBy equals _created.Id into a14
                              from created in a14.DefaultIfEmpty()

                              join _checked in ctx.User on db.CreatedBy equals _checked.Id into a15
                              from checkedBy in a15.DefaultIfEmpty()

                              join _approve in ctx.User on db.ApprovedBy equals _approve.Id into a16
                              from approve in a16.DefaultIfEmpty()

                              join _keeper in ctx.User on db.KeeperBy equals _keeper.Id into a17
                              from keeper in a17.DefaultIfEmpty()

                              where db.ContractId == contractId

                              select new CreditContractDetail
                {
                    ContractId = contractId,
                    ContractNo = db.ContractNo,
                    ContractType = contractType.TypeDesc,
                    ContractDate = db.ContractDate,
                    AreaPayment = areaPayment.BranchName,
                    ContractPoint = contractPoint.ZoneName,
                    ContractGroup = contractGroup.GroupDesc,
                    ContractHire = $"{contrachHire.CustomerPrename}{contrachHire.CustomerName} {contrachHire.CustomerSurname}",
                    ContractMate = $"{contractMate.CustomerPrename}{contractMate.CustomerName} {contractMate.CustomerSurname}",
                    ContractBooking = $"{contractBooking.CustomerPrename}{contractBooking.CustomerName} {contractBooking.CustomerSurname}",
                    ContractGurantor1 = $"{gurantor1.CustomerPrename}{gurantor1.CustomerName} {gurantor1.CustomerSurname}",
                    GurantorRelation1 = relation1.RelationDesc,
                    ContractGurantor2 = $"{gurantor2.CustomerPrename}{gurantor2.CustomerName} {gurantor2.CustomerSurname}",
                    GurantorRelation2 = relation2.RelationDesc,
                    CreatedBy = created.FullName,
                    CheckedBy = checkedBy.FullName,
                    ApprovedBy = approve.FullName,
                    KeeperBy = keeper.FullName,
                    StatusDesc = status.StatusDesc,
                    Remark = db.Remark
                }).SingleOrDefault();

                CreditContract contract = ctx.CreditContract.Where(o => o.ContractId == contractId).SingleOrDefault();

                var __branch = ctx.Branch.SingleOrDefault(x => x.BranchId == 1);

                var __company = ctx.Company.FirstOrDefault(x => x.ComId == 1);

                var booking = iBookService.GetBookingById(contract.BookingId);
                booking.CusTaxNo     = __branch.BranchRegisterNo;
                booking.CusTaxBranch = __branch.BranchName;
                booking.CusSellName  = __company.ComName;


                var calculate = ctx.CreditCalculate.Where(p => p.CalculateId == contract.CalculateId).SingleOrDefault();

                var statusDropdown = iStatusService.GetDropdown();
                //statusDropdown = statusDropdown.Where(x => x.Value == "27" && x.Value == "33").ToArray();

                //var contItem = ctx.CreditContractItem
                //   .Where(p => p.ContractId == contract.ContractId && p.RefNo == contract.RefNo)
                //   .OrderBy(o => o.InstalmentNo).ToList();

                var outstanding = SetOutstanding(contractId.ToString());

                var delayedInterest = SetDelayedInterest(contractId.ToString());

                var discounts = SetDiscounts(contractId.ToString());

                var cutOffSale = SetCutOffSale(contractId.ToString());

                var historyPayment = SetHistoryPayment(contractId.ToString());

                var obj = new Dictionary <string, object>
                {
                    { "creditCalculate", calculate },
                    { "statusDropdown", statusDropdown },
                    { "creditContractDetail", detail },
                    { "booking", booking },
                    { "outstanding", outstanding },
                    { "delayedInterest", delayedInterest },
                    { "discounts", discounts },
                    { "cutOffSale", cutOffSale },
                    { "historyPayment", historyPayment }
                };

                return(Ok(obj));
            }
            catch (Exception ex)
            {
                Console.Write(ex);
                return(StatusCode(500, ex.Message));
            }
        }