private string GetTaxNewSchool(ShirtVariation currentContent)
        {
            IMarket market    = _currentMarket.GetCurrentMarket();
            Guid    currCust  = CustomerContext.Current.CurrentContactId;
            string  bogusCart = "BogusCart";

            ICart cart = _orderRepository.LoadOrCreateCart <ICart>(
                currCust, bogusCart);

            ILineItem lineItem = _orderGroupFactory.CreateLineItem(currentContent.Code, cart);

            lineItem.Quantity      = 1;
            lineItem.PlacedPrice   = GetCustomerPricingPrice(currentContent).UnitPrice.Amount;
            lineItem.TaxCategoryId = currentContent.TaxCategoryId;
            cart.AddLineItem(lineItem);

            IOrderAddress bogusAddress = _orderGroupFactory.CreateOrderAddress(cart);

            bogusAddress.CountryCode = "sv";
            bogusAddress.City        = "Stockholm";
            bogusAddress.CountryName = "Sweden";

            string str = String.Empty;
            //str += _taxCalc.Service.GetTaxTotal(cart, market, market.DefaultCurrency).Amount.ToString();

            var taxValues = Enumerable.Empty <ITaxValue>();

            taxValues = OrderContext.Current.GetTaxes(Guid.Empty, currentContent.theTaxCategory, "sv", bogusAddress);

            str = _taxCalc.Service.GetSalesTax(lineItem, market, bogusAddress, new Money(0m, "SEK")).ToString();


            return(str);
        }
        public IOrderAddress ConvertToAddress(IOrderGroup orderGroup, AddressModel model)
        {
            var address = _orderGroupFactory.CreateOrderAddress(orderGroup);

            address.Id = model.Name;
            MapToAddress(model, address);

            return(address);
        }
Пример #3
0
        private IOrderAddress AddAddressToOrder(ICart cart)
        {
            IOrderAddress shippingAddress = null;

            if (CustomerContext.Current.CurrentContact == null)
            {
                IShipment shipment = cart.GetFirstShipment();
                if (shipment.ShippingAddress != null)
                {
                    //using the cart.GetFirstShipment() seems only useful if we are checking for an existing address, otherwise
                    //the solution code's recommended 'new school' approach doesn't use it.
                }
                IOrderAddress myOrderAddress = _orderGroupFactory.CreateOrderAddress(cart);
                myOrderAddress.CountryName = "United States";
                myOrderAddress.Id          = "HomersShippingAddress";
                myOrderAddress.Email       = "*****@*****.**";

                shippingAddress = myOrderAddress;
            }
            else
            {
                //User is logged in
                if (CustomerContext.Current.CurrentContact.PreferredShippingAddress == null)
                {
                    CustomerAddress newCustAddress = CustomerAddress.CreateInstance();
                    newCustAddress.AddressType        = CustomerAddressTypeEnum.Shipping | CustomerAddressTypeEnum.Public; //mandatory
                    newCustAddress.ContactId          = CustomerContext.Current.CurrentContact.PrimaryKeyId;
                    newCustAddress.CountryCode        = "USA";
                    newCustAddress.CountryName        = "United States";
                    newCustAddress.Name               = "Wilbur's customer address"; // mandatory
                    newCustAddress.DaytimePhoneNumber = "9008675309";
                    newCustAddress.FirstName          = CustomerContext.Current.CurrentContact.FirstName;
                    newCustAddress.LastName           = CustomerContext.Current.CurrentContact.LastName;
                    newCustAddress.Email              = "*****@*****.**";

                    // note: Line1 & City is what is shown in CM at a few places... not the Name
                    CustomerContext.Current.CurrentContact.AddContactAddress(newCustAddress);
                    CustomerContext.Current.CurrentContact.SaveChanges();

                    // ... needs to be in this order
                    CustomerContext.Current.CurrentContact.PreferredShippingAddress = newCustAddress;
                    CustomerContext.Current.CurrentContact.SaveChanges(); // need this ...again

                    // then, for the cart
                    //.Cart.OrderAddresses.Add(new OrderAddress(newCustAddress)); - OLD
                    shippingAddress = new OrderAddress(newCustAddress); // - NEW
                }
                else
                {
                    shippingAddress = new OrderAddress(CustomerContext.Current.CurrentContact.PreferredShippingAddress);
                }
            }

            return(shippingAddress);
        }
Пример #4
0
        private IOrderAddress GetOrderAddress(IOrderGroup cart)
        {
            var shipAddress = _orderGroupFactory.CreateOrderAddress(cart);

            shipAddress.City        = "Atlanta";
            shipAddress.CountryCode = "USA";
            shipAddress.CountryName = "United States";
            shipAddress.Id          = "DemoShipAddress";

            return(shipAddress);
        }
Пример #5
0
        private IOrderAddress CreateAddress(QuickBuyModel model, Cart cart, string name)
        {
            var shippingAddress = _orderGroupFactory.CreateOrderAddress(cart);

            shippingAddress.Id          = name;
            shippingAddress.LastName    = model.LastName;
            shippingAddress.FirstName   = model.FirstName;
            shippingAddress.Line1       = model.Address;
            shippingAddress.PostalCode  = model.ZipCode;
            shippingAddress.City        = model.City;
            shippingAddress.CountryCode = "NOR";
            return(shippingAddress);
        }
Пример #6
0
        protected virtual IOrderAddress ConvertToAddress(
            IOrderGroup orderGroup,
            SaleShippingViewModel shipping)
        {
            if (shipping == null)
            {
                return(null);
            }

            var orderAddress = _orderGroupFactory.CreateOrderAddress(orderGroup);

            orderAddress.Id                 = "Shipping";
            orderAddress.City               = shipping.Address.City;
            orderAddress.CountryCode        = shipping.Address.CountryCode;
            orderAddress.CountryName        = shipping.Address.Country;
            orderAddress.DaytimePhoneNumber = shipping.CustomerInfo.Phone;
            orderAddress.Email              = shipping.CustomerInfo.Email;
            orderAddress.FirstName          = shipping.Address.Name;
            orderAddress.Line1              = shipping.Address.Street;
            orderAddress.PostalCode         = shipping.Address.PostalCode;

            return(orderAddress);
        }
Пример #7
0
        private void GetTaxInfo(DemoMarketsViewModel viewModel)
        {
            ICart cart = _orderRepository.LoadOrCreateCart <ICart>(CustomerContext.Current.CurrentContactId, "BogusCart");

            IOrderAddress bogusAddress = _orderGroupFactory.CreateOrderAddress(cart);

            bogusAddress.CountryCode = viewModel.SelectedMarket.Countries.FirstOrDefault();
            bogusAddress.City        = "Stockholm";

            ILineItem lineItem = _orderGroupFactory.CreateLineItem(viewModel.Shirt.Code, cart);

            lineItem.Quantity      = 1;
            lineItem.PlacedPrice   = viewModel.Shirt.GetDefaultPrice().UnitPrice;
            lineItem.TaxCategoryId = viewModel.Shirt.TaxCategoryId;
            cart.AddLineItem(lineItem);

            viewModel.TaxAmount = _taxCalculator.GetSalesTax(lineItem, viewModel.SelectedMarket,
                                                             bogusAddress, new Money(lineItem.PlacedPrice, viewModel.SelectedMarket.DefaultCurrency));

            viewModel.TaxAmountOldSchool = GetTaxOldSchool(viewModel, bogusAddress);
        }
        private IOrderAddress GetOrderAddressFromWarehosue(ICart cart, IWarehouse warehouse)
        {
            var address = _orderGroupFactory.CreateOrderAddress(cart);

            address.Id                 = warehouse.Code;
            address.City               = warehouse.ContactInformation.City;
            address.CountryCode        = warehouse.ContactInformation.CountryCode;
            address.CountryName        = warehouse.ContactInformation.CountryName;
            address.DaytimePhoneNumber = warehouse.ContactInformation.DaytimePhoneNumber;
            address.Email              = warehouse.ContactInformation.Email;
            address.EveningPhoneNumber = warehouse.ContactInformation.EveningPhoneNumber;
            address.FaxNumber          = warehouse.ContactInformation.FaxNumber;
            address.FirstName          = warehouse.ContactInformation.FirstName;
            address.LastName           = warehouse.ContactInformation.LastName;
            address.Line1              = warehouse.ContactInformation.Line1;
            address.Line2              = warehouse.ContactInformation.Line2;
            address.Organization       = warehouse.ContactInformation.Organization;
            address.PostalCode         = warehouse.ContactInformation.PostalCode;
            address.RegionName         = warehouse.ContactInformation.RegionName;
            address.RegionCode         = warehouse.ContactInformation.RegionCode;
            return(address);
        }
Пример #9
0
        private IOrderAddress AddAddressToOrder(ICart cart)
        {
            IOrderAddress shippingAddress;

            if (CustomerContext.Current.CurrentContact == null) // anonymous
            {
                // Anonymous... one way of "doing it"... for example, if no other address exist
                var shipment = cart.GetFirstShipment(); // ... moved to shipment - prev. = .OrderAddresses.Add(

                if (shipment.ShippingAddress != null)
                {
                    //return false/true; // Should we clean upfirst?
                }

                // New School
                IOrderAddress myOrderAddress = _orderGroupFactory.CreateOrderAddress(cart);
                myOrderAddress.CountryName = "Sweden";
                myOrderAddress.Id          = "MyNewAddress";
                myOrderAddress.Email       = "*****@*****.**";

                // temp-fix this
                shippingAddress = myOrderAddress;

                // OldSchool
                //shippingAddress = shipment.ShippingAddress = //
                //    new OrderAddress
                //    {
                //        CountryCode = "USA",
                //        CountryName = "United States",
                //        Name = "SomeCustomerAddressName",
                //        DaytimePhoneNumber = "123456",
                //        FirstName = "John",
                //        LastName = "Smith",
                //        Email = "*****@*****.**",
                //    };
            } // end anonymous
            else
            {
                // Logged in
                if (CustomerContext.Current.CurrentContact.PreferredShippingAddress == null)
                {
                    // no pref. address set... so we set one for the contact
                    CustomerAddress newCustAddress = CustomerAddress.CreateInstance();
                    newCustAddress.AddressType        = CustomerAddressTypeEnum.Shipping | CustomerAddressTypeEnum.Public; // mandatory
                    newCustAddress.ContactId          = CustomerContext.Current.CurrentContact.PrimaryKeyId;
                    newCustAddress.CountryCode        = "SWE";
                    newCustAddress.CountryName        = "Sweden";
                    newCustAddress.Name               = "new customer address"; // mandatory
                    newCustAddress.DaytimePhoneNumber = "123456";
                    newCustAddress.FirstName          = CustomerContext.Current.CurrentContact.FirstName;
                    newCustAddress.LastName           = CustomerContext.Current.CurrentContact.LastName;
                    newCustAddress.Email              = "*****@*****.**";

                    // note: Line1 & City is what is shown in CM at a few places... not the Name
                    CustomerContext.Current.CurrentContact.AddContactAddress(newCustAddress);
                    CustomerContext.Current.CurrentContact.SaveChanges();

                    // ... needs to be in this order
                    CustomerContext.Current.CurrentContact.PreferredShippingAddress = newCustAddress;
                    CustomerContext.Current.CurrentContact.SaveChanges(); // need this ...again

                    // then, for the cart
                    //.Cart.OrderAddresses.Add(new OrderAddress(newCustAddress)); - OLD
                    shippingAddress = new OrderAddress(newCustAddress); // - NEW
                }
                else
                {
                    // ...a 3:rd vay, there is a preferred address set
                    shippingAddress = new OrderAddress(
                        CustomerContext.Current.CurrentContact.PreferredShippingAddress);
                }
            }

            return(shippingAddress);
        }