Exemple #1
0
        private Money getServiceChargeForOrder(IOrder order, IInstrumentExchange instrumentExchange)
        {
            Money serviceCharge = null;

            if (order == null)
                throw new ApplicationException("It is not possible to calculate the Service Charge when the order id null");

            if (instrumentExchange != null && order.Amount != null && order.Amount.IsNotZero)
            {
                decimal percentage = instrumentExchange.GetServiceChargePercentageForOrder(order);
                serviceCharge = order.Amount * (percentage / (1M + percentage));
            }
            if (serviceCharge == null)
                serviceCharge = new Money(0M, order.OrderCurrency);
            else
                serviceCharge = (serviceCharge.Abs() * -1);

            return serviceCharge;
        }
Exemple #2
0
    private void InitializeExchangeDetails(IInstrumentExchange exchange)
    {
        IList<ICurrency> currencies;
        ListItem lstItem;
        IList countries;
        string strAbbr;

        tbExchangeName.Text = exchange.Exchange.ExchangeName;
        tbNumberOfDecimals.Text = exchange.NumberOfDecimals.ToString();

        IDalSession session = NHSessionFactory.CreateSession();
        currencies = InstrumentMapper.GetCurrencies(session);
        lstItem = new ListItem("--Choose--", "-1");
        ddDefaultExchangeCurrency.Items.Add(lstItem);

        foreach (IInstrument curr in currencies)
        {
            lstItem = new ListItem(curr.Name.ToString(), curr.Key.ToString());
            if (exchange.Exchange.DefaultCurrency != null &&
                (exchange.Exchange.DefaultCurrency.Key == curr.Key))
            {
                lstItem.Selected = true;
            }
            ddDefaultExchangeCurrency.Items.Add(lstItem);
        }
        ddDefaultExchangeCurrency.DataBind();

        countries = CountryMapper.GetCountries(session);
        lstItem = new ListItem("--Choose--", "-1");
        ddDefaultExchangeCountry.Items.Add(lstItem);
        foreach (ICountry country in countries)
        {
            if (country.CountryName.ToString().Length > 18)
            {
                strAbbr = country.CountryName.ToString().Substring(0, 18);
            }
            else
            {
                strAbbr = country.CountryName.ToString();
            }
            lstItem = new ListItem(strAbbr, country.Key.ToString());
            if (exchange.Exchange.DefaultCurrency != null &&
                ((ICountry)exchange.Exchange.DefaultCountry).Key == country.Key)
            {
                lstItem.Selected = true;
            }
            ddDefaultExchangeCountry.Items.Add(lstItem);
        }
        ddDefaultExchangeCountry.DataBind();
        session.Close();
    }