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} }; }
public VillageDisburseLoanForm(Village village) { _village = village; _accumulatedAmount = 0; _notEnoughMoney = false; _fLServices = new FundingLineServices(User.CurrentUser); InitializeComponent(); InitializeControls(); }
public VillageAddLoanForm(Village village, LoanProduct product, NonSolidaryGroupForm nsgForm) { _village = village; _product = product; _nsgForm = nsgForm; _product.EntryFees = ServicesProvider.GetInstance().GetProductServices().GetProductEntryFees(_product, village); _fLServices = new FundingLineServices(User.CurrentUser); _accumulatedAmount = 0; InitializeComponent(); InitializeControls(); }
public LoanServices(User pUser) : base(pUser) { _user = pUser; _loanManager = new LoanManager(pUser); _instalmentManager = new InstallmentManager(pUser); _clientManager = new ClientManager(pUser, true, true); _branchService = new BranchService(pUser); _econimcActivityServices = new EconomicActivityServices(pUser); _ePs = ServicesProvider.GetInstance().GetEventProcessorServices(); _accountingServices = new AccountingServices(pUser); _fundingLineServices = new FundingLineServices(pUser); _savingServices = new SavingServices(pUser); _savingEventManager = new SavingEventManager(pUser); var settings = ApplicationSettings.GetInstance(string.Empty); var nonWorkingDate = NonWorkingDateSingleton.GetInstance(string.Empty); _configurationFactory = new OctopusScheduleConfigurationFactory(nonWorkingDate, settings); MefContainer.Current.Bind(this); }
public void InitManager() { TechnicalSettings.CheckSettings(); LoanProductManager loanProductManager = new LoanProductManager(DataUtil.TESTDB); AccountingTransactionManager accountingTransactionManager = new AccountingTransactionManager(DataUtil.TESTDB); EventManager eventManager = new EventManager(DataUtil.TESTDB); ExchangeRateManager exchangeRateManager = new ExchangeRateManager(DataUtil.TESTDB); ProvisioningRuleManager provisioningRuleManager = new ProvisioningRuleManager(DataUtil.TESTDB); AccountManager accountManager = new AccountManager(DataUtil.TESTDB); InstallmentTypeManager installmentTypeManager = new InstallmentTypeManager(DataUtil.TESTDB); UserManager userManager = new UserManager(DataUtil.TESTDB); EconomicActivityManager economicActivityManager = new EconomicActivityManager(DataUtil.TESTDB); InstallmentManager installmentManager = new InstallmentManager(DataUtil.TESTDB); FundingLineManager fundingLineManager = new FundingLineManager(DataUtil.TESTDB); ClientManager clientManager = new ClientManager(DataUtil.TESTDB); LocationsManager locationsManager = new LocationsManager(DataUtil.TESTDB); LoanManager loanManager = new LoanManager(DataUtil.TESTDB); ProjectManager projectManager = new ProjectManager(DataUtil.TESTDB); MFIManager mfiManager = new MFIManager(DataUtil.TESTDB); SavingManager savingManager = new SavingManager(DataUtil.TESTDB); SavingProductManager savingProductManager = new SavingProductManager(DataUtil.TESTDB); SavingEventManager savingEventManager = new SavingEventManager(DataUtil.TESTDB); CurrencyManager currencyManager = new CurrencyManager(DataUtil.TESTDB); AccountingRuleManager accountingRuleManager = new AccountingRuleManager(DataUtil.TESTDB); FundingLineServices fundingLineServices = new FundingLineServices(DataUtil.TESTDB); container = new Hashtable { {"LoanProductManager", loanProductManager}, {"AccountingTransactionManager", accountingTransactionManager}, {"EventManager", eventManager}, {"ExchangeRateManager", exchangeRateManager}, {"ProvisioningRuleManager", provisioningRuleManager}, {"AccountManager", accountManager}, {"InstallmentTypeManager", installmentTypeManager}, {"UserManager", userManager}, {"FundingLineManager", fundingLineManager}, {"LoanManager", loanManager}, {"ClientManager", clientManager}, {"LocationsManager", locationsManager}, {"ProjectManager", projectManager}, {"EconomicActivityManager", economicActivityManager}, {"InstallmentManager", installmentManager}, {"MFIManager", mfiManager}, {"SavingManager", savingManager}, {"SavingProductManager", savingProductManager}, {"SavingEventManager", savingEventManager}, {"CurrencyManager", currencyManager}, {"FundingLineServices", fundingLineServices}, {"AccountingRuleManager", accountingRuleManager} }; }
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); }
private void AddFundingLineEvent(Loan loan) { 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); }
public FundingLine AddGenericFundingLineWithThreeEvents(DateTime startDate) { ChartOfAccounts _chartOfAccounts = ChartOfAccounts.GetInstance(new User { Id = 5 }); AccountManager accountManager = new AccountManager(new User { Id = 5 }); _chartOfAccounts.Accounts = accountManager.SelectAllAccounts(); FundingLineServices service = new FundingLineServices(new User{Id = 5}); int newFL_ID = AddGenericFundingLine4(); FundingLine fundingLineInitial = service.SelectFundingLineById(newFL_ID, true); FundingLineEvent ev0 = new FundingLineEvent(); ev0.Code = "6012"; ev0.CreationDate = startDate.AddDays(-2); ev0.Amount = 1000; ev0.Movement = OBookingDirections.Credit; ev0.Type = OFundingLineEventTypes.Entry; ev0.FundingLine = fundingLineInitial; ev0.IsDeleted = false; fundingLineInitial.AddEvent( service.AddFundingLineEvent(ev0)); FundingLineEvent ev1 = new FundingLineEvent(); ev1.Code = "6013"; ev1.CreationDate = startDate.AddDays(-1); ev1.Amount = 500; ev1.Movement = OBookingDirections.Debit; ev1.Type = OFundingLineEventTypes.Disbursment; ev1.FundingLine = fundingLineInitial; ev1.IsDeleted = false; fundingLineInitial.AddEvent(service.AddFundingLineEvent(ev1)); FundingLineEvent ev2 = new FundingLineEvent(); ev2.Code = "6014"; ev2.CreationDate = startDate; ev2.Amount = 100; ev2.Movement = OBookingDirections.Credit; ev2.Type = OFundingLineEventTypes.Repay; ev2.FundingLine = fundingLineInitial; ev2.IsDeleted = false; fundingLineInitial.AddEvent(service.AddFundingLineEvent(ev2)); return fundingLineInitial; }
public LoanServices(User pUser) : base(pUser) { _user = pUser; _loanManager = new LoanManager(pUser); _instalmentManager = new InstallmentManager(pUser); _clientManager = new ClientManager(pUser, true, true); _branchService = new BranchService(pUser); _econimcActivityServices = new EconomicActivityServices(pUser); _ePs = ServicesProvider.GetInstance().GetEventProcessorServices(); _accountingServices = new AccountingServices(pUser); _fundingLineServices = new FundingLineServices(pUser); _savingServices = new SavingServices(pUser); _savingEventManager = new SavingEventManager(pUser); }