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);
        }
Exemplo n.º 2
0
        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;
                    }
        }
Exemplo n.º 3
0
        private static Credit _AddCredit()
        {
            GeneralSettings.GetInstance("").DeleteAllParameters();
            GeneralSettings.GetInstance("").AddParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash);
            GeneralSettings.GetInstance("").AddParameter(OGeneralSettings.USECENTS, true);
            FundingLineManager _fundingLineManager = new FundingLineManager(DataUtil.TESTDB);
            FundingLine        fund = new FundingLine();

            fund.Purpose   = "Microsoft financement";
            fund.Name      = "AFD130";
            fund.Deleted   = false;
            fund.StartDate = DateTime.Now;
            fund.EndDate   = DateTime.Now;
            _fundingLineManager.AddFundingLine(fund, null);
            Package _package = new Package();

            _package.Name       = "Package";
            _package.Delete     = false;
            _package.LoanType   = OLoanTypes.Flat;
            _package.ClientType = 'G';
            _package.ChargeInterestWithinGracePeriod = true;
            _package.InstallmentType = new DataHelper().AddBiWeeklyInstallmentType();
            _package.FundingLine     = fund;
            _package.Id = new ProductManager(DataUtil.TESTDB).AddPackage(_package);
            User user = new User();

            user.Id = new DataHelper().AddUserWithIntermediaryAttributs();

            Credit credit =
                new Credit(_package, 1000, 3, 6, 0, new DateTime(2006, 1, 1), user, GeneralSettings.GetInstance(""),
                           NonWorkingDateSingleton.GetInstance(""), ProvisioningTable.GetInstance(user));

            credit.CreationDate = DateTime.Today.AddDays(-1);
            credit.StartDate    = DateTime.Today;
            credit.LoanOfficer  = user;
            credit.CloseDate    = DateTime.Today.AddDays(1);
            credit.BranchCode   = "CA";


            credit.FundingLine = fund;
            //new DataHelper().AddGenericFundingLine();
            credit.Code = "TEST";

            return(credit);
        }