public void InitManager()
        {
            ApplicationSettings.GetInstance("").DeleteAllParameters();
            ApplicationSettings.GetInstance("").AddParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true);
            ApplicationSettings.GetInstance("").AddParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash);
            TechnicalSettings.UseOnlineMode = false;
            //Create Manager
            FundingLineManager fundingLineManager = new FundingLineManager(DataUtil.TESTDB);
            ClientManager clientManagement = new ClientManager(DataUtil.TESTDB);
            ConnectionManager connectionManager = ConnectionManager.GetInstance(DataUtil.TESTDB);
            //Create Service
            EconomicActivityServices economicActivityServices = new EconomicActivityServices(DataUtil.TESTDB);
            ClientServices clientService = new ClientServices(clientManagement);
            FundingLineServices fundingLineService = new FundingLineServices(fundingLineManager, clientManagement);
            ProjectServices projectService = new ProjectServices(DataUtil.TESTDB);

            container = new Hashtable
                            {
                                {"EconomicActivityServices", economicActivityServices},
                                {"ClientServices", clientService},
                                {"FundingLineServices", fundingLineService},
                                {"ProjectServices", projectService},
                                {"ConnectionManager", connectionManager}
                            };
        }
Beispiel #2
0
 public ProjectServices(User pUser,string testDB)
 {
     _user = pUser;
     _ProjectManager = new ProjectManager(testDB, pUser);
     _ClientServices = new ClientServices(pUser, testDB);
     _branchService = new BranchService(pUser);
 }
Beispiel #3
0
 public ProjectServices(User pUser)
 {
     _user = pUser;
     _ProjectManager = new ProjectManager(pUser, true);
     _ClientServices = new ClientServices(pUser);
     _branchService = new BranchService(pUser);
 }
Beispiel #4
0
        public void TestFindTiersWhenNoResult()
        {
            int numberTotalPage = 1;
            int numberOfRecords = 1;
            string query = "nicolas";
            List <ClientSearchResult> list = new List<ClientSearchResult>();
            //mockClientManagement.ExpectAndReturn("GetNumberGroup", 0, query);
            //mockClientManagement.ExpectAndReturn("GetNumberPerson", 0, query);
            //mockClientManagement.ExpectAndReturn("GetNumberVillages", 0, query);

            //mockClientManagement.ExpectAndReturn("SearchGroupByCriteres", list, numberTotalPage, query);
            //mockClientManagement.ExpectAndReturn("SearchPersonByCriteres", list, numberTotalPage, query);
            //mockClientManagement.ExpectAndReturn("SearchVillagesByCriteres", list, numberTotalPage, query);
            mockClientManagement.ExpectAndReturn("GetFoundRecordsNumber",0, query, 2, 1, 1, 1);

            mockClientManagement.ExpectAndReturn("SearchAllByCriteres", list, query,2, numberTotalPage,1, 1, 1);

            clientManagement = (ClientManager)mockClientManagement.MockInstance;
            clientServices = new ClientServices(clientManagement);

            List<ClientSearchResult> result = clientServices.FindTiers(out numberTotalPage, out numberOfRecords,query, 2,  numberTotalPage, 1, 1, 1);
            Assert.AreEqual(0, result.Count);
        }
Beispiel #5
0
        public void TestCreatingContractForNonSolidaryGroupWithLoanCycles()
        {
            LoanProductManager productManager = new LoanProductManager(DataUtil.TESTDB);
            ProductServices productServices = new ProductServices(productManager);

            ClientManager clientManager = new ClientManager(DataUtil.TESTDB);
            ClientServices clientServices = new ClientServices(clientManager);

            Village village = new Village();
            Person person = clientServices.FindPersonById(2);
            person.LoanCycle = 0;

            VillageMember villageMember = new VillageMember();
            villageMember.Tiers = person;
            village.Members.Add(villageMember);

            person = clientServices.FindPersonById(4);
            person.LoanCycle = 1;

            villageMember = new VillageMember();
            villageMember.Tiers = person;
            village.Members.Add(villageMember);

            person = clientServices.FindPersonById(6);
            person.LoanCycle = 2;
            villageMember = new VillageMember();
            villageMember.Tiers = person;
            village.Members.Add(villageMember);

            var loanAmountCycle = GetLoanAmountCycles();
            var maturityCycles = GetMaturityCycles();
            var rateCycles = GetRateCycles();
            var entryFees = new List<EntryFee>();

            Currency currency = new Currency();
            currency.Id = 1;
            var nrp = new NonRepaymentPenaltiesNullableValues(100, 200, 10, 0.2);
            LoanProduct product = CreatePackage(
                                                "NewPackage68", //package name
                                                null, //anticipatedTotalRepaymentPenalties
                                                3, //anticipatedTotalRepaymentPenaltiesMin
                                                6, //anticipatedTotalRepaymentPenaltiesMax
                                                4, //grace period
                                                null, //gracePeriodMin
                                                null, //gracePeriodMax
                                                0.2m, //interestRate
                                                null, //interesrRateMin
                                                null, //interestRateMax
                                                10, //NmbOfInstallments
                                                null, //NmbOfInstallmentsMin
                                                null, //NmbOfInstallmentsMax
                                                entryFees, //List<EntryFee>
                                                nrp, //NonRepaymentPenalties
                                                null, //NonRepaymentPenaltiesMin
                                                null, //NonRepaymentPenaltiesMax
                                                _monthly, //InstallmentType
                                                2000, //amount
                                                null, //amountMin
                                                null, //AmountMax
                                                null, //ExoticInstallmentsTable
                                                2, //cycleId
                                                loanAmountCycle, //List<LoanAmountCycle>
                                                rateCycles, //List<RateCycle>
                                                maturityCycles, //List<MaturityCycle>
                                                "CODE1", //ProductCode
                                                null, //List<ProductClientType>
                                                null, //amountUnderLoc
                                                null, //amountUnderLocMin
                                                null, //amountUnderLocMax
                                                1, //anticipatedPartialRRepaymentPenalties
                                                null, //anticipatedPartialRRepaymentPenaltiesMin
                                                null, //anticipatedPartialRRepaymentPenaltiesMax
                                                null, //compulsoryAmount
                                                null, //compulsoryAmountMin
                                                null, //compulsoryAmountMax
                                                currency
                );
            product.ClientType = '-';
            product.ProductClientTypes = new List<ProductClientType>();
            product.AddedEntryFees = entryFees;
            product.Id=productServices.AddPackage(product);
            productServices.SaveAllCycleParams(loanAmountCycle, rateCycles, maturityCycles);

            foreach (VillageMember member in village.Members)
            {
                productServices.SetVillageMemberCycleParams(member, product.Id, ((Person)member.Tiers).LoanCycle);
            }

            for (int i = 0; i < village.Members.Count; i++)
            {
                int j = i;
                //to avoid index out of range exception (it occurs in product.LoanAmountCycleParams)
                if (i == product.LoanAmountCycleParams.Count) j = product.LoanAmountCycleParams.Count - 1;
                Assert.AreEqual(village.Members[i].Product.AmountMin, product.LoanAmountCycleParams[j].Min);
                Assert.AreEqual(village.Members[i].Product.AmountMax, product.LoanAmountCycleParams[j].Max);
                Assert.AreEqual(village.Members[i].Product.InterestRateMin, product.RateCycleParams[j].Min.Value);
                Assert.AreEqual(village.Members[i].Product.InterestRateMax, product.RateCycleParams[j].Max.Value);
                Assert.AreEqual(village.Members[i].Product.NbOfInstallmentsMin, (int) product.MaturityCycleParams[j].Min.Value);
                Assert.AreEqual(village.Members[i].Product.NbOfInstallmentsMax, (int) product.MaturityCycleParams[j].Max.Value);
            }

            foreach (VillageMember member in village.Members)
            {
                Loan loan = new Loan();
                loan.LoanPurpose = "Unit tests";
                loan.Product = member.Product;

                loan.Amount = member.Product.AmountMin;
                loan.AmountMin = member.Product.AmountMin;
                loan.AmountMax = member.Product.AmountMax;
                loan.InterestRate = member.Product.InterestRateMin.Value;
                loan.InterestRateMin = member.Product.InterestRateMin.Value;
                loan.InterestRateMax = member.Product.InterestRateMax.Value;
                loan.NbOfInstallments = member.Product.NbOfInstallmentsMin.Value;
                loan.NmbOfInstallmentsMin = member.Product.NbOfInstallmentsMin.Value;
                loan.NmbOfInstallmentsMax = member.Product.NbOfInstallmentsMax;
                loan.StartDate = TimeProvider.Now;
                loan.FirstInstallmentDate = loan.FirstInstallmentDate = DateTime.Now + new TimeSpan(30, 0, 0, 0);
                loan.CloseDate = TimeProvider.Now + new TimeSpan(365, 0, 0, 0);
                loan.EconomicActivityId = 1;

                loan.NonRepaymentPenalties = new NonRepaymentPenalties
                {
                    InitialAmount = member.Product.NonRepaymentPenalties.InitialAmount ?? 0,
                    OLB = member.Product.NonRepaymentPenalties.OLB ?? 0,
                    OverDuePrincipal = member.Product.NonRepaymentPenalties.OverDuePrincipal ?? 0,
                    OverDueInterest = member.Product.NonRepaymentPenalties.OverDueInterest ?? 0
                };
                loan.LoanEntryFeesList = new List<LoanEntryFee>();
                loan.InstallmentType = member.Product.InstallmentType;
                loan.AnticipatedTotalRepaymentPenalties = 0;
                loan.FundingLine = new FundingLine("New_Founding_line", false);
                loan.FundingLine.Currency = loan.Product.Currency;
                loan.FundingLine.Id = 1;
                loan.LoanOfficer = User.CurrentUser;
                loan.LoanOfficer.LastName = "Unit";
                loan.LoanOfficer.FirstName = "Test";
                loan.Synchronize = false;
                loan.ContractStatus = OContractStatus.Validated;
                loan.CreditCommitteeCode = "OK";
                loan.GracePeriod = 0;
                loan.GracePeriodOfLateFees = member.Product.GracePeriodOfLateFees;
                loan.AnticipatedPartialRepaymentPenalties = 2;
                loan.AnticipatedTotalRepaymentPenalties = 3;
                loan.LoanCycle = ((Person)member.Tiers).LoanCycle;
                loan.InstallmentList = new List<Installment>();
                loan.InstallmentList.Add(new Installment());
                loan.InstallmentList[0].ExpectedDate = TimeProvider.Now + new TimeSpan(60, 0, 0, 0);
                loan.InstallmentList[0].InterestsRepayment = 10;
                loan.InstallmentList[0].Number = 1;
                loan.InstallmentList[0].CapitalRepayment = 10;
                loan.InstallmentList[0].PaidInterests = 10;
                loan.InstallmentList[0].PaidCapital = 10;
                loan.InstallmentList[0].PaidDate = TimeProvider.Now;
                loan.InstallmentList[0].FeesUnpaid = 10;
                loan.InstallmentList[0].PaidFees = 10;
                loan.InstallmentList[0].Comment = "Unit test";
                loan.InstallmentList[0].IsPending = false;
                loan.InstallmentList[0].StartDate = TimeProvider.Now;
                loan.InstallmentList[0].OLB = 20;

                loan.InstallmentList.Add(new Installment());
                loan.InstallmentList[1].ExpectedDate = TimeProvider.Now + new TimeSpan(120, 0, 0, 0);
                loan.InstallmentList[1].InterestsRepayment = 10;
                loan.InstallmentList[1].Number = 2;
                loan.InstallmentList[1].CapitalRepayment = 10;
                loan.InstallmentList[1].PaidInterests = 10;
                loan.InstallmentList[1].PaidCapital = 10;
                loan.InstallmentList[1].PaidDate = TimeProvider.Now + new TimeSpan(120, 0, 0, 0);
                loan.InstallmentList[1].FeesUnpaid = 10;
                loan.InstallmentList[1].PaidFees = 10;
                loan.InstallmentList[1].Comment = "Unit test2";
                loan.InstallmentList[1].IsPending = false;
                loan.InstallmentList[1].StartDate = TimeProvider.Now.AddDays(60);
                loan.InstallmentList[1].OLB = 10;
                loan.Events = new EventStock();
                loan.AlignDisbursementDate = TimeProvider.Now;
                loan.CreditCommiteeDate = TimeProvider.Now;
                loan.Guarantors = new List<Guarantor>();
                loan.Collaterals = new List<ContractCollateral>();

                Project project;
                IClient client = member.Tiers;
                if (0 == client.Projects.Count)
                {
                    project = new Project("Village");
                    project.Name = "Village";
                    project.Code = "Village";
                    project.Aim = "Village";
                    project.BeginDate = TimeProvider.Now;
                    project.Id = ServicesProvider.GetInstance().GetProjectServices().SaveProject(project, client);
                    member.Tiers.AddProject(project);
                }
                project = client.Projects[0];
                client.District = new District(1, "Unit Test");
                client.Name = "Unit Test";

                ApplicationSettings appSettings = ApplicationSettings.GetInstance(User.CurrentUser.Md5);
                appSettings.UpdateParameter("ALLOWS_MULTIPLE_LOANS", 1);
                appSettings.UpdateParameter("CONTRACT_CODE_TEMPLATE", "Contract");

                ServicesProvider.GetInstance().GetContractServices().SaveLoan(ref loan, project.Id, ref client);
            }

            foreach (VillageMember member in village.Members)
            {
                member.ActiveLoans = ServicesProvider.GetInstance().GetContractServices().FindActiveContracts(member.Tiers.Id);
            }

            for (int i = 0; i < village.Members.Count; i++)
            {
                int j = i;
                //to avoid index out of range exception (it occurs in product.LoanAmountCycleParams)
                if (i == product.LoanAmountCycleParams.Count) j = product.LoanAmountCycleParams.Count - 1;
                for (int k = 0; k < village.Members[i].ActiveLoans.Count; k++)
                {
                    Assert.AreEqual(village.Members[i].ActiveLoans[k].AmountMin, loanAmountCycle[j].Min);
                    Assert.AreEqual(village.Members[i].ActiveLoans[k].AmountMax, loanAmountCycle[j].Max);
                    Assert.AreEqual(village.Members[i].ActiveLoans[k].Amount, loanAmountCycle[j].Min);
                    Assert.AreEqual(village.Members[i].ActiveLoans[k].InterestRateMin, (double?) rateCycles[j].Min.Value);
                    Assert.AreEqual(village.Members[i].ActiveLoans[k].InterestRateMax, (double?) rateCycles[j].Max.Value);
                    Assert.AreEqual(village.Members[i].ActiveLoans[k].InterestRate, (double?) rateCycles[j].Min.Value);
                    Assert.AreEqual(village.Members[i].ActiveLoans[k].NmbOfInstallmentsMin,
                                    (int) maturityCycles[j].Min.Value);
                    Assert.AreEqual(village.Members[i].ActiveLoans[k].NmbOfInstallmentsMax,
                                    (int) maturityCycles[j].Max.Value);
                    Assert.AreEqual(village.Members[i].ActiveLoans[k].NbOfInstallments, (int) maturityCycles[j].Min.Value);
                }
            }
        }
Beispiel #6
0
        public void TestFindTiersWhenTiersIsPersonAndRecordsAreFound()
        {
            int numberTotalPage = 1;
            int numberOfRecords = 1;
            string query = "nicolas";

            List<ClientSearchResult> listGroup = new List<ClientSearchResult>();

            for (int i = 1; i <= 15; i++)
            {
                listGroup.Add(new ClientSearchResult(i, "nicolas", OClientTypes.Person, true, 1, "district", "city", false, "OOOOO","test"));
            }

            //mockClientManagement.ExpectAndReturn("GetNumberGroup", 0, query);
            //mockClientManagement.ExpectAndReturn("GetNumberPerson", 0, query);
            //mockClientManagement.ExpectAndReturn("GetNumberVillages", 0, query);
            mockClientManagement.ExpectAndReturn("GetFoundRecordsNumber", 15, query, 1, 1, 1, 1);
            //mockClientManagement.ExpectAndReturn("SearchGroupByCriteres", listGroup, numberTotalPage, query);
            //mockClientManagement.ExpectAndReturn("SearchPersonByCriteres", listPerson, numberTotalPage, query);
            //mockClientManagement.ExpectAndReturn("SearchVillagesByCriteres", listVillages, numberTotalPage, query);
            mockClientManagement.ExpectAndReturn("SearchAllByCriteres", listGroup, query,1, numberTotalPage,1, 1, 1);
            clientManagement = (ClientManager)mockClientManagement.MockInstance;
            clientServices = new ClientServices(clientManagement);

            List<ClientSearchResult> result = clientServices.FindTiers(out numberTotalPage, out numberOfRecords, query, 1, numberTotalPage, 1, 1, 1);
            Assert.AreEqual(15, result.Count);
        }
Beispiel #7
0
        public void TestUpdatePerson()
        {
            AddDataForTestingTransaction addDataForTesting = new AddDataForTestingTransaction();
            clientManagement = new ClientManager(DataUtil.TESTDB);
            clientServices = new ClientServices(clientManagement);

            DeleteAllData();
            ApplicationSettingsServices _appSettings = ServicesProvider.GetInstance().GetApplicationSettingsServices();
            _appSettings.FillGeneralDatabaseParameter();
            _appSettings.UpdateSelectedParameter(OGeneralSettings.ID_PATTERN, "[0-9]{2}[A-Z]{2}");

            EconomicActivity agriculture = addDataForTesting.AddDomainOfApplicationAgriculture();
            District district = addDataForTesting.AddDistrictIntoDatabase();

            Person person = AddPerson(true, agriculture, 1, "Dushambe", district, "Nicolas", "MANGIN", 'M', "12ED");
            person.Branch = _branch;
            Assert.AreEqual(String.Empty, clientServices.SavePerson(ref person));

            person.FirstName = "floriane";
            person.IdentificationData = "34PP";
            Assert.AreEqual(String.Empty, clientServices.SavePerson(ref person));
        }
Beispiel #8
0
        public void TestUpdateGroup()
        {
            AddDataForTestingTransaction addDataForTesting = new AddDataForTestingTransaction();
            clientManagement = new ClientManager(DataUtil.TESTDB);
            clientServices = new ClientServices(clientManagement);

            DeleteAllData();

            Person leader = addDataForTesting.AddPerson();
            Person members = addDataForTesting.AddPersonBis();
            Person membersTer = addDataForTesting.AddPersonTer();
            Person membersQuater = addDataForTesting.AddPersonQuater();
            Group group = new Group
                              {
                                  Active = true,
                                  City = "Dushambe",
                                  District = leader.District,
                                  LoanCycle = 2,
                                  Name = "SCG",
                                  Leader =new Member{Tiers = leader,LoanShareAmount = 1000,CurrentlyIn = true,IsLeader = true,JoinedDate = TimeProvider.Today},
                                  Branch = _branch
                              };

            group.AddMember(new Member { Tiers = members, LoanShareAmount = 200, CurrentlyIn = true, IsLeader = false, JoinedDate = TimeProvider.Today });
            group.AddMember(new Member { Tiers = membersTer, LoanShareAmount = 400, CurrentlyIn = true, IsLeader = false, JoinedDate = TimeProvider.Today });
            group.AddMember(new Member { Tiers = membersQuater, LoanShareAmount = 700, CurrentlyIn = true, IsLeader = false, JoinedDate = TimeProvider.Today });

            Assert.AreEqual(String.Empty, clientServices.SaveSolidarityGroup(ref group));

            group.Name = "SCG2";
            Assert.AreEqual(String.Empty, clientServices.SaveSolidarityGroup(ref group));
        }
Beispiel #9
0
        public void TestSaveGroupWhenOtherOrganizationDebtsIsBadlyInformed()
        {
            ApplicationSettings dataParam = GetDataBaseParam(4, true);

            ClientServices services = new ClientServices(dataParam);

            Member leader = new Member {Tiers = {Id = 1}};
            Group group = AddGroup(true, "Dushambe", new District(1, "district", new Province(1, "province")), "Nicolas", leader, 4);
            group.OtherOrgAmount = 100;
            group.OtherOrgDebts = ERRORVALUE;

            services.SaveSolidarityGroup(ref group);
        }
Beispiel #10
0
        public void TestSaveGroupWhenNoEnoughMembers()
        {
            ApplicationSettings dataParam = GetDataBaseParam(4, true);

            ClientServices services = new ClientServices(dataParam);
            Member leader = new Member {Tiers = {Id = 1}};
            Group group = AddGroup(true, "Dushambe", new District(1, "district", new Province(1, "province")), "Nicolas", leader, 0);

            services.SaveSolidarityGroup(ref group);
        }
Beispiel #11
0
        public void TestSaveGroupWhenLeaderIsNull()
        {
            ApplicationSettings dataParam = GetDataBaseParam(4, true);

            ClientServices services = new ClientServices(dataParam);
            Group group = AddGroup(true, "Dushambe", new District(1, "district", new Province(1, "province")), "Nicolas", null, 4);

            services.SaveSolidarityGroup(ref group);
        }
Beispiel #12
0
        public void TestSaveGroupWhenGroupIsNull()
        {
            ApplicationSettings dataParam = ApplicationSettings.GetInstance("");
            dataParam = GetDataBaseParam(4, true);

            ClientServices services = new ClientServices(dataParam);
            Group group = null;

            services.SaveSolidarityGroup(ref group);
        }
Beispiel #13
0
        public void TestSaveGroupWhenDistrictIsNull()
        {
            ApplicationSettings dataParam = GetDataBaseParam(4, true);

            ClientServices services = new ClientServices(dataParam);

            Member leader = new Member {Tiers = {Id = 1}};
            Group group = AddGroup(true, "Dushambe", null, "Nicolas", leader, 4);

            services.SaveSolidarityGroup(ref group);
        }
Beispiel #14
0
        public void TestIfClientCanBeAddToAGroupWhenClientIsALeader()
        {
            Person person = new Person {Id = 1, Active = false};
            Group group = new Group();

            mockClientManagement.ExpectAndReturn("IsLeader", true, person.Id);
            clientManagement = (ClientManager)mockClientManagement.MockInstance;
            clientServices = new ClientServices(clientManagement);

            clientServices.ClientCanBeAddToAGroup(person, group);
        }
Beispiel #15
0
        public void TestIfClientCanBeAddToAGroupWhenClientIsActive()
        {
            Person person = new Person {Id = 1, Active = true};
            Group group = new Group();

            clientManagement = new ClientManager(DataUtil.TESTDB);
            clientServices = new ClientServices(clientManagement);

            clientServices.ClientCanBeAddToAGroup(person, group);
        }
Beispiel #16
0
        public void TestSaveGroupWhenCityIsNotMandatory()
        {
            AddDataForTestingTransaction addDataForTesting = new AddDataForTestingTransaction();
            clientManagement = new ClientManager(DataUtil.TESTDB);
            clientServices = new ClientServices(clientManagement);
            branchManager = new BranchManager(DataUtil.TESTDB);
            //List<Branch> branchs = branchManager.SelectAll();

            ApplicationSettings dataParam = ApplicationSettings.GetInstance("");
            dataParam.DeleteAllParameters();
            dataParam.AddParameter(OGeneralSettings.GROUPMINMEMBERS, 4);
            dataParam.AddParameter(OGeneralSettings.GROUPMAXMEMBERS, 10);
            dataParam.AddParameter(OGeneralSettings.CITYMANDATORY, false);
            DeleteAllData();

            Person leader = addDataForTesting.AddPerson();
            Person members = addDataForTesting.AddPersonBis();
            Person membersTer = addDataForTesting.AddPersonTer();
            Person membersQuater = addDataForTesting.AddPersonQuater();
            Group group = new Group
                              {
                                  Active = true,
                                  City = null,
                                  District = leader.District,
                                  Name = "SCG",
                                  Leader = new Member { Tiers = leader, LoanShareAmount = 1000, CurrentlyIn = true, IsLeader = true, JoinedDate = TimeProvider.Today },
                                  LoanCycle = 3,
                                  Branch = _branch
                              };

            group.AddMember(new Member { Tiers = members, LoanShareAmount = 200, CurrentlyIn = true, IsLeader = false, JoinedDate = TimeProvider.Today });
            group.AddMember(new Member { Tiers = membersTer, LoanShareAmount = 400, CurrentlyIn = true, IsLeader = false, JoinedDate = TimeProvider.Today });
            group.AddMember(new Member { Tiers = membersQuater, LoanShareAmount = 700, CurrentlyIn = true, IsLeader = false, JoinedDate = TimeProvider.Today });

            Assert.AreEqual(String.Empty, clientServices.SaveSolidarityGroup(ref group));
        }