Ejemplo n.º 1
0
    private static Dictionary <TaxElement, decimal> GetTaxItems(ShoppingCart shoppingCart, CustomerContact shippingContact, CustomerContact billingContact)
    {
        var taxesItems = new Dictionary <TaxElement, decimal>();

        foreach (var item in shoppingCart)
        {
            var t = (List <TaxElement>)TaxServices.GetTaxesForProduct(item.EntityId, billingContact, shippingContact);
            foreach (var tax in t)
            {
                if (taxesItems.ContainsKey(tax))
                {
                    taxesItems[tax] += TaxServices.CalculateTax((OrderItem)item, tax);
                }
                else
                {
                    taxesItems.Add(tax, TaxServices.CalculateTax((OrderItem)item, tax));
                }
            }
        }
        return(taxesItems);
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (EmptyCheck || Order == null)
        {
            return;
        }
        _currency = (Order.OrderCurrency ?? CurrencyService.Currency("USD")) ?? new Currency
        {
            IsCodeBefore = true,
            Iso3         = "USD",
            Name         = "USD",
            PriceFormat  = CurrencyService.DefaultPriceFormat,
            Symbol       = "$",
            Value        = 1
        };

        //var check = new Check_PaymentModule();

        lCompanyName.Text = _Check.CompanyName;
        lAddress.Text     = _Check.Adress;
        lCountry.Text     = _Check.Country;
        lState.Text       = _Check.State;
        lCity.Text        = _Check.City;

        lCompanyPhone.Text = _Check.Phone;
        lInterPhone.Text   = _Check.IntPhone;
        lCompanyFax.Text   = _Check.Fax;

        lOrderDate.Text      = AdvantShop.Localization.Culture.ConvertDate(Order.OrderDate); // AdvantShop.Localization.Culture.ConvertDate((DateTime)reader["OrderDate"]);
        lOrderId.Text        = @"#" + Order.OrderID;
        lShippingMethod.Text = Order.ShippingMethodName;                                     // reader["ShippingMethod"].ToString();

        lName.Text  = Order.BillingContact.Name;
        lPhone.Text = Order.OrderCustomer.MobilePhone;
        //lFax.Text = Order.BillingContact.Fax;
        //lEmail.Text = Order.BillingContact.Email;
        lEmail.Text = Order.OrderCustomer.Email;

        lBillingAddress.Text = Order.BillingContact.Address;
        lBillingCity.Text    = Order.BillingContact.City;
        lBillingState.Text   = Order.BillingContact.Zone;
        lBillingCountry.Text = Order.BillingContact.Country;
        lBillingZip.Text     = Order.BillingContact.Zip;

        lShippingAddress.Text = Order.ShippingContact.Address;
        lShippingCity.Text    = Order.ShippingContact.City;
        lShippingState.Text   = Order.ShippingContact.Zone;
        lShippingCountry.Text = Order.ShippingContact.Country;
        lShippingZip.Text     = Order.ShippingContact.Zip;



        lSubTotal.Text =
            EvalPrice((Order.Sum - Order.ShippingCost) * 100.0M / (100 - Order.OrderDiscount));
        lShippingCost.Text = EvalPrice(Order.ShippingCost);
        lDiscount.Text     =
            EvalPrice(Order.OrderDiscount * (Order.Sum - Order.ShippingCost / (100 - Order.OrderDiscount)));


        var shippingContact = new AdvantShop.Customers.CustomerContact
        {
            CountryId = CountryService.GetCountryIdByName(lShippingCountry.Text),
            RegionId  = RegionService.GetRegionIdByName(lShippingState.Text)
        };
        var billingContact = new AdvantShop.Customers.CustomerContact
        {
            CountryId = CountryService.GetCountryIdByName(lBillingCountry.Text),
            RegionId  = RegionService.GetRegionIdByName(lBillingState.Text)
        };

        rptOrderItems.DataBind();
        IList <OrderItem> dtOrder = Order.OrderItems;
        var taxedItems            = new List <TaxValue>();

        foreach (OrderItem item in dtOrder)
        {
            ICollection <TaxElement> t = TaxServices.GetTaxesForProduct(item.EntityId, billingContact, shippingContact);
            foreach (TaxElement tax in t)
            {
                TaxValue taxedItem = taxedItems.Find(tv => tv.TaxID == tax.TaxId);
                if (taxedItem != null)
                {
                    taxedItem.TaxSum += TaxServices.CalculateTax(item, tax);
                }
                else
                {
                    taxedItems.Add(new TaxValue
                    {
                        TaxID          = tax.TaxId,
                        TaxName        = tax.Name,
                        TaxShowInPrice = tax.ShowInPrice,
                        TaxSum         = TaxServices.CalculateTax(item, tax)
                    });
                }
            }
        }


        literalTaxCost.Text = BuildTaxTable(taxedItems, _currency.Value, _currency.Iso3, Resource.Admin_ViewOrder_Taxes);
        lTotal.Text         = EvalPrice(Order.Sum);
    }