private bool CheckAllFieldsMatch(Jurisdiction jurisdiction, string countryCode, string state, string postalCode, string regionCode, string district, string geoCode, string city)
		{
			var retVal = true;

			if (!string.IsNullOrEmpty(jurisdiction.GeoCode))
			{
				retVal = string.Equals(jurisdiction.GeoCode, geoCode);
				if (!retVal)
					return false;
			}

			if (!string.IsNullOrEmpty(jurisdiction.District))
			{
				retVal = string.Equals(jurisdiction.District, district);
				if (!retVal)
					return false;
			}

			if (!string.IsNullOrEmpty(jurisdiction.City))
			{
				retVal = string.Equals(jurisdiction.City, city);
				if (!retVal)
					return false;
			}
			
			if (!string.IsNullOrEmpty(jurisdiction.ZipPostalCodeEnd) && !string.IsNullOrEmpty(jurisdiction.ZipPostalCodeStart))
			{
				retVal = (System.String.CompareOrdinal(jurisdiction.ZipPostalCodeStart, postalCode) <= 0 &&
										System.String.CompareOrdinal(jurisdiction.ZipPostalCodeEnd, postalCode) >= 0);
				if (!retVal)
					return false;
			}

			if (!string.IsNullOrEmpty(jurisdiction.StateProvinceCode))
			{
				retVal = string.Equals(jurisdiction.StateProvinceCode, state);
				if (!retVal)
					return false;
			}

			if (!string.IsNullOrEmpty(jurisdiction.CountryCode))
			{
				retVal = string.Equals(jurisdiction.CountryCode, countryCode);
				if (!retVal)
					return false;
			}

			return true;
		}
 public JurisdictionOverviewStepViewModel(IRepositoryFactory<IOrderRepository> repositoryFactory, IRepositoryFactory<ICountryRepository> countryRepositoryFactory,
     IOrderEntityFactory entityFactory, JurisdictionTypes jurisdictionType, Jurisdiction item)
     : base(repositoryFactory, countryRepositoryFactory,  entityFactory, jurisdictionType, item)
 {
 }
		public void Can_run_activity_calculatetaxtotals()
		{
			var orderGroup = CreateOrderConstant();

			var catrepository = new Mock<ICatalogRepository>();
			var items = new List<Item>();
			orderGroup.OrderForms[0].Shipments[0].ShipmentItems.ToList().ForEach(item => items.Add(new Product
				{
					ItemId = item.LineItem.CatalogItemId,
					TaxCategory = "472b9809-3530-4d95-9886-cbddcaa0b72e"
				}));

			orderGroup.OrderForms[0].Shipments[0].ShippingCost = 10;

			catrepository.Setup(x => x.Items).Returns(() => items.ToArray().AsQueryable());
			catrepository.SetupAllProperties();

			var taxrepository = new Mock<ITaxRepository>();
			var taxes = new[] 
			{ 
				new Tax { Name = "US Shipment tax", TaxType = (int)TaxTypes.ShippingTax, SortOrder = 1},
				new Tax { Name = "US Sales tax", TaxType = (int)TaxTypes.SalesTax, SortOrder = 1}
			};

			var jurisdiction = new Jurisdiction
			{
				Code = "VAT",
				CountryCode = "USA",
				JurisdictionType = (int)JurisdictionTypes.All
			};

			var jurisdictionGroup = new JurisdictionGroup
			{
				DisplayName = "USA VAT",
				Code = "USAVAT",
				JurisdictionType = (int)JurisdictionTypes.All
			};
			var jurisdictionRel = new JurisdictionRelation
			{
				JurisdictionGroup = jurisdictionGroup,
				JurisdictionGroupId = jurisdictionGroup.JurisdictionGroupId,
				Jurisdiction = jurisdiction,
				JurisdictionId = jurisdiction.JurisdictionId
			};

			jurisdictionGroup.JurisdictionRelations.Add(jurisdictionRel);

			taxes[0].TaxValues.Add(new TaxValue()
			{
				AffectiveDate = new DateTime(2013, 6, 1),
				Percentage = 18,
				TaxCategory = "472b9809-3530-4d95-9886-cbddcaa0b72e",
				TaxId = taxes[0].TaxId,
				Tax = taxes[0],
				JurisdictionGroup = jurisdictionGroup,
				JurisdictionGroupId = jurisdictionGroup.JurisdictionGroupId
			});

			taxes[1].TaxValues.Add(new TaxValue()
			{
				AffectiveDate = new DateTime(2013, 6, 1),
				Percentage = 5,
				TaxCategory = "472b9809-3530-4d95-9886-cbddcaa0b72e",
				TaxId = taxes[1].TaxId,
				Tax = taxes[1],
				JurisdictionGroup = jurisdictionGroup,
				JurisdictionGroupId = jurisdictionGroup.JurisdictionGroupId
			});

			taxrepository.Setup(x => x.Taxes).Returns(taxes.AsQueryable);
			taxrepository.SetupAllProperties();

			var activity = new CalculateTaxActivity(catrepository.Object, taxrepository.Object, CacheRepository);

			var result = InvokeActivity(activity, orderGroup);

			var order = result.OrderGroup;
			// now check totals            

			// Order totals
			Assert.Equal(order.TaxTotal, 660.24M);
			Assert.Equal(order.OrderForms[0].Shipments[0].ItemTaxTotal, 609.84M);
			Assert.Equal(order.OrderForms[0].Shipments[0].ShippingTaxTotal, 12.6M);
		}
 public CreateJurisdictionViewModel(IViewModelsFactory<IJurisdictionOverviewStepViewModel> vmFactory, JurisdictionTypes jurisdictionType, Jurisdiction item)
 {
     RegisterStep(vmFactory.GetViewModelInstance(
         new KeyValuePair<string, object>("item", item)
         , new KeyValuePair<string, object>("jurisdictionType", jurisdictionType)));
 }
		private static Jurisdiction InitializeItem(Jurisdiction item, IEnumerable<ImportItem> systemValues)
		{
			if (item == null)
				item = new OrderEntityFactory().CreateEntity<Jurisdiction>();
			var itemProperties = item.GetType().GetProperties();
			systemValues.ToList().ForEach(x => SetPropertyValue(item, itemProperties.FirstOrDefault(y => y.Name == x.Name), x.Value));

			return item;
		}