private LoanDisbursementVcr CreateLoanDisbursementVoucher(Agreement agreement, AmortizationItemsModel itemModel, DateTime today, decimal amountBalance)
        {
            LoanDisbursementVcr voucher = new LoanDisbursementVcr();
            voucher.Agreement = agreement;
            voucher.Amount = itemModel.NewLoanAmount;
            voucher.Date = today;
            voucher.Balance = amountBalance;

            Context.LoanDisbursementVcrs.AddObject(voucher);
            return voucher;
        }
        private LoanApplication CreateLoanApplication(Application application, DateTime today, AmortizationItemsModel itemModel)
        {
            LoanApplication loanApplicationNew1 = new LoanApplication();
            loanApplicationNew1.Application = application;
            loanApplicationNew1.InterestRate = itemModel.InterestRate;
            loanApplicationNew1.LoanTermUomId = itemModel.UnitId;
            loanApplicationNew1.LoanTermLength = itemModel.Term;
            loanApplicationNew1.PaymentModeUomId = itemModel.PaymentModeId;
            loanApplicationNew1.LoanAmount = itemModel.NewLoanAmount;
            loanApplicationNew1.InterestRateDescription = itemModel.InterestRateDescription;
            loanApplicationNew1.IsInterestProductFeatureInd = true;

            return loanApplicationNew1;
        }
        private AmortizationSchedule CreateAmortizationScheduleWithParent(LoanAgreement loanAgreement, AmortizationItemsModel schedule, DateTime today, AmortizationSchedule parentSchedule)
        {
            AmortizationSchedule amortizationScheduleNew1 = new AmortizationSchedule();
            amortizationScheduleNew1.LoanAgreement = loanAgreement;
            amortizationScheduleNew1.LoanReleaseDate = schedule.LoanReleaseDate;
            amortizationScheduleNew1.PaymentStartDate = schedule.PaymentStartDate;
            amortizationScheduleNew1.DateGenerated = today;
            amortizationScheduleNew1.EffectiveDate = today;
            amortizationScheduleNew1.ParentAmortizationScheduleId = parentSchedule.Id;

            return amortizationScheduleNew1;
        }
        private LoanAccount CreateLoanAccount(FinancialAccount financialAccount, AmortizationItemsModel item, DateTime maturityDate, DateTime today)
        {
            LoanAccount loanAccountNew = new LoanAccount();
            loanAccountNew.FinancialAccount = financialAccount;
            loanAccountNew.LoanAmount = item.NewLoanAmount;
            loanAccountNew.LoanBalance = item.NewLoanAmount;
            //loanAccountNew.LoanReleaseDate = today.Date;
            loanAccountNew.LoanReleaseDate = item.LoanReleaseDate;
            loanAccountNew.InterestType = InterestType.PercentageInterestTYpe;
            if(item.Term != 0)
                loanAccountNew.MaturityDate = maturityDate;

            return loanAccountNew;
        }
        private AgreementItem CreateAgreementItemFromOldInterest(Agreement agreement, DateTime today, AmortizationItemsModel item, AgreementItem oldItem)
        {
            AgreementItem agreementItemNew1 = new AgreementItem();
            agreementItemNew1.Agreement = agreement;
            agreementItemNew1.InterestComputationMode = oldItem.InterestComputationMode;
            agreementItemNew1.InterestRateDescription = oldItem.InterestRateDescription;
            agreementItemNew1.InterestRate = item.NewInterestRate;
            agreementItemNew1.LoanAmount = oldItem.LoanAmount;
            agreementItemNew1.LoanTermLength = oldItem.LoanTermLength;
            agreementItemNew1.LoanTermUom = oldItem.LoanTermUom;
            agreementItemNew1.MethodOfChargingInterest = oldItem.MethodOfChargingInterest;
            agreementItemNew1.PaymentMode = oldItem.PaymentMode;
            agreementItemNew1.TransitionDateTime = today;
            agreementItemNew1.IsActive = true;

            return agreementItemNew1;
        }