예제 #1
0
        private void InitializeExternalCurrency()
        {
            lblPivotCurrency.Visible     = false;
            lblFeesCurrencyPivot.Visible = false;
            if (!_loan.Product.Currency.IsPivot && _exchangeRate != null)
            {
                lblPivotCurrency.Visible     = true;
                lblFeesCurrencyPivot.Visible = true;
                OCurrency amount =
                    ServicesProvider.GetInstance().GetAccountingServices().ConvertAmountToExternalCurrency(
                        _loan.Amount, _exchangeRate);
                lblPivotCurrency.Text = amount.GetFormatedValue(_loan.UseCents);


                decimal value;
                decimal.TryParse(tbEntryFee.Text, out value);

                lblFeesCurrencyPivot.Text = _disableFees
                                                ? "0"
                                                : ServicesProvider.GetInstance().GetAccountingServices().
                                            ConvertAmountToExternalCurrency(
                    value,
                    _exchangeRate).
                                            GetFormatedValue(_loan.UseCents) + " ";
                string pivot = ServicesProvider.GetInstance().GetCurrencyServices().GetPivot().Code;
                lblPivotCurrency.Text     += pivot;
                lblFeesCurrencyPivot.Text += pivot;
            }
        }
예제 #2
0
        private void UpdateTotal()
        {
            OCurrency    total = 0m;
            ExchangeRate customExchangeRate;

            foreach (ListViewItem item in lvMembers.Items)
            {
                if (!item.Checked)
                {
                    continue;
                }
                if (item == _itemTotal)
                {
                    continue;
                }
                item.UseItemStyleForSubItems = false;

                customExchangeRate = ServicesProvider.GetInstance().GetAccountingServices().
                                     FindLatestExchangeRate(TimeProvider.Today, (Currency)item.SubItems[IdxCurrency].Tag);

                total += customExchangeRate.Rate == 0 ? 0 : (OCurrency)Convert.ToDecimal(item.SubItems[IdxAmount].Tag) / customExchangeRate.Rate;
            }
            _itemTotal.SubItems[IdxAmount].Text   = total.GetFormatedValue(ServicesProvider.GetInstance().GetCurrencyServices().GetPivot().UseCents);
            _itemTotal.SubItems[IdxCurrency].Text = ServicesProvider.GetInstance().GetCurrencyServices().GetPivot().Code;
        }
예제 #3
0
        void UpdateAmount()
        {
            OCurrency principalAmount = 0;
            OCurrency interestAmount  = 0;

            for (int i = 0; i <= _loan.InstallmentList.Count - 1; i++)
            {
                Installments.Add((Installment)(lvSchedule.Items[i].Tag));
                principalAmount += (lvSchedule.Items[i].Tag as Installment).CapitalRepayment;
                interestAmount  += (lvSchedule.Items[i].Tag as Installment).InterestsRepayment;
            }

            Color fg = principalAmount != _loan.Amount ? Color.Red : Color.Black;

            //update principal
            for (int i = 0; i <= _loan.InstallmentList.Count - 1; i++)
            {
                lvSchedule.Items[i].UseItemStyleForSubItems = false;
                lvSchedule.Items[i].SubItems[3].ForeColor   = fg;
            }

            btnOK.Enabled = principalAmount != _loan.Amount || !_isEditable ? false : true;

            //update OLB
            OCurrency olb = _loan.Amount;

            for (int i = 0; i <= _loan.InstallmentList.Count - 1; i++)
            {
                lvSchedule.Items[i].UseItemStyleForSubItems = false;
                lvSchedule.Items[i].SubItems[5].Text        = olb.GetFormatedValue(_loan.UseCents);
                olb -= ((Installment)(lvSchedule.Items[i].Tag)).CapitalRepayment;
                lvSchedule.Items[i].SubItems[5].ForeColor = Color.Black;
            }

            //update Interest
            if (chxAutomaticCalculation.Checked)
            {
                for (int i = 0; i <= _loan.InstallmentList.Count - 1; ++i)
                {
                    lvSchedule.Items[i].SubItems[2].Text = GetFormattedValue(Convert.ToDecimal(lvSchedule.Items[i].SubItems[5].Text) * (_loan.InterestRate));
                }
            }

            //update total amount
            for (int i = 0; i <= _loan.InstallmentList.Count - 1; i++)
            {
                lvSchedule.Items[i].UseItemStyleForSubItems = false;
                lvSchedule.Items[i].SubItems[4].Text        = (((Installment)(lvSchedule.Items[i].Tag)).CapitalRepayment + ((Installment)(lvSchedule.Items[i].Tag)).InterestsRepayment).GetFormatedValue(_loan.UseCents);
                lvSchedule.Items[i].SubItems[4].ForeColor   = Color.Black;
            }

            //update total amount
            int index = lvSchedule.Items.Count - 1;

            lvSchedule.Items[index].SubItems[3].Text      = principalAmount.GetFormatedValue(_loan.UseCents);
            lvSchedule.Items[index].SubItems[3].ForeColor = Color.Black;
            lvSchedule.Items[index].SubItems[2].Text      = interestAmount.GetFormatedValue(_loan.UseCents);
            lvSchedule.Items[index].SubItems[2].ForeColor = Color.Black;
        }
예제 #4
0
        public MembersOfGroup(List <Member> pMembers, Loan pLoan, DateTime pDate)
        {
            InitializeComponent();
            _loan        = pLoan;
            _paymentDate = pDate;
            OCurrency olb        = _loan.CalculateActualOlb();
            Member    leader     = null;
            int       roundTo    = _loan.UseCents ? 2 : 0;
            OCurrency loanAmount =
                _loan.Events.GetLoanRepaymentEvents().Where(
                    rpe => rpe.RepaymentType == OPaymentType.PersonTotalPayment && !rpe.Deleted).Aggregate(
                    _loan.Amount, (current, rpe) => current - rpe.Principal);

            foreach (Member person in pMembers)
            {
                OCurrency olbByPerson = 0;
                OCurrency actualOlb   = _loan.CalculateActualOlb();

                foreach (LoanShare loanShare in _loan.LoanShares)
                {
                    if (loanShare.PersonId == person.Tiers.Id && person.CurrentlyIn)
                    {
                        olbByPerson = actualOlb * loanShare.Amount / loanAmount;
                    }
                }
                olb -= Math.Round(olbByPerson.Value, roundTo);
                // Define the list items
                if (!person.IsLeader)
                {
                    Color        color = person.CurrentlyIn ? Color.Black : Color.Silver;
                    ListViewItem lvi   = new ListViewItem {
                        Tag = person, Text = ((Person)person.Tiers).Name
                    };
                    lvi.UseItemStyleForSubItems = false;
                    lvi.ForeColor = color;
                    lvi.SubItems.Add(olbByPerson.GetFormatedValue(_loan.UseCents));
                    listViewMembers.Items.Add(lvi);
                }
                else
                {
                    leader = person;
                    leader.LoanShareAmount = olbByPerson;
                }
            }

            if (leader != null)
            {
                leader.LoanShareAmount += olb;
                Color        color = leader.CurrentlyIn ? Color.Red : Color.Silver;
                ListViewItem lvi   = new ListViewItem {
                    Tag = leader, Text = ((Person)leader.Tiers).Name
                };
                lvi.UseItemStyleForSubItems = false;
                lvi.ForeColor = color;
                lvi.SubItems.Add(leader.LoanShareAmount.GetFormatedValue(_loan.UseCents));
                listViewMembers.Items.Add(lvi);
            }
        }
예제 #5
0
 private void checkBoxDesactivateFees_CheckedChanged(object sender, EventArgs e)
 {
     if (checkBoxDesactivateFees.Checked)
     {
         lbTotalAmountValue.Text  = _amount.GetFormatedValue(UseCents);
         udCloseFees.Value        = udCloseFees.Minimum;
         udCloseFees.Enabled      = false;
         labelCloseFeesValue.Text = "0";
     }
     else
     {
         lbTotalAmountValue.Text  = _amount.GetFormatedValue(UseCents);
         labelCloseFeesValue.Text = _closeFees.GetFormatedValue(UseCents);
         udCloseFees.Value        = udCloseFees.Minimum;
         udCloseFees.Enabled      = true;
     }
     udCloseFees_ValueChanged(sender, e);
 }
예제 #6
0
        private void UpdateTotal()
        {
            ExchangeRate customExchangeRate;
            OCurrency    principal        = 0m;
            OCurrency    interest         = 0m;
            OCurrency    penalty          = 0m;
            OCurrency    olb              = 0m;
            OCurrency    total            = 0m;
            OCurrency    totalDueInterest = 0m;

            foreach (ListViewItem item in lvContracts.Items)
            {
                if (!item.Checked)
                {
                    continue;
                }

                if (item == _itemTotal)
                {
                    continue;
                }

                customExchangeRate =
                    ServicesProvider.GetInstance().GetAccountingServices().FindLatestExchangeRate(
                        TimeProvider.Today, (Currency)item.SubItems[8].Tag);

                principal += customExchangeRate.Rate == 0
                                          ? 0
                                          : Convert.ToDecimal(item.SubItems[2].Text) / (decimal)customExchangeRate.Rate;
                interest += customExchangeRate.Rate == 0
                                          ? 0
                                          : Convert.ToDecimal(item.SubItems[3].Text) / (decimal)customExchangeRate.Rate;
                penalty += customExchangeRate.Rate == 0
                                          ? 0
                                          : Convert.ToDecimal(item.SubItems[4].Text) / (decimal)customExchangeRate.Rate;
                olb += customExchangeRate.Rate == 0
                                          ? 0
                                          : Convert.ToDecimal(item.SubItems[6].Text) / (decimal)customExchangeRate.Rate;
                totalDueInterest += customExchangeRate.Rate == 0
                                          ? 0
                                          : Convert.ToDecimal(item.SubItems[7].Text) / (decimal)customExchangeRate.Rate;
            }

            total += principal + interest + penalty;
            if (_itemTotal != null)
            {
                bool useCents = ServicesProvider.GetInstance().GetCurrencyServices().GetPivot().UseCents;
                _itemTotal.SubItems[2].Text = principal.GetFormatedValue(useCents);
                _itemTotal.SubItems[3].Text = interest.GetFormatedValue(useCents);
                _itemTotal.SubItems[4].Text = penalty.GetFormatedValue(useCents);
                _itemTotal.SubItems[5].Text = total.GetFormatedValue(useCents);
                _itemTotal.SubItems[6].Text = olb.GetFormatedValue(useCents);
                _itemTotal.SubItems[7].Text = totalDueInterest.GetFormatedValue(useCents);
                _itemTotal.SubItems[8].Text = ServicesProvider.GetInstance().GetCurrencyServices().GetPivot().Code;
            }
        }
예제 #7
0
        private void udCloseFees_ValueChanged(object sender, EventArgs e)
        {
            if (checkBoxDesactivateFees.Checked)
            {
                return;
            }
            OCurrency fees = udCloseFees.Value;

            labelCloseFeesValue.Text = fees.GetFormatedValue(UseCents);
            lbTotalAmountValue.Text  = (_amount - fees).GetFormatedValue(UseCents);
        }
예제 #8
0
        private string GetFormatted(decimal value, Currency currency)
        {
            if (!IsFlat)
            {
                return(string.Format("{0:.00} %", value));
            }
            OCurrency t   = value;
            string    fmt = t.GetFormatedValue(currency.UseCents);

            return(string.Format("{0} {1}", fmt, currency.Code));
        }
예제 #9
0
 //to add a function to convert OCurrency to string
 public static string ConvertDecimalToString(OCurrency number)
 {
     try
     {
         return(number.GetFormatedValue(true));
     }
     catch
     {
         return(String.Empty);
     }
 }
예제 #10
0
        public CloseSavingsForm(OCurrency pBalance)
        {
            InitializeComponent();

            lbTotalAmountValue.Text = pBalance.GetFormatedValue(UseCents);
            gbCloseFees.Enabled     = false;
            _amount    = pBalance;
            _closeFees = 0;

            Initialize();
        }
예제 #11
0
        private void UpdateEvents(IEnumerable <TellerSavingEvent> events)
        {
            if (InvokeRequired)
            {
                Invoke(new UpdateListViewDelegate(UpdateEvents), new object[] { events });
                return;
            }

            totalItem = new ListViewItem("Total: ");
            lvTellerEvent.Items.Clear();

            OCurrency totalBalance    = 0;
            OCurrency totalFeeBalance = 0;

            foreach (TellerSavingEvent ev in events)
            {
                ListViewItem item = new ListViewItem(ev.Date.ToString("dd/MM/yyyy HH:mm:ss"));
                item.SubItems.Add(ev.Fee.GetFormatedValue(true));
                string amt = ev.Amount.GetFormatedValue(true);
                item.SubItems.Add(amt);
                item.SubItems.Add(ev.Code);
                item.SubItems.Add(ev.Account);
                item.SubItems.Add(ev.ReferenceNumber);
                item.SubItems.Add(ev.Description);
                item.SubItems.Add(ev.CancelDate.HasValue ? ev.CancelDate.Value.ToString("dd/MM/yyyy HH:mm:ss") : string.Empty);

                if (ev.IsPending)
                {
                    item.BackColor = Color.Orange;
                    item.ForeColor = Color.White;
                }

                if (ev.Deleted)
                {
                    item.BackColor = Color.FromArgb(188, 209, 199);
                    item.ForeColor = Color.White;
                }

                totalBalance    += ev.GetAmountForBalance();
                totalFeeBalance += ev.Fee;
                item.Tag         = ev;
                lvTellerEvent.Items.Add(item);
            }

            totalItem.SubItems.Add(totalFeeBalance.GetFormatedValue(true));
            totalItem.Font = new Font(totalItem.Font, FontStyle.Bold);
            //totalItem.SubItems.Add("");
            //totalItem.SubItems.Add("");
            totalItem.SubItems.Add(totalBalance.GetFormatedValue(true));
            lvTellerEvent.Items.Add(totalItem);

            UpdateTitle();
        }
예제 #12
0
        private void udEntryFees_ValueChanged(object sender, EventArgs e)
        {
            OCurrency fees          = udEntryFees.Value;
            OCurrency initialAmount = nudInitialAmount.Value;

            lbEntryFeesValue.Text = fees.GetFormatedValue(UseCents) + " " + _savingsProduct.Currency.Code;

            OCurrency total = initialAmount + udEntryFees.Value;

            lbTotalAmountValue.Text = string.Format("{0} {1}",
                                                    total.GetFormatedValue(UseCents),
                                                    _savingsProduct.Currency.Code);
        }
예제 #13
0
        public string GetFmtBalance(DateTime date, bool showCurrency)
        {
            OCurrency balance    = GetBalance(date);
            bool      useCents   = Product.Currency.UseCents;
            string    fmtBalance = balance.GetFormatedValue(useCents);

            if (!showCurrency)
            {
                return(fmtBalance);
            }

            string currency = Product.Currency.Code;

            return(string.Format("{0} {1}", fmtBalance, currency));
        }
예제 #14
0
        public CloseSavingsForm(ISavingProduct savingBookProduct, OCurrency pBalance, OCurrency pCloseFees)
        {
            InitializeComponent();

            _amount    = pBalance;
            _closeFees = pCloseFees;

            if (savingBookProduct is SavingsBookProduct)
            {
                _savingsBookProduct = (SavingsBookProduct)savingBookProduct;
            }
            lbTotalAmountValue.Text = pBalance.GetFormatedValue(UseCents);
            gbCloseFees.Enabled     = (_closeFees.Value > 0);

            Initialize();
        }
예제 #15
0
        private void _UpdateSum()
        {
            OCurrency sum = 0;

            for (int i = 0; i < lvLoanShares.Items.Count - 1; i++)
            {
                OCurrency share = (OCurrency)lvLoanShares.Items[i].SubItems[1].Tag;
                sum += share;
            }
            int   index = lvLoanShares.Items.Count - 1;
            Color fg    = sum == _loan.Amount ? Color.Black : Color.Red;

            lvLoanShares.Items[index].SubItems[1].Text      = sum.GetFormatedValue(_loan.UseCents);
            lvLoanShares.Items[index].SubItems[1].ForeColor = fg;
            btnOK.Enabled = !IsReadOnly && sum == _loan.Amount;
        }
예제 #16
0
        private void LoadSavings()
        {
            foreach (var member in _village.Members)
            {
                //List<ISavingsContract> savings = member.Tiers.Savings.Where(item => item.Status != OSavingsStatus.Closed).ToList();
                List <ISavingsContract> savings = ServicesProvider.GetInstance().GetSavingServices().GetSavingsByClientId(member.Tiers.Id);

                if (savings.Count > 0)
                {
                    _hasMember = true;
                    ListViewGroup group = new ListViewGroup(member.Tiers.Name);
                    group.Tag = member.Tiers;
                    lvContracts.Groups.Add(group);

                    foreach (var saving in savings.Where(item => item.Status != OSavingsStatus.Closed))
                    {
                        ListViewItem item = new ListViewItem(saving.Code)
                        {
                            Tag = saving
                        };
                        item.SubItems.Add(MultiLanguageStrings.GetString(Ressource.ClientForm,
                                                                         saving is SavingBookContract ? "SavingsBook.Text" : "CompulsorySavings.Text"));
                        item.SubItems.Add(saving.GetFmtBalance(false));
                        item.SubItems.Add("");
                        item.SubItems.Add("");
                        item.Group = group;
                        lvContracts.Items.Add(item);
                    }
                }
            }
            if (_hasMember)
            {
                OCurrency     zero       = 0m;
                ListViewGroup totalgroup = new ListViewGroup(GetString("total"));
                totalgroup.Tag = "Total";
                lvContracts.Groups.Add(totalgroup);
                _itemTotal.SubItems.Add("");
                _itemTotal.SubItems.Add("");
                _itemTotal.SubItems.Add(zero.GetFormatedValue(false));
                _itemTotal.SubItems.Add("");
                _itemTotal.Group = totalgroup;
                lvContracts.Items.Add(_itemTotal);
            }
        }
예제 #17
0
        private void InitAlerts()
        {
            colAlerts_Status.AspectToStringConverter = delegate(object value)
            {
                OContractStatus status = (OContractStatus)value;
                string          key    = string.Format("Status{0}", status);
                return(GetString(key));
            };

            colAlerts_Date.AspectToStringConverter = delegate(object value)
            {
                DateTime date = (DateTime)value;
                return(date.ToShortDateString());
            };

            colAlerts_Amount.AspectToStringConverter = delegate(object value)
            {
                OCurrency amount = (OCurrency)value;
                return(amount.GetFormatedValue(true));
            };

            colAlerts_ContractCode.ImageGetter = delegate(object value)
            {
                Alert_v2 alert = (Alert_v2)value;
                return(alert.ImageIndex);
            };

            byte[] state = UserSettings.GetAlertState();
            if (state != null)
            {
                olvAlerts.RestoreState(state);
            }

            _triggerAlertsUpdate        = false;
            chkLateLoans.Checked        = UserSettings.GetShowLateLoans();
            chkPendingLoans.Checked     = UserSettings.GetShowPendingLoans();
            chkPendingSavings.Checked   = UserSettings.GetShowPendingSavings();
            chkOverdraftSavings.Checked = UserSettings.GetShowOverdraftSavings();
            chkValidatedLoan.Checked    = UserSettings.GetValidatedLoans();
            chkPostponedLoans.Checked   = UserSettings.GetPostponedLoans();
            _triggerAlertsUpdate        = true;
        }
예제 #18
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;
                }
            }
        }
예제 #19
0
        private void comboBoxSavingsMethod_SelectedIndexChanged(object sender, EventArgs e)
        {
            cbxPending.Visible = (_pendingSavingsMode.Contains(cbSavingsMethod.SelectedItem.ToString().ToUpper()));

            switch (_bookingDirection)
            {
            case OSavingsOperation.Credit:
                switch (((PaymentMethod)cbSavingsMethod.SelectedItem).Name.ToString())
                {
                case "Cheque":
                    if (((SavingsBookProduct)_saving.Product).ChequeDepositFeesMin.HasValue)
                    {
                        _feesMin  = ((SavingsBookProduct)_saving.Product).ChequeDepositFeesMin;
                        _feesMax  = ((SavingsBookProduct)_saving.Product).ChequeDepositFeesMax;
                        _flatFees = _feesMin;
                    }
                    else
                    {
                        _flatFees = ((SavingBookContract)_saving).ChequeDepositFees.Value;
                        _feesMin  = _feesMax = _flatFees;
                    }

                    updAmountFees.Minimum = _feesMin.Value;
                    updAmountFees.Maximum = _feesMax.Value;
                    updAmountFees.Text    = ((SavingBookContract)_saving).ChequeDepositFees.GetFormatedValue(_saving.Product.Currency.UseCents);

                    nudAmount_ValueChanged(nudAmount, e);

                    lbAmountMinMax.Text = string.Format("{0} {1} {4}\n\r{2} {3} {4}",
                                                        "min", _chequeAmountMin.GetFormatedValue(_saving.Product.Currency.UseCents),
                                                        "max", _chequeAmountMax.GetFormatedValue(_saving.Product.Currency.UseCents),
                                                        _saving.Product.Currency.Code);

                    lblAmountFeesMinMax.Text = string.Format("{0} {1} {4}\n\r{2} {3} {4}",
                                                             "min", _feesMin.GetFormatedValue(_saving.Product.Currency.UseCents),
                                                             "max", _feesMax.GetFormatedValue(_saving.Product.Currency.UseCents),
                                                             _saving.Product.Currency.Code);

                    break;

                default:
                    if (_saving is SavingBookContract)
                    {
                        if (((SavingsBookProduct)_saving.Product).DepositFeesMin.HasValue)
                        {
                            _feesMin  = ((SavingsBookProduct)_saving.Product).DepositFeesMin;
                            _feesMax  = ((SavingsBookProduct)_saving.Product).DepositFeesMax;
                            _flatFees = _feesMin;
                        }
                        else
                        {
                            _flatFees = ((SavingBookContract)_saving).DepositFees.Value;
                            _feesMin  = _feesMax = _flatFees;
                        }

                        updAmountFees.Minimum = _feesMin.Value;
                        updAmountFees.Maximum = _feesMax.Value;
                        updAmountFees.Text    = ((SavingBookContract)_saving).DepositFees.GetFormatedValue(_saving.Product.Currency.UseCents);
                    }

                    nudAmount_ValueChanged(nudAmount, e);

                    lbAmountMinMax.Text = string.Format("{0} {1} {4}\n\r{2} {3} {4}",
                                                        "min", _amountMin.GetFormatedValue(_saving.Product.Currency.UseCents),
                                                        "max", _amountMax.GetFormatedValue(_saving.Product.Currency.UseCents),
                                                        _saving.Product.Currency.Code);

                    lblAmountFeesMinMax.Text = string.Format("{0} {1} {4}\n\r{2} {3} {4}",
                                                             "min", _feesMin.GetFormatedValue(_saving.Product.Currency.UseCents),
                                                             "max", _feesMax.GetFormatedValue(_saving.Product.Currency.UseCents),
                                                             _saving.Product.Currency.Code);

                    break;
                }
                break;

            default: break;
            }
        }
예제 #20
0
        private void Initialize()
        {
            lblSavingCurrency.Text      = _saving.Product.Currency.Code;
            lblTotalSavingCurrency.Text = _saving.Product.Currency.Code;
            lblSavingCurrencyFees.Text  = _saving.Product.Currency.Code;

            nudTotalAmount.Minimum = 0;
            nudTotalAmount.Maximum = decimal.MaxValue;

            nudAmount.Minimum = _amountMin.Value;
            nudAmount.Maximum = _amountMax.Value;

            lbAmountMinMax.Text = string.Format("{0} {1} {4}\n\r{2} {3} {4}",
                                                "min", _amountMin.GetFormatedValue(_saving.Product.Currency.UseCents),
                                                "max", _amountMax.GetFormatedValue(_saving.Product.Currency.UseCents),
                                                _saving.Product.Currency.Code);

            lblAmountFeesMinMax.Text = string.Format("{0} {1} {4}\n\r{2} {3} {4}",
                                                     "min", _feesMin.GetFormatedValue(_saving.Product.Currency.UseCents),
                                                     "max", _feesMax.GetFormatedValue(_saving.Product.Currency.UseCents),
                                                     _saving.Product.Currency.Code);

            switch (_bookingDirection)
            {
            case OSavingsOperation.Credit:
            {
                Text                       = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "Deposit.Text");
                Name                       = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "Deposit.Text");
                btnSave.Text               = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "Deposit.Text");
                tbxSavingCode.Text         = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "Deposit.Text");
                plTransfer.Visible         = false;
                pnlSavingPending.Visible   = true;
                rbxDebit.Visible           = false;
                rbxCredit.Visible          = false;
                cbBookings.Visible         = false;
                _chequeNumberLabel.Visible = _chequeNumberTextBox.Visible = true;
                break;
            }

            case OSavingsOperation.Debit:
            {
                Text                     = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "Withdrawal.Text");
                Name                     = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "Withdrawal.Text");
                btnSave.Text             = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "Withdrawal.Text");
                tbxSavingCode.Text       = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "Withdrawal.Text");
                plTransfer.Visible       = false;
                pnlSavingPending.Visible = true;
                //cbSavingsMethod.Visible = true;
                rbxDebit.Visible           = false;
                rbxCredit.Visible          = false;
                cbBookings.Visible         = false;
                lblPaymentMethod.Visible   = true;
                _chequeNumberLabel.Visible = _chequeNumberTextBox.Visible = true;
                break;
            }

            case OSavingsOperation.Transfer:
            {
                Text                       = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "Transfer.Text");
                Name                       = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "Transfer.Text");
                btnSave.Text               = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "Transfer.Text");
                tbxSavingCode.Text         = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "Transfer.Text");
                plTransfer.Visible         = true;
                tbTargetAccount.Visible    = true;
                btnSearchContract.Visible  = true;
                pnlSavingPending.Visible   = false;
                lbTargetSavings.Visible    = true;
                lblClientName.Visible      = true;
                rbxDebit.Visible           = false;
                rbxCredit.Visible          = false;
                cbBookings.Visible         = false;
                cbSavingsMethod.Visible    = false;
                _chequeNumberLabel.Visible = _chequeNumberTextBox.Visible = false;
                break;
            }

            case OSavingsOperation.SpecialOperation:
            {
                Text                                = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "SpecialOperation.Text");
                Name                                = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "SpecialOperation.Text");
                btnSave.Text                        = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "ComfirmOperation.Text");
                tbxSavingCode.Text                  = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "SpecialOperation.Text");
                lblPaymentMethod.Text               = MultiLanguageStrings.GetString(Ressource.FrmAddSavingEvent, "StandardBooking.Text");
                plTransfer.Visible                  = true;
                pnlSavingPending.Visible            = true;
                cbxPending.Visible                  = false;
                cbSavingsMethod.Visible             = false;
                lblAmountFeesMinMax.Visible         = false;
                lbAmountMinMax.Visible              = false;
                rbxDebit.Visible                    = true;
                rbxCredit.Visible                   = true;
                btnSearchContract.Visible           = false;
                tbTargetAccount.Visible             = false;
                lblClientName.Visible               = false;
                updAmountFees.Visible               = false;
                lblSavingCurrencyFees.Visible       = false;
                lblFees.Visible                     = false;
                lblTotalAmount.Visible              = false;
                nudTotalAmount.Visible              = false;
                lblTotalSavingCurrency.Visible      = false;
                lbAmountMinMaxCurrencyPivot.Visible = false;
                _chequeNumberLabel.Visible          = _chequeNumberTextBox.Visible = false;

                cbBookings.Items.Clear();
                foreach (Booking booking in ServicesProvider.GetInstance().GetStandardBookingServices().SelectAllStandardBookings())
                {
                    cbBookings.Items.Add(booking);
                }
                cbBookings.Visible = true;

                _feesMin  = 0;
                _feesMax  = 0;
                _rateFees = 0;

                break;
            }
            }

            dtpDate.Value = TimeProvider.Now;

            _pendingSavingsMode = ServicesProvider.GetInstance().GetGeneralSettings().PendingSavingsMode.ToUpper();
            var paymentMethods =
                ServicesProvider.GetInstance().GetPaymentMethodServices().GetAllPaymentMethods();

            foreach (var method in paymentMethods)
            {
                cbSavingsMethod.Items.Add(method);
            }
            cbSavingsMethod.SelectedItem = paymentMethods[0];
            //cbSavingsMethod.DataBind(typeof(OPaymentMethods), Ressource.SavingsOperationForm, false);
            // cbSavingsMethod.DataBind(typeof(OSavingsMethods), Ressource.FrmAddSavingEvent, false);

            switch (_bookingDirection)
            {
            case OSavingsOperation.Credit:
            {
                //switch (cbSavingsMethod.SelectedValue.ToString())
                //{
                //    case "Cheque":
                //        _flatFees = ((SavingBookContract)_saving).ChequeDepositFees;
                //        break;
                //    default:
                _flatFees = ((SavingBookContract)_saving).DepositFees;
                //  break;
                //}
                break;
            }

            case OSavingsOperation.Debit:
            {
                if (((SavingBookContract)_saving).FlatWithdrawFees.HasValue)
                {
                    _flatFees = ((SavingBookContract)_saving).FlatWithdrawFees;
                }
                else
                {
                    _rateFees = ((SavingBookContract)_saving).RateWithdrawFees;
                }
                break;
            }

            case OSavingsOperation.Transfer:
            {
                if (((SavingBookContract)_saving).FlatTransferFees.HasValue)
                {
                    _flatFees = ((SavingBookContract)_saving).FlatTransferFees;
                }
                else
                {
                    _rateFees = ((SavingBookContract)_saving).RateTransferFees;
                }
                break;
            }
            }

            updAmountFees.Minimum = _feesMin.Value;
            updAmountFees.Maximum = _feesMax.Value;

            decimal value = _flatFees.HasValue ? _flatFees.Value : ((decimal)(_rateFees)) * 100;

            updAmountFees.Value = value <updAmountFees.Minimum || value> updAmountFees.Maximum
                                      ? updAmountFees.Minimum
                                      : value;
        }
예제 #21
0
        private void IntializeTreeViewChartOfAccounts()
        {
            //Retrive data accounts and balances
            if (cbBranches.SelectedItem != null && cbCurrencies.SelectedItem != null)
            {
                List <Account> accounts = ServicesProvider.GetInstance().GetChartOfAccountsServices().FindAllAccounts();

                foreach (Account account in accounts)
                {
                    account.Balance =
                        ServicesProvider.GetInstance().GetAccountingServices().GetAccountBalance(account.Id,
                                                                                                 ((Currency)
                                                                                                  cbCurrencies.
                                                                                                  SelectedItem).Id,
                                                                                                 _contractId, _mode, 1,
                                                                                                 ((Branch)
                                                                                                  cbBranches.
                                                                                                  SelectedItem).
                                                                                                 Id);

                    account.CurrencyCode = ((Currency)cbCurrencies.SelectedItem).Code;
                }

                List <AccountCategory> accountCategories =
                    ServicesProvider.GetInstance().GetChartOfAccountsServices().SelectAccountCategories();
                /////////////////////////////////////////////////////////////////////////////////////////

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

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

                tlvBalances.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));
                };

                tlvBalances.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, FontStyle.Bold);
                    }
                };

                TreeListView.TreeRenderer renderer = tlvBalances.TreeColumnRenderer;
                renderer.LinePen           = new Pen(Color.Gray, 0.5f);
                renderer.LinePen.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,
                        Balance =
                            ServicesProvider.GetInstance().GetAccountingServices().
                            GetAccountCategoryBalance(accountCategory.Id,
                                                      ((Currency)cbCurrencies.SelectedItem).Id,
                                                      _contractId, _mode),
                        AccountCategory = (OAccountCategories)accountCategory.Id,
                        CurrencyCode    = ((Currency)cbCurrencies.SelectedItem).Code,
                        Id = -1
                    };

                    list.Add(account);
                }

                olvColumnLACBalance.AspectToStringConverter = delegate(object value)
                {
                    if (value.ToString().Length > 0)
                    {
                        OCurrency amount = (OCurrency)value;
                        return(amount.GetFormatedValue(true));
                    }
                    return(null);
                };

                tlvBalances.Roots = list;
                tlvBalances.ExpandAll();
            }
        }
예제 #22
0
        private void IntializeTreeViewChartOfAccounts(List <Booking> bookings)
        {
            Currency       currency = ServicesProvider.GetInstance().GetCurrencyServices().GetPivot();
            List <Account> accounts =
                ServicesProvider.GetInstance().GetAccountingServices().GetTrialBalance(TimeProvider.Now,
                                                                                       TimeProvider.Now, currency.Id, currency.Id);

            if (accounts != null)
            {
                foreach (Account account in accounts)
                {
                    OCurrency debit =
                        bookings.Sum(item => item.DebitAccount.Number == account.Number ? item.Amount.Value : 0);
                    OCurrency credit =
                        bookings.Sum(item => item.CreditAccount.Number == account.Number ? item.Amount.Value : 0);
                    account.CloseBalance = account.DebitPlus
                                               ? account.OpenBalance + debit - credit
                                               : account.OpenBalance + credit - debit;
                    account.CurrencyCode = currency.Code;
                }

                List <AccountCategory> accountCategories =
                    ServicesProvider.GetInstance().GetChartOfAccountsServices().SelectAccountCategories();
                /////////////////////////////////////////////////////////////////////////////////////////

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

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

                tlvBalances.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));
                };

                tlvBalances.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, FontStyle.Bold);
                    }
                };

                TreeListView.TreeRenderer renderer = tlvBalances.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,
                        Balance         = 0,
                        AccountCategory = (OAccountCategories)accountCategory.Id,
                        CurrencyCode    = "",
                        Id = -1
                    };

                    list.Add(account);
                }

                olvColumn_CloseBalance.AspectToStringConverter = delegate(object value)
                {
                    if (value.ToString().Length > 0)
                    {
                        OCurrency amount = (OCurrency)value;
                        return(amount.GetFormatedValue(true));
                    }
                    return(null);
                };
                olvColumnLACBalance.AspectToStringConverter = delegate(object value)
                {
                    if (value.ToString().Length > 0)
                    {
                        OCurrency amount = (OCurrency)value;
                        return(amount.GetFormatedValue(true));
                    }
                    return(null);
                };

                tlvBalances.Roots = list;
                tlvBalances.ExpandAll();
            }
        }
예제 #23
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;
                    }
                    if (loan.NsgID != _village.Id)
                    {
                        continue;
                    }

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

                    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);
        }
예제 #24
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>();

                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();
        }
예제 #25
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;
            }
        }
예제 #26
0
        private void InitializeControls()
        {
            udInitialAmount.Minimum = _product.InitialAmountMin.Value;
            udInitialAmount.Maximum = _product.InitialAmountMax.Value;

            if (!_product.InterestRate.HasValue)
            {
                _defaultInterestRate   = _product.InterestRateMin.Value * 100;
                udInterestRate.Minimum = (decimal)_product.InterestRateMin * 100;
                udInterestRate.Maximum = (decimal)_product.InterestRateMax * 100;
            }
            else
            {
                _defaultInterestRate = _product.InterestRate.Value * 100;
            }

            if (!_product.EntryFees.HasValue)
            {
                _defaultEntryFees   = _product.EntryFeesMin;
                udEntryFees.Minimum = _product.EntryFeesMin.Value;
                udEntryFees.Maximum = _product.EntryFeesMax.Value;
            }
            else
            {
                _defaultEntryFees = _product.EntryFees;
            }

            if (_product is SavingsBookProduct)
            {
                SavingsBookProduct sbp = (SavingsBookProduct)_product;
                lvMembers.Columns.Remove(chLoan);
                if (sbp.WithdrawFeesType == OSavingsFeesType.Flat)
                {
                    if (!sbp.FlatWithdrawFees.HasValue)
                    {
                        _defaultWithdrawFees   = sbp.FlatWithdrawFeesMin.Value;
                        udWithdrawFees.Minimum = sbp.FlatWithdrawFeesMin.Value;
                        udWithdrawFees.Maximum = sbp.FlatWithdrawFeesMax.Value;
                    }
                    else
                    {
                        _defaultWithdrawFees = sbp.FlatWithdrawFees.Value;
                    }
                }
                else
                {
                    if (!sbp.RateWithdrawFees.HasValue)
                    {
                        _defaultWithdrawFees   = (decimal)sbp.RateWithdrawFeesMin.Value * 100;
                        udWithdrawFees.Minimum = (decimal)sbp.RateWithdrawFeesMin.Value * 100;
                        udWithdrawFees.Maximum = (decimal)sbp.RateWithdrawFeesMax.Value * 100;
                    }
                    else
                    {
                        _defaultWithdrawFees = (decimal)sbp.RateWithdrawFees.Value * 100;
                    }
                }

                if (sbp.TransferFeesType == OSavingsFeesType.Flat)
                {
                    if (!sbp.FlatTransferFees.HasValue)
                    {
                        _defaultTransferFees   = sbp.FlatTransferFeesMin.Value;
                        udTransferFees.Minimum = sbp.FlatTransferFeesMin.Value;
                        udTransferFees.Maximum = sbp.FlatTransferFeesMax.Value;
                    }
                    else
                    {
                        _defaultTransferFees = sbp.FlatTransferFees.Value;
                    }
                }
                else
                {
                    if (!sbp.RateTransferFees.HasValue)
                    {
                        _defaultTransferFees   = (decimal)sbp.RateTransferFeesMin.Value * 100;
                        udTransferFees.Minimum = (decimal)sbp.RateTransferFeesMin.Value * 100;
                        udTransferFees.Maximum = (decimal)sbp.RateTransferFeesMax.Value * 100;
                    }
                    else
                    {
                        _defaultTransferFees = (decimal)sbp.RateTransferFees.Value * 100;
                    }
                }

                if (sbp.InterBranchTransferFee.IsRange)
                {
                    _defaultIbtFees      = sbp.InterBranchTransferFee.Min.Value;
                    nudIbtFees.Minimum   = sbp.InterBranchTransferFee.Min.Value;
                    nudIbtFees.Maximum   = sbp.InterBranchTransferFee.Max.Value;
                    nudIbtFees.Increment = sbp.InterBranchTransferFee.IsFlat ? 1 : 0.01m;
                }
                else
                {
                    _defaultIbtFees    = sbp.InterBranchTransferFee.Value.Value;
                    nudIbtFees.Minimum = _defaultIbtFees;
                    nudIbtFees.Maximum = _defaultIbtFees;
                }

                // Deposit fees
                if (!sbp.DepositFees.HasValue)
                {
                    _defaultDepositFees   = sbp.DepositFeesMin.Value;
                    udDepositFees.Minimum = sbp.DepositFeesMin.Value;
                    udDepositFees.Maximum = sbp.DepositFeesMax.Value;
                }
                else
                {
                    _defaultDepositFees = sbp.DepositFees.Value;
                }

                // Cheque deposit fees
                if (!sbp.ChequeDepositFees.HasValue)
                {
                    _defaultChequeDepositFees   = sbp.ChequeDepositFeesMin.Value;
                    udChequeDepositFees.Minimum = sbp.ChequeDepositFeesMin.Value;
                    udChequeDepositFees.Maximum = sbp.ChequeDepositFeesMax.Value;
                }
                else
                {
                    _defaultChequeDepositFees = sbp.ChequeDepositFees.Value;
                }

                // Close fees
                if (!sbp.CloseFees.HasValue)
                {
                    _defaultCloseFees   = sbp.CloseFeesMin.Value;
                    udCloseFees.Minimum = sbp.CloseFeesMin.Value;
                    udCloseFees.Maximum = sbp.CloseFeesMax.Value;
                }
                else
                {
                    _defaultCloseFees = sbp.CloseFees.Value;
                }

                // Management
                if (!sbp.ManagementFees.HasValue)
                {
                    _defaultManagementFees   = sbp.ManagementFeesMin.Value;
                    udManagementFees.Minimum = sbp.ManagementFeesMin.Value;
                    udManagementFees.Maximum = sbp.ManagementFeesMax.Value;
                }
                else
                {
                    _defaultManagementFees = sbp.ManagementFees.Value;
                }

                // Overdraft
                if (!sbp.OverdraftFees.HasValue)
                {
                    _defaultOverdraftFees   = sbp.OverdraftFeesMin.Value;
                    udOverdraftFees.Minimum = sbp.OverdraftFeesMin.Value;
                    udOverdraftFees.Maximum = sbp.OverdraftFeesMax.Value;
                }
                else
                {
                    _defaultOverdraftFees = sbp.OverdraftFees.Value;
                }

                // Agio
                if (!sbp.AgioFees.HasValue)
                {
                    _defaultAgioFees   = (decimal)sbp.AgioFeesMin.Value * 100;
                    udAgioFees.Minimum = (decimal)sbp.AgioFeesMin.Value * 100;
                    udAgioFees.Maximum = (decimal)sbp.AgioFeesMax.Value * 100;
                }
                else
                {
                    _defaultAgioFees = (decimal)sbp.AgioFees.Value * 100;
                }

                // Reopen
                if (!sbp.ReopenFees.HasValue)
                {
                    _defaultReopenFees   = sbp.ReopenFeesMin.Value;
                    udReopenFees.Minimum = sbp.ReopenFeesMin.Value;
                    udReopenFees.Maximum = sbp.ReopenFeesMax.Value;
                }
                else
                {
                    _defaultReopenFees = sbp.ReopenFees.Value;
                }
            }

            lvMembers.Items.Clear();
            Color dfc = Color.Gray;
            Color fc  = Color.Black;
            Color bc  = Color.White;

            foreach (VillageMember member in _village.Members)
            {
                Person       person = (Person)member.Tiers;
                ListViewItem item   = new ListViewItem(person.Name)
                {
                    Tag = member
                };
                item.UseItemStyleForSubItems = false;
                item.SubItems.Add(person.IdentificationData);
                item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", fc, bc, item.Font));
                item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", fc, bc, item.Font));
                item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", _product.InterestRate.HasValue ? dfc : fc, bc, item.Font));
                item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", _product.EntryFees.HasValue ? dfc : fc, bc, item.Font));
                if (_product is SavingsBookProduct)
                {
                    SavingsBookProduct sbp = (SavingsBookProduct)_product;
                    if (sbp.WithdrawFeesType == OSavingsFeesType.Flat)
                    {
                        item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "",
                                                                           sbp.FlatWithdrawFees.HasValue ? dfc : fc, bc, item.Font));
                    }
                    else
                    {
                        item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "",
                                                                           sbp.RateWithdrawFees.HasValue ? dfc : fc, bc, item.Font));
                    }

                    if (sbp.TransferFeesType == OSavingsFeesType.Flat)
                    {
                        item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "",
                                                                           sbp.FlatTransferFees.HasValue ? dfc : fc, bc, item.Font));
                    }
                    else
                    {
                        item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "",
                                                                           sbp.RateTransferFees.HasValue ? dfc : fc, bc, item.Font));
                    }
                    LVSI lvsi = new LVSI(item, "", sbp.InterBranchTransferFee.IsRange ? fc : dfc, bc, item.Font);
                    item.SubItems.Add(lvsi);

                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", sbp.DepositFees.HasValue ? dfc : fc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", sbp.ChequeDepositFees.HasValue ? dfc : fc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", sbp.CloseFees.HasValue ? dfc : fc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", sbp.ManagementFees.HasValue ? dfc : fc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", sbp.OverdraftFees.HasValue ? dfc : fc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", sbp.AgioFees.HasValue ? dfc : fc, bc, item.Font));
                    item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "", sbp.ReopenFees.HasValue ? dfc : fc, bc, item.Font));
                }
                lvMembers.Items.Add(item);
                _hasMember = true;
            }

            if (0 == lvMembers.Items.Count)
            {
                btnSave.Enabled = false;
                return;
            }

            if (_hasMember)
            {
                OCurrency zero = 0m;
                _itemTotal.Text = GetString("total");
                _itemTotal.SubItems.Add("");
                _itemTotal.SubItems.Add("");
                _itemTotal.SubItems.Add(zero.GetFormatedValue(true));
                lvMembers.Items.Add(_itemTotal);
            }
            lvMembers.SubItemClicked       += lvMembers_SubItemClicked;
            lvMembers.SubItemEndEditing    += lvMembers_SubItemEndEditing;
            lvMembers.DoubleClickActivation = true;
        }
예제 #27
0
        public void Initialize()
        {
            nudInitialAmount.DecimalPlaces = UseCents ? 2 : 0;
            nudInitialAmount.Minimum       = _savingsProduct.InitialAmountMin.Value;
            nudInitialAmount.Maximum       = _savingsProduct.InitialAmountMax.Value;
            nudInitialAmount.Text          = _initialAmount.Value.ToString();

            if (_loanAmount.HasValue)
            {
                lbInitialAmountMinMax.Text = string.Format("{0} \n\r{1} ", "Min", "Max");
            }
            else
            {
                lbInitialAmountMinMax.Text =
                    string.Format("{0}{1} {4}\r\n{2}{3} {4}",
                                  "Min: ", _savingsProduct.InitialAmountMin.GetFormatedValue(UseCents),
                                  "Max: ", _savingsProduct.InitialAmountMax.GetFormatedValue(UseCents),
                                  _savingsProduct.Currency.Code);
            }

            OCurrency fees    = 0;
            OCurrency feesMin = 0;
            OCurrency feesMax = 0;

            fees    = _isReopen ? _savingsProduct.ReopenFees : _savingsProduct.EntryFees;
            feesMin = _isReopen ? _savingsProduct.ReopenFeesMin : _savingsProduct.EntryFeesMin;
            feesMax = _isReopen ? _savingsProduct.ReopenFeesMax : _savingsProduct.EntryFeesMax;


            if (fees.HasValue)
            {
                udEntryFees.Minimum = _entryFees.Value;
                udEntryFees.Maximum = _entryFees.Value;
                udEntryFees.Value   = _entryFees.Value;

                lbEntryFeesMinMax.Text = string.Format("{0} {1}",
                                                       _entryFees.GetFormatedValue(UseCents),
                                                       _savingsProduct.Currency.Code);
            }
            else
            {
                udEntryFees.DecimalPlaces = UseCents ? 2 : 0;
                udEntryFees.Minimum       = feesMin.Value;
                udEntryFees.Maximum       = feesMax.Value;
                if (_entryFees.Value >= udEntryFees.Minimum && _entryFees.Value <= udEntryFees.Maximum)
                {
                    udEntryFees.Value = _entryFees.Value;
                }
                else
                {
                    udEntryFees.Value = feesMin.Value;
                }

                lbEntryFeesMinMax.Text = string.Format("{0}{1} {4}\r\n{2}{3} {4}",
                                                       "Min: ", feesMin.GetFormatedValue(UseCents),
                                                       "Max: ", feesMax.GetFormatedValue(UseCents),
                                                       _savingsProduct.Currency.Code);
            }

            lbEntryFeesValue.Text =
                new OCurrency(udEntryFees.Value).GetFormatedValue(UseCents)
                + " " + _savingsProduct.Currency.Code;
            lbInitialAmountValue.Text =
                _initialAmount.GetFormatedValue(UseCents)
                + " " + _savingsProduct.Currency.Code;

            OCurrency total = _initialAmount + udEntryFees.Value;

            lbTotalAmountValue.Text = total.GetFormatedValue(UseCents) + " " + _savingsProduct.Currency.Code;
        }
예제 #28
0
        public void DisplaySavings(IEnumerable <ISavingsContract> pSavings)
        {
            OCurrency    totalBalance        = 0;
            OCurrency    totalBalanceInPivot = 0;
            ExchangeRate latestExchangeRate;
            bool         usedCents = false;

            string currencyCodeHolder = null; // to detect, if credits are in different currencies
            bool   multiCurrency      = false;

            lvSavings.Items.Clear();
            //_alreadyActiveCompulosrySavings = false;
            foreach (ISavingsContract saving in pSavings)
            {
                // it will be done for the first credit
                if (currencyCodeHolder == null)
                {
                    currencyCodeHolder = saving.Product.Currency.Code;
                }

                //if not the first
                if (saving.Product.Currency.Code != currencyCodeHolder)
                {
                    multiCurrency = true;
                }
                currencyCodeHolder = saving.Product.Currency.Code;

                //In case, if there are contracts in different currencies, total value of Balance is displayed in pivot currency

                latestExchangeRate =
                    ServicesProvider.GetInstance().GetAccountingServices().FindLatestExchangeRate(TimeProvider.Today,
                                                                                                  saving.Product.Currency);
                string       status = MultiLanguageStrings.GetString(Ressource.ClientForm, "Savings" + saving.Status + ".Text");
                ListViewItem item   = new ListViewItem(saving.Code)
                {
                    Tag = saving
                };
                item.SubItems.Add(MultiLanguageStrings.GetString(Ressource.ClientForm,
                                                                 saving is SavingBookContract ? "SavingsBook.Text" : "CompulsorySavings.Text"));
                item.SubItems.Add(saving.Product.Name);
                item.SubItems.Add(saving.GetFmtBalance(false));
                item.SubItems.Add(saving.Product.Currency.Code);
                item.SubItems.Add(saving.CreationDate.ToShortDateString());
                item.SubItems.Add((saving.Events.Count != 0) ? saving.Events[saving.Events.Count - 1].Date.ToShortDateString() : "");
                item.SubItems.Add(status);
                item.SubItems.Add(saving.ClosedDate.HasValue ? saving.ClosedDate.Value.ToShortDateString() : "");

                totalBalance        += saving.GetBalance();
                totalBalanceInPivot += latestExchangeRate.Rate == 0
                                           ? 0
                                           : saving.GetBalance() / latestExchangeRate.Rate;

                lvSavings.Items.Add(item);

                if (saving.Product.Currency.UseCents)
                {
                    usedCents = saving.Product.Currency.UseCents;
                }

                //if (saving is CompulsorySavings && saving.Status == OSavingsStatus.Active)
                //    _alreadyActiveCompulosrySavings = true;
            }

            totalItem.Font = new Font(totalItem.Font, FontStyle.Bold);
            totalItem.SubItems.Add("");
            totalItem.SubItems.Add("");

            if (multiCurrency)
            {
                totalItem.SubItems.Add(totalBalanceInPivot.GetFormatedValue(ServicesProvider.GetInstance().GetCurrencyServices().GetPivot().UseCents&& usedCents));
                totalItem.SubItems.Add(ServicesProvider.GetInstance().GetCurrencyServices().GetPivot().Code);
            }
            else
            {
                totalItem.SubItems.Add(totalBalance.GetFormatedValue(usedCents));
                totalItem.SubItems.Add(currencyCodeHolder);
            }

            lvSavings.Items.Add(totalItem);
        }
예제 #29
0
        private void InitializeControls()
        {
            lvMembers.Items.Clear();
            _fLServices.EmptyTemporaryFLAmountsStorage();
            ApplicationSettings dataParam = ApplicationSettings.GetInstance(string.Empty);
            int decimalPlaces             = dataParam.InterestRateDecimalPlaces;

            foreach (VillageMember member in _village.NonDisbursedMembers)
            {
                foreach (Loan loan in member.ActiveLoans)
                {
                    if (loan.ContractStatus == OContractStatus.Active ||
                        loan.ContractStatus == OContractStatus.Refused ||
                        loan.ContractStatus == OContractStatus.Abandoned
                        )
                    {
                        continue;
                    }
                    _hasMember = true;
                    Person       person = member.Tiers as Person;
                    ListViewItem item   = new ListViewItem(person.Name)
                    {
                        Tag = loan
                    };
                    item.UseItemStyleForSubItems = true;
                    item.SubItems.Add(person.IdentificationData);
                    ListViewItem.ListViewSubItem subitem = new ListViewItem.ListViewSubItem
                    {
                        Text = TimeProvider.Today.ToShortDateString(),
                        Tag  = TimeProvider.Today
                    };
                    item.SubItems.Add(subitem);
                    item.SubItems.Add(loan.FirstInstallmentDate.ToShortDateString());
                    item.SubItems.Add(loan.Amount.GetFormatedValue(loan.UseCents));
                    item.SubItems.Add(loan.Product.Currency.Code);
                    item.SubItems.Add(Math.Round(loan.InterestRate * 100, decimalPlaces).ToString());
                    item.SubItems.Add(loan.GracePeriod.ToString());
                    item.SubItems.Add(loan.NbOfInstallments.ToString());
                    item.SubItems.Add(loan.LoanOfficer.Name);
                    item.SubItems.Add(loan.FundingLine.Name);

                    _accumulatedAmount = _fLServices.CheckIfAmountIsEnough(loan.FundingLine, loan.Amount.Value);
                    if (_accumulatedAmount <= 0)
                    {
                        item.BackColor = Color.Red;
                    }
                    item.SubItems.Add(_accumulatedAmount.ToString());

                    cbPaymentMethods.Items.Clear();
                    List <PaymentMethod> methods = ServicesProvider.GetInstance().GetPaymentMethodServices().GetAllPaymentMethods();
                    item.SubItems.Add(methods[0].Name);

                    lvMembers.Items.Add(item);
                    item.SubItems[IdxAmount].Tag   = loan.Amount.GetFormatedValue(loan.UseCents);
                    item.SubItems[IdxCurrency].Tag = loan.Product.Currency;
                }
            }

            if (_hasMember)
            {
                OCurrency zero = 0m;
                _itemTotal.Text = GetString("total");
                _itemTotal.SubItems.Add("");
                _itemTotal.SubItems.Add("");
                _itemTotal.SubItems.Add("");
                _itemTotal.SubItems.Add(zero.GetFormatedValue(true));
                _itemTotal.SubItems.Add("");
                lvMembers.Items.Add(_itemTotal);
            }

            lvMembers.SubItemClicked       += lvMembers_SubItemClicked;
            lvMembers.DoubleClickActivation = true;
        }
예제 #30
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[idxInitialAmount].Text)) // Initial Amount
                {
                    item.SubItems[idxInitialAmount].Text = _product.InitialAmountMin.GetFormatedValue(_product.Currency.UseCents);
                    item.SubItems[idxInitialAmount].Tag  = _product.InitialAmountMin;
                }
                if (string.IsNullOrEmpty(item.SubItems[idxCurrency].Text)) // Currency
                {
                    item.SubItems[idxCurrency].Text = _product.Currency.Code;
                    item.SubItems[idxCurrency].Tag  = _product.Currency;
                }

                if (string.IsNullOrEmpty(item.SubItems[idxInterestRate].Text)) // Interest Rate
                {
                    item.SubItems[idxInterestRate].Text = _defaultInterestRate.ToString();
                    item.SubItems[idxInterestRate].Tag  = _defaultInterestRate;
                }
                if (string.IsNullOrEmpty(item.SubItems[idxEntryFees].Text)) // Entry Fees
                {
                    item.SubItems[idxEntryFees].Text = _defaultEntryFees.GetFormatedValue(_product.Currency.UseCents);
                    item.SubItems[idxEntryFees].Tag  = _defaultEntryFees;
                }
                if (_product is SavingsBookProduct)
                {
                    if (string.IsNullOrEmpty(item.SubItems[idxWithdrawFees].Text)) // Withdraw Fees
                    {
                        item.SubItems[idxWithdrawFees].Text = _defaultWithdrawFees.ToString();
                        item.SubItems[idxWithdrawFees].Tag  = _defaultWithdrawFees;
                    }
                    if (string.IsNullOrEmpty(item.SubItems[idxTransferFees].Text)) // Transfer Fees
                    {
                        item.SubItems[idxTransferFees].Text = _defaultTransferFees.ToString();
                        item.SubItems[idxTransferFees].Tag  = _defaultTransferFees;
                    }
                    if (string.IsNullOrEmpty(item.SubItems[idxIbtFees].Text))
                    {
                        item.SubItems[idxIbtFees].Text = _defaultIbtFees.ToString();
                        item.SubItems[idxIbtFees].Tag  = _defaultIbtFees;
                    }
                    if (string.IsNullOrEmpty(item.SubItems[idxDepositFees].Text)) // Deposit Fees
                    {
                        item.SubItems[idxDepositFees].Text = _defaultDepositFees.ToString();
                        item.SubItems[idxDepositFees].Tag  = _defaultDepositFees;
                    }
                    if (string.IsNullOrEmpty(item.SubItems[idxChequeDepositFees].Text)) // Cheque Deposit Fees
                    {
                        item.SubItems[idxChequeDepositFees].Text = _defaultChequeDepositFees.ToString();
                        item.SubItems[idxChequeDepositFees].Tag  = _defaultChequeDepositFees;
                    }
                    if (string.IsNullOrEmpty(item.SubItems[idxCloseFees].Text)) // Close Fees
                    {
                        item.SubItems[idxCloseFees].Text = _defaultCloseFees.ToString();
                        item.SubItems[idxCloseFees].Tag  = _defaultCloseFees;
                    }
                    if (string.IsNullOrEmpty(item.SubItems[idxManagementFees].Text)) // Management Fees
                    {
                        item.SubItems[idxManagementFees].Text = _defaultManagementFees.ToString();
                        item.SubItems[idxManagementFees].Tag  = _defaultManagementFees;
                    }
                    if (string.IsNullOrEmpty(item.SubItems[idxOverdraftFees].Text)) // Overdraft Fees
                    {
                        item.SubItems[idxOverdraftFees].Text = _defaultOverdraftFees.ToString();
                        item.SubItems[idxOverdraftFees].Tag  = _defaultOverdraftFees;
                    }
                    if (string.IsNullOrEmpty(item.SubItems[idxAgioFees].Text)) // Agio Fees
                    {
                        item.SubItems[idxAgioFees].Text = _defaultAgioFees.ToString();
                        item.SubItems[idxAgioFees].Tag  = _defaultAgioFees;
                    }
                    if (string.IsNullOrEmpty(item.SubItems[idxReopenFees].Text)) // Reopen Fees
                    {
                        item.SubItems[idxReopenFees].Text = _defaultReopenFees.ToString();
                        item.SubItems[idxReopenFees].Tag  = _defaultReopenFees;
                    }
                }
            }
            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();
        }