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)); }
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)); }
private void DeleteAllData() { AddDataForTestingTransaction addDataForTesting = new AddDataForTestingTransaction(); addDataForTesting.DeleteSaving(); addDataForTesting.DeleteCreditContract(); addDataForTesting.DeleteTiers(); addDataForTesting.DeleteCity(); addDataForTesting.DeleteDistrict(); addDataForTesting.DeleteProvince(); addDataForTesting.DeleteCorporate(); addDataForTesting.DeleteEconomicActivities(); }
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)); }
public void ShouldNotDisburseMultipleTimes() { var settings = ApplicationSettings.GetInstance(""); settings.UpdateParameter(OGeneralSettings.ALLOWSMULTIPLELOANS, true); settings.UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash); Teller.CurrentTeller = null; AddDataForTestingTransaction dataHelper = new AddDataForTestingTransaction(); int creditId = dataHelper.AddGenericCreditContractIntoDatabase(); LoanManager loanManager = new LoanManager(new User { Id = 1 }); Loan loan = loanManager.SelectLoan(creditId, true, true, true); FundingLine f = loan.FundingLine; f.Currency.Id = loan.Product.Currency.Id; FundingLineServices fundingLineServices = new FundingLineServices(new User() { Id = 1 }); var ev = new FundingLineEvent { Code = "KAO", Type = OFundingLineEventTypes.Entry, CreationDate = new DateTime(2008, 1, 10), EndDate = DateTime.Now.AddDays(1), Amount = 1000, FundingLine = f, Movement = OBookingDirections.Credit, IsDeleted = false }; fundingLineServices.AddFundingLineEvent(ev, null); f.AddEvent(ev); loan.CreditCommiteeDate = loan.StartDate; LoanServices loanServices = new LoanServices(new User { Id = 1 }); PaymentMethod method = new PaymentMethod(1, "Savings", "Savings method", false); try { loan.Disbursed = true; loanServices.Disburse(loan, new DateTime(2005, 10, 10), true, false, method); Assert.Fail("Contract should not be validated"); } catch(OpenCbsContractSaveException) { } try { loan.Disbursed = false; loanServices.Disburse(loan, new DateTime(2005, 10, 10), true, false, method); loanServices.Disburse(loan, new DateTime(2005, 10, 10), true, false, method); Assert.Fail("Contract should not be failed due to double disbursements"); } catch (OpenCbsContractSaveException) { } }
public void RepayWrittenOffLoan() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ALLOWSMULTIPLELOANS, false); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.INCREMENTALDURINGDAYOFF, false); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, 0); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.INTERESTS_ALSO_CREDITED_IN_FL, 1); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.DONOTSKIPWEEKENDSININSTALLMENTSDATE, 0); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.BAD_LOAN_DAYS, "180"); ProvisionTable _provisionningTable = ProvisionTable.GetInstance(new User() {Id = 1}); _provisionningTable.ProvisioningRates = new List<ProvisioningRate>(); _provisionningTable.Add(new ProvisioningRate { Number = 1, NbOfDaysMin = 0, NbOfDaysMax = 0, ProvisioningValue = 0.02, ProvisioningInterest = 0.02, ProvisioningPenalty = 0.02 }); _provisionningTable.Add(new ProvisioningRate { Number = 2, NbOfDaysMin = 1, NbOfDaysMax = 30, ProvisioningValue = 0.1, ProvisioningInterest = 0.01, ProvisioningPenalty = 0.01 }); _provisionningTable.Add(new ProvisioningRate { Number = 3, NbOfDaysMin = 31, NbOfDaysMax = 60, ProvisioningValue = 0.25, ProvisioningInterest = 0.025, ProvisioningPenalty = 0.025 }); _provisionningTable.Add(new ProvisioningRate { Number = 4, NbOfDaysMin = 61, NbOfDaysMax = 90, ProvisioningValue = 0.5, ProvisioningInterest = 0.5, ProvisioningPenalty = 0.5 }); _provisionningTable.Add(new ProvisioningRate { Number = 5, NbOfDaysMin = 91, NbOfDaysMax = 180, ProvisioningValue = 0.75, ProvisioningInterest = 0.75, ProvisioningPenalty = 0.75 }); _provisionningTable.Add(new ProvisioningRate { Number = 6, NbOfDaysMin = 181, NbOfDaysMax = 365, ProvisioningValue = 1, ProvisioningInterest = 1, ProvisioningPenalty = 1 }); _provisionningTable.Add(new ProvisioningRate { Number = 7, NbOfDaysMin = 366, NbOfDaysMax = 99999, ProvisioningValue = 1, ProvisioningInterest = 1, ProvisioningPenalty = 1 }); Teller.CurrentTeller = null; //DynamicMock mockClientManager = new DynamicMock(typeof(ClientManager)); //DynamicMock mockLoanManager = new DynamicMock(typeof(LoanManager)); //Loan loan = new Loan //{ // Amount = 11, // Code = "Test", // InterestRate = 1, // NbOfInstallments = 2, // InstallmentType = new InstallmentType(), // AnticipatedTotalRepaymentPenalties = 2, // NonRepaymentPenalties = new NonRepaymentPenalties(1, 1, 1, 1), // GracePeriod = 2, // Events = new EventStock(), // StartDate = new DateTime(2009, 1, 1), // FundingLine = new FundingLine { Currency = new Currency { Id = 1, Code = "Code", Name = "Name" } }, // LoanOfficer = new User(), // Product = new LoanProduct { Currency = new Currency { Id = 1, Code = "Code", Name = "Name" } }, // InstallmentList = new List<Installment> { _installment1, _installment2 } //}; //Person person = new Person { Active = false, LoanCycle = 1 }; //IClient group = new Group { Active = false, LoanCycle = 1, Members = new List<Member> { new Member { Tiers = person } } }; //mockClientManager.Expect("UpdateClientStatus", group, null); //mockClientManager.Expect("UpdateClientLoanCycle", group, null); //mockClientManager.Expect("UpdateClientStatus", person, null); //mockClientManager.Expect("UpdateClientLoanCycle", person, null); //LoanServices loanServices = new LoanServices(null, (ClientManager)mockClientManager.MockInstance, (LoanManager)mockLoanManager.MockInstance); //loanServices.SaveLoan(ref loan, 1, ref group); //loanServices.Disburse(loan, new DateTime(2008, 1, 1), true, true); //loanServices.Repay(loan, group, 1, DateTime.Now, 1, true, 0, 0, false, 0, true); //Loan disbursedLoan = loan; //disbursedLoan.Disbursed = true; //LoanDisbursmentEvent loanDisbursmentEvent = new LoanDisbursmentEvent // { // Date = new DateTime(2008, 1, 1), // Amount = disbursedLoan.Amount, // Commission = disbursedLoan.CalculateEntryFeesAmount(), // ClientType = disbursedLoan.ClientType // }; //disbursedLoan.Events.Add(loanDisbursmentEvent); //loanServices.Repay(disbursedLoan, group, 1, DateTime.Now, 1, true, 0,0, false, 1, true); AddDataForTestingTransaction dataHelper = new AddDataForTestingTransaction(); int _creditId = dataHelper.AddGenericCreditContractIntoDatabase(); IClient _client = new Group {Id = 5}; LoanManager _loanManager = new LoanManager(new User() {Id = 1}); Loan _loan = _loanManager.SelectLoan(_creditId, true, true, true); _loan.CreditCommiteeDate = _loan.StartDate; AccountManager accountManager = new AccountManager(new User() {Id = 1}); //accountManager.AddForCurrency(_loan.Product.Currency.Id); FundingLine f = _loan.FundingLine; f.Currency.Id = _loan.Product.Currency.Id; FundingLineServices fundingLineServices = new FundingLineServices(new User() {Id = 1}); var ev = new FundingLineEvent { Code = "KAO", Type = OFundingLineEventTypes.Entry, CreationDate = new DateTime(2008,1,1), EndDate = DateTime.Now.AddDays(1), Amount = 1000, FundingLine = f, Movement = OBookingDirections.Credit, IsDeleted = false }; fundingLineServices.AddFundingLineEvent(ev, null); f.AddEvent(ev); _loan.LoanEntryFeesList=new List<LoanEntryFee>(); EntryFee productEntryFee = new EntryFee(); productEntryFee.Value = 1; productEntryFee.IsRate = false; productEntryFee.Id = 21; LoanEntryFee loanEntryFee = new LoanEntryFee(); loanEntryFee.FeeValue = 1; loanEntryFee.ProductEntryFee = productEntryFee; loanEntryFee.ProductEntryFeeId = 21; LoanServices loanServices = new LoanServices(new User() { Id = 1 }); PaymentMethod method = new PaymentMethod(1, "Savings", "Savings method", false); loanServices.Disburse(_loan, new DateTime(2008, 1, 1), true, false, method); ////_loan.WrittenOff = true; ////_loan = loanServices.Repay(_loan, _client, 1, DateTime.Now, 10, true, 0, 0,false, 1, true); //Assert.AreEqual(_loan.Disbursed, true); //_loan.WrittenOff = true; //OCurrency prevAmount = _loan.ChartOfAccounts.GetAccountByNumber(OAccounts.RECOVERY_OF_CHARGED_OFF_ASSETS, _loan.Product.Currency.Id).Balance; //_loan = loanServices.Repay(_loan, _client, 1, DateTime.Now, 100, true, 0, 0, false, 5, false, OPaymentMethods.Cash, null, false); //Assert.AreEqual(_loan.Events.GetNumberOfEvents, 1); //_loan.Events.SortEventsByDate(); //Assert.AreEqual(_loan.Events.GetEvent(0).Code, "ROWO"); //_loan = loanServices.Repay(_loan, _client, 2, DateTime.Now, 100, true, 0, 0, false, 5, false, OPaymentMethods.Cash, null, false); //Assert.AreEqual(_loan.Events.GetNumberOfEvents, 2); //_loan.Events.SortEventsByDate(); //Assert.AreEqual(_loan.Events.GetEvent(0).Code, "ROWO"); }
public void RepayLoanBeforeDisburse() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ALLOWSMULTIPLELOANS, false); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.INCREMENTALDURINGDAYOFF, false); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, 0); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.INTERESTS_ALSO_CREDITED_IN_FL, 1); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.DONOTSKIPWEEKENDSININSTALLMENTSDATE, 0); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.BAD_LOAN_DAYS, "180"); ProvisionTable _provisionningTable = ProvisionTable.GetInstance(new User() { Id = 1 }); _provisionningTable.ProvisioningRates = new List<ProvisioningRate>(); _provisionningTable.Add(new ProvisioningRate { Number = 1, NbOfDaysMin = 0, NbOfDaysMax = 0, ProvisioningValue = 0.02, ProvisioningInterest = 0.02, ProvisioningPenalty = 0.02 }); _provisionningTable.Add(new ProvisioningRate { Number = 2, NbOfDaysMin = 1, NbOfDaysMax = 30, ProvisioningValue = 0.1, ProvisioningInterest = 0.1, ProvisioningPenalty = 0.1 }); _provisionningTable.Add(new ProvisioningRate { Number = 3, NbOfDaysMin = 31, NbOfDaysMax = 60, ProvisioningValue = 0.25, ProvisioningInterest = 0.25, ProvisioningPenalty = 0.25 }); _provisionningTable.Add(new ProvisioningRate { Number = 4, NbOfDaysMin = 61, NbOfDaysMax = 90, ProvisioningValue = 0.5, ProvisioningInterest= 0.5, ProvisioningPenalty= 0.5 }); _provisionningTable.Add(new ProvisioningRate { Number = 5, NbOfDaysMin = 91, NbOfDaysMax = 180, ProvisioningValue = 0.75, ProvisioningInterest = 0.75, ProvisioningPenalty = 0.75 }); _provisionningTable.Add(new ProvisioningRate { Number = 6, NbOfDaysMin = 181, NbOfDaysMax = 365, ProvisioningValue = 1, ProvisioningInterest = 1, ProvisioningPenalty= 1 }); _provisionningTable.Add(new ProvisioningRate { Number = 7, NbOfDaysMin = 366, NbOfDaysMax = 99999, ProvisioningValue = 1, ProvisioningInterest= 1, ProvisioningPenalty= 1 }); Teller.CurrentTeller = null; AddDataForTestingTransaction dataHelper = new AddDataForTestingTransaction(); int _creditId = dataHelper.AddGenericCreditContractIntoDatabase(); IClient _client = new Group { Id = 5 }; LoanManager _loanManager = new LoanManager(new User() { Id = 1 }); Loan _loan = _loanManager.SelectLoan(_creditId, true, true, true); _loan.CreditCommiteeDate = _loan.StartDate; FundingLine f = _loan.FundingLine; f.Currency.Id = _loan.Product.Currency.Id; FundingLineServices fundingLineServices = new FundingLineServices(new User() { Id = 1 }); var ev = new FundingLineEvent { Code = "KAO", Type = OFundingLineEventTypes.Entry, CreationDate = new DateTime(2008, 1, 10), EndDate = DateTime.Now.AddDays(1), Amount = 1000, FundingLine = f, Movement = OBookingDirections.Credit, IsDeleted = false }; fundingLineServices.AddFundingLineEvent(ev, null); f.AddEvent(ev); LoanServices loanServices = new LoanServices(new User() { Id = 1 }); PaymentMethod method = new PaymentMethod(1, "Savings", "Savings method", false); _loan = loanServices.Disburse(_loan, new DateTime(2005, 10, 10), true, false, method); Assert.AreEqual(_loan.Disbursed, true); PaymentMethod paymentMethod = new PaymentMethod(1, "Cash", "", false); loanServices.Repay(_loan, _client, 1, new DateTime(2005, 1, 5), 100, true, 0, 0, false, 5, false, false, paymentMethod, null, false); }
public void DoRepaymentFromSavingsAccount() { SetApplicationSettings(); AddDataForTestingTransaction dataHelper = new AddDataForTestingTransaction(); int _creditId = dataHelper.AddGenericCreditContractIntoDatabase(); IClient _client = ServicesProvider.GetInstance().GetClientServices().FindGroupByName("SCG"); LoanManager _loanManager = new LoanManager(new User() { Id = 1 }); Loan _loan = _loanManager.SelectLoan(_creditId, true, true, true); _loan.CreditCommiteeDate = _loan.StartDate; _loan.CompulsorySavings = GetSavingContract(_client); _loanManager.UpdateLoan(_loan); AddFundingLineEvent(_loan); LoanServices loanServices = new LoanServices(new User() { Id = 1 }); PaymentMethod method = new PaymentMethod(1, "Cash", "Cash", false); _loan = loanServices.Disburse(_loan, new DateTime(2005, 10, 10), true, false, method); Assert.AreEqual(_loan.Disbursed, true); PaymentMethod paymentMethod = new PaymentMethod(1, "Savings", "", false); loanServices.Repay(_loan, _client, 1, new DateTime(2005, 10, 11), 100, true, 0, 0, false, 5, false, false, paymentMethod, null, false); Assert.IsTrue(_loan.CompulsorySavings.Events.FindAll(item => item is LoanRepaymentFromSavingEvent).Count==1); }