Exemplo n.º 1
0
        private void lvContracts_SubItemEndEditing(object sender, UserControl.SubItemEndEditingEventArgs e)
        {
            if (4 == e.SubItem && e.Item.Tag != null)
            {
                e.Item.SubItems[e.SubItem].Tag  = (OCurrency)decimal.Parse(e.DisplayText);
                e.Item.SubItems[e.SubItem].Text = e.DisplayText;
            }
            if (5 == e.SubItem && e.Item.Tag != null)
            {
                e.Item.SubItems[e.SubItem].Tag  = (OCurrency)decimal.Parse(e.DisplayText);
                e.Item.SubItems[e.SubItem].Text = e.DisplayText;
            }

            var loan = new Loan();

            if (4 == e.SubItem || 5 == e.SubItem || 9 == e.SubItem && e.Item.Tag != null)
            {
                loan = e.Item.Tag as Loan;
            }

            if (loan != null && loan.Id != 0)
            {
                Installment i           = loan.GetFirstUnpaidInstallment();
                bool        disableFees = false;
                var         result      = new KeyValuePair <Loan, RepaymentEvent>();

                if (loan.Product.LoanType == OLoanTypes.DecliningFixedPrincipalWithRealInterest)
                {
                    OCurrency amountForToday = loan.CalculateMaximumAmountToRegradingLoan(i.Number,
                                                                                          TimeProvider.Now,
                                                                                          false,
                                                                                          0,
                                                                                          0,
                                                                                          false,
                                                                                          0,
                                                                                          true);
                    PaymentMethod paymentMethod =
                        ServicesProvider.GetInstance().GetPaymentMethodServices().GetPaymentMethodById(1);
                    result = ServicesProvider.GetInstance().GetContractServices().ShowNewContract(loan,
                                                                                                  i.Number,
                                                                                                  TimeProvider.Now.Date,
                                                                                                  amountForToday,
                                                                                                  false,
                                                                                                  0,
                                                                                                  0,
                                                                                                  false,
                                                                                                  0,
                                                                                                  true,
                                                                                                  false,
                                                                                                  paymentMethod,
                                                                                                  false,
                                                                                                  false);
                }

                OCurrency penalties = (OCurrency)e.Item.SubItems[4].Tag;
                OCurrency principal = result.Value == null ? i.PrincipalHasToPay : result.Value.Principal;
                OCurrency interest  = result.Value == null ? i.InterestHasToPay : result.Value.InterestPrepayment;
                OCurrency total;

                if (penalties != loan.CalculateDuePenaltiesForInstallment(i.Number, TimeProvider.Today))
                {
                    disableFees = true;
                }

                total = (OCurrency)e.Item.SubItems[5].Tag;
                if (e.SubItem == 5)
                {
                    if (total < 0)
                    {
                        throw new ArithmeticException("Total cannot be negative.");
                    }
                    if (total > penalties)
                    {
                        OCurrency remainder = total - penalties;
                        if (remainder > interest)
                        {
                            remainder -= interest;
                            principal  = remainder > principal ? principal : remainder;
                            remainder -= principal;
                            total      = principal + interest + penalties + remainder;
                        }
                        else
                        {
                            interest  = remainder;
                            principal = 0;
                        }
                    }
                    else
                    {
                        penalties = total;
                        principal = 0;
                        interest  = 0;
                    }
                }

                e.Item.SubItems[2].Text = principal.GetFormatedValue(loan.UseCents);
                e.Item.SubItems[2].Tag  = principal;
                e.Item.SubItems[3].Text = interest.GetFormatedValue(loan.UseCents);
                e.Item.SubItems[3].Tag  = interest;
                e.Item.SubItems[4].Text = penalties.GetFormatedValue(loan.UseCents);
                e.Item.SubItems[4].Tag  = penalties;
                e.Item.SubItems[5].Text = total.GetFormatedValue(loan.UseCents);
                e.Item.SubItems[5].Tag  = total;

                if (e.Item.SubItems.Count > 9)
                {
                    e.Item.SubItems[9].Tag = cbItem.SelectedItem;
                }

                if (5 == e.SubItem)
                {
                    e.DisplayText = total.GetFormatedValue(loan.UseCents);
                }

                if (9 == e.SubItem)
                {
                    e.DisplayText = cbItem.SelectedItem.ToString();
                }
                if (10 == e.SubItem)
                {
                    e.Item.SubItems[10].Text = e.DisplayText;
                }


                int paymentOption = cbItem.SelectedIndex + 1;

                KeyValuePair <Loan, RepaymentEvent> keyValuePair = CalculatePrincipalAndInterest(loan,
                                                                                                 total.Value,
                                                                                                 disableFees,
                                                                                                 penalties.Value,
                                                                                                 paymentOption);
                if (keyValuePair.Value != null)
                {
                    e.Item.SubItems[2].Text =
                        keyValuePair.Value.Principal.GetFormatedValue(loan.Product.UseCents);
                    e.Item.SubItems[2].Tag  = keyValuePair.Value.Principal;
                    e.Item.SubItems[3].Text =
                        keyValuePair.Value.Interests.GetFormatedValue(loan.Product.UseCents);
                    e.Item.SubItems[3].Tag  = keyValuePair.Value.Interests;
                    e.Item.SubItems[4].Text =
                        keyValuePair.Value.Penalties.GetFormatedValue(loan.Product.UseCents);
                    e.Item.SubItems[4].Tag = keyValuePair.Value.Penalties;
                }
            }
            UpdateTotal();
        }
Exemplo n.º 2
0
        private void lvMembers_SubItemClicked(object sender, SubItemEventArgs e)
        {
            if (e.Item.Checked && e.Item != _itemTotal)
            {
                switch (e.SubItem)
                {
                case IdxAmount:     // Amount
                    if (_product.CycleId != null)
                    {
                        lvMembers.StartEditing(tbAmount, e.Item, e.SubItem);
                    }
                    if (!_product.Amount.HasValue)
                    {
                        lvMembers.StartEditing(tbAmount, e.Item, e.SubItem);
                    }
                    break;

                case IdxInterest:     // Interest
                    if (_product.CycleId != null)
                    {
                        lvMembers.StartEditing(tbInterest, e.Item, e.SubItem);
                    }
                    else if (!_product.InterestRate.HasValue)
                    {
                        lvMembers.StartEditing(tbInterest, e.Item, e.SubItem);
                    }
                    break;

                case IdxGracePeriod:     // Grace period
                    if (!_product.GracePeriod.HasValue)
                    {
                        lvMembers.StartEditing(udGracePeriod, e.Item, e.SubItem);
                    }
                    break;

                case IdxInstallments:     // Installments
                    if (_product.CycleId != null)
                    {
                        udInstallments.Minimum = ((VillageMember)e.Item.Tag).Product.NbOfInstallmentsMin.Value;
                        udInstallments.Maximum = ((VillageMember)e.Item.Tag).Product.NbOfInstallmentsMax.Value;
                        lvMembers.StartEditing(udInstallments, e.Item, e.SubItem);
                    }
                    else if (!_product.NbOfInstallments.HasValue)
                    {
                        lvMembers.StartEditing(udInstallments, e.Item, e.SubItem);
                    }
                    break;

                case IdxLoanOfficer:
                    lvMembers.StartEditing(cbLoanOfficer, e.Item, e.SubItem);
                    break;

                case IdxCreationDate:
                    lvMembers.StartEditing(dtCreationDate, e.Item, e.SubItem);
                    break;

                case IdxFundingLine:
                    lvMembers.StartEditing(cbFundingLine, e.Item, e.SubItem);
                    break;

                case IdxCompulsorySavings:
                    if (_product.UseCompulsorySavings)
                    {
                        cbCompulsorySavings.Items.Clear();
                        List <ISavingsContract> savings = ServicesProvider.GetInstance().GetSavingServices().
                                                          GetSavingsByClientId(((VillageMember)e.Item.Tag).Tiers.Id);
                        savings = savings.Where(item2 => item2 is SavingBookContract &&
                                                item2.Status != OSavingsStatus.Closed).ToList(); // Only savings book

                        foreach (SavingBookContract saving in savings)
                        {
                            cbCompulsorySavings.Items.Add(saving);
                        }

                        lvMembers.StartEditing(cbCompulsorySavings, e.Item, e.SubItem);
                    }
                    break;

                case IdxCompulsoryPercentage:
                    if (_product.UseCompulsorySavings && !_product.CompulsoryAmount.HasValue)
                    {
                        lvMembers.StartEditing(udCompulsoryPercentage, e.Item, e.SubItem);
                    }
                    break;

                /*
                 * case IdxPaymentMethod:
                 *  cbPaymentMethods.Items.Clear();
                 *  List<PaymentMethod> methods = ServicesProvider.GetInstance().GetPaymentMethodServices().GetAllPaymentMethods();
                 *
                 *  foreach (PaymentMethod method in methods)
                 *      cbPaymentMethods.Items.Add(method.Name);
                 *
                 *  lvMembers.StartEditing(cbPaymentMethods, e.Item, e.SubItem);
                 *  break;
                 */
                default:
                    break;
                }
            }
        }
Exemplo n.º 3
0
        private void InitializeControls()
        {
            lvMembers.Items.Clear();
            Color dfc = Color.Gray;
            Color fc  = Color.Black;
            Color bc  = Color.White;

            _fLServices.EmptyTemporaryFLAmountsStorage();

            dtCreationDate.Format       = DateTimePickerFormat.Custom;
            dtCreationDate.CustomFormat = ApplicationSettings.GetInstance("").SHORT_DATE_FORMAT;

            ApplicationSettings generalParameters = ApplicationSettings.GetInstance("");

            decimalPlaces = generalParameters.InterestRateDecimalPlaces;
            ProductServices productServices = ServicesProvider.GetInstance().GetProductServices();
            List <Loan>     listLoan;

            foreach (VillageMember member in _village.Members)
            {
                listLoan = member.ActiveLoans;
                if (listLoan.Count != 0 && !generalParameters.IsAllowMultipleLoans)
                {
                    continue;
                }

                _hasMember = true;
                Person person = (Person)member.Tiers;

                if (_product.CycleId != null)
                {
                    productServices.SetVillageMemberCycleParams(member, _product.Id, person.LoanCycle);
                }
                else
                {
                    member.Product = _product;
                }

                ListViewItem item = new ListViewItem(person.Name)
                {
                    Tag = member
                };
                if (_product.CycleId != null)
                {
                    item.SubItems.Add(person.IdentificationData);
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", member.Product.Amount.HasValue ? dfc : fc, bc, item.Font));
                    item.SubItems.Add(member.Product.Currency.Code);
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", member.Product.InterestRate.HasValue ? dfc : fc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", member.Product.GracePeriod.HasValue ? dfc : fc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", member.Product.NbOfInstallments.HasValue ? dfc : fc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", dfc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", dfc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", dfc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", dfc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", true ? dfc : fc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", dfc, bc, item.Font));
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", member.Product.Amount.HasValue ? dfc : fc, bc, item.Font));
                    if (_product.UseCompulsorySavings)
                    {
                        item.SubItems.Add("");
                        item.SubItems.Add(
                            new ListViewItem.ListViewSubItem(item, "", member.Product.CompulsoryAmount.HasValue ? dfc : fc, bc, item.Font));
                    }
                    lvMembers.Items.Add(item);
                    item.SubItems[IdxAmount].Tag       = member.Product.AmountMin;
                    item.SubItems[IdxInterest].Tag     = member.Product.InterestRateMin;
                    item.SubItems[IdxInstallments].Tag = member.Product.NbOfInstallmentsMin;
                    item.SubItems[IdxCurrency].Tag     = member.Product.Currency;
                }
                else
                {
                    item.SubItems.Add(person.IdentificationData);
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", _product.Amount.HasValue ? dfc : fc, bc, item.Font));
                    item.SubItems.Add(_product.Currency.Code);
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", _product.InterestRate.HasValue ? dfc : fc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", _product.GracePeriod.HasValue ? dfc : fc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", _product.NbOfInstallments.HasValue ? dfc : fc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", dfc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", dfc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", dfc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", dfc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", true ? dfc : fc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", dfc, bc, item.Font));
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", _product.Amount.HasValue ? dfc : fc, bc, item.Font));
                    if (_product.UseCompulsorySavings)
                    {
                        item.SubItems.Add("");
                        item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", _product.CompulsoryAmount.HasValue ? dfc : fc, bc, item.Font));
                    }
                    lvMembers.Items.Add(item);
                    item.SubItems[IdxCurrency].Tag = member.Product.Currency;
                }
            }
            if (_hasMember)
            {
                OCurrency zero = 0m;
                _itemTotal.Text = GetString("Total");
                _itemTotal.SubItems.Add("");
                _itemTotal.SubItems.Add(zero.GetFormatedValue(true));
                _itemTotal.SubItems.Add("");
                lvMembers.Items.Add(_itemTotal);
            }
            lvMembers.SubItemClicked       += lvMembers_SubItemClicked;
            lvMembers.SubItemEndEditing    += lvMembers_SubItemEndEditing;
            lvMembers.DoubleClickActivation = true;

            if (!_product.GracePeriod.HasValue)
            {
                udGracePeriod.Minimum = _product.GracePeriodMin ?? 0;
                udGracePeriod.Maximum = _product.GracePeriodMax ?? 0;
            }

            if (_product.CycleId == null)
            {
                if (!_product.NbOfInstallments.HasValue)
                {
                    udInstallments.Minimum = _product.NbOfInstallmentsMin ?? 0;
                    udInstallments.Maximum = _product.NbOfInstallmentsMax ?? 0;
                }
            }

            List <User> users = ServicesProvider.GetInstance().GetUserServices().FindAll(false);

            foreach (User user in users)
            {
                cbLoanOfficer.Items.Add(user);
            }

            List <FundingLine> lines = ServicesProvider.GetInstance().GetFundingLinesServices().SelectFundingLines();

            foreach (FundingLine line in lines)
            {
                cbFundingLine.Items.Add(line);
            }

            // Compulsory savings
            if (_product.UseCompulsorySavings)
            {
                if (!_product.CompulsoryAmount.HasValue)
                {
                    udCompulsoryPercentage.Minimum = _product.CompulsoryAmountMin ?? 0;
                    udCompulsoryPercentage.Maximum = _product.CompulsoryAmountMax ?? 0;
                }
            }
        }
Exemplo n.º 4
0
        private void InitializePerson()
        {
            if (_tempPerson.Id != 0)
            {
                buttonSave.Text                     = MultiLanguageStrings.GetString(Ressource.PersonUserControl, "Update");
                textBoxLastname.Text                = _tempPerson.LastName;
                textBoxFirstName.Text               = _tempPerson.FirstName;
                textBoxIdentificationData.Text      = _tempPerson.IdentificationData;
                dateTimePickerFirstContact.Text     = ServicesHelper.ConvertNullableDateTimeToString(_tempPerson.FirstContact);
                dateTimePickerFirstAppointment.Text = ServicesHelper.ConvertNullableDateTimeToString(_tempPerson.FirstAppointment);
                dateTimePickerDateOfBirth.Text      = ServicesHelper.ConvertNullableDateTimeToString(_tempPerson.DateOfBirth);
                checkBoxHeadOfHousehold.Checked     = _tempPerson.HouseHoldHead;
                textBoxLoanCycle.Text               = _tempPerson.LoanCycle.ToString();
                textBoxFatherName.Text              = _tempPerson.FatherName;
                textBoxBirthPlace.Text              = _tempPerson.BirthPlace ?? String.Empty;
                textBoxNationality.Text             = _tempPerson.Nationality ?? ServicesProvider.GetInstance().GetGeneralSettings().Country;
                richTextBoxCommentsActivity.Text    = _tempPerson.FollowUpComment;

                comboBoxSex.SelectGender(_tempPerson.Sex);

                comboBoxSex.Text   = _tempPerson.Sex.ToString();
                eacPerson.Activity = _tempPerson.Activity;

                comboBoxSponsor1.Text = _tempPerson.Sponsor1;
                comboBoxSponsor2.Text = _tempPerson.Sponsor2;
                textBoxSponsor1.Text  = _tempPerson.Sponsor1Comment;
                textBoxSponsor2.Text  = _tempPerson.Sponsor2Comment;

                addressUserControlFirst.ZipCode       = _tempPerson.ZipCode;
                addressUserControlFirst.HomeType      = _tempPerson.HomeType;
                addressUserControlFirst.Email         = _tempPerson.Email;
                addressUserControlFirst.District      = _tempPerson.District;
                addressUserControlFirst.City          = _tempPerson.City;
                addressUserControlFirst.Comments      = _tempPerson.Address;
                addressUserControlFirst.HomePhone     = _tempPerson.HomePhone ?? String.Empty;
                addressUserControlFirst.PersonalPhone = _tempPerson.PersonalPhone ?? String.Empty;

                if (!_tempPerson.SecondaryAddressIsEmpty)
                {
                    addressUserControlSecondaryAddress.ZipCode       = _tempPerson.SecondaryZipCode;
                    addressUserControlSecondaryAddress.HomeType      = _tempPerson.SecondaryHomeType;
                    addressUserControlSecondaryAddress.Email         = _tempPerson.SecondaryEmail;
                    addressUserControlSecondaryAddress.District      = _tempPerson.SecondaryDistrict;
                    addressUserControlSecondaryAddress.City          = _tempPerson.SecondaryCity;
                    addressUserControlSecondaryAddress.Comments      = _tempPerson.SecondaryAddress;
                    addressUserControlSecondaryAddress.HomePhone     = _tempPerson.SecondaryHomePhone ?? String.Empty;
                    addressUserControlSecondaryAddress.PersonalPhone = _tempPerson.SecondaryPersonalPhone ?? String.Empty;
                }
                //_InitializeCustomizeFields();
                DisplayProjects(_tempPerson.Projects);

                cbBranch.SelectedItem = _tempPerson.Branch;
            }
            else
            {
                _tempPerson.LoanCycle = 0;
                if (cbBranch.Items.Count > 0)
                {
                    cbBranch.SelectedIndex = 0;
                }
            }
            InitializePhoto();
        }
Exemplo n.º 5
0
        private void _InitializeListViewBookings(Account pAccount, DateTime pBeginDate, DateTime pEndDate, OBookingTypes pBookingType)
        {
            lvBooking.Items.Clear();
            lblAccountBalance.Text = String.Empty;
            if (pAccount != null)
            {
                _bookingsStock = ServicesProvider.GetInstance().GetAccountingServices().FindAllBookings(pAccount, pBeginDate, pEndDate, ((Currency)(cmbCurrencies.SelectedItem)).Id, pBookingType, ((Branch)cmbBranches.SelectedItem).Id);
                if (_bookingsStock.Count != 0)
                {
                    foreach (BookingToView bookingToView in _bookingsStock)
                    {
                        ListViewItem listViewItem = new ListViewItem(bookingToView.Date.ToShortDateString());
                        if (bookingToView.Direction == OBookingDirections.Debit)
                        {
                            listViewItem.SubItems.Add(bookingToView.AmountInternal.GetFormatedValue(true));
                            listViewItem.SubItems.Add("");
                        }
                        else
                        {
                            listViewItem.SubItems.Add("");
                            listViewItem.SubItems.Add(bookingToView.AmountInternal.GetFormatedValue(true));
                        }

                        if (cmbCurrencies.Items.Count > 0)
                        {
                            listViewItem.SubItems.Add(bookingToView.ExchangeRate.ToString());
                            if (!bookingToView.ExchangeRate.HasValue)
                            {
                                listViewItem.BackColor = Color.Red;
                            }
                            listViewItem.SubItems.Add(bookingToView.ExternalAmount.GetFormatedValue(true));
                        }

                        if (bookingToView.IsExported)
                        {
                            listViewItem.ForeColor = Color.Gray;
                        }

                        string purpose = string.Format("{0} {1} {2}",
                                                       MultiLanguageStrings.GetString(Ressource.AccountView, bookingToView.EventCode + @".Text"),
                                                       bookingToView.ContractCode,
                                                       MultiLanguageStrings.GetString(Ressource.AccountView, bookingToView.AccountingLabel + @".Text"));

                        listViewItem.SubItems.Add(purpose);
                        lvBooking.Items.Add(listViewItem);
                    }
                }

                if (((Currency)cmbCurrencies.SelectedItem).Id != 0)
                {
                    Currency  selectedcur = cmbCurrencies.SelectedItem as Currency;
                    OCurrency balance     = ServicesProvider.GetInstance().GetAccountingServices().
                                            GetAccountBalance(pAccount.Id, selectedcur.Id, 0, null, 0, (cmbBranches.SelectedItem as Branch).Id);
                    lblAccountBalance.Text = string.Format("{0}  {1}", balance.GetFormatedValue(selectedcur.UseCents), selectedcur);
                }
                else
                {
                    Currency selectedcur = new Currency();
                    foreach (var item in cmbCurrencies.Items)
                    {
                        if (((Currency)item).IsPivot)
                        {
                            selectedcur = (Currency)item;
                        }
                    }
                    OCurrency balance = ServicesProvider.GetInstance().GetAccountingServices().
                                        GetAccountBalance(pAccount.Id, 0, 0, null, 0, (cmbBranches.SelectedItem as Branch).Id);
                    lblAccountBalance.Text = string.Format("{0} {1}", balance.GetFormatedValue(selectedcur.UseCents), selectedcur.Name);
                }
            }
            else
            {
                _bookingsStock = null;
            }
        }
Exemplo n.º 6
0
 private void InitMenu()
 {
     tellersToolStripMenuItem.Visible = ServicesProvider.GetInstance().GetGeneralSettings().UseTellerManagement;
 }
Exemplo n.º 7
0
 private void LogUser()
 {
     ServicesProvider.GetInstance().GetEventProcessorServices().LogUser(OUserEvents.UserLogInEvent,
                                                                        OUserEvents.UserLoginDescription, User.CurrentUser.Id);
 }
Exemplo n.º 8
0
        private void SaveCorporate(object sender, EventArgs e)
        {
            try
            {
                _corporate.CreationDate       = TimeProvider.Now;
                _corporate.RegistrationDate   = dateTimePickerDateOfCreate.Value;
                _corporate.AgrementSolidarity = false;


                RecoverDatasFromUserControlsAddress();
                _corporate.Name      = textBoxLastNameCorporate.Text;
                _corporate.SmallName = textBoxSmallNameCorporate.Text;

                _corporate.Branch    = (Branch)cbBranch.SelectedItem;
                _corporate.CreatedBy = User.CurrentUser;
                if (_corporate.Name != null)
                {
                    _corporate.Name = _corporate.Name.Trim();
                }

                _corporate.SmallName = _corporate.SmallName.Trim();
                EventProcessorServices es = ServicesProvider.GetInstance().GetEventProcessorServices();
                if (_corporate.Id == 0)
                {
                    _corporate.Id = ServicesProvider
                                    .GetInstance()
                                    .GetClientServices()
                                    .SaveCorporate(_corporate, _fundingLine, tx =>
                    {
                        foreach (var extension in Extensions)
                        {
                            extension.Save(_corporate, tx);
                        }
                    });
                    buttonSave.Text = MultiLanguageStrings.GetString(Ressource.CorporateUserControl, "buttonUpdate.Text");
                    es.LogClientSaveUpdateEvent(_corporate, true);
                }
                else
                {
                    ServicesProvider.
                    GetInstance()
                    .GetClientServices()
                    .SaveCorporate(Corporate, null, tx => Extensions.ForEach(c => c.Save(Corporate, tx)));
                    es.LogClientSaveUpdateEvent(_corporate, false);
                }

                if (SaveCorporateFundingLine != null)
                {
                    SaveCorporateFundingLine(this, e);
                }

                _saved = true;
            }
            catch (OpenCBS.ExceptionsHandler.Exceptions.CustomFieldsExceptions.CustomFieldsAreNotFilledCorrectlyException)
            {
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
            finally
            {
                _create = false;
                if (CloseCorporate != null)
                {
                    CloseCorporate(this, null);
                }
            }
            if (ButtonSaveClick != null)
            {
                ButtonSaveClick(this, e);
            }
        }
Exemplo n.º 9
0
        private void ShowPicture()
        {
            if (personUserControl != null)
            {
                if (person.Id == 0)
                {
                    UserPicture.Image = null;
                }
                if (photoSubId == 0 && !string.IsNullOrEmpty(person.ImagePath))
                {
                    Bitmap tempImage = new Bitmap(person.ImagePath);
                    image = ServicesProvider.GetInstance().GetPicturesServices().Resize(tempImage, 600);
                }
                else if (photoSubId == 1 && !string.IsNullOrEmpty(person.Image2Path))
                {
                    Bitmap tempImage = new Bitmap(person.Image2Path);
                    image = ServicesProvider.GetInstance().GetPicturesServices().Resize(tempImage, 600);
                }
                else
                {
                    image = ServicesProvider.GetInstance().GetPicturesServices().GetPicture("PERSON", person.Id, false, photoSubId);
                }
            }
            else if (villageForm != null)
            {
                if (village.Id == 0)
                {
                    UserPicture.Image = null;
                }

                if (photoSubId == 0)
                {
                    if (!string.IsNullOrEmpty(village.ImagePath))
                    {
                        Bitmap tempImage = new Bitmap(village.ImagePath);
                        image = ServicesProvider.GetInstance().GetPicturesServices().Resize(tempImage, 600);
                    }
                    else
                    {
                        image = ServicesProvider.GetInstance().GetPicturesServices().GetPicture("VILLAGE", village.Id, false, photoSubId);
                    }
                }
                else if (photoSubId == 1)
                {
                    if (!string.IsNullOrEmpty(village.Image2Path))
                    {
                        Bitmap tempImage = new Bitmap(village.Image2Path);
                        image = ServicesProvider.GetInstance().GetPicturesServices().Resize(tempImage, 600);
                    }
                    else
                    {
                        image = ServicesProvider.GetInstance().GetPicturesServices().GetPicture("VILLAGE", village.Id, false, photoSubId);
                    }
                }
            }
            else if (groupUserControl != null)
            {
                if (photoSubId == 0)
                {
                    if (!string.IsNullOrEmpty(group.ImagePath))
                    {
                        Bitmap tempImage = new Bitmap(group.ImagePath);
                        image = ServicesProvider.GetInstance().GetPicturesServices().Resize(tempImage, 600);
                    }
                    else
                    {
                        image = ServicesProvider.GetInstance().GetPicturesServices().GetPicture("GROUP", group.Id, false,
                                                                                                photoSubId);
                    }
                }
                else if (photoSubId == 1)
                {
                    if (!string.IsNullOrEmpty(group.Image2Path))
                    {
                        Bitmap tempImage = new Bitmap(group.Image2Path);
                        image = ServicesProvider.GetInstance().GetPicturesServices().Resize(tempImage, 600);
                    }
                    else
                    {
                        image = ServicesProvider.GetInstance().GetPicturesServices().GetPicture("GROUP", group.Id, false,
                                                                                                photoSubId);
                    }
                }
            }

            else if (corporateUserControl != null)
            {
                if (photoSubId == 0)
                {
                    if (!string.IsNullOrEmpty(corporate.ImagePath))
                    {
                        Bitmap tempImage = new Bitmap(corporate.ImagePath);
                        image = ServicesProvider.GetInstance().GetPicturesServices().Resize(tempImage, 600);
                    }
                    else
                    {
                        image = ServicesProvider.GetInstance().GetPicturesServices().GetPicture("CORPORATE", corporate.Id,
                                                                                                false, photoSubId);
                    }
                }
                else if (photoSubId == 1)
                {
                    if (!string.IsNullOrEmpty(corporate.Image2Path))
                    {
                        Bitmap tempImage = new Bitmap(corporate.Image2Path);
                        image = ServicesProvider.GetInstance().GetPicturesServices().Resize(tempImage, 600);
                    }
                    else
                    {
                        image = ServicesProvider.GetInstance().GetPicturesServices().GetPicture("CORPORATE", corporate.Id,
                                                                                                false, photoSubId);
                    }
                }
            }
            if (image != null)
            {
                UserPicture.Image         = image;
                UserPicture.Height        = image.Height;
                UserPicture.Width         = image.Width;
                deletePhotoButton.Enabled = true;
            }
        }
Exemplo n.º 10
0
        private void ExportAccounts()
        {
            DataSet dataSet = ServicesProvider.GetInstance().GetChartOfAccountsServices().GetAccountsDataset();

            ExportFile.SaveToFile(dataSet, string.Empty, @",");
        }
Exemplo n.º 11
0
        private void IntializeTreeViewChartOfAccounts()
        {
            List <Account>         accounts          = ServicesProvider.GetInstance().GetChartOfAccountsServices().FindAllAccounts();
            List <AccountCategory> accountCategories = ServicesProvider.GetInstance().GetChartOfAccountsServices().SelectAccountCategories();

            tlvAccounts.CanExpandGetter = delegate(object o)
            {
                Account account = (Account)o;
                if (account.Id == -1)
                {
                    return(true);
                }

                return(accounts.FirstOrDefault(item => item.ParentAccountId == account.Id) != null);
            };

            tlvAccounts.ChildrenGetter = delegate(object o)
            {
                Account account = (Account)o;
                if (account.Id == -1)
                {
                    return(accounts.Where(item => item.AccountCategory == account.AccountCategory && item.ParentAccountId == null));
                }

                return(accounts.Where(item => item.ParentAccountId == account.Id));
            };

            tlvAccounts.RowFormatter = delegate(OLVListItem o)
            {
                Account account = (Account)o.RowObject;
                if (account.Id == -1)
                {
                    o.ForeColor = Color.FromArgb(0, 88, 56);
                    o.Font      = new Font("Arial", 9);
                }
            };

            TreeListView.TreeRenderer renderer = tlvAccounts.TreeColumnRenderer;
            renderer.LinePen = new Pen(Color.Gray, 0.5f)
            {
                DashStyle = DashStyle.Dot
            };

            List <Account> list = new List <Account>();

            foreach (AccountCategory accountCategory in accountCategories)
            {
                string name = MultiLanguageStrings.GetString(
                    Ressource.ChartOfAccountsForm, accountCategory.Name + ".Text");
                name = name ?? accountCategory.Name;

                Account account = new Account
                {
                    Number          = name,
                    AccountCategory = (OAccountCategories)accountCategory.Id,
                    Id = -1
                };

                list.Add(account);
            }
            tlvAccounts.Roots = list;
            tlvAccounts.ExpandAll();
        }
Exemplo n.º 12
0
        private void ImportAccounts()
        {
            fileDialog.InitialDirectory = Application.CommonAppDataPath;
            fileDialog.Filter           = @"CSV (*.csv)|*.csv|All files (*.*)|*.*";
            fileDialog.FilterIndex      = 1;
            fileDialog.RestoreDirectory = true;

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    bool deleteRelated = Confirm(MultiLanguageStrings.GetString(Ressource.ChartOfAccountsForm, "ToDeleteTheChartOfAccounts.Text"));

                    CsvImportExport         importer    = new CsvImportExport();
                    string                  filePath    = fileDialog.FileName;
                    List <Account>          accounts    = new List <Account>();
                    ChartOfAccountsServices coaServices = ServicesProvider.GetInstance().GetChartOfAccountsServices();
                    if (deleteRelated)
                    {
                        IEnumerable <string> relatedDatas = coaServices.HasRelatedDatas();
                        if (relatedDatas != null && relatedDatas.Any())
                        {
                            string[] domainObjects =
                                relatedDatas
                                .Select(
                                    r => GetString(string.Format("RelatedData.{0}", r))
                                    ).Distinct().ToArray();

                            string message =
                                string.Format(
                                    GetString("RelatedDataExists.Text"),
                                    string.Join(",", domainObjects));
                            if (!Confirm(message))
                            {
                                return;
                            }
                        }
                    }
                    importer.Import(filePath, items =>
                    {
                        Account account = new Account
                        {
                            Id              = Convert.ToInt32(items[0]),
                            Number          = items[1],
                            Label           = items[2],
                            DebitPlus       = Convert.ToBoolean(items[3]),
                            TypeCode        = items[4],
                            AccountCategory = (OAccountCategories)(Convert.ToInt32(items[5])),
                            Type            = Convert.ToBoolean(items[6]),
                            ParentAccountId = items[5].ToUpper() == "0" ? null : (int?)Convert.ToInt32(items[7]),
                            Left            = Convert.ToInt32(items[8]),
                            Right           = Convert.ToInt32(items[9])
                        };
                        accounts.Add(account);
                    });

                    coaServices.InsertCoa(accounts.ToArray(), deleteRelated);
                    IntializeTreeViewChartOfAccounts();
                }
                catch (Exception ex)
                {
                    new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
                }
            }
        }
Exemplo n.º 13
0
        private void BtnOkClick(object sender, EventArgs e)
        {
            foreach (ListViewItem item in lvContracts.Items)
            {
                if (item == _itemTotal)
                {
                    continue;
                }
                if (!item.Checked)
                {
                    continue;
                }
                var           loan         = item.Tag as Loan;
                VillageMember activeMember = null;
                int           index        = 0;
                foreach (VillageMember member in _village.Members)
                {
                    int tIndex = member.ActiveLoans.IndexOf(loan);
                    if (tIndex > -1)
                    {
                        activeMember = member;
                        index        = tIndex;
                    }
                }

                if (activeMember != null)
                {
                    Person person = activeMember.Tiers as Person;
                    if (loan != null)
                    {
                        int       number = loan.GetFirstUnpaidInstallment().Number;
                        OCurrency total  = (OCurrency)item.SubItems[5].Tag;
                        bool      doProportionPayment = cbItem.SelectedIndex == 2;
                        OCurrency penalties           = (OCurrency)item.SubItems[4].Tag;
                        bool      disableFees         = penalties != loan.CalculateDuePenaltiesForInstallment(number, TimeProvider.Today);
                        string    comment             = item.SubItems[10].Text;

                        PaymentMethod paymentMethod = ServicesProvider.GetInstance().GetPaymentMethodServices().GetPaymentMethodById(1);

                        try
                        {
                            activeMember.ActiveLoans[index] =
                                ServicesProvider.GetInstance().GetContractServices().Repay(loan,
                                                                                           person,
                                                                                           number,
                                                                                           TimeProvider.Today,
                                                                                           total,
                                                                                           disableFees,
                                                                                           penalties,
                                                                                           0,
                                                                                           false,
                                                                                           0,
                                                                                           true,
                                                                                           doProportionPayment,
                                                                                           paymentMethod,
                                                                                           comment,
                                                                                           false);
                        }
                        catch (Exception ex)
                        {
                            new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
                        }
                    }
                }

                if (loan != null)
                {
                    if (loan.Closed)
                    {
                        if (activeMember != null)
                        {
                            activeMember.ActiveLoans[index] = null;
                        }
                    }
                }
            }

            if (_AllContractsClosed())
            {
                _village.Active = false;
                ServicesProvider.GetInstance().GetContractServices().UpdateVillageStatus(_village);
            }
        }
Exemplo n.º 14
0
        private void LoadContracts()
        {
            int loans = 0;

            lvContracts.Items.Clear();

            PaymentMethod paymentMethod =
                ServicesProvider.GetInstance().GetPaymentMethodServices().GetPaymentMethodById(1);

            foreach (VillageMember member in _village.Members)
            {
                foreach (Loan loan in member.ActiveLoans)
                {
                    if (null == loan || loan.ContractStatus != OContractStatus.Active)
                    {
                        continue;
                    }

                    var         result      = new KeyValuePair <Loan, RepaymentEvent>();
                    Installment installment = loan.GetFirstUnpaidInstallment();

                    if (loan.Product.LoanType == OLoanTypes.DecliningFixedPrincipalWithRealInterest)
                    {
                        OCurrency amountForToday = loan.CalculateMaximumAmountToRegradingLoan(installment.Number,
                                                                                              TimeProvider.Now.Date,
                                                                                              false,
                                                                                              0,
                                                                                              0,
                                                                                              false,
                                                                                              0,
                                                                                              true);

                        result = ServicesProvider.GetInstance().GetContractServices().ShowNewContract(loan,
                                                                                                      installment.Number,
                                                                                                      TimeProvider.Now,
                                                                                                      amountForToday,
                                                                                                      false,
                                                                                                      0,
                                                                                                      0,
                                                                                                      false,
                                                                                                      0,
                                                                                                      true,
                                                                                                      false,
                                                                                                      paymentMethod,
                                                                                                      false,
                                                                                                      false);
                    }


                    if (null == installment)
                    {
                        continue;
                    }

                    loans++;

                    Person       person = member.Tiers as Person;
                    ListViewItem item   = new ListViewItem(person.Name)
                    {
                        Tag = loan
                    };
                    item.SubItems.Add(loan.Code);

                    OCurrency principalHasToPay = result.Value == null
                                                      ? installment.PrincipalHasToPay
                                                      : (result.Value).Principal;

                    ListViewItem.ListViewSubItem subitem = new ListViewItem.ListViewSubItem
                    {
                        Text = principalHasToPay.GetFormatedValue(
                            loan.UseCents),
                        Tag = principalHasToPay
                    };
                    item.SubItems.Add(subitem);

                    OCurrency interestHasToPay = result.Value == null
                                                      ? installment.InterestHasToPay
                                                      : (result.Value).Interests;

                    subitem = new ListViewItem.ListViewSubItem
                    {
                        Text = interestHasToPay.GetFormatedValue(loan.UseCents),
                        Tag  = interestHasToPay
                    };
                    item.SubItems.Add(subitem);

                    subitem = new ListViewItem.ListViewSubItem();
                    OCurrency penalties = loan.CalculateDuePenaltiesForInstallment(installment.Number,
                                                                                   TimeProvider.Today);
                    subitem.Text = penalties.GetFormatedValue(loan.UseCents);
                    subitem.Tag  = penalties;
                    item.SubItems.Add(subitem);

                    subitem = new ListViewItem.ListViewSubItem();
                    OCurrency total = principalHasToPay + interestHasToPay + penalties;
                    subitem.Text = total.GetFormatedValue(loan.UseCents);
                    subitem.Tag  = total;
                    item.SubItems.Add(subitem);

                    subitem = new ListViewItem.ListViewSubItem();
                    OCurrency olb = ServicesProvider.GetInstance().GetGeneralSettings().IsOlbBeforeRepayment
                                        ? installment.OLB
                                        : installment.OLBAfterRepayment;
                    subitem.Text = olb.GetFormatedValue(loan.UseCents);
                    subitem.Tag  = olb;
                    item.SubItems.Add(subitem);

                    OCurrency dueInterest = 0;
                    foreach (Installment installmentItem in loan.InstallmentList)
                    {
                        if (!installmentItem.IsRepaid)
                        {
                            dueInterest += installmentItem.InterestsRepayment - installmentItem.PaidInterests;
                        }
                    }

                    subitem = new ListViewItem.ListViewSubItem
                    {
                        Text = dueInterest.GetFormatedValue(loan.UseCents),
                        Tag  = dueInterest
                    };
                    item.SubItems.Add(subitem);

                    subitem = new ListViewItem.ListViewSubItem
                    {
                        Text = loan.Product.Currency.Code,
                        Tag  = loan.Product.Currency
                    };
                    item.SubItems.Add(subitem);

                    cbItem.SelectedIndex = 0;

                    subitem = new ListViewItem.ListViewSubItem
                    {
                        Text = cbItem.SelectedItem.ToString(),
                        Tag  = cbItem.SelectedItem
                    };
                    item.SubItems.Add(subitem);

                    subitem = new ListViewItem.ListViewSubItem();
                    item.SubItems.Add(subitem);

                    lvContracts.Items.Add(item);
                }
            }

            if (0 == loans)
            {
                btnOK.Enabled = false;
                return;
            }

            _itemTotal.SubItems.Add("");
            _itemTotal.SubItems.Add("0");
            _itemTotal.SubItems.Add("0");
            _itemTotal.SubItems.Add("0");
            _itemTotal.SubItems.Add("0");
            _itemTotal.SubItems.Add("");
            _itemTotal.SubItems.Add("");
            _itemTotal.SubItems.Add("");
            _itemTotal.SubItems.Add("");

            lvContracts.Items.Add(_itemTotal);
        }
Exemplo n.º 15
0
        private void OnEditLoan(EditLoanMessage message)
        {
            var client = ServicesProvider.GetInstance().GetClientServices().FindTiersByContractId(message.Id);

            InitializeCreditContractForm(client, message.Id);
        }
Exemplo n.º 16
0
        private void ProcessImage(string fileName)
        {
            if (personUserControl != null)
            {
                if (photoSubId == 0)
                {
                    person.ImagePath = fileName;
                    Bitmap bitmap  = new Bitmap(fileName);
                    Bitmap resized = ServicesProvider.GetInstance().GetPicturesServices().Resize(bitmap, 600);
                    UserPicture.Height = resized.Height;
                    UserPicture.Width  = resized.Width;
                    UserPicture.Image  = resized;
                    Bitmap thumbnail = ServicesProvider.GetInstance().GetPicturesServices().Resize(bitmap, 128);
                    personUserControl.pictureBox.Image    = thumbnail;
                    personUserControl.pictureBox.SizeMode = PictureBoxSizeMode.Zoom;
                    UserPicture.Image = resized;
                }
                else if (photoSubId == 1)
                {
                    person.Image2Path = fileName;
                    Bitmap bitmap  = new Bitmap(fileName);
                    Bitmap resized = ServicesProvider.GetInstance().GetPicturesServices().Resize(bitmap, 600);
                    UserPicture.Height = resized.Height;
                    UserPicture.Width  = resized.Width;
                    UserPicture.Image  = resized;
                    Bitmap thumbnail = ServicesProvider.GetInstance().GetPicturesServices().Resize(bitmap, 128);
                    personUserControl.pictureBox2.Image    = thumbnail;
                    personUserControl.pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;
                    UserPicture.Image = resized;
                }
            }

            else if (villageForm != null)
            {
                if (photoSubId == 0)
                {
                    village.ImagePath = fileName;
                    Bitmap bitmap  = new Bitmap(fileName);
                    Bitmap resized = ServicesProvider.GetInstance().GetPicturesServices().Resize(bitmap, 600);
                    UserPicture.Height = resized.Height;
                    UserPicture.Width  = resized.Width;
                    UserPicture.Image  = resized;
                    Bitmap thumbnail = ServicesProvider.GetInstance().GetPicturesServices().Resize(bitmap, 128);
                    villageForm.pictureBox1.Image    = thumbnail;
                    villageForm.pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
                    UserPicture.Image = resized;
                }
                else if (photoSubId == 1)
                {
                    village.Image2Path = fileName;
                    Bitmap bitmap  = new Bitmap(fileName);
                    Bitmap resized = ServicesProvider.GetInstance().GetPicturesServices().Resize(bitmap, 600);
                    UserPicture.Height = resized.Height;
                    UserPicture.Width  = resized.Width;
                    UserPicture.Image  = resized;
                    Bitmap thumbnail = ServicesProvider.GetInstance().GetPicturesServices().Resize(bitmap, 128);
                    villageForm.pictureBox2.Image    = thumbnail;
                    villageForm.pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;
                    UserPicture.Image = resized;
                }
            }

            else if (groupUserControl != null)
            {
                if (photoSubId == 0)
                {
                    group.ImagePath = fileName;
                    Bitmap bitmap  = new Bitmap(fileName);
                    Bitmap resized = ServicesProvider.GetInstance().GetPicturesServices().Resize(bitmap, 600);
                    UserPicture.Height = resized.Height;
                    UserPicture.Width  = resized.Width;
                    UserPicture.Image  = resized;
                    Bitmap thumbnail = ServicesProvider.GetInstance().GetPicturesServices().Resize(bitmap, 128);
                    groupUserControl.pictureBox1.Image    = thumbnail;
                    groupUserControl.pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
                    UserPicture.Image = resized;
                }
                else if (photoSubId == 1)
                {
                    group.Image2Path = fileName;
                    Bitmap bitmap  = new Bitmap(fileName);
                    Bitmap resized = ServicesProvider.GetInstance().GetPicturesServices().Resize(bitmap, 600);
                    UserPicture.Height = resized.Height;
                    UserPicture.Width  = resized.Width;
                    UserPicture.Image  = resized;
                    Bitmap thumbnail = ServicesProvider.GetInstance().GetPicturesServices().Resize(bitmap, 128);
                    groupUserControl.pictureBox2.Image    = thumbnail;
                    groupUserControl.pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;
                    UserPicture.Image = resized;
                }
            }
            else if (corporateUserControl != null)
            {
                if (photoSubId == 0)
                {
                    corporate.ImagePath = fileName;
                    Bitmap bitmap  = new Bitmap(fileName);
                    Bitmap resized = ServicesProvider.GetInstance().GetPicturesServices().Resize(bitmap, 600);
                    UserPicture.Height = resized.Height;
                    UserPicture.Width  = resized.Width;
                    UserPicture.Image  = resized;
                    Bitmap thumbnail = ServicesProvider.GetInstance().GetPicturesServices().Resize(bitmap, 128);
                    corporateUserControl.pictureBox1.Image    = thumbnail;
                    corporateUserControl.pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
                    UserPicture.Image = resized;
                }
                else if (photoSubId == 1)
                {
                    corporate.Image2Path = fileName;
                    Bitmap bitmap  = new Bitmap(fileName);
                    Bitmap resized = ServicesProvider.GetInstance().GetPicturesServices().Resize(bitmap, 600);
                    UserPicture.Height = resized.Height;
                    UserPicture.Width  = resized.Width;
                    UserPicture.Image  = resized;
                    Bitmap thumbnail = ServicesProvider.GetInstance().GetPicturesServices().Resize(bitmap, 128);
                    corporateUserControl.pictureBox2.Image    = thumbnail;
                    corporateUserControl.pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;
                    UserPicture.Image = resized;
                }
            }
        }
Exemplo n.º 17
0
        private void OnEditSaving(EditSavingMessage message)
        {
            var client = ServicesProvider.GetInstance().GetClientServices().FindTiersBySavingsId(message.Id);

            InitializeSavingContractForm(client, message.Id);
        }
Exemplo n.º 18
0
        private void GetBookings(ClosureOptions options)
        {
            List <Booking> bookings   = new List <Booking>();
            EventStock     eventStock = new EventStock();

            AccountingRuleCollection rules = ServicesProvider.GetInstance().GetAccountingRuleServices().SelectAll();

            rules.SortByOrder();

            if (options.DoLoanClosure)
            {
                UpdateStatus("LoanClosureProcessing", "");
                eventStock =
                    ServicesProvider.GetInstance().GetEventProcessorServices().SelectEventsForClosure(_beginDate, _endDate, _branch);
                UpdateStatus("LoanClosureProcessing", eventStock.GetEvents().Count.ToString());
                //add generated events for processing
            }

            if (options.DoSavingClosure)
            {
                UpdateStatus("SavingsClosureProcessing", "");

                eventStock.AddRange(
                    ServicesProvider.GetInstance().GetSavingServices().SelectEventsForClosure(
                        _beginDate, _endDate, _branch));

                UpdateStatus("SavingsClosureProcessing", eventStock.GetEvents().Count.ToString());
            }

            if (options.DoTellerManagementClosure)
            {
                UpdateStatus("TellerManagementProcessing", "");
                eventStock.AddRange(ServicesProvider.GetInstance().GetEventProcessorServices().GetTellerEventsForClosure(
                                        _beginDate, _endDate));
                UpdateStatus("EventClosureProcessing", eventStock.GetEvents().Count.ToString());
            }

            //important to have sorted list
            eventStock.SortEventsById();
            //closure procesing
            timerClosure.Start();
            timerClosure.Enabled = true;

            //set ex rate
            List <ExchangeRate> rates =
                ServicesProvider.GetInstance().GetExchangeRateServices().SelectRatesByDate(_beginDate, _endDate);

            List <CoreDomain.Accounting.FiscalYear> fiscalYears =
                ServicesProvider.GetInstance().GetChartOfAccountsServices().SelectFiscalYears();

            bookings.AddRange(
                _accountingClosure.GetBookings(
                    rules,
                    eventStock,
                    ServicesProvider.GetInstance().GetTellerServices().FindAllTellers(),
                    ServicesProvider.GetInstance().GetPaymentMethodServices().GetAllPaymentMethodsForClosure(),
                    rates,
                    fiscalYears));

            timerClosure.Stop();
            timerClosure.Enabled = false;

            //manual transactions
            if (options.DoManualEntries)
            {
                bookings.AddRange(ServicesProvider.GetInstance().GetAccountingServices().SelectMovements(false, rates,
                                                                                                         fiscalYears));
            }

            #region Reversal
            if (options.DoReversalTransactions)
            {
                UpdateStatus("ReversalTransactionProcessing", "");
                bookings.AddRange(ServicesProvider.GetInstance().GetAccountingServices().SelectMovementsForReverse(
                                      rates,
                                      fiscalYears));
            }
            #endregion

            //add reversal provision booking
            if (options.DoLoanClosure)
            {
                bookings.AddRange(
                    _generatedEvents.GetProvisionEvents().Select(
                        provisionEvent =>
                        ServicesProvider.GetInstance().GetAccountingServices().SelectProvisionMovments(
                            provisionEvent.ContracId, rates,
                            fiscalYears)).Where(b => b != null));
            }

            SortBookingsByDate(bookings);

            FillListView(bookings);
        }
Exemplo n.º 19
0
 private void mnuChartOfAccounts_Click(object sender, EventArgs e)
 {
     InitializeChartOfAccountsForm(ServicesProvider.GetInstance().GetCurrencyServices().GetPivot().Id);
 }
Exemplo n.º 20
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!_nsgForm.Save())
            {
                return;
            }

            bool             isError = false;
            ISavingsContract saving  = null;

            try
            {
                foreach (ListViewItem item in lvMembers.Items)
                {
                    if (item == _itemTotal)
                    {
                        continue;
                    }
                    if (!item.Checked)
                    {
                        continue;
                    }
                    var     member = item.Tag as VillageMember;
                    IClient client = member.Tiers;

                    OCurrency initialAmount = (OCurrency)item.SubItems[idxInitialAmount].Tag;
                    double    interestRate  = (double)item.SubItems[idxInterestRate].Tag;
                    OCurrency entryFees     = (OCurrency)item.SubItems[idxEntryFees].Tag;

                    if (_product is SavingsBookProduct)
                    {
                        SavingsBookProduct sbp               = (SavingsBookProduct)_product;
                        decimal            withdrawFees      = (decimal)item.SubItems[idxWithdrawFees].Tag;
                        decimal            transferFees      = (decimal)item.SubItems[idxTransferFees].Tag;
                        decimal            ibtFees           = Convert.ToDecimal(item.SubItems[idxIbtFees].Tag);
                        decimal            depositFees       = (decimal)item.SubItems[idxDepositFees].Tag;
                        decimal            chequeDepositFees = (decimal)item.SubItems[idxChequeDepositFees].Tag;
                        decimal            closeFees         = (decimal)item.SubItems[idxCloseFees].Tag;
                        decimal            managementFees    = (decimal)item.SubItems[idxManagementFees].Tag;
                        decimal            overdraftFees     = (decimal)item.SubItems[idxOverdraftFees].Tag;
                        decimal            agioFees          = (decimal)item.SubItems[idxAgioFees].Tag;
                        decimal            reopenFees        = (decimal)item.SubItems[idxReopenFees].Tag;

                        saving = new SavingBookContract(ServicesProvider.GetInstance().GetGeneralSettings(),
                                                        User.CurrentUser, TimeProvider.Today, sbp, client)
                        {
                            InterestRate = interestRate / 100
                        };
                        SavingBookContract s = (SavingBookContract)saving;

                        if (sbp.WithdrawFeesType == OSavingsFeesType.Flat)
                        {
                            s.FlatWithdrawFees = withdrawFees;
                        }
                        else
                        {
                            s.RateWithdrawFees = (double)withdrawFees / 100;
                        }

                        if (sbp.TransferFeesType == OSavingsFeesType.Flat)
                        {
                            s.FlatTransferFees = transferFees;
                        }
                        else
                        {
                            s.RateTransferFees = (double)transferFees / 100;
                        }

                        if (sbp.InterBranchTransferFee.IsFlat)
                        {
                            s.FlatInterBranchTransferFee = ibtFees;
                        }
                        else
                        {
                            s.RateInterBranchTransferFee = Convert.ToDouble(ibtFees);
                        }

                        s.DepositFees       = depositFees;
                        s.ChequeDepositFees = chequeDepositFees;
                        s.CloseFees         = closeFees;
                        s.ManagementFees    = managementFees;
                        s.OverdraftFees     = overdraftFees;
                        s.AgioFees          = (double)agioFees / 100;
                        s.ReopenFees        = reopenFees;
                    }

                    saving.SavingsOfficer = _village.LoanOfficer;
                    saving.InitialAmount  = initialAmount;
                    saving.EntryFees      = entryFees;
                    saving.NsgID          = _village.Id;
                    saving.Id             = ServicesProvider.GetInstance().GetSavingServices().SaveContract(saving, (Client)member.Tiers);
                    saving = ServicesProvider.GetInstance().GetSavingServices().GetSaving(saving.Id);

                    ServicesProvider.GetInstance().GetSavingServices().FirstDeposit(saving, initialAmount, TimeProvider.Now, entryFees,
                                                                                    User.CurrentUser, Teller.CurrentTeller);
                    ServicesProvider.GetInstance().GetSavingServices().UpdateInitialData(saving.Id, initialAmount, entryFees);

                    saving = ServicesProvider.GetInstance().GetSavingServices().GetSaving(saving.Id);
                    ((Client)member.Tiers).AddSaving(saving);
                }
            }
            catch (Exception ex)
            {
                isError = true;
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
            finally
            {
                InitializeControls();
            }

            if (!isError)
            {
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Exemplo n.º 21
0
        private void _DisplayAllGroups(List <IClient> listAllGroups)
        {
            //tabControlEconomicInfo.TabPages.Remove(tabPageGroupMember);
            if (listAllGroups.Count != 0)
            {
                //tabControlEconomicInfo.TabPages.Add(tabPageGroupMember);
                listViewGroup.Items.Clear();
                foreach (IClient client in listAllGroups)
                {
                    ListViewItem item = new ListViewItem(client.Name)
                    {
                        Tag = client
                    };
                    if (client is Group)
                    {
                        Group group = (Group)client;
                        item.SubItems.Add("SG");
                        if (group.EstablishmentDate.HasValue)
                        {
                            item.SubItems.Add(group.EstablishmentDate.Value.ToShortDateString());
                        }
                        else
                        {
                            item.SubItems.Add("-");
                        }

                        List <Member> members = ServicesProvider.GetInstance().GetClientServices().FindGroupHistoryPersons(group.Id);
                        //string joinedDate = "-";
                        //string leftDate = "-";
                        foreach (Member member in members)
                        {
                            if (member.Tiers.Id == _tempPerson.Id)
                            {
                                item.SubItems.Add(member.JoinedDate.ToShortDateString());
                                if (member.LeftDate.HasValue)
                                {
                                    item.SubItems.Add(member.LeftDate.Value.ToShortDateString());
                                }
                                else
                                {
                                    item.SubItems.Add("-");
                                }

                                listViewGroup.Items.Add(item);
                                break;
                            }
                        }
                        //item.SubItems.Add(joinedDate);
                        //item.SubItems.Add(leftDate);
                    }
                    else if (client is Village)
                    {
                        Village village = (Village)client;
                        item.SubItems.Add("NSG");
                        if (village.EstablishmentDate.HasValue)
                        {
                            item.SubItems.Add(village.EstablishmentDate.Value.ToShortDateString());
                        }
                        else
                        {
                            item.SubItems.Add("-");
                        }

                        List <VillageMember> members = ServicesProvider.GetInstance().GetClientServices().FindVillageHistoryPersons(village.Id);
                        //string joinedDate = "-";
                        //string leftDate = "-";
                        foreach (VillageMember member in members)
                        {
                            if (member.Tiers.Id == _tempPerson.Id)
                            {
                                item.SubItems.Add(member.JoinedDate.ToShortDateString());
                                if (member.LeftDate.HasValue)
                                {
                                    item.SubItems.Add(member.LeftDate.Value.ToShortDateString());
                                }
                                else
                                {
                                    item.SubItems.Add("-");
                                }

                                listViewGroup.Items.Add(item);
                                break;
                            }
                        }
                        //item.SubItems.Add(joinedDate);
                        //item.SubItems.Add(leftDate);
                    }
                }
            }
        }
Exemplo n.º 22
0
 private void _InitializeCity()
 {
     textBoxCity.MyAutoCompleteSource = ServicesProvider.GetInstance().GetLocationServices().GetCities();
 }
Exemplo n.º 23
0
        private void SavePerson()
        {
            _personSaved = false;
            RecoverDatasFromUserControlsAddress();
            RecoverDataFromCombobox();

            _tempPerson.FirstContact     = dateTimePickerFirstContact.Value;
            _tempPerson.FirstAppointment = dateTimePickerFirstAppointment.Value;
            _tempPerson.Branch           = (Branch)cbBranch.SelectedItem;

            try
            {
                bool save = 0 == _tempPerson.Id;
                if (_tempPerson.FirstName != null)
                {
                    _tempPerson.FirstName = _tempPerson.FirstName.Trim();
                }
                if (_tempPerson.LastName != null)
                {
                    _tempPerson.LastName = _tempPerson.LastName.Trim();
                }
                if (_tempPerson.FatherName != null)
                {
                    _tempPerson.FatherName = _tempPerson.FatherName.Trim();
                }
                if (_tempPerson.IdentificationData != null)
                {
                    _tempPerson.IdentificationData = _tempPerson.IdentificationData.Trim();
                }
                _tempPerson.Nationality = textBoxNationality.Text;

                string result = ServicesProvider
                                .GetInstance()
                                .GetClientServices()
                                .SavePerson(ref _tempPerson, (tx, id) =>
                {
                    foreach (var extension in Extensions)
                    {
                        extension.Save(_tempPerson, tx);
                    }
                });

                EventProcessorServices es = ServicesProvider.GetInstance().GetEventProcessorServices();
                es.LogClientSaveUpdateEvent(_tempPerson, save);

                if (result != string.Empty)
                {
                    MessageBox.Show(result, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                _personSaved    = true;
                buttonSave.Text = MultiLanguageStrings.GetString(Ressource.PersonUserControl, "Update");

                var formatInfo = new NameFormatInfo();
                var settings   = ServicesProvider.GetInstance().GetGeneralSettings();
                //var fnFormat = @"{0:" + settings.FirstNameFormat + @"}";
                //var lnFormat = @"{0:" + settings.LastNameFormat + @"}";
                textBoxFirstName.Text = string.Format(_tempPerson.FirstName);
                textBoxLastname.Text  = string.Format(_tempPerson.LastName);
                if (_tempPerson.FatherName != null)
                {
                    textBoxFatherName.Text = string.Format(_tempPerson.FatherName);
                }
                textBoxIdentificationData.Text = string.Format(_tempPerson.IdentificationData);
                //EnableDocuments();
                ResetImagesFlags();

                if (ApplicationSettings.GetInstance(User.CurrentUser.Md5).UseMandatorySavingAccount&&
                    Person.Savings.Count == 0)
                {
                    Person.Savings.Add(
                        ServicesProvider.GetInstance().GetSavingServices().AddAndActivateDefaultSavingAccount(Person));
                    DisplaySavings(Person.Savings);
                }
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
Exemplo n.º 24
0
        private void InitializeControls()
        {
            _ucAddress              = new AddressUserControl();
            _ctxProducts            = new ContextMenuStrip();
            _ucAddress.ExtraVisible = false;
            _ucAddress.Dock         = DockStyle.Fill;
            gbAddress.Controls.Add(_ucAddress);
            InitializeLoanOfficers();
            if (_village != null && _village.Id > 0)
            {
                tbName.Text         = _village.Name;
                dtDate.Value        = _village.EstablishmentDate.HasValue ? _village.EstablishmentDate.Value : TimeProvider.Now;
                _ucAddress.District = _village.District;
                _ucAddress.City     = _village.City;
                _ucAddress.Comments = _village.Address;
                _ucAddress.ZipCode  = _village.ZipCode;
                btnSave.Text        = MultiLanguageStrings.GetString(Ressource.VillageForm, "Update.Text");
                DisplayMembers();
                DisplaySavings();
                DisplayLoans();

                if (_village.MeetingDay.HasValue)
                {
                    cmbWeekDay.SelectedIndex = (int)_village.MeetingDay;
                    cbMeetingDay.Checked     = true;
                }

                if (_village.LoanOfficer != null)
                {
                    foreach (object item in cbLoanOfficers.Items)
                    {
                        User user = item as User;
                        if (user != null && user.Id == _village.LoanOfficer.Id)
                        {
                            cbLoanOfficers.SelectedItem = item;
                            break;
                        }
                    }
                }
            }
            else
            {
                tabPageLoan.Enabled    = false;
                tabPageSavings.Enabled = false;
            }

            PicturesServices ps = ServicesProvider.GetInstance().GetPicturesServices();

            if (ps.IsEnabled())
            {
                pictureBox1.Image    = ps.GetPicture("VILLAGE", _village.Id, true, 0);
                pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
                pictureBox2.Image    = ps.GetPicture("VILLAGE", _village.Id, true, 1);
                pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;
            }
            else
            {
                pictureBox1.Visible           = false;
                pictureBox2.Visible           = false;
                linkLabelChangePhoto.Visible  = false;
                linkLabelChangePhoto2.Visible = false;
            }

            foreach (Branch branch in User.CurrentUser.Branches)
            {
                cbBranch.Items.Add(branch);
            }
            if (_village.Id > 0)
            {
                cbBranch.SelectedItem = _village.Branch;
            }
            else if (cbBranch.Items.Count > 0)
            {
                cbBranch.SelectedIndex = 0;
            }

            btnPrint.ReportInitializer = report => report.SetParamValue("village_id", _village.Id);
            btnPrint.LoadReports();
        }
Exemplo n.º 25
0
        private void lvMembers_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            ListViewItem item = e.Item;

            item.Font = new Font("Arial", 9F, item.Checked ? FontStyle.Bold : FontStyle.Regular);
            foreach (ListViewItem.ListViewSubItem subitem in item.SubItems)
            {
                subitem.Font = item.Font;
            }
            if (item.Checked && item != _itemTotal)
            {
                if (string.IsNullOrEmpty(item.SubItems[IdxAmount].Text)) // Amount
                {
                    if (_product.CycleId == null)
                    {
                        if (_product.Amount.HasValue)
                        {
                            item.SubItems[IdxAmount].Text = _product.Amount.GetFormatedValue(_product.Currency.UseCents);
                            item.SubItems[IdxAmount].Tag  = _product.Amount;
                        }
                        else
                        {
                            item.SubItems[IdxAmount].Text = _product.AmountMin.GetFormatedValue(_product.Currency.UseCents);
                            item.SubItems[IdxAmount].Tag  = _product.AmountMin;
                        }
                    }
                    else
                    {
                        item.SubItems[IdxAmount].Text = ((VillageMember)item.Tag).Product.AmountMin.GetFormatedValue(_product.Currency.UseCents);
                    }
                }
                if (string.IsNullOrEmpty(item.SubItems[IdxCurrency].Text)) // Currency
                {
                    if (_product.CycleId == null)
                    {
                        if (_product.Amount.HasValue)
                        {
                            item.SubItems[IdxCurrency].Text = _product.Currency.Code;
                            item.SubItems[IdxCurrency].Tag  = _product.Currency.Code;
                        }
                        else
                        {
                            item.SubItems[IdxCurrency].Text = _product.Currency.Code;
                            item.SubItems[IdxCurrency].Tag  = _product.Currency.Code;
                        }
                    }
                    else
                    {
                        item.SubItems[IdxCurrency].Text = ((VillageMember)item.Tag).Product.Currency.Code;
                    }
                }
                if (string.IsNullOrEmpty(item.SubItems[IdxInterest].Text)) // Interest
                {
                    if (_product.CycleId == null)
                    {
                        if (_product.InterestRate.HasValue)
                        {
                            item.SubItems[IdxInterest].Text = Math.Round(_product.InterestRate.Value * 100, decimalPlaces).ToString();
                            item.SubItems[IdxInterest].Tag  = _product.InterestRate;
                        }
                        else
                        {
                            item.SubItems[IdxInterest].Text = Math.Round(_product.InterestRateMin.Value * 100, decimalPlaces).ToString();
                            item.SubItems[IdxInterest].Tag  = _product.InterestRateMin;
                        }
                    }
                    else
                    {
                        item.SubItems[IdxInterest].Text = Math.Round(((VillageMember)item.Tag).Product.InterestRateMin.Value * 100, decimalPlaces).ToString();
                    }
                }
                if (string.IsNullOrEmpty(item.SubItems[IdxGracePeriod].Text)) // Grace period
                {
                    if (_product.GracePeriod.HasValue)
                    {
                        item.SubItems[IdxGracePeriod].Text = _product.GracePeriod.ToString();
                        item.SubItems[IdxGracePeriod].Tag  = _product.GracePeriod;
                    }
                    else
                    {
                        item.SubItems[IdxGracePeriod].Text = _product.GracePeriodMin.ToString();
                        item.SubItems[IdxGracePeriod].Tag  = _product.GracePeriodMin;
                    }
                }
                if (string.IsNullOrEmpty(item.SubItems[IdxInstallments].Text)) // Installments
                {
                    if (_product.CycleId == null)
                    {
                        if (_product.NbOfInstallments.HasValue)
                        {
                            item.SubItems[IdxInstallments].Text = _product.NbOfInstallments.ToString();
                            item.SubItems[IdxInstallments].Tag  = _product.NbOfInstallments;
                        }
                        else
                        {
                            item.SubItems[IdxInstallments].Text = _product.NbOfInstallmentsMin.ToString();
                            item.SubItems[IdxInstallments].Tag  = _product.NbOfInstallmentsMin;
                        }
                    }
                    else
                    {
                        item.SubItems[IdxInstallments].Text = ((VillageMember)item.Tag).Product.NbOfInstallmentsMin.ToString();
                    }
                }
                if (string.IsNullOrEmpty(item.SubItems[IdxLoanOfficer].Text)) // Loan officer
                {
                    item.SubItems[IdxLoanOfficer].Text = _village.LoanOfficer.ToString();
                    item.SubItems[IdxLoanOfficer].Tag  = _village.LoanOfficer;
                }

                if (string.IsNullOrEmpty(item.SubItems[IdxCreationDate].Text)) // Credit Committee date
                {
                    item.SubItems[IdxCreationDate].Text = TimeProvider.Today.ToString(ApplicationSettings.GetInstance("").SHORT_DATE_FORMAT);
                    item.SubItems[IdxCreationDate].Tag  = TimeProvider.Today.ToString(ApplicationSettings.GetInstance("").SHORT_DATE_FORMAT);
                }

                if (string.IsNullOrEmpty(item.SubItems[IdxFundingLine].Text)) // Funding line
                {
                    FundingLine fl;
                    string      flName;
                    if (_product.FundingLine != null)
                    {
                        flName = _product.FundingLine.Name;
                        fl     = _product.FundingLine;
                    }
                    else if (cbFundingLine.Items.Count > 0)
                    {
                        flName = ((FundingLine)cbFundingLine.Items[0]).Name;
                        fl     = (FundingLine)cbFundingLine.Items[0];
                    }
                    else
                    {
                        flName = string.Empty;
                        fl     = null;
                    }
                    item.SubItems[IdxFundingLine].Text = flName;
                    item.SubItems[IdxFundingLine].Tag  = fl;
                    _accumulatedAmount = _fLServices.CheckIfAmountIsEnough(fl, decimal.Parse(item.SubItems[2].Text));
                    item.SubItems[IdxRemainingFlMoney].Text = _accumulatedAmount.ToString();
                    if (_accumulatedAmount <= 0)
                    {
                        item.BackColor = Color.Red;
                    }
                    else
                    {
                        item.BackColor = Color.Transparent;
                    }
                }
                if (_product.UseCompulsorySavings && string.IsNullOrEmpty(item.SubItems[IdxCompulsorySavings].Text))
                {
                    //item.SubItems[IdxCompulsorySavings]. = _village.
                    //item.SubItems[IdxCompulsorySavings].Tag = _village.LoanOfficer;

                    cbCompulsorySavings.Items.Clear();
                    List <ISavingsContract> savings = ServicesProvider.GetInstance().GetSavingServices().GetSavingsByClientId(((VillageMember)e.Item.Tag).Tiers.Id);
                    savings = savings.Where(item2 => item2 is SavingBookContract).ToList(); // Only savings book

                    if (savings.Count > 0)
                    {
                        foreach (SavingBookContract saving in savings)
                        {
                            cbCompulsorySavings.Items.Add(saving);
                        }

                        item.SubItems[IdxCompulsorySavings].Text = savings[0].Code;
                        item.SubItems[IdxCompulsorySavings].Tag  = savings[0];
                    }
                }
                if (_product.UseCompulsorySavings && string.IsNullOrEmpty(item.SubItems[IdxCompulsoryPercentage].Text))
                {
                    if (_product.CompulsoryAmount.HasValue)
                    {
                        item.SubItems[IdxCompulsoryPercentage].Text = _product.CompulsoryAmount.ToString();
                        item.SubItems[IdxCompulsoryPercentage].Tag  = _product.CompulsoryAmount;
                    }
                    else
                    {
                        item.SubItems[IdxCompulsoryPercentage].Text = _product.CompulsoryAmountMin.ToString();
                        item.SubItems[IdxCompulsoryPercentage].Tag  = _product.CompulsoryAmountMin;
                    }
                }

                /*if (string.IsNullOrEmpty(item.SubItems[IdxPaymentMethod].Text))
                 * {
                 *  cbPaymentMethods.Items.Clear();
                 *  List<PaymentMethod> methods = ServicesProvider.GetInstance().GetPaymentMethodServices().GetAllPaymentMethods();
                 *
                 *  if (methods.Count > 0)
                 *  {
                 *      foreach (PaymentMethod method in methods)
                 *          cbPaymentMethods.Items.Add(method.Name);
                 *
                 *      item.SubItems[IdxPaymentMethod].Text = methods[0].Name;
                 *      item.SubItems[IdxPaymentMethod].Tag = methods[0].Method;
                 *  }
                 * }*/
            }
            else
            {
                for (int i = 2; i < item.SubItems.Count; i++)
                {
                    item.SubItems[i].Text = "";
                }
            }
            if (item == _itemTotal)
            {
                foreach (ListViewItem i in item.ListView.Items)
                {
                    i.Checked = item.Checked;
                }
            }
            UpdateTotal();
        }
Exemplo n.º 26
0
 private void LoadMeetingDates()
 {
     comboBoxMeetingDates.DataSource
         = ServicesProvider.GetInstance().GetContractServices().FindInstallmentDatesForVillageActiveContracts(_village.Id);
 }
Exemplo n.º 27
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool isError = false;

            if (_CheckIfMoneyIsEnough())
            {
                if (!MessageBox.Show(MultiLanguageStrings.GetString(Ressource.VillageForm, "MoneyNotEnoughForAll.Text"), @"!",
                                     MessageBoxButtons.YesNo).Equals(DialogResult.Yes))
                {
                    return;
                }
            }

            if (_product.GracePeriod == null && !_CheckGracePeriod())
            {
                MessageBox.Show(MultiLanguageStrings.GetString(Ressource.VillageForm, "GracePeriodNotCorrect"),
                                MultiLanguageStrings.GetString(Ressource.VillageForm, "GracePeriod"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            foreach (ListViewItem item in lvMembers.Items)
            {
                if (item == _itemTotal)
                {
                    continue;
                }
                if (!item.Checked)
                {
                    continue;
                }
                if (_product.UseCompulsorySavings && item.SubItems[IdxCompulsorySavings].Tag == null)
                {
                    string text = string.Format(@"The loan of client '{0}' requires a compulsory savings account!", ((VillageMember)item.Tag).Tiers.Name);
                    MessageBox.Show(text, @"No compulsory savings", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                /*if (item.SubItems[IdxPaymentMethod].Tag != null &&
                 *  item.SubItems[IdxPaymentMethod].Tag.ToString() == OPaymentMethods.Savings.ToString())
                 * {
                 *  if (_product.UseCompulsorySavings && item.SubItems[IdxCompulsorySavings].Tag == null)
                 *  {
                 *      string text = string.Format(@"The loan of client '{0}' requires a compulsory savings account!", ((VillageMember)item.Tag).Tiers.Name);
                 *      MessageBox.Show(text, @"No compulsory savings", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 *      return;
                 *  }
                 * }*/
            }

            if (!_nsgForm.Save())
            {
                return;
            }

            Loan          loan = null;
            VillageMember member;

            try
            {
                foreach (ListViewItem item in lvMembers.Items)
                {
                    if (!item.Checked || item == _itemTotal)
                    {
                        continue;
                    }
                    member = item.Tag as VillageMember;
                    Project project;
                    if (null == member)
                    {
                        continue;
                    }

                    switch (member.Product.LoanType)
                    {
                    case OLoanTypes.All:
                        break;

                    case OLoanTypes.Flat:
                        member.Product.ScriptName = null;
                        break;

                    case OLoanTypes.DecliningFixedPrincipal:
                        member.Product.ScriptName = null;
                        break;

                    case OLoanTypes.DecliningFixedInstallments:
                        member.Product.ScriptName = null;
                        break;

                    case OLoanTypes.CustomLoanType:
                        break;

                    default:
                        break;
                    }

                    OCurrency amount       = (OCurrency)item.SubItems[IdxAmount].Tag;
                    decimal   interest     = (decimal)item.SubItems[IdxInterest].Tag;
                    int       gracePeriod  = (int)item.SubItems[IdxGracePeriod].Tag;
                    int       installments = (int)item.SubItems[IdxInstallments].Tag;
                    DateTime  date         = Convert.ToDateTime(item.SubItems[IdxCreationDate].Tag);

                    //creation of loan
                    loan = new Loan(_product,
                                    amount,
                                    interest,
                                    installments,
                                    gracePeriod,
                                    date,
                                    _village.MeetingDay,
                                    User.CurrentUser,
                                    ServicesProvider.GetInstance().GetGeneralSettings(),
                                    ServicesProvider.GetInstance().GetNonWorkingDate(),
                                    CoreDomainProvider.GetInstance().GetProvisioningTable(),
                                    CoreDomainProvider.GetInstance().GetChartOfAccounts())
                    {
                        NonRepaymentPenalties =
                        {
                            InitialAmount    = _product.NonRepaymentPenalties.InitialAmount ?? 0,
                            OLB              = _product.NonRepaymentPenalties.OLB ?? 0,
                            OverDuePrincipal = _product.NonRepaymentPenalties.OverDuePrincipal ?? 0,
                            OverDueInterest  = _product.NonRepaymentPenalties.OverDueInterest ?? 0
                        },
                        InstallmentType = _product.InstallmentType,
                        AnticipatedTotalRepaymentPenalties = 0,
                        FundingLine           = item.SubItems[IdxFundingLine].Tag as FundingLine,
                        LoanOfficer           = (User)item.SubItems[IdxLoanOfficer].Tag,
                        Synchronize           = false,
                        ContractStatus        = OContractStatus.Pending,
                        CreditCommitteeCode   = string.Empty,
                        GracePeriod           = gracePeriod,
                        GracePeriodOfLateFees = _product.GracePeriodOfLateFees,
                        AmountMin             = member.Product.AmountMin,
                        AmountMax             = member.Product.AmountMax,
                        InterestRateMin       = member.Product.InterestRateMin,
                        InterestRateMax       = member.Product.InterestRateMax,
                        NmbOfInstallmentsMin  = member.Product.NbOfInstallmentsMin,
                        NmbOfInstallmentsMax  = member.Product.NbOfInstallmentsMax,
                        ScheduleType          = member.Product.LoanType,
                        ScriptName            = member.Product.ScriptName
                    };
                    loan.InstallmentList =
                        ServicesProvider.GetInstance().GetContractServices().SimulateScheduleCreation(loan);
                    loan.LoanEntryFeesList = new List <LoanEntryFee>();
                    foreach (EntryFee fee in loan.Product.EntryFees)
                    {
                        LoanEntryFee loanEntryFee = new LoanEntryFee();
                        loanEntryFee.ProductEntryFee   = fee;
                        loanEntryFee.ProductEntryFeeId = (int)fee.Id;
                        if (fee.Value.HasValue)
                        {
                            loanEntryFee.FeeValue = (decimal)fee.Value;
                        }
                        else
                        {
                            loanEntryFee.FeeValue = (decimal)fee.Min;
                        }
                        loan.LoanEntryFeesList.Add(loanEntryFee);
                    }

                    var client = member.Tiers;
                    if (0 == client.Projects.Count)
                    {
                        project           = new Project("Village");
                        project.Name      = "Village";
                        project.Code      = "Village";
                        project.Aim       = "Village";
                        project.BeginDate = date;
                        project.Id        = ServicesProvider.GetInstance().GetProjectServices().SaveProject(project, client);
                        member.Tiers.AddProject(project);
                    }
                    project = client.Projects[0];

                    // Compulsory savings
                    if (_product.UseCompulsorySavings)
                    {
                        loan.CompulsorySavings           = (SavingBookContract)item.SubItems[IdxCompulsorySavings].Tag;
                        loan.CompulsorySavingsPercentage = (int)item.SubItems[IdxCompulsoryPercentage].Tag;
                    }
                    var person = client as Person;
                    if (person == null)
                    {
                        throw new ApplicationException("Member can not be other than person.");
                    }
                    loan.EconomicActivity =
                        ServicesProvider.GetInstance()
                        .GetEconomicActivityServices()
                        .FindAllEconomicActivities(true)
                        .FirstOrDefault();

                    ServicesProvider.GetInstance().GetContractServices().CheckLoanFilling(loan);
                    loan.NsgID = _village.Id;
                    ServicesProvider.GetInstance().GetContractServices().SaveLoan(ref loan, project.Id, ref client);
                    project.AddCredit(loan, loan.ClientType);
                    if (!_village.Active)
                    {
                        _village.Active = true;
                        ServicesProvider.GetInstance().GetContractServices().UpdateVillageStatus(_village);
                    }
                    loan.Closed   = false;
                    client.Active = true;
                    client.Status = OClientStatus.Active;
                    member.ActiveLoans.Add(loan);
                }
            }
            catch (Exception ex)
            {
                isError             = true;
                loan.ContractStatus = OContractStatus.Pending;
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }

            if (!isError)
            {
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Exemplo n.º 28
0
 private void InitializeCoreMenu()
 {
     mainMenu.Items["mnuAccounting"].Visible = !ServicesProvider.GetInstance().GetGeneralSettings().UseExternalAccounting;
 }
Exemplo n.º 29
0
        private void SavePerson()
        {
            _personSaved = false;
            RecoverDatasFromUserControlsAddress();

            _tempPerson.Branch    = (Branch)cbBranch.SelectedItem;
            _tempPerson.CreatedBy = User.CurrentUser;

            try
            {
                bool save = 0 == _tempPerson.Id;
                if (_tempPerson.FirstName != null)
                {
                    _tempPerson.FirstName = _tempPerson.FirstName.Trim();
                }
                if (_tempPerson.LastName != null)
                {
                    _tempPerson.LastName = _tempPerson.LastName.Trim();
                }
                if (_tempPerson.FatherName != null)
                {
                    _tempPerson.FatherName = _tempPerson.FatherName.Trim();
                }
                if (_tempPerson.IdentificationData != null)
                {
                    _tempPerson.IdentificationData = _tempPerson.IdentificationData.Trim();
                }
                _tempPerson.Nationality = textBoxNationality.Text;

                string result = ServicesProvider
                                .GetInstance()
                                .GetClientServices()
                                .SavePerson(ref _tempPerson, (tx, id) =>
                {
                    foreach (var extension in Extensions)
                    {
                        extension.Save(_tempPerson, tx);
                    }
                });

                EventProcessorServices es = ServicesProvider.GetInstance().GetEventProcessorServices();
                es.LogClientSaveUpdateEvent(_tempPerson, save);

                if (result != string.Empty)
                {
                    MessageBox.Show(result, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                _personSaved    = true;
                buttonSave.Text = MultiLanguageStrings.GetString(Ressource.PersonUserControl, "Update");

                textBoxFirstName.Text = string.Format(_tempPerson.FirstName);
                textBoxLastname.Text  = string.Format(_tempPerson.LastName);
                if (_tempPerson.FatherName != null)
                {
                    textBoxFatherName.Text = string.Format(_tempPerson.FatherName);
                }
                textBoxIdentificationData.Text = string.Format(_tempPerson.IdentificationData);
                ResetImagesFlags();
            }
            catch (OpenCBS.ExceptionsHandler.Exceptions.CustomFieldsExceptions.CustomFieldsAreNotFilledCorrectlyException)
            {
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
Exemplo n.º 30
0
 public void Init()
 {
     ServicesProvider.GetInstance().GetApplicationSettingsServices().CheckApplicationSettings();
 }