Example #1
0
 public TaxValueViewModel(TaxCategory[] allAvailableTaxCategories, JurisdictionGroup[] allAvailableJurisdictionGroups, TaxValue item)
 {
     AllAvailableTaxCategories = allAvailableTaxCategories;
     AllAvailableJurisdictionGroups = allAvailableJurisdictionGroups;
     InnerItem = item;
     InnerItem.PropertyChanged += InnerItem_PropertyChanged;
 }
		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 JurisdictionGroupOverviewStepViewModel(IRepositoryFactory<IOrderRepository> repositoryFactory, IOrderEntityFactory entityFactory, JurisdictionTypes jurisdictionType, JurisdictionGroup item)
     : base(repositoryFactory, entityFactory, jurisdictionType, item)
 {
 }
		private static JurisdictionGroup InitializeItem(JurisdictionGroup item, IEnumerable<ImportItem> systemValues)
		{
			if (item == null)
				item = new OrderEntityFactory().CreateEntity<JurisdictionGroup>();
			var itemProperties = item.GetType().GetProperties();
			systemValues.ToList().ForEach(x => SetPropertyValue(item, itemProperties.FirstOrDefault(y => y.Name == x.Name), x.Value));

			return item;
		}
 public CreateJurisdictionGroupViewModel(IViewModelsFactory<IJurisdictionGroupOverviewStepViewModel> vmFactory, JurisdictionTypes jurisdictionType, JurisdictionGroup item)
 {
     RegisterStep(vmFactory.GetViewModelInstance(
         new KeyValuePair<string, object>("item", item)
         , new KeyValuePair<string, object>("jurisdictionType", jurisdictionType)));
 }