예제 #1
0
        private List<LoanAmountCycle> GetLoanAmountCycles()
        {
            var amountCycle = new LoanAmountCycle();
            amountCycle.CycleId = 2;
            amountCycle.LoanCycle = 0;
            amountCycle.Min = 1000;
            amountCycle.Max = 2000;
            amountCycle.CycleObjectId = 1;
            var loanAmountCycles = new List<LoanAmountCycle>();
            loanAmountCycles.Add(amountCycle);

            amountCycle = new LoanAmountCycle();
            amountCycle.CycleId = 2;
            amountCycle.LoanCycle = 1;
            amountCycle.Min = 2000;
            amountCycle.Max = 3000;
            amountCycle.CycleObjectId = 1;
            loanAmountCycles.Add(amountCycle);

            amountCycle = new LoanAmountCycle();
            amountCycle.CycleId = 2;
            amountCycle.LoanCycle = 2;
            amountCycle.Min = 3000;
            amountCycle.Max = 4000;
            amountCycle.CycleObjectId = 1;
            loanAmountCycles.Add(amountCycle);

            return loanAmountCycles;
        }
예제 #2
0
        private void buttonAddAmountCycle_Click(object sender, EventArgs e)
        {
            int loanCycle;
            if (listViewLoanCycles.Items.Count == 0)
                loanCycle = 0;
            else
                loanCycle = ((Cycle)listViewLoanCycles.Items[listViewLoanCycles.Items.Count - 1].Tag).LoanCycle + 1;

            textBoxCycleMin.TextChanged -= textBoxCycleMin_TextChanged;
            textBoxCycleMax.TextChanged -= textBoxCycleMax_TextChanged;
            textBoxCycleMin.Text = "0";
            textBoxCycleMax.Text = "0";
            textBoxCycleMin.TextChanged += textBoxCycleMin_TextChanged;
            textBoxCycleMax.TextChanged += textBoxCycleMax_TextChanged;
            buttonRemoveAmountCycles.Enabled = true;
            buttonAmountCyclesSave.Enabled = true;

            int cycleObjectId = ((CycleObject)cbxCycleObjects.SelectedItem).Id;

            switch (cycleObjectId)
            {
                case 1:
                    var parameter = new LoanAmountCycle
                    {
                        CycleId = ((LoanCycle)comboBoxLoanCyclesName.SelectedItem).Id,
                        CycleObjectId = cycleObjectId,
                        Min = 0,
                        Max = 0,
                        LoanCycle = loanCycle
                    };
                    var amountCycleItem = new ListViewItem((parameter.LoanCycle + 1).ToString()) { Tag = parameter };
                    amountCycleItem.SubItems.Add(parameter.Min.ToString());
                    amountCycleItem.SubItems.Add(parameter.Max.ToString());
                    listViewLoanCycles.Items.Add(amountCycleItem);
                    _product.LoanAmountCycleParams.Add(parameter);
                    break;
                case 2:
                    var rateCycleParam = new RateCycle
                    {
                        CycleId = ((LoanCycle)comboBoxLoanCyclesName.SelectedItem).Id,
                        CycleObjectId = cycleObjectId,
                        Min = 0,
                        Max = 0,
                        LoanCycle = loanCycle
                    };
                    var interestRateCycleItem = new ListViewItem((rateCycleParam.LoanCycle + 1).ToString()) { Tag = rateCycleParam };
                    interestRateCycleItem.SubItems.Add(rateCycleParam.Min.ToString());
                    interestRateCycleItem.SubItems.Add(rateCycleParam.Max.ToString());
                    listViewLoanCycles.Items.Add(interestRateCycleItem);
                    _product.RateCycleParams.Add(rateCycleParam);
                    break;
                case 3:
                    var maturityCycleParam = new MaturityCycle
                    {
                        CycleId = ((LoanCycle)comboBoxLoanCyclesName.SelectedItem).Id,
                        CycleObjectId = cycleObjectId,
                        Min = 0,
                        Max = 0,
                        LoanCycle = loanCycle
                    };
                    var maturityCycleItem = new ListViewItem((maturityCycleParam.LoanCycle + 1).ToString()) { Tag = maturityCycleParam };
                    maturityCycleItem.SubItems.Add(maturityCycleParam.Min.ToString());
                    maturityCycleItem.SubItems.Add(maturityCycleParam.Max.ToString());
                    listViewLoanCycles.Items.Add(maturityCycleItem);
                    _product.MaturityCycleParams.Add(maturityCycleParam);
                    break;
                default: break;
            }
            listViewLoanCycles.Items[listViewLoanCycles.Items.Count - 1].Selected = true;
        }
예제 #3
0
        public void TestProductWithoutMaturityCycle()
        {
            var loanAmountCycles = new List<LoanAmountCycle>();
            var loanAmountCycle = new LoanAmountCycle(0, 0, 1,2,1,1);
            loanAmountCycles.Add(loanAmountCycle);
            var rateCycles = new List<RateCycle>();
            var rateCycle = new RateCycle(0,0,1,2,1,1);
            var maturityCycles = new List<MaturityCycle>();
            rateCycles.Add(rateCycle);
            Currency currency = new Currency();
            currency.Id = 1;
            var entryFees = new List<EntryFee>();

            var nrp = new NonRepaymentPenaltiesNullableValues(100, 200, 10, 0.2);

            LoanProduct product = CreatePackage(
                                                "NewPackage", //package name
                                                null, //anticipatedTotalRepaymentPenalties
                                                3, //anticipatedTotalRepaymentPenaltiesMin
                                                6, //anticipatedTotalRepaymentPenaltiesMax
                                                4, //grace period
                                                null, //gracePeriodMin
                                                null, //gracePeriodMax
                                                null, //interestRate
                                                null, //interesrRateMin
                                                null, //interestRateMax
                                                null, //NmbOfInstallments
                                                null, //NmbOfInstallmentsMin
                                                null, //NmbOfInstallmentsMax
                                                entryFees, //List<EntryFee>
                                                nrp, //NonRepaymentPenalties
                                                null, //NonRepaymentPenaltiesMin
                                                null, //NonRepaymentPenaltiesMax
                                                _monthly, //InstallmentType
                                                null, //amount
                                                null, //amountMin
                                                null, //AmountMax
                                                null, //ExoticInstallmentsTable
                                                1, //cycleId
                                                loanAmountCycles, //List<LoanAmountCycle>
                                                rateCycles, //List<RateCycle>
                                                maturityCycles, //List<MaturityCycle>
                                                "CODE1", //ProductCode
                                                null, //List<ProductClientType>
                                                null, //amountUnderLoc
                                                null, //amountUnderLocMin
                                                null, //amountUnderLocMax
                                                5, //anticipatedPartialRepaymentPenalties
                                                null, //anticipatedPartialRepaymentPenaltiesMin
                                                null, //anticipatedPartialRepaymentPenaltiesMax
                                                null, //compulsoryAmount
                                                null, //compulsoryAmountMin
                                                null, //compulsoryAmountMax
                                                currency
                );
            ProductServices productServices = new ProductServices(new User() { Id = 1 });
            productServices.ParseFieldsAndCheckErrors(product, false);
        }
예제 #4
0
        public List<LoanAmountCycle> SelectLoanAmountCycleParams(int cycleId)
        {
            List<LoanAmountCycle> cycleParameters = new List<LoanAmountCycle>();
            string q = @"SELECT [id]
                                  ,[loan_cycle]
                                  ,[min]
                                  ,[max]
                                  ,[cycle_object_id]
                                  ,[cycle_id]
                              FROM [dbo].[CycleParameters]
                              WHERE [cycle_object_id]=1
                                    AND [cycle_id]=@cycle_id
                              ORDER BY [loan_cycle]";
            using (SqlConnection conn = GetConnection())
            using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
            {
                c.AddParam("@cycle_id", cycleId);

                using (OpenCbsReader r = c.ExecuteReader())
                {
                    while (r.Read())
                    {
                        LoanAmountCycle parameter = new LoanAmountCycle();
                        parameter.Id = r.GetInt("id");
                        parameter.LoanCycle = r.GetInt("loan_cycle");
                        parameter.Min = r.GetDecimal("min");
                        parameter.Max = r.GetDecimal("max");
                        parameter.CycleObjectId = r.GetInt("cycle_object_id");
                        parameter.CycleId = r.GetNullInt("cycle_id");
                        cycleParameters.Add(parameter);
                    }
                }
            }
            return cycleParameters;
        }