public CorporateUserControl(FundingLine pFundingLine)
 {
     _fundingLine = pFundingLine;
     InitializeComponent();
     InitializeUserControlsAddress();
     _corporate = new Corporate();
 }
        public void AddFundinLineWithNameThatAlreadyExists()
        {
            var fundingLineServices = (FundingLineServices)container["FundingLineServices"];

            var fund = new FundingLine
            {
                Purpose   = "Microsoft financement",
                Name      = "XXX",
                Deleted   = false,
                StartDate = DateTime.Now,
                EndDate   = DateTime.Now
            };

            fundingLineServices.Create(fund);

            var fundingLineToAdd = new FundingLine
            {
                Purpose   = "Microsoft financement",
                Name      = "XXX",
                Deleted   = false,
                StartDate = DateTime.Now,
                EndDate   = DateTime.Now
            };

            fundingLineServices.Create(fund);
        }
Beispiel #3
0
        public int AddFundingLine(FundingLine pFund, SqlTransaction sqlTransac)
        {
            string q =
                @"INSERT INTO [FundingLines]([name],[begin_date],[end_date],[amount],[purpose], [deleted], [currency_id]) 
                    VALUES(@name,@beginDate,@endDate,@amount,@purpose,@deleted, @currency_id ) SELECT SCOPE_IDENTITY()";

            using (OpenCbsCommand c = new OpenCbsCommand(q, sqlTransac.Connection, sqlTransac))
            {
                c.AddParam("@name", pFund.Name);
                c.AddParam("@beginDate", pFund.StartDate);
                c.AddParam("@endDate", pFund.EndDate);
                c.AddParam("@amount", pFund.Amount);
                c.AddParam("@purpose", pFund.Purpose);
                c.AddParam("@deleted", pFund.Deleted);
                c.AddParam("@currency_id", pFund.Currency.Id);
                pFund.Id = int.Parse(c.ExecuteScalar().ToString());


                foreach (FundingLineEvent eventFL in pFund.Events)
                {
                    if (eventFL.Id == 0)
                    {
                        _eventFundingLineManager.AddFundingLineEvent(eventFL, sqlTransac); //new event
                    }
                    else
                    {
                        _eventFundingLineManager.UpdateFundingLineEvent(eventFL, sqlTransac); // delete event
                    }
                }
            }
            SetLazyLoader(pFund);
            return(pFund.Id);
        }
Beispiel #4
0
        public int AddFundingLine(FundingLine pFund, SqlTransaction sqlTransac)
        {
            string q =
                @"INSERT INTO [FundingLines]([name],[begin_date],[end_date],[amount],[purpose], [deleted], [currency_id])
                    VALUES(@name,@beginDate,@endDate,@amount,@purpose,@deleted, @currency_id ) SELECT SCOPE_IDENTITY()";

            using (OpenCbsCommand c = new OpenCbsCommand(q, sqlTransac.Connection, sqlTransac))
            {
                c.AddParam("@name", pFund.Name);
                c.AddParam("@beginDate", pFund.StartDate);
                c.AddParam("@endDate", pFund.EndDate);
                c.AddParam("@amount", pFund.Amount);
                c.AddParam("@purpose", pFund.Purpose);
                c.AddParam("@deleted", pFund.Deleted);
                c.AddParam("@currency_id", pFund.Currency.Id);
                pFund.Id = int.Parse(c.ExecuteScalar().ToString());

                foreach (FundingLineEvent eventFL in pFund.Events)
                {
                    if (eventFL.Id == 0)
                        _eventFundingLineManager.AddFundingLineEvent(eventFL, sqlTransac); //new event
                    else
                        _eventFundingLineManager.UpdateFundingLineEvent(eventFL, sqlTransac); // delete event
                }
            }
            SetLazyLoader(pFund);
            return pFund.Id;
        }
Beispiel #5
0
 public CorporateUserControl(Corporate corporate, Form pMdiParent, IApplicationController applicationController)
 {
     _applicationController = applicationController;
     _mdifrom = pMdiParent;
        _corporate = corporate;
     _fundingLine = null;
     InitializeComponent();
     InitializeUserControlsAddress();
     InitializeCorporate();
     PicturesServices ps = ServicesProvider.GetInstance().GetPicturesServices();
     if (ps.IsEnabled())
     {
         pictureBox1.Image = ps.GetPicture("CORPORATE", corporate.Id, true, 0);
         pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
         pictureBox2.Image = ps.GetPicture("CORPORATE", corporate.Id, true, 1);
         pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;
     }
     else
     {
         pictureBox1.Visible = false;
         pictureBox2.Visible = false;
         linkLabelChangePhoto.Visible = false;
         linkLabelChangePhoto2.Visible = false;
     }
 }
 public CorporateUserControl(Corporate corporate, Form pMdiParent, IExtensionActivator extensionActivator)
     : base(extensionActivator)
 {
     _mdifrom = pMdiParent;
        _corporate = corporate;
     _fundingLine = null;
     InitializeComponent();
     InitializeUserControlsAddress();
     InitializeCorporate();
     PicturesServices ps = ServicesProvider.GetInstance().GetPicturesServices();
     if (ps.IsEnabled())
     {
         pictureBox1.Image = ps.GetPicture("CORPORATE", corporate.Id, true, 0);
         pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
         pictureBox2.Image = ps.GetPicture("CORPORATE", corporate.Id, true, 1);
         pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;
     }
     else
     {
         pictureBox1.Visible = false;
         pictureBox2.Visible = false;
         linkLabelChangePhoto.Visible = false;
         linkLabelChangePhoto2.Visible = false;
     }
     InitializeCustomizableFields(_corporate.Id);
 }
Beispiel #7
0
        private OCurrency GetAmountImpl(FundingLine fl, OFundingLineEventTypes type, bool equals)
        {
            string q = @"SELECT ISNULL(SUM(
                CASE 
                    WHEN 1 = direction THEN CAST(amount AS DECIMAL(20,4))
                    ELSE -1*CAST(amount  AS DECIMAL(20,4))
                END), 0) amount
            FROM dbo.FundingLineEvents
            WITH (READUNCOMMITTED)
            WHERE fundingline_id = @id
            AND deleted = 0
            AND CAST(FLOOR(CAST(creation_date AS FLOAT)) AS DATETIME) <= @date
            AND type ";

            q += equals ? "= @type" : "<> @type";
            using (SqlConnection conn = GetConnection())
                using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
                {
                    c.AddParam("@id", fl.Id);
                    c.AddParam("@date", TimeProvider.Now.Date);
                    c.AddParam("@type", (int)type);
                    object retval = c.ExecuteScalar();
                    return(null == retval ? 0m : Convert.ToDecimal(retval));
                }
        }
Beispiel #8
0
 private void SetLazyLoader(FundingLine fl)
 {
     if (null == fl)
     {
         return;
     }
     fl.SetLazyLoader(this);
 }
Beispiel #9
0
 public FrmFundingLineEvent(FundingLine pFundingLine, FundingLineEvent pFundingLineEvent)
 {
     InitializeComponent();
     _FundingLine = pFundingLine;
     _fundingLineEvent = pFundingLineEvent;
     InitializeComboBoxDirections();
     dateTimePickerEvent.Value = TimeProvider.Now;
 }
Beispiel #10
0
        public FundingLine SelectFundingLineByNameAndPurpose(FundingLine lookupFundingLine, SqlTransaction sqlTransac,
                                                             bool includeAll)
        {
            FundingLine newFL = new FundingLine();

            string q =
                @"SELECT FundingLines.[id],
                         [deleted],
                         [currency_id],
                         Currencies.[name] as currency_name,
                         Currencies.[code] as currency_code, 
                         Currencies.[is_pivot] as currency_pivot,
                         Currencies.[is_swapped] as currency_is_swapped
                FROM [FundingLines] 
                LEFT JOIN Currencies ON FundingLines.currency_id = Currencies.id
                WHERE [purpose] = @purpose AND
                FundingLines.[name] = @name";

            if (!includeAll)
            {
                q += "and [deleted]=@deleted";
            }
            using (OpenCbsCommand c = new OpenCbsCommand(q, sqlTransac.Connection, sqlTransac))
            {
                c.AddParam("@purpose", lookupFundingLine.Purpose);
                c.AddParam("@name", lookupFundingLine.Name);

                if (!includeAll)
                {
                    c.AddParam("@deleted", lookupFundingLine.Deleted);
                }

                using (OpenCbsReader r = c.ExecuteReader())
                {
                    if (r != null)
                    {
                        if (!r.Empty)
                        {
                            r.Read();

                            newFL.Id       = r.GetInt("id");
                            newFL.Deleted  = r.GetBool("deleted");
                            newFL.Currency = new Currency
                            {
                                Id        = r.GetInt("currency_id"),
                                Name      = r.GetString("currency_name"),
                                Code      = r.GetString("currency_code"),
                                IsPivot   = r.GetBool("currency_is_pivot"),
                                IsSwapped = r.GetBool("currency_is_swapped")
                            };
                        }
                    }
                }
            }
            SetLazyLoader(newFL);

            return(newFL);
        }
Beispiel #11
0
 public FrmFundingLineEvent(FundingLine pFundingLine)
 {
     InitializeComponent();
     _FundingLine = pFundingLine;
     _exchangeRate=null;
     _fundingLineEvent = new FundingLineEvent();
     InitializeComboBoxDirections();
     dateTimePickerEvent.Value = TimeProvider.Now;
 }
Beispiel #12
0
        public FundingLine SelectFundingLineByName(string name)
        {
            FundingLine fundingLine = null;

            string q =
                @"SELECT FundingLines.[id],
                         FundingLines.[name], 
                         FundingLines.[deleted],
                         FundingLines.[amount],
                         FundingLines.[begin_date],
                         FundingLines.[end_date],
                         FundingLines.[purpose], 
                         FundingLines.[currency_id],
                         Currencies.[name] as currency_name, 
                         Currencies.[code] as currency_code, 
                         Currencies.[is_pivot] as currency_is_pivot,
                         Currencies.[is_swapped] as currency_is_swapped
                        FROM [FundingLines] 
                        LEFT JOIN Currencies ON FundingLines.currency_id = Currencies.id
                        WHERE FundingLines.[name]=@name AND [deleted]=0";

            using (SqlConnection conn = GetConnection())
                using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
                {
                    c.AddParam("@name", name);

                    using (OpenCbsReader r = c.ExecuteReader())
                    {
                        if (r != null)
                        {
                            if (!r.Empty)
                            {
                                r.Read();
                                fundingLine           = new FundingLine();
                                fundingLine.Id        = r.GetInt("id");
                                fundingLine.Name      = r.GetString("name");
                                fundingLine.Deleted   = r.GetBool("deleted");
                                fundingLine.StartDate = r.GetDateTime("begin_date");
                                fundingLine.Purpose   = r.GetString("purpose");
                                fundingLine.EndDate   = r.GetDateTime("end_date");
                                fundingLine.Amount    = r.GetMoney("amount");
                                fundingLine.Currency  = new Currency
                                {
                                    Id        = r.GetInt("currency_id"),
                                    Name      = r.GetString("currency_name"),
                                    Code      = r.GetString("currency_code"),
                                    IsPivot   = r.GetBool("currency_is_pivot"),
                                    IsSwapped = r.GetBool("currency_is_swapped")
                                };
                            }
                        }
                    }
                }
            SetLazyLoader(fundingLine);

            return(fundingLine);
        }
Beispiel #13
0
 public CashPrevisionForm(FundingLine pfundingLine, bool pIncludeDeleted)
 {
     InitializeComponent();
        date = TimeProvider.Today;
        _cashForFundingLine = pfundingLine;
        forecastDays = 5;
        includeDeleted = pIncludeDeleted;
        checkBoxIncludeLateLoans.Checked = pIncludeDeleted;
        DrawZedGraphForCashPrevision();
 }
Beispiel #14
0
 public FrmFundingLineEvent(FundingLine pFundingLine)
 {
     InitializeComponent();
     _FundingLine = pFundingLine;
     _exchangeRate=null;
     _fundingLineEvent = new FundingLineEvent();
     InitializeComboBoxDirections();
     dateTimePickerEvent.Value = TimeProvider.Now;
     dateTimePickerEvent.Format = DateTimePickerFormat.Custom;
     dateTimePickerEvent.CustomFormat = ApplicationSettings.GetInstance("").SHORT_DATE_FORMAT;
 }
        public FundingLine Create(FundingLine fund)
        {
            using (SqlConnection conn = _fundingLineManager.GetConnection())
                using (SqlTransaction sqlTransac = conn.BeginTransaction())
                    try
                    {
                        if (string.IsNullOrEmpty(fund.Purpose))
                        {
                            throw new OpenCbsFundingLineException(OpenCbsFundingLineExceptionEnum.CodeIsEmpty);
                        }
                        if (fund.StartDate > fund.EndDate)
                        {
                            throw new OpenCbsFundingLineException(OpenCbsFundingLineExceptionEnum.BeginDateGreaterEndDate);
                        }
                        if (string.IsNullOrEmpty(fund.Name))
                        {
                            throw new OpenCbsFundingLineException(OpenCbsFundingLineExceptionEnum.NameIsEmpty);
                        }
                        if (fund.Currency == null)
                        {
                            throw new OpenCbsFundingLineException(OpenCbsFundingLineExceptionEnum.CurrencyIsEmpty);
                        }
                        if (fund.Currency.Id == 0)
                        {
                            throw new OpenCbsFundingLineException(OpenCbsFundingLineExceptionEnum.CurrencyIsEmpty);
                        }
                        FundingLine tempfund = _fundingLineManager.SelectFundingLineByNameAndPurpose(fund, sqlTransac, true);

                        if (tempfund.Id > 0)
                        {
                            if (tempfund.Deleted)
                            {
                                fund.Deleted = false;
                                UpdateFundingLine(fund, sqlTransac);
                                return(fund);
                            }
                            else
                            {
                                throw new OpenCbsFundingLineException(OpenCbsFundingLineExceptionEnum.FundingLineNameExists);
                            }
                        }

                        fund.Id = _fundingLineManager.AddFundingLine(fund, sqlTransac);

                        sqlTransac.Commit();
                        return(fund);
                    }
                    catch (Exception ex)
                    {
                        sqlTransac.Rollback();
                        throw ex;
                    }
        }
Beispiel #16
0
        public void DeleteFundingLine(FundingLine fund)
        {
            string q = "UPDATE [FundingLines] SET [deleted] = @deleted WHERE [id] = @id";

            using (SqlConnection conn = GetConnection())
                using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
                {
                    c.AddParam("@id", fund.Id);
                    c.AddParam("@deleted", true);
                    c.ExecuteScalar();
                }
        }
Beispiel #17
0
        public List <FundingLine> SelectFundingLines()
        {
            List <FundingLine> list = new List <FundingLine>();
            string             q    =
                @"SELECT FundingLines.[id],
                         FundingLines.[name],
                         [begin_date],
                         [end_date],
                         [amount],
                         [purpose], 
                         [deleted], 
                         [currency_id],
                         Currencies.[name] as currency_name, 
                         Currencies.[code] as currency_code,
                         Currencies.[is_pivot] as currency_is_pivot,
                         Currencies.[is_swapped] as currency_is_swapped      
                FROM [FundingLines] 
                LEFT JOIN Currencies ON FundingLines.currency_id = Currencies.id
                WHERE [deleted] = 0";

            using (SqlConnection conn = GetConnection())
                using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
                    using (OpenCbsReader r = c.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            FundingLine fundingLine = new FundingLine();
                            fundingLine.Id        = r.GetInt("id");
                            fundingLine.Name      = r.GetString("name");
                            fundingLine.StartDate = r.GetDateTime("begin_date");
                            fundingLine.EndDate   = r.GetDateTime("end_date");
                            fundingLine.Amount    = r.GetMoney("amount");
                            fundingLine.Amount    = r.GetMoney("amount");
                            fundingLine.Purpose   = r.GetString("purpose");
                            fundingLine.Deleted   = r.GetBool("deleted");
                            fundingLine.Currency  = new Currency
                            {
                                Id        = r.GetInt("currency_id"),
                                Name      = r.GetString("currency_name"),
                                Code      = r.GetString("currency_code"),
                                IsPivot   = r.GetBool("currency_is_pivot"),
                                IsSwapped = r.GetBool("currency_is_swapped")
                            };
                            SetLazyLoader(fundingLine);
                            list.Add(fundingLine);
                        }
                    }

            return(list);
        }
        /* this method returns
         * estimated amount of funding line for several loans (ex. village members)
         * to check whether financial commitment will be enough
         */
        public decimal CheckIfAmountIsEnough(FundingLine fL, decimal amount)
        {
            decimal prevAmount = fundingLinesWithAmounts[fL.Id] == null ? 0 : (decimal)fundingLinesWithAmounts[fL.Id];

            if (fundingLinesWithAmounts.ContainsKey(fL.Id))
            {
                fundingLinesWithAmounts[fL.Id] = prevAmount + amount;
            }
            else
            {
                fundingLinesWithAmounts.Add(fL.Id, amount);
            }
            return(fL.AnticipatedRemainingAmount.Value - (decimal)fundingLinesWithAmounts[fL.Id]);
        }
 public void UpdateFundingLine(FundingLine fund)
 {
     using (SqlConnection conn = _fundingLineManager.GetConnection())
         using (SqlTransaction sqlTransac = conn.BeginTransaction())
             try
             {
                 UpdateFundingLine(fund, sqlTransac);
                 sqlTransac.Commit();
             }
             catch (Exception ex)
             {
                 sqlTransac.Rollback();
                 throw ex;
             }
 }
Beispiel #20
0
 public void AddFundinLine()
 {
     var fundingLineManager = (FundingLineManager)container["FundingLineManager"];
     var fund = new FundingLine
                    {
                        Id = 0,
                        Purpose = "Microsoft financement",
                        Name = "Clyon",
                        Deleted = false,
                        StartDate = DateTime.Now,
                        EndDate = DateTime.Now,
                        Currency = new Currency{Id = 1}
                    };
     fundingLineManager.AddFundingLine(fund);
     Assert.IsTrue(fund.Id > 0);
 }
Beispiel #21
0
        public double[] CalculateChartForFundingLine(FundingLine pFundingLine, DateTime pStartDate, int pDayNum, bool pAssumeLateLoansRepaidToday)
        {
            bool creditInterestsInFundingLine = ApplicationSettings.GetInstance(_user.Md5).InterestsCreditedInFL;
            List<KeyValuePair<DateTime, decimal>> result = _contractManagement.CalculateCashToRepayByDayByFundingLine(pFundingLine.Id,
                                                                                              pAssumeLateLoansRepaidToday,
                                                                                              creditInterestsInFundingLine);
            double[] y = pFundingLine.CalculateCashProvisionChart(pStartDate, pDayNum, pAssumeLateLoansRepaidToday);

            if (y == null) return y;
            for (int i = 0; i < pDayNum; i++)
            {
                decimal amount = result.Where(x => x.Key <= pStartDate.AddDays(i)).Sum(x => x.Value);
                y[i] += Convert.ToDouble(amount);
            }
            return y;
        }
Beispiel #22
0
 public void UpdateFundingLine(FundingLine fund)
 {
     using (SqlConnection conn = GetConnection())
         using (SqlTransaction t = conn.BeginTransaction())
         {
             try
             {
                 UpdateFundingLine(fund, t);
                 t.Commit();
             }
             catch (Exception)
             {
                 t.Rollback();
                 throw;
             }
         }
 }
        public void UpdateFundingLine(FundingLine fund, SqlTransaction sqlTransac)
        {
            if (fund.Purpose == string.Empty)
            {
                throw new OpenCbsFundingLineException(OpenCbsFundingLineExceptionEnum.NameIsEmpty);
            }
            if (fund.StartDate > fund.EndDate)
            {
                throw new OpenCbsFundingLineException(OpenCbsFundingLineExceptionEnum.BeginDateGreaterEndDate);
            }
            if (fund.Name == string.Empty)
            {
                throw new OpenCbsFundingLineException(OpenCbsFundingLineExceptionEnum.CodeIsEmpty);
            }

            _fundingLineManager.UpdateFundingLine(fund, sqlTransac);
        }
Beispiel #24
0
 public int AddFundingLine(FundingLine pFund)
 {
     using (SqlConnection conn = GetConnection())
         using (SqlTransaction t = conn.BeginTransaction())
         {
             try
             {
                 int id = AddFundingLine(pFund, t);
                 t.Commit();
                 return(id);
             }
             catch (Exception)
             {
                 t.Rollback();
                 throw;
             }
         }
 }
Beispiel #25
0
 public int AddFundingLine(FundingLine pFund)
 {
     using (SqlConnection conn = GetConnection())
     using (SqlTransaction t = conn.BeginTransaction())
     {
         try
         {
             int id = AddFundingLine(pFund, t);
             t.Commit();
             return id;
         }
         catch (Exception)
         {
             t.Rollback();
             throw;
         }
     }
 }
Beispiel #26
0
        public List <FundingLineEvent> GetEvents(FundingLine fl)
        {
            List <FundingLineEvent> list = new List <FundingLineEvent>();
            const string            q    = @"SELECT id,
                                    code,
                                    amount,
                                    direction, 
                                    deleted,
                                    creation_date,
                                    type 
                               FROM dbo.FundingLineEvents
                               WITH (READUNCOMMITTED)
                               WHERE fundingline_id = @id
                               ORDER BY creation_date DESC, id DESC";

            using (SqlConnection conn = GetConnection())
                using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
                {
                    c.AddParam("@id", fl.Id);
                    using (OpenCbsReader r = c.ExecuteReader())
                    {
                        if (null == r || r.Empty)
                        {
                            return(list);
                        }
                        while (r.Read())
                        {
                            FundingLineEvent e = new FundingLineEvent();
                            e.Id           = r.GetInt("id");
                            e.Code         = r.GetString("code");
                            e.Amount       = r.GetMoney("amount");
                            e.Movement     = (OBookingDirections)r.GetSmallInt("direction");
                            e.IsDeleted    = r.GetBool("deleted");
                            e.CreationDate = r.GetDateTime("creation_date");
                            e.Type         = (OFundingLineEventTypes)r.GetSmallInt("type");
                            e.FundingLine  = fl;
                            list.Add(e);
                        }
                    }
                }
            return(list);
        }
Beispiel #27
0
        public void DeleteFundinLine()
        {
            FundingLineManager fundingLineManager = (FundingLineManager)container["FundingLineManager"];
            FundingLine fund = new FundingLine
                           {
                               Purpose = "Microsoft financement",
                               Name = "XXX",
                               Deleted = false,
                               StartDate = DateTime.Now,
                               EndDate = DateTime.Now,
                               Currency = new Currency{Id = 1}
                           };
            fundingLineManager.AddFundingLine(fund);

            FundingLine fundingLineInitial = fundingLineManager.SelectFundingLineById(fund.Id, false);

            Assert.AreEqual("XXX", fundingLineInitial.Name);
            fundingLineManager.DeleteFundingLine(fundingLineInitial);
            FundingLine fundingLineFinal = fundingLineManager.SelectFundingLineById(fundingLineInitial.Id, false);
            Assert.IsNull(fundingLineFinal);
        }
Beispiel #28
0
        public void UpdateFundingLine(FundingLine fund, SqlTransaction pSqlTransac)
        {
            string q =
                @"UPDATE [FundingLines] 
                        SET [name] = @name, 
                        [begin_date] = @beginDate,
                        [end_date]=@endDate,
                        [amount] = @amount,
                        [purpose] = @purpose, 
                        [deleted]=@deleted, 
                        [currency_id] = @currency_id
                        WHERE [id] = @id";

            using (OpenCbsCommand c = new OpenCbsCommand(q, pSqlTransac.Connection, pSqlTransac))
            {
                c.AddParam("@id", fund.Id);
                c.AddParam("@name", fund.Name);
                c.AddParam("@beginDate", fund.StartDate);
                c.AddParam("@purpose", fund.Purpose);
                c.AddParam("@endDate", fund.EndDate);
                c.AddParam("@amount", fund.Amount);
                c.AddParam("@deleted", fund.Deleted);
                c.AddParam("@currency_id", fund.Currency.Id);
                c.ExecuteNonQuery();


                foreach (FundingLineEvent eventFL in fund.Events)
                {
                    if (eventFL.Id == 0)
                    {
                        _eventFundingLineManager.AddFundingLineEvent(eventFL, pSqlTransac); //new event
                    }
                    else
                    {
                        _eventFundingLineManager.UpdateFundingLineEvent(eventFL, pSqlTransac); // delete event
                    }
                }
            }
        }
        public void AddCredit_SelectByCode_ContractChartOfAccounts()
        {
            FundingLine fund = new FundingLine
                                   {
                                       Purpose = "Microsoft financement",
                                       Name = "AFD130",
                                       Deleted = false,
                                       StartDate = DateTime.Now,
                                       EndDate = DateTime.Now,
                                       Currency = new Currency { Id = 1 }
                                   };
            fundingLineManager.AddFundingLine(fund, null);
            credit.FundingLine = fund;
            credit.Code = "TEST";
            credit.ChartOfAccounts.Accounts[1].Balance = 3000;
            credit.ChartOfAccounts.Accounts[4].Balance = 1254;
            credit.ChartOfAccounts.Accounts[6].Balance = 4587;
            credit.ChartOfAccounts.Accounts[16].Balance = 32.54m;
            credit.Id = creditManagement.AddCredit(credit, _project.Id, null);
            Loan contractRetrieved = creditManagement.SelectContractByContractCode(credit.Code);

            Assert.AreEqual(3000m, contractRetrieved.ChartOfAccounts.Accounts[1].Balance.Value);
            Assert.AreEqual(1254m, contractRetrieved.ChartOfAccounts.Accounts[4].Balance.Value);
            Assert.AreEqual(4587m, contractRetrieved.ChartOfAccounts.Accounts[6].Balance.Value);
            Assert.AreEqual(32.54m, contractRetrieved.ChartOfAccounts.Accounts[16].Balance.Value);
        }
        public void TestSearchContractInDatabaseWithStartDateSetAndLoanOfficerFilterNotActive()
        {
            ApplicationSettings dataParam = ApplicationSettings.GetInstance("");
            dataParam.DeleteAllParameters();
            dataParam.AddParameter(OGeneralSettings.LOANOFFICERPORTFOLIOFILTER, false);
            dataParam.AddParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash);
            dataParam.AddParameter(OGeneralSettings.USECENTS, true);

            FundingLine fund = new FundingLine();
            fund.Purpose = "Microsoft financement";
            fund.Name = "AFD130";
            fund.Deleted = false;
            fund.StartDate = DateTime.Now;
            fund.EndDate = DateTime.Now;
            fund.Currency = new Currency { Id = 1 };
            fundingLineManager.AddFundingLine(fund, null);
            credit.FundingLine = fund;
            creditManagement.AddCredit(credit, _project.Id, null);
            Assert.AreEqual(1, creditManagement.SearchCreditInDatabase(1, null).Count);
        }
Beispiel #31
0
 public OCurrency GetAmount(FundingLine fl)
 {
     return(GetAmountImpl(fl, OFundingLineEventTypes.Entry, true));
 }
Beispiel #32
0
 private void _DisplayAmounts(FundingLine fl)
 {
     bool useCents = null == fl.Currency ? true : fl.Currency.UseCents;
     tbInitialAmt.Text = fl.Amount.GetFormatedValue(useCents);
     tbRealAmt.Text = fl.RealRemainingAmount.GetFormatedValue(useCents);
     tbAnticipatedAmt.Text = fl.AnticipatedRemainingAmount.GetFormatedValue(useCents);
 }
Beispiel #33
0
        private void InitializeTabPageFundingLineDetails(FundingLine fl)
        {
            btnSave.Text = GetString(0 == fl.Id ? "save" : "update");
            textBoxFundingLineCode.Text = fl.Name;
            textBoxFundingLineName.Text = fl.Purpose;
            dateTimePickerFundingLineBeginDate.Value = fl.StartDate == DateTime.MinValue
                                                           ? TimeProvider.Today
                                                           : fl.StartDate;

            dateTimePickerFundingLineEndDate.Value = fl.EndDate == DateTime.MinValue
                                                         ? TimeProvider.Today
                                                         : fl.EndDate;
            _InitializeComboBoxCurrencies();
            if (fl.Currency != null)
            {
                comboBoxCurrencies.Text = fl.Currency.Name;
                comboBoxCurrencies.Enabled = false;
            }
            else
                comboBoxCurrencies.Enabled = true;
            RefreshView();
        }
Beispiel #34
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            if (listViewFundingLine.SelectedItems != null)
            {
                _fundingLine = (FundingLine) listViewFundingLine.SelectedItems[0].Tag;

                ServicesProvider.GetInstance().GetFundingLinesServices().DeleteFundingLine(_fundingLine);
                InitializeFundingLines();
            }
        }
Beispiel #35
0
 private void comboBoxLoanFundingLine_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!(comboBoxLoanFundingLine.SelectedItem is FundingLine))
     {
         comboBoxLoanFundingLine.Tag = null;
         return;
     }
     _fundingLine = (FundingLine)comboBoxLoanFundingLine.SelectedItem;
     if (!_fundingLine.Deleted)
     {
         comboBoxLoanFundingLine.ForeColor = Color.Black;
         comboBoxLoanFundingLine.Font = new Font(Font, FontStyle.Regular);
         buttonLoanRepaymentRepay.Enabled = true;
         if (_credit != null && !_credit.WrittenOff)
             btnWriteOff.Enabled = true;
     }
     comboBoxLoanFundingLine.Tag = _fundingLine;
 }
        public void TestAddLoanInDatabaseWithCreditCommitteeCode()
        {
            FundingLine fund = new FundingLine
            {
                Purpose = "Microsoft financement",
                Name = "AFD130",
                Deleted = false,
                StartDate = DateTime.Now,
                EndDate = DateTime.Now,
                Currency = new Currency { Id = 1 }
            };

            fundingLineManager.AddFundingLine(fund, null);
            credit.FundingLine = fund;
            credit.CreditCommitteeCode = "Code";

            credit.Id = creditManagement.AddCredit(credit, _project.Id, null);
            Loan contractRetrieved = creditManagement.SelectCreditById(credit.Id);

            Assert.AreEqual("Code", contractRetrieved.CreditCommitteeCode);
        }
Beispiel #37
0
 public List <FundingLineEvent> SelectFundingLineEvents(FundingLine fl)
 {
     return(_eventFundingLineManager.SelectFundingLineEvents(fl));
 }
Beispiel #38
0
 public OCurrency GetAnticipatedAmount(FundingLine fl)
 {
     return(GetAmountImpl(fl, OFundingLineEventTypes.Disbursment, false));
 }
 public void DeleteFundingLine(FundingLine fund)
 {
     _fundingLineManager.DeleteFundingLine(fund);
 }
        public FundingLine SelectFundingLineById(int id, bool pAddOptionalEventInformations)
        {
            FundingLine fund = _fundingLineManager.SelectFundingLineById(id, pAddOptionalEventInformations);

            return(fund);
        }
        public FundingLine SelectFundingLineById(int id, SqlTransaction sqlTransac)
        {
            FundingLine fund = _fundingLineManager.SelectFundingLineById(id, sqlTransac);

            return(fund);
        }
Beispiel #42
0
 public OCurrency GetRealAmount(FundingLine fl)
 {
     return(GetAmountImpl(fl, OFundingLineEventTypes.Commitment, false));
 }
        public void TestSearchContractInDatabaseWithUserIdSetAndUserLastNameAndFirstNameNull()
        {
            ApplicationSettings dataParam = ApplicationSettings.GetInstance("");
            dataParam.DeleteAllParameters();
            dataParam.AddParameter(OGeneralSettings.LOANOFFICERPORTFOLIOFILTER, false);
            dataParam.AddParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash);
            dataParam.AddParameter(OGeneralSettings.USECENTS, true);

            UserManager userManager = new UserManager(DataUtil.TESTDB);
            User loanOfficer = new User();
            loanOfficer.UserName = "******";
            loanOfficer.Password = "******";
            loanOfficer.Role = User.Roles.LOF;
            loanOfficer.Mail = "Not Set";
            loanOfficer.Id = userManager.AddUser(loanOfficer);
            credit.LoanOfficer = loanOfficer;
            FundingLine fund = new FundingLine();
            fund.Purpose = "Microsoft financement";
            fund.Name = "AFD130";
            fund.Deleted = false;
            fund.StartDate = DateTime.Now;
            fund.EndDate = DateTime.Now;
            fund.Currency = new Currency { Id = 1 };
            fundingLineManager.AddFundingLine(fund, null);
            credit.FundingLine = fund;
            creditManagement.AddCredit(credit, _project.Id, null);
            List<CreditSearchResult> ds = creditManagement.SearchCreditInDatabase(1, "G");
            Assert.AreEqual(1, ds.Count);
            Assert.AreEqual("lo", ds[0].LoanOfficerName);
        }
        public void TestSelectAllAlertsDisbursmentAlertWhenStartDateGreaterThanTodayAndDisbursedTrueAndLoanOfficerFilterNotActive()
        {
            ApplicationSettings dataParam = ApplicationSettings.GetInstance("");
            dataParam.DeleteAllParameters();
            dataParam.AddParameter(OGeneralSettings.LOANOFFICERPORTFOLIOFILTER, false);
            dataParam.AddParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash);
            dataParam.AddParameter(OGeneralSettings.USECENTS, true);
            credit.StartDate = DateTime.Today.AddDays(1);
            credit.Disbursed = true;
            FundingLine fund = new FundingLine();
            fund.Purpose = "Microsoft financement";
            fund.Name = "AFD130";
            fund.Deleted = false;
            fund.StartDate = DateTime.Now;
            fund.EndDate = DateTime.Now;
            fund.Currency = new Currency { Id = 1 };
            fundingLineManager.AddFundingLine(fund, null);
            credit.FundingLine = fund;
            creditManagement.AddCredit(credit, _project.Id, null);

            AlertStock alertStock = creditManagement.SelectAllAlerts("");
            Assert.AreEqual(0, alertStock.GetNumberOfAlerts);
        }
        public void TestDeleteContract()
        {
            FundingLine fund = new FundingLine
                                   {
                                       Purpose = "Microsoft financement",
                                       Name = "AFD130",
                                       Deleted = false,
                                       StartDate = DateTime.Now,
                                       EndDate = DateTime.Now,
                                       Currency = new Currency { Id = 1 }
                                   };
            fundingLineManager.AddFundingLine(fund, null);
            credit.FundingLine = fund;
            guarantor.Tiers = tiers;
            guarantor.Amount = 1000m;
            credit.AddGuarantor(guarantor);

            credit.Events.Add(new LoanDisbursmentEvent { Date = new DateTime(2006, 1, 1), Amount = 100, Commission = 100, ClientType = credit.ClientType });

            credit.Id = creditManagement.AddCredit(credit, _project.Id, null);
            Loan contractRetrievedBeforeDelete = creditManagement.SelectCreditById(credit.Id);

            Assert.AreEqual(credit.Id, contractRetrievedBeforeDelete.Id);
            creditManagement.DeleteContract(credit, null);
            Loan contractRetrievedAfterDelete = creditManagement.SelectCreditById(credit.Id);
            Assert.IsNull(contractRetrievedAfterDelete);
        }
Beispiel #46
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     tabControlFundingLines.TabPages.Remove(tabPageFundingLineDetails);
     tabControlFundingLines.TabPages.Add(tabPageFundingLineDetails);
     tabControlFundingLines.SelectedTab = tabPageFundingLineDetails;
     _fundingLine = new FundingLine();
     InitializeTabPageFundingLineDetails(_fundingLine);
 }
        public void TestReassignContract()
        {
            User user = new User();
            user.FirstName = "Andrey";
            user.LastName = "Galkin";
            user.Password = "******";
            user.UserName = "******";
            user.Mail = "*****@*****.**";

            userManager.AddUser(user);

            Assert.AreEqual(2, credit.InstallmentList.Count);
            FundingLine fund = new FundingLine
            {
                Purpose = "Microsoft financement",
                Name = "AFD130",
                Deleted = false,
                StartDate = DateTime.Now,
                EndDate = DateTime.Now,
                Currency = new Currency { Id = 1 }
            };

            fundingLineManager.AddFundingLine(fund, null);
            credit.FundingLine = fund;
            credit.LoanOfficer = user;
            credit.Id = creditManagement.AddCredit(credit, _project.Id, null);

            var newUser = new User { Id = addDataForTesting.AddUserWithMaximumAttributs() };

            creditManagement.UpdateCreditByOfficer(credit.Id, newUser.Id, user.Id, null);

            List<int> contract_id = creditManagement.SelectContractIdByNewOldLoanOfficer(newUser.Id, user.Id, null);
            Assert.AreEqual(credit.Id, contract_id[0]);
        }
Beispiel #48
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            try
            {
                _fundingLine.Name = textBoxFundingLineCode.Text;
                _fundingLine.Purpose = textBoxFundingLineName.Text;
                _fundingLine.StartDate = dateTimePickerFundingLineBeginDate.Value;
                _fundingLine.EndDate = dateTimePickerFundingLineEndDate.Value;
                _fundingLine.Currency = comboBoxCurrencies.SelectedItem as Currency;
                if (_fundingLine.Id != 0)
                    ServicesProvider.GetInstance().GetFundingLinesServices().UpdateFundingLine(_fundingLine);
                else
                    _fundingLine = ServicesProvider.GetInstance().GetFundingLinesServices().Create(_fundingLine);

                InitializeFundingLines();
                InitializeTabPageFundingLineDetails(_fundingLine);
                btnSave.Text = GetString("update");
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
        public void TestSeachContractByCode()
        {
            FundingLine fund = new FundingLine();
            fund.Purpose = "Microsoft financement";
            fund.Name = "AFD130";
            fund.Deleted = false;
            fund.StartDate = DateTime.Now;
            fund.EndDate = DateTime.Now;
            fund.Currency = new Currency { Id = 1 };
            fundingLineManager.AddFundingLine(fund, null);
            credit.FundingLine = fund;
            credit.Code = "TEST22";
            credit.Id = creditManagement.AddCredit(credit, _project.Id, null);
            int id = credit.Id;

            Assert.AreEqual(id, creditManagement.SelectContractByContractCode(credit.Code).Id);
        }
Beispiel #50
0
        private void listViewFundingLine_DoubleClick(object sender, EventArgs e)
        {
            tabControlFundingLines.TabPages.Remove(tabPageFundingLineDetails);
            tabControlFundingLines.TabPages.Add(tabPageFundingLineDetails);
            tabControlFundingLines.SelectedTab = tabPageFundingLineDetails;

            _fundingLine = (FundingLine) listViewFundingLine.SelectedItems[0].Tag;
            InitializeTabPageFundingLineDetails(_fundingLine);
        }
        public void TestSearchContractInDatabaseWithClientNameSetWhenClientIsPerson()
        {
            ApplicationSettings dataParam = ApplicationSettings.GetInstance("");
            dataParam.DeleteAllParameters();
            dataParam.AddParameter(OGeneralSettings.LOANOFFICERPORTFOLIOFILTER, false);
            dataParam.AddParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash);
            dataParam.AddParameter(OGeneralSettings.USECENTS, true);

            addDataForTesting.DeleteInstallments();
            addDataForTesting.DeleteCreditContract();
            addDataForTesting.DeletedProject();
            addDataForTesting.DeleteInstallmentTypes();
            addDataForTesting.DeleteTiers();
            addDataForTesting.DeleteAllUser();

            biWeekly = addDataForTesting.AddBiWeeklyInstallmentType();
            package.Id = addDataForTesting.AddGenericPackage();
            user.Id = addDataForTesting.AddUserWithIntermediaryAttributs();
            addDataForTesting.AddGenericFundingLine();

            credit.InstallmentType = biWeekly;
            credit.Product = package;
            credit.LoanOfficer = user;

            Person person = new Person();
            person.Id = addDataForTesting.AddGenericTiersIntoDatabase(OClientTypes.Person);
            _project.Id = projectManager.Add(_project, person.Id, null);
            FundingLine fund = new FundingLine();
            fund.Purpose = "Microsoft financement";
            fund.Name = "AFD130";
            fund.Deleted = false;
            fund.StartDate = DateTime.Now;
            fund.EndDate = DateTime.Now;
            fund.Currency = new Currency { Id = 1 };
            fundingLineManager.AddFundingLine(fund, null);
            credit.FundingLine = fund;
            creditManagement.AddCredit(credit, _project.Id, null);
            List<CreditSearchResult> ds = creditManagement.SearchCreditInDatabase(1, "Nico");
            Assert.AreEqual(1, ds.Count);
            Assert.AreEqual("Nicolas BARON", ds[0].ClientName);
        }
 public void FireFundingLineEvent(Event e, FundingLine fundingLine, SqlTransaction sqlTransac)
 {
     e.IsFired = true;
     FundingLineEvent fL = e as FundingLineEvent;
     //_movementSetManagement.AddTransaction(mS, sqlTransac);
 }
        public void TestSearchContractInDatabaseWithStartDateSetAndLoanOfficerFilterActiveButCurrentUserIsAdmin()
        {
            ApplicationSettings dataParam = ApplicationSettings.GetInstance("");
            dataParam.DeleteAllParameters();
            dataParam.AddParameter(OGeneralSettings.LOANOFFICERPORTFOLIOFILTER, false);
            dataParam.AddParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash);
            dataParam.AddParameter(OGeneralSettings.USECENTS, true);

            User _user = new User();
            _user.Id = this.addDataForTesting.AddUserWithMaximumAttributs();
            _user.Role = User.Roles.ADMIN;
            FundingLine fund = new FundingLine();
            fund.Purpose = "Microsoft financement";
            fund.Name = "AFD130";
            fund.Deleted = false;
            fund.StartDate = DateTime.Now;
            fund.EndDate = DateTime.Now;
            fund.Currency = new Currency { Id = 1 };
            fundingLineManager.AddFundingLine(fund, null);
            credit.FundingLine = fund;
            creditManagement.AddCredit(credit, _project.Id, null);
            credit.LoanOfficer = _user;
            creditManagement.AddCredit(credit, _project.Id, null);

            Assert.AreEqual(2, creditManagement.SearchCreditInDatabase(1, null).Count);

            dataParam.DeleteAllParameters();
            dataParam.AddParameter(OGeneralSettings.LOANOFFICERPORTFOLIOFILTER, true);
            dataParam.AddParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash);
            dataParam.AddParameter(OGeneralSettings.USECENTS, true);
            User.CurrentUser = new User();
            User.CurrentUser.Id = _user.Id;
            User.CurrentUser.Role = User.Roles.ADMIN;

            CreditContractManagement manager = new CreditContractManagement(DataUtil.TESTDB, User.CurrentUser);
            Assert.AreEqual(2, manager.SearchCreditInDatabase(1, null).Count);
        }