Example #1
0
        void SetFee(bool AddInterest)
        {
            CWSetFeeAmount cwwin = new CWSetFeeAmount(AddInterest);

#if !SILVERLIGHT
            cwwin.DialogTableId = AddInterest ? 2000000070 : 2000000071;
#endif
            collectionType = string.Empty;
            cwwin.Closing += delegate
            {
                if (cwwin.DialogResult == true)
                {
                    this.AddInterest = AddInterest;
                    var debtorPayments = dgDebtorTranOpenGrid.GetVisibleRows() as IEnumerable <DebtorTransPayment>;
                    if (AddInterest)
                    {
                        if (cwwin.value != 0)
                        {
                            var desm = api.CompanyEntity.HasDecimals ? 2 : 0;
                            foreach (var rec in debtorPayments)
                            {
                                rec.FeeAmount     = !rec._OnHold ? Math.Round(((rec._AmountOpenCur != 0 ? rec._AmountOpenCur : rec._AmountOpen) * cwwin.value) / 100d, desm) : 0d;
                                rec.PaymentCharge = 0d;
                            }
                        }
                        collectionType = Uniconta.ClientTools.Localization.lookup("InterestNote");
                    }
                    else
                    {
                        Currencies currencuEnum, chargeCurrency;
                        Enum.TryParse(cwwin.FeeCurrency, out currencuEnum);
                        Enum.TryParse(cwwin.ChargeCurrency, out chargeCurrency);

                        if (cwwin.SelectedType == Uniconta.ClientTools.Localization.lookup("Transaction"))
                        {
                            SetFeeAmount(debtorPayments, cwwin.value, currencuEnum, cwwin.Charge, chargeCurrency);
                        }
                        else if (cwwin.SelectedType == Uniconta.ClientTools.Localization.lookup("Account"))
                        {
                            foreach (var rec in debtorPayments)
                            {
                                rec.FeeAmount = rec.PaymentCharge = 0d;
                            }

                            var selectedAccounts = debtorPayments.GroupBy(x => x.Account).Select(x => x.FirstOrDefault(x2 => x2._AmountOpen > 0 && !x2._OnHold));
                            SetFeeAmount(selectedAccounts, cwwin.value, currencuEnum, cwwin.Charge, chargeCurrency);
                        }
                        collectionType = cwwin.CollectionType;
                    }
                }
            };
            cwwin.Show();
        }
Example #2
0
        void SetFee(bool AddInterest)
        {
            CWSetFeeAmount cwwin = new CWSetFeeAmount(AddInterest);

            collectionType = string.Empty;
            cwwin.Closing += delegate
            {
                if (cwwin.DialogResult == true)
                {
                    this.AddInterest = AddInterest;
                    var debtorPayments = dgDebtorTranOpenGrid.GetVisibleRows() as IEnumerable <DebtorTransPayment>;
                    if (AddInterest)
                    {
                        if (cwwin.value != 0)
                        {
                            var desm = api.CompanyEntity.HasDecimals ? 2 : 0;
                            foreach (var rec in debtorPayments)
                            {
                                rec.FeeAmount = !rec._OnHold ? Math.Round((rec._AmountOpen * cwwin.value) / 100d, desm) : 0d;
                            }
                        }
                        collectionType = Uniconta.ClientTools.Localization.lookup("InterestNote");
                    }
                    else
                    {
                        Currencies currencuEnum;
                        Enum.TryParse(cwwin.FeeCurrency, out currencuEnum);

                        if (cwwin.SelectedType == Uniconta.ClientTools.Localization.lookup("Transaction"))
                        {
                            SetFeeAmount(debtorPayments, cwwin.value, currencuEnum, false);
                        }
                        else if (cwwin.SelectedType == Uniconta.ClientTools.Localization.lookup("Account"))
                        {
                            debtorPayments.ToList().ForEach(p => p.FeeAmount = 0.0d);
                            var selectedAccounts = debtorPayments.GroupBy(x => x.Account).Select(x => x.First());
                            SetFeeAmount(selectedAccounts, cwwin.value, currencuEnum, true);
                        }
                        collectionType = cwwin.CollectionType;
                    }
                }
            };
            cwwin.Show();
        }