Beispiel #1
0
        public void SetPropertiesFromDataRow(DataRow dataRow)
        {
            ID                    = (int)dataRow["ID"];
            Name                  = (string)dataRow["Name"];
            LoanType              = (string)dataRow["LoanType"];
            ModeOfPayment         = (string)dataRow["ModeOfPayment"];
            AnnualInterestRate    = (decimal)dataRow["AnnualInterestRate"];
            ProductCode           = DataConverter.ToString(dataRow["ProductCode"]);
            MinimumTerm           = DataConverter.ToInteger(dataRow["MinimumTerm"]);
            MaximumTerm           = DataConverter.ToInteger(dataRow["MaximumTerm"]);
            MinimumLoanableAmount = DataConverter.ToDecimal(dataRow["MinimumLoanableAmount"]);
            MaximumLoanableAmount = DataConverter.ToDecimal(dataRow["MaximumLoanableAmount"]);
            MonthlyCapitalBuildUp = DataConverter.ToDecimal(dataRow["MonthlyCapitalBuildUp"]);

            LoanCharges = LoanCharge.GetListByLoanProductId(ID);

            Description = string.Format("Loanable amount of P{0:N} - P{1:N}", MinimumLoanableAmount,
                                        MaximumLoanableAmount);

            var productImage = ProductImage.WhereProductCodeIs(ProductCode);

            if (null == productImage)
            {
                return;
            }

            BitmapImage = productImage.BitmapImage;
        }
Beispiel #2
0
        public static List <LoanCharge> GetList()
        {
            string    sqlCommandText = string.Format("SELECT * FROM {0}", TableName);
            DataTable dataTable      = DatabaseController.ExecuteSelectQuery(sqlCommandText);
            var       list           = new List <LoanCharge>();

            foreach (DataRow row in dataTable.Rows)
            {
                var item = new LoanCharge();
                item.SetPropertiesFromDataRow(row);
                list.Add(item);
            }
            return(list);
        }
Beispiel #3
0
        public static List <LoanCharge> GetListByLoanProductId(int loanProductId)
        {
            string sqlCommandText = string.Format("SELECT * FROM {0} WHERE LoanProductId = ?LoanProductId ORDER BY AccountCode",
                                                  TableName);
            DataTable dataTable = DatabaseController.ExecuteSelectQuery(sqlCommandText,
                                                                        new SqlParameter("?LoanProductId", loanProductId));

            var list = new List <LoanCharge>();

            foreach (DataRow row in dataTable.Rows)
            {
                var item = new LoanCharge();
                item.SetPropertiesFromDataRow(row);
                list.Add(item);
            }
            return(list);
            //return (from DataRow row in dataTable.Rows
            //        select new LoanCharge
            //            ((int)row["LoanChargeId"], (int)row["LoanProductId"], (string)row["AccountCode"], (decimal)row["Rate"])).ToList();
        }
Beispiel #4
0
        public LoanComputation(decimal loanAmount, int loanProductId) : this()
        {
            LoanAmount = loanAmount;

            var loanProduct = new LoanProduct();

            loanProduct.Find(loanProductId);


            var loanApplied = Account.FindByCode(loanProduct.ProductCode);

            LoanDescription = string.Format("{0} - {1}", loanApplied.AccountCode, loanApplied.AccountTitle);

            LoanDetails.AccountCode = loanApplied.AccountCode;


            #region --- Populate Charges ---

            var loanCharges = LoanCharge.GetListByLoanProductId(loanProduct.ID);
            int i           = 0;
            foreach (var loanCharge in loanCharges)
            {
                i++;
                if (i == 1)
                {
                    ChargeCode1   = loanCharge.AccountCode;
                    ChargeTitle1  = loanCharge.AccountTitle;
                    ChargeAmount1 = Math.Round(loanCharge.Rate * LoanAmount, 2);
                    continue;
                }
                if (i == 2)
                {
                    ChargeCode2   = loanCharge.AccountCode;
                    ChargeTitle2  = loanCharge.AccountTitle;
                    ChargeAmount2 = Math.Round(loanCharge.Rate * LoanAmount, 2);
                    continue;
                }
                if (i == 3)
                {
                    ChargeCode3   = loanCharge.AccountCode;
                    ChargeTitle3  = loanCharge.AccountTitle;
                    ChargeAmount3 = Math.Round(loanCharge.Rate * LoanAmount, 2);
                    continue;
                }
                if (i == 4)
                {
                    ChargeCode4   = loanCharge.AccountCode;
                    ChargeTitle4  = loanCharge.AccountTitle;
                    ChargeAmount4 = Math.Round(loanCharge.Rate * LoanAmount, 2);
                    continue;
                }
                if (i == 5)
                {
                    ChargeCode5   = loanCharge.AccountCode;
                    ChargeTitle5  = loanCharge.AccountTitle;
                    ChargeAmount5 = Math.Round(loanCharge.Rate * LoanAmount, 2);
                    continue;
                }
                if (i == 6)
                {
                    ChargeCode6   = loanCharge.AccountCode;
                    ChargeTitle6  = loanCharge.AccountTitle;
                    ChargeAmount6 = Math.Round(loanCharge.Rate * LoanAmount, 2);
                    break;
                }
            }

            #endregion

            #region --- Populate Deductions ---

            var loanDeductions = LoanDeduction.GetListByLoanProductId(loanProduct.ID);
            i = 0;
            foreach (var loanDeduct in loanDeductions)
            {
                i++;
                if (i == 1)
                {
                    DeductCode1   = loanDeduct.AccountCode;
                    DeductTitle1  = loanDeduct.AccountTitle;
                    DeductAmount1 = loanDeduct.Amount;
                    continue;
                }
                if (i == 2)
                {
                    DeductCode2   = loanDeduct.AccountCode;
                    DeductTitle2  = loanDeduct.AccountTitle;
                    DeductAmount2 = loanDeduct.Amount;
                    continue;
                }
                if (i == 3)
                {
                    DeductCode3   = loanDeduct.AccountCode;
                    DeductTitle3  = loanDeduct.AccountTitle;
                    DeductAmount3 = loanDeduct.Amount;
                    continue;
                }
                if (i == 4)
                {
                    DeductCode4   = loanDeduct.AccountCode;
                    DeductTitle4  = loanDeduct.AccountTitle;
                    DeductAmount4 = loanDeduct.Amount;
                    continue;
                }
                if (i == 5)
                {
                    DeductCode5   = loanDeduct.AccountCode;
                    DeductTitle5  = loanDeduct.AccountTitle;
                    DeductAmount5 = loanDeduct.Amount;
                    continue;
                }
                if (i == 6)
                {
                    DeductCode6   = loanDeduct.AccountCode;
                    DeductTitle6  = loanDeduct.AccountTitle;
                    DeductAmount6 = loanDeduct.Amount;
                    break;
                }
            }

            #endregion

            #region --- INITIALIZE DEFAULT NET PROCEEDS ---

            var netProceedsAccount = Account.FindByCode(GlobalSettings.CodeOfCashOnHand);
            NetProceedsCode = netProceedsAccount.AccountCode;
            //NetProceedsTitle = netProceedsAccount.AccountTitle;

            #endregion --- INITIALIZE DEFAULT NET PROCEEDS ---
        }