Beispiel #1
0
 public void TestAddDeleteLeftDate()
 {
     Person person = new Person {Id = 1};
     VillageMember member = new VillageMember {Tiers = person, JoinedDate = TimeProvider.Now, CurrentlyIn = true, IsLeader = false};
     _village.AddMember(member);
     _village.DeleteMember(member);
     Assert.IsTrue(TimeProvider.Now.Equals(member.LeftDate));
 }
Beispiel #2
0
 public void TestAddDelete()
 {
     Person person = new Person {Id = 1};
     VillageMember member = new VillageMember {Tiers = person, JoinedDate = TimeProvider.Now, CurrentlyIn = true, IsLeader = false};
     _village.AddMember(member);
     Assert.AreEqual(1, _village.Members.Count);
     _village.DeleteMember(member);
     Assert.AreEqual(0, _village.Members.Count);
 }
Beispiel #3
0
 public void TestAddDeleteDifferent()
 {
     Person person1 = new Person {Id = 1};
     Person person2 = new Person {Id = 2};
     VillageMember member1 = new VillageMember {Tiers = person1, JoinedDate = TimeProvider.Now, CurrentlyIn = true, IsLeader = false};
     VillageMember member2 = new VillageMember {Tiers = person2, JoinedDate = TimeProvider.Now, CurrentlyIn = true, IsLeader = false};
     _village.AddMember(member1);
     _village.DeleteMember(member2);
     Assert.AreEqual(1, _village.Members.Count);
 }
Beispiel #4
0
        public void DeleteMember(VillageMember member)
        {
            VillageMember remove = null;

            foreach (VillageMember _member in _members)
            {
                if (_member.Tiers.Id == member.Tiers.Id)
                {
                    remove = _member;
                    break;
                }
            }
            if (remove != null)
            {
                _members.Remove(remove);
                member.LeftDate    = TimeProvider.Now;
                member.CurrentlyIn = false;
            }
        }
Beispiel #5
0
        public void AddMember(VillageMember member)
        {
            int tierId = member.Tiers.Id;

            if (member.CurrentlyIn && _members.All(m => m.Tiers.Id != tierId))
            {
                _members.Add(member);
            }

            VillageMember curHistoryMember = _memberHistory.FirstOrDefault(m => m.Tiers.Id == tierId);

            if (curHistoryMember == null)
            {
                _memberHistory.Add(member);
            }
            else
            {
                curHistoryMember.CurrentlyIn = member.CurrentlyIn;
            }
        }
        private void ShowLoanInListView(VillageMember member, Loan loan)
        {
            Person person = (Person)member.Tiers;
            ApplicationSettings dataParam = ApplicationSettings.GetInstance(string.Empty);
            int decimalPlaces = dataParam.InterestRateDecimalPlaces;
            ListViewItem item = new ListViewItem(person.Name) { Tag = member };
            if (loan == null || _village.EstablishmentDate==null) return;
            if (loan.CreationDate.Date >= _village.EstablishmentDate.Value.Date && _village.Id == loan.NsgID)
            {
                item.SubItems.Add(loan.ProductName);
                item.SubItems.Add(loan.Code);
                item.SubItems.Add(MultiLanguageStrings.GetString(Ressource.ClientForm, loan.ContractStatus + ".Text"));
                item.SubItems.Add(loan.Amount.GetFormatedValue(loan.UseCents));
                item.SubItems.Add(
                    loan.CalculateActualOlbBasedOnRepayments().GetFormatedValue(loan.UseCents));
                item.SubItems.Add(loan.Product.Currency.Name);
                item.SubItems.Add(Math.Round(loan.InterestRate*100m, decimalPlaces).ToString());
                item.SubItems.Add(loan.InstallmentType.Name);
                item.SubItems.Add(loan.NbOfInstallments.ToString());
                item.SubItems.Add(loan.AlignDisbursementDate.ToShortDateString());

                if (loan.GetLastNonDeletedEvent() != null) item.SubItems.Add(loan.GetLastNonDeletedEvent().Date.ToShortDateString());
                else item.SubItems.Add("-");

                if (loan.NextInstallment != null)
                {
                    item.SubItems.Add(loan.NextInstallment.ExpectedDate.ToShortDateString());
                    item.SubItems.Add(
                        ServicesHelper.ConvertDecimalToString(loan.NextInstallment.Amount.Value));
                }
                else
                {
                    item.SubItems.Add("-");
                    item.SubItems.Add("-");
                }
                item.SubItems.Add(loan.CloseDate.ToShortDateString());
                if (member.LeftDate != null)
                    item.BackColor = Color.Red;
                listViewLoans.Items.Add(item);
            }
        }
Beispiel #7
0
 /// <summary>
 /// The method sets number of installments limitation 
 /// for the village member according to the loan cycle
 /// </summary>
 /// <param name="member">Member of the NonSolidaryGroup</param>
 /// <param name="loanCycle">LoanCycle of the member</param>
 private void SetMaturityCycle(VillageMember member, int loanCycle)
 {
     List<MaturityCycle> maturityCycles = member.Product.MaturityCycleParams;
     member.Product.NbOfInstallments = null;
     for (int i = 0; i < maturityCycles.Count; i++)
     {
         if (i == maturityCycles.Count - 1)
         {
             member.Product.NbOfInstallmentsMin = (int)maturityCycles[i].Min.Value;
             member.Product.NbOfInstallmentsMax = (int)maturityCycles[i].Max.Value;
             break;
         }
         if (maturityCycles[i].LoanCycle == loanCycle)
         {
             member.Product.NbOfInstallmentsMin = (int)maturityCycles[i].Min.Value;
             member.Product.NbOfInstallmentsMax = (int)maturityCycles[i].Max.Value;
             break;
         }
     }
 }
Beispiel #8
0
 /// <summary>
 /// The method sets to the village member cycle parameters such as 
 /// loan amount, rate and number of installments 
 /// according to the loan cycle
 /// </summary>
 /// <param name="member">Member of the NonSolidaryGroup</param>
 /// <param name="productId">Product id</param>
 /// <param name="loanCycle">LoanCycle of the member</param>
 public void SetVillageMemberCycleParams(VillageMember member, int productId, int loanCycle)
 {
     member.Product = ServicesProvider.GetInstance().GetProductServices().FindPackage(productId);
     if (member.Product.LoanAmountCycleParams.Count != 0 &&
         member.Product.RateCycleParams.Count != 0 &&
         member.Product.MaturityCycleParams.Count != 0)
     {
         SetLoanAmountCycle(member, loanCycle);
         SetRateCycle(member, loanCycle);
         SetMaturityCycle(member, loanCycle);
     }
 }
Beispiel #9
0
 public void TestLeftDateIsNull()
 {
     VillageMember member = new VillageMember();
     Assert.IsNull(member.LeftDate);
 }
Beispiel #10
0
 public Village()
 {
     _members = new List<VillageMember>();
     _memberHistory = new List<VillageMember>();
     _leader = new VillageMember();
 }
Beispiel #11
0
 public void DeleteMember(VillageMember member)
 {
     VillageMember remove = null;
     foreach (VillageMember _member in _members)
     {
         if (_member.Tiers.Id == member.Tiers.Id)
         {
             remove = _member;
             break;
         }
     }
     if (remove != null)
     {
         _members.Remove(remove);
         member.LeftDate = TimeProvider.Now;
         member.CurrentlyIn = false;
     }
 }
Beispiel #12
0
 public bool IsLeader(VillageMember pMember)
 {
     return ((Person)_leader.Tiers).IdentificationData == ((Person)pMember.Tiers).IdentificationData;
 }
Beispiel #13
0
        public void AddMember(VillageMember member)
        {    
            int tierId = member.Tiers.Id;            

            if (member.CurrentlyIn && _members.All(m => m.Tiers.Id != tierId))
                _members.Add(member);

            VillageMember curHistoryMember = _memberHistory.FirstOrDefault(m => m.Tiers.Id == tierId);
            if(curHistoryMember == null) _memberHistory.Add(member);
            else curHistoryMember.CurrentlyIn = member.CurrentlyIn;
        }
 public void RemoveMember(Village village, VillageMember member)
 {
     if (null == village || null == member) return;
     village.DeleteMember(member);
 }
 public void AddExistingMember(Village village, VillageMember member)
 {
     if (null == village || null == member) return;
     village.AddMember(member);
 }
Beispiel #16
0
 private void _ChangeLeader(VillageMember newLeader)
 {
     _village.Leader = newLeader;
     DisplayMembers();
 }
Beispiel #17
0
 public void TestCurrentlyIn()
 {
     VillageMember member = new VillageMember();
     member.CurrentlyIn = true;
     Assert.IsTrue(member.CurrentlyIn);
 }
Beispiel #18
0
        private void AddMemberToVillage(VillageMember pMember, Village pVillage, bool leader, SqlTransaction pSqlTransac)
        {
            const string q = @"INSERT INTO VillagesPersons
                                (
                                    village_id,
                                    person_id,
                                    joined_date,
                                    left_date,
                                    is_leader,
                                    currently_in
                                )
                            VALUES
                                (
                                    @village_id,
                                    @person_id,
                                    @joined_date,
                                    @left_date,
                                    @isLeader,
                                    @currentlyIn
                                )";

            using (OpenCbsCommand c = new OpenCbsCommand(q, pSqlTransac.Connection, pSqlTransac))
            {
                c.AddParam("@village_id", pVillage.Id);
                c.AddParam("@person_id", pMember.Tiers.Id);
                c.AddParam("@joined_date", TimeProvider.Now);
                c.AddParam("@left_date", null);
                c.AddParam("@isLeader", leader);
                c.AddParam("@currentlyIn", true);
                c.ExecuteNonQuery();
            }
        }
Beispiel #19
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 #20
0
        private void UpdateMemberInVillage(VillageMember pMember, Village pVillage, bool leader, SqlTransaction pSqlTransac)
        {
            const string q = @"UPDATE VillagesPersons SET left_date = NULL,
                                is_leader = @isLeader,
                                currently_in = @currentlyIn
                                WHERE village_id = @village_id
                                AND person_id = @person_id";

            using (OpenCbsCommand c = new OpenCbsCommand(q, pSqlTransac.Connection, pSqlTransac))
            {
                c.AddParam("@village_id", pVillage.Id);
                c.AddParam("@person_id", pMember.Tiers.Id);
                c.AddParam("@isLeader", leader);
                c.AddParam("@currentlyIn", true);
                c.ExecuteNonQuery();
            }
        }
Beispiel #21
0
 /// <summary>
 /// The method sets loan amount limitation 
 /// for the village member according to the loan cycle
 /// </summary>
 /// <param name="member">VillageMember</param>
 /// <param name="loanCycle">Value of the loan cycle</param>
 private void SetLoanAmountCycle(VillageMember member, int loanCycle)
 {
     List<LoanAmountCycle> loanAmountCycleParams = member.Product.LoanAmountCycleParams;
     member.Product.Amount = null;
     for (int i = 0; i < loanAmountCycleParams.Count; i++)
     {
         if (i == loanAmountCycleParams.Count - 1)
         {
             member.Product.AmountMin = loanAmountCycleParams[i].Min;
             member.Product.AmountMax = loanAmountCycleParams[i].Max;
             break;
         }
         if (loanAmountCycleParams[i].LoanCycle == loanCycle)
         {
             member.Product.AmountMin = loanAmountCycleParams[i].Min;
             member.Product.AmountMax = loanAmountCycleParams[i].Max;
             break;
         }
     }
 }
Beispiel #22
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ClientForm frm = new ClientForm(OClientTypes.Person, MdiParent, true);
            if (frm.ShowDialog() != DialogResult.OK) return;
            try
            {
                Person person = frm.Person;
                if (ServicesProvider.GetInstance().GetClientServices().ClientIsAPerson(person))
                {
                    var member = new VillageMember { Tiers = person, JoinedDate = TimeProvider.Now, CurrentlyIn = true, IsLeader = false, IsSaved = false};
                    member.ActiveLoans = ServicesProvider.GetInstance().GetContractServices().
                         FindActiveContracts(member.Tiers.Id);

                    _village.AddMember(member);
                    membersSaved = false;
                    DisplayMembers();
                    DisplayLoans();
                }
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
Beispiel #23
0
 /// <summary>
 /// The method sets interest rate limitation 
 /// for the village member according to the loan cycle
 /// </summary>
 /// <param name="member">Member of the NonSolidaryGroup</param>
 /// <param name="loanCycle">LoanCycle of the member</param>
 private void SetRateCycle(VillageMember member, int loanCycle)
 {
     List<RateCycle> rateCycles = member.Product.RateCycleParams;
     member.Product.InterestRate = null;
     for (int i = 0; i < rateCycles.Count; i++)
     {
         if (i == rateCycles.Count - 1)
         {
             member.Product.InterestRateMin = rateCycles[i].Min.Value;
             member.Product.InterestRateMax = rateCycles[i].Max.Value;
             break;
         }
         if (rateCycles[i].LoanCycle == loanCycle)
         {
             member.Product.InterestRateMin = rateCycles[i].Min.Value;
             member.Product.InterestRateMax = rateCycles[i].Max.Value;
             break;
         }
     }
 }
Beispiel #24
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            SearchClientForm frm = SearchClientForm.GetInstanceForVillage();
            frm.ShowDialog();
            if (DialogResult.OK != frm.DialogResult) return;

            try
            {
                var clientServices = ServicesProvider.GetInstance().GetClientServices();
                var client = frm.Client;
                if (clientServices.ClientIsAPerson(client))
                {
                    var personId = client.Id;
                    clientServices.CheckPersonGroupCount(personId);
                    var member = new VillageMember { Tiers = client, JoinedDate = TimeProvider.Now, CurrentlyIn = true, IsLeader = false, IsSaved = false};
                    member.ActiveLoans = ServicesProvider.GetInstance().GetContractServices().
                        FindActiveContracts(personId);

                    List<ISavingsContract> savingsContracts =
                        ServicesProvider.GetInstance().GetSavingServices().GetSavingsByClientId(member.Tiers.Id);

                    foreach (ISavingsContract contract in savingsContracts)
                    {
                        member.Tiers.Savings.Add(contract);
                    }

                    clientServices.AddExistingMember(_village, member);
                    membersSaved = false;
                    DisplayMembers();
                    DisplayLoans();
                    DisplaySavings();
                }
            } catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
Beispiel #25
0
 public bool IsLeader(VillageMember pMember)
 {
     return(((Person)_leader.Tiers).IdentificationData == ((Person)pMember.Tiers).IdentificationData);
 }
Beispiel #26
0
 private void ShowActiveLoans(VillageMember member)
 {
     if (member.ActiveLoans != null)
     {
         foreach (Loan loan in member.ActiveLoans)
         {
             ShowLoanInListView(member, loan);
         }
     }
 }
Beispiel #27
0
 public Village()
 {
     _members       = new List <VillageMember>();
     _memberHistory = new List <VillageMember>();
     _leader        = new VillageMember();
 }
Beispiel #28
0
 private void ShowAllLoans(VillageMember member)
 {
     List<Loan> allLoansOfMember =
         ServicesProvider.GetInstance().GetContractServices().FindAllLoansOfClient(member.Tiers.Id);
     foreach (Loan item in allLoansOfMember)
     {
         if (item.CreationDate.Date>=member.JoinedDate.Date)
             if (member.LeftDate!=null)
             {
                 if (member.LeftDate.Value.Date>=item.CreationDate.Date
                     && member.JoinedDate.Date<=item.CreationDate.Date)
                     ShowLoanInListView(member, item);
             }
             else
             {
                 ShowLoanInListView(member,item);
             }
     }
 }