コード例 #1
0
        public static AcquittanceViewModel Create(ITLoanRepository loanRepository, IMEmployeeRepository mEmployeeRepository, string loanCode)
        {
            AcquittanceViewModel viewModel = new AcquittanceViewModel();

            TLoan loan = loanRepository.GetLoanByLoanCode(loanCode);

            viewModel.BasicPrice      = loan.LoanBasicPrice;
            viewModel.CreditPrice     = loan.LoanCreditPrice;
            viewModel.Installment     = loan.LoanBasicInstallment;
            viewModel.LoanTenor       = loan.LoanTenor;
            viewModel.PaidInstallment =
                (loan.Installments).Where(x => x.InstallmentStatus == EnumInstallmentStatus.Paid.ToString()).Count();

            viewModel.RequiredInstallment      = Math.Ceiling(loan.LoanTenor.Value * 0.75m);
            viewModel.RequiredInstallmentTotal = (viewModel.RequiredInstallment - viewModel.PaidInstallment) * viewModel.Installment;
            viewModel.LoseSort      = viewModel.LoanTenor - viewModel.RequiredInstallment;
            viewModel.LoseSortTotal = viewModel.LoseSort * (viewModel.CreditPrice / viewModel.LoanTenor);
            viewModel.Provision     = viewModel.LoseSortTotal.Value * 0.1m;
            viewModel.MustPaid      = viewModel.RequiredInstallmentTotal + viewModel.LoseSortTotal + viewModel.Provision;


            var       listEmployee = mEmployeeRepository.GetEmployeeByDept(EnumDepartment.COL.ToString());
            MEmployee employee     = new MEmployee();

            listEmployee.Insert(0, employee);

            var collector = from emp in listEmployee
                            select new { Id = emp.Id, Name = emp.PersonId != null ? emp.PersonId.PersonName : "-Pilih Kolektor-" };

            viewModel.CollectorList = new SelectList(collector, "Id", "Id", string.Empty);
            return(viewModel);
        }
コード例 #2
0
        public static DetailLoanViewModel Create(ITLoanRepository loanRepository, ITInstallmentRepository installmentRepository, string loanCode)
        {
            DetailLoanViewModel viewModel = new DetailLoanViewModel();

            viewModel.Loan = loanRepository.GetLoanByLoanCode(loanCode);

            var l = from t in viewModel.Loan.Installments
                    where
                    t.InstallmentStatus == EnumInstallmentStatus.Not_Paid.ToString() &&
                    t.InstallmentMaturityDate < DateTime.Today
                    select t;

            viewModel.InstallmentLate = l.Count();

            viewModel.InstallmentMore =
                (viewModel.Loan.Installments).Where(x => x.InstallmentStatus == EnumInstallmentStatus.Paid.ToString()).
                Sum(x => x.InstallmentSisa).Value;

            viewModel.InstallmentMinus =
                (viewModel.Loan.Installments).Where(x => x.InstallmentStatus == EnumInstallmentStatus.Paid.ToString()).
                Sum(x => x.InstallmentSisa).Value;

            viewModel.InstallmentFine =
                (viewModel.Loan.Installments).Where(x => x.InstallmentStatus == EnumInstallmentStatus.Paid.ToString()).
                Sum(x => x.InstallmentFine).Value;

            string separator = "|";

            string[] photos = viewModel.Loan.LoanDesc.Split(separator.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            viewModel.Photo1 = "~/Content/Images/no_photo104_on.jpg";
            viewModel.Photo2 = "~/Content/Images/no_photo104_on.jpg";
            if (photos.Count() > 0)
            {
                viewModel.Photo1 = photos[0];
            }
            if (photos.Count() > 1)
            {
                viewModel.Photo2 = photos[1];
            }
            return(viewModel);
        }