private static void WriteRecordFormat3(TextWriter writer, string type, int line, TaxCategory tc, string payee, decimal total) { // Example: // TD // N287 // C1 // L1 // $120.00 // PBank of America writer.WriteLine(type); writer.WriteLine("N" + tc.RefNum); writer.WriteLine("C1"); // copy 1 of this value writer.WriteLine("L" + line); // line 1 of this value string sign = ""; if (tc.DefaultSign == -1 && total > 0) { sign = "+"; } writer.WriteLine("$" + sign + Round(tc.DefaultSign > 0, total)); if (type == "TD") { writer.WriteLine("X" + payee); } else { writer.WriteLine("P" + payee); } writer.WriteLine("^"); // end of record }
public override int GetHashCode() { int hash = 1; if (entityId_ != null) { hash ^= EntityId.GetHashCode(); } if (Status != 0) { hash ^= Status.GetHashCode(); } if (TaxExempt != false) { hash ^= TaxExempt.GetHashCode(); } if (TaxId.Length != 0) { hash ^= TaxId.GetHashCode(); } if (GroupPaysLodging != false) { hash ^= GroupPaysLodging.GetHashCode(); } if (GroupPaysIncidentals != false) { hash ^= GroupPaysIncidentals.GetHashCode(); } if (AdditionalNotes.Length != 0) { hash ^= AdditionalNotes.GetHashCode(); } if (CustomerBookingId.Length != 0) { hash ^= CustomerBookingId.GetHashCode(); } if (dateRange_ != null) { hash ^= DateRange.GetHashCode(); } if (rateSchedule_ != null) { hash ^= RateSchedule.GetHashCode(); } if (group_ != null) { hash ^= Group.GetHashCode(); } if (confirmationTemplateId_ != null) { hash ^= ConfirmationTemplateId.GetHashCode(); } if (bookingMethod_ != null) { hash ^= BookingMethod.GetHashCode(); } if (arrivalTemplateId_ != null) { hash ^= ArrivalTemplateId.GetHashCode(); } if (reservationSourceId_ != null) { hash ^= ReservationSourceId.GetHashCode(); } if (travelAgent_ != null) { hash ^= TravelAgent.GetHashCode(); } if (cancellationPolicy_ != null) { hash ^= CancellationPolicy.GetHashCode(); } if (GroupName.Length != 0) { hash ^= GroupName.GetHashCode(); } if (SurpressRateInfo != false) { hash ^= SurpressRateInfo.GetHashCode(); } if (TaxCategory.Length != 0) { hash ^= TaxCategory.GetHashCode(); } if (bookingProperty_ != null) { hash ^= BookingProperty.GetHashCode(); } return(hash); }
/// <summary> /// Import products from XLSX file /// </summary> /// <param name="stream">Stream</param> public virtual void MigrateProductsFromXlsx(Stream stream) { using (var xlPackage = new ExcelPackage(stream)) { // get the first worksheet in the workbook var worksheet = xlPackage.Workbook.Worksheets.FirstOrDefault(); if (worksheet == null) { throw new NopException("No worksheet found"); } var metadata = PrepareImportProductDataForMigration(worksheet); if (_catalogSettings.ExportImportSplitProductsFile && metadata.CountProductsInFile > _catalogSettings.ExportImportProductsCountInOneFile) { MigrateProductsFromSplitedXlsx(worksheet, metadata); return; } //performance optimization, load all categories in one SQL request IList <Category> allCategoryList = _categoryService.GetAllCategories(showHidden: true, loadCacheableCopy: false); //performance optimization, load all manufacturers in one SQL request var allManufacturers = _manufacturerService.GetAllManufacturers(showHidden: true); var specificationAttributesInImport = new List <string> { "Type", "Segment", "Group", "SegmentID", "SubSegment", "Number of units", "Volume (in liter)", "Unit" }; //Specification attributes List <SpecificationAttribute> existingSpecificationAttributes = _specificationAttributeService .GetSpecificationAttributes().ToList(); foreach (string attributeInImport in specificationAttributesInImport) { if (existingSpecificationAttributes.Any(x => x.Name.Equals(attributeInImport))) { continue; } //insert specification attribute var specificationAttribute = new SpecificationAttribute() { Name = attributeInImport, DisplayOrder = 0, }; _specificationAttributeService.InsertSpecificationAttribute(specificationAttribute); //insert specification attribute option var specificationAttributeOption = new SpecificationAttributeOption { SpecificationAttributeId = specificationAttribute.Id, Name = attributeInImport, DisplayOrder = 0, }; _specificationAttributeService.InsertSpecificationAttributeOption(specificationAttributeOption); //update the existing specification attributes existingSpecificationAttributes.Add(specificationAttribute); } //tier price customer role mapping List <CustomerRole> allB2BRoles = _customerService.GetAllCustomerRoles() .Where(x => x.SystemName.Contains("B2BLevel-")).ToList(); var tierPriceDictionary = new Dictionary <string, string>() { { "B2BLevel-1", "SellingPrice1" }, { "B2BLevel-2", "SellingPrice2" }, { "B2BLevel-3", "SellingPrice3" }, { "B2BLevel-4", "SellingPrice4" }, { "B2BLevel-5", "SellingPrice5" }, { "B2BLevel-6", "SellingPrice6" }, { "B2BLevel-7", "SellingPrice7" }, { "B2BLevel-8", "SellingPrice8" }, { "B2BLevel-9", "SellingPrice9" }, }; //tax category IList <TaxCategory> allTaxCategories = _taxCategoryService.GetAllTaxCategories(); string taxCategoryPrefix = "Drinks {0}%"; //todo product pictures ////product to import images //var productPictureMetadata = new List<ProductPictureMetadata>(); Product lastLoadedProduct = null; //common value preparation int simpleTemplateId = _productTemplateService.GetAllProductTemplates() .First(x => x.Name == "Simple product").Id; for (var iRow = 2; iRow < metadata.EndRow; iRow++) { metadata.Manager.ReadFromXlsx(worksheet, iRow); var product = new Product(); //base value from excel foreach (var property in metadata.Manager.GetProperties) { switch (property.PropertyName) { case "Name": product.Name = property.StringValue; break; case "ArtikelID": product.Sku = property.StringValue; break; case "SellingPrice0": product.Price = property.DecimalValue; break; case "Exise": product.AdminComment = $"Exise: {property.StringValue}"; break; case "Price Refundable packaging": product.RefundablePrice = property.DecimalValue; break; } } //the product already exist in the system no need to process further if (_productService.GetProductBySku(product.Sku) != null) { continue; } //default values product.CreatedOnUtc = DateTime.UtcNow; product.UpdatedOnUtc = DateTime.UtcNow; product.ProductType = ProductType.SimpleProduct; product.ParentGroupedProductId = 0; product.VisibleIndividually = true; product.ProductTemplateId = simpleTemplateId; product.AllowCustomerReviews = true; product.Published = true; product.IsShipEnabled = true; product.StockQuantity = 1000; product.NotifyAdminForQuantityBelow = 1; product.OrderMinimumQuantity = 1; product.OrderMaximumQuantity = int.MaxValue - 1; product.ManageInventoryMethod = ManageInventoryMethod.ManageStock; product.BackorderMode = BackorderMode.NoBackorders; //disable shipping by default product.IsShipEnabled = false; //tax var taxProperty = metadata.Manager.GetProperty("Percent VAT"); if (taxProperty != null && !string.IsNullOrWhiteSpace(taxProperty.StringValue)) { var taxPercent = taxProperty.DecimalValue; string taxCategoryName = string.Format(taxCategoryPrefix, taxPercent); var taxCategory = allTaxCategories.FirstOrDefault(x => x.Name.Equals(taxCategoryName)); if (taxCategory == null) { taxCategory = new TaxCategory { Name = taxCategoryName, }; _taxCategoryService.InsertTaxCategory(taxCategory); allTaxCategories.Add(taxCategory); } product.TaxCategoryId = taxCategory.Id; } //Insert the product _productService.InsertProduct(product); //quantity change history _productService.AddStockQuantityHistoryEntry(product, product.StockQuantity, product.StockQuantity, product.WarehouseId, _localizationService.GetResource("Admin.StockQuantityHistory.Messages.ImportProduct.Edit")); //search engine name var seName = _urlRecordService.GetSeName(product, 0); _urlRecordService.SaveSlug(product, _urlRecordService.ValidateSeName(product, seName, product.Name, true), 0); //categories var tempProperty = metadata.Manager.GetProperty("Brand"); if (tempProperty != null && !string.IsNullOrWhiteSpace(tempProperty.StringValue)) { var categoryName = tempProperty.StringValue.Trim(); int parentCategoryId = 0; //great grand parent category tempProperty = metadata.Manager.GetProperty("Group"); var greatGrandParentName = tempProperty.StringValue.Trim(); var greatGrandParent = allCategoryList .FirstOrDefault(x => x.Name.Equals(greatGrandParentName) && x.ParentCategoryId == parentCategoryId); if (greatGrandParent == null) { var category = CreateCategoryAndSlug(greatGrandParentName, parentCategoryId); //Update existing list and parent category id allCategoryList.Add(category); parentCategoryId = category.Id; } else { parentCategoryId = greatGrandParent.Id; } //grand parent category tempProperty = metadata.Manager.GetProperty("SegmentID"); var grandParentName = tempProperty.StringValue.Trim(); var grandParent = allCategoryList.FirstOrDefault(x => x.Name.Equals(grandParentName) && x.ParentCategoryId == parentCategoryId); if (grandParent == null) { var category = CreateCategoryAndSlug(grandParentName, parentCategoryId); // Update existing list and parent category id allCategoryList.Add(category); parentCategoryId = category.Id; } else { parentCategoryId = grandParent.Id; } //parent category tempProperty = metadata.Manager.GetProperty("SubSegment"); var parentName = tempProperty.StringValue.Trim(); var parent = allCategoryList.FirstOrDefault(x => x.Name.Equals(parentName) && x.ParentCategoryId == parentCategoryId); if (parent == null && !string.IsNullOrWhiteSpace(parentName)) { var category = CreateCategoryAndSlug(parentName, parentCategoryId); // Update existing list and parent category id allCategoryList.Add(category); parentCategoryId = category.Id; } else if (parent != null) { parentCategoryId = parent.Id; } int?rez = allCategoryList.FirstOrDefault(x => x.Name.Equals(categoryName) && x.ParentCategoryId == parentCategoryId)?.Id; //categories does not exist. Insert new category if (rez == null) { var category = CreateCategoryAndSlug(categoryName, parentCategoryId); rez = category.Id; allCategoryList.Add(category); } //insert product category mapping var productCategory = new ProductCategory { ProductId = product.Id, CategoryId = rez.Value, IsFeaturedProduct = false, DisplayOrder = 1 }; _categoryService.InsertProductCategory(productCategory); } //manufacturer tempProperty = metadata.Manager.GetProperty("Producer Name"); if (tempProperty != null && !string.IsNullOrWhiteSpace(tempProperty.StringValue)) { var manufacturerName = tempProperty.StringValue.Trim(); //manufacturer mappings var manufacturer = allManufacturers.FirstOrDefault(x => x.Name == manufacturerName); //manufacturer does not exist. Insert the new manufacturer if (manufacturer == null) { manufacturer = new Manufacturer { Name = manufacturerName, Published = true, DisplayOrder = 0, AllowCustomersToSelectPageSize = true, PageSizeOptions = "6,3,9" }; //save manufacturer and search engine name _manufacturerService.InsertManufacturer(manufacturer); string manufacturerSeName = _urlRecordService.ValidateSeName(manufacturer, "", manufacturer.Name, true); _urlRecordService.SaveSlug(manufacturer, manufacturerSeName, 0); allManufacturers.Add(manufacturer); } //Insert product manufacturer mapping var productManufacturer = new ProductManufacturer { ProductId = product.Id, ManufacturerId = manufacturer.Id, IsFeaturedProduct = false, DisplayOrder = 1 }; _manufacturerService.InsertProductManufacturer(productManufacturer); } //Tier prices foreach (KeyValuePair <string, string> b2BRole in tierPriceDictionary) { tempProperty = metadata.Manager.GetProperty(b2BRole.Value); var price = tempProperty.DecimalValueNullable; if (!price.HasValue || price.Value <= 0) { continue; } _productService.InsertTierPrice(new TierPrice { CustomerRole = allB2BRoles.First(x => x.SystemName.Equals(b2BRole.Key)), Price = price.Value, ProductId = product.Id, Quantity = 0 }); } //Specification attribute foreach (var specAttribute in specificationAttributesInImport) { tempProperty = metadata.Manager.GetProperty(specAttribute); string specAttributeValue = tempProperty.StringValue.Trim(); if (specAttributeValue.IsNullOrWhiteSpace()) { continue; } _specificationAttributeService.InsertProductSpecificationAttribute(new ProductSpecificationAttribute { ProductId = product.Id, AttributeType = SpecificationAttributeType.CustomText, SpecificationAttributeOption = existingSpecificationAttributes. First(x => x.Name.Contains(specAttribute)).SpecificationAttributeOptions.First(), CustomValue = specAttributeValue, AllowFiltering = false, ShowOnProductPage = true, DisplayOrder = 0, }); } //todo import with picture //var picture1 = DownloadFile(metadata.Manager.GetProperty("Picture1")?.StringValue, downloadedFiles); //var picture2 = DownloadFile(metadata.Manager.GetProperty("Picture2")?.StringValue, downloadedFiles); //var picture3 = DownloadFile(metadata.Manager.GetProperty("Picture3")?.StringValue, downloadedFiles); //productPictureMetadata.Add(new ProductPictureMetadata //{ // ProductItem = product, // Picture1Path = picture1, // Picture2Path = picture2, // Picture3Path = picture3, // IsNew = true //}); lastLoadedProduct = product; //update "HasTierPrices" and "HasDiscountsApplied" properties //_productService.UpdateHasTierPricesProperty(product); //_productService.UpdateHasDiscountsApplied(product); } //if (_mediaSettings.ImportProductImagesUsingHash && _pictureService.StoreInDb && _dataProvider.SupportedLengthOfBinaryHash > 0) // ImportProductImagesUsingHash(productPictureMetadata, allProductsBySku); //else // ImportProductImagesUsingServices(productPictureMetadata); //activity log _customerActivityService.InsertActivity("ImportProducts", string.Format(_localizationService.GetResource("ActivityLog.ImportProducts"), metadata.CountProductsInFile)); } }
/// <summary> /// Inserts a tax category /// </summary> /// <param name="taxCategory">Tax category</param> public virtual void InsertTaxCategory(TaxCategory taxCategory) { _taxCategoryRepository.Insert(taxCategory); }
public static TaxCategoryModel ToModel(this TaxCategory entity) { return(Mapper.Map <TaxCategory, TaxCategoryModel>(entity)); }
public static ProductDraft DefaultProductDraftWithTaxCategory(ProductDraft draft, TaxCategory taxCategory) { var productDraft = DefaultProductDraft(draft); productDraft.TaxCategory = taxCategory.ToKeyResourceIdentifier(); return(productDraft); }
public static OrderImportDraft DefaultOrderImportDraftWithLineItemWithShippingInfo(OrderImportDraft draft, string productId, TaxCategory taxCategory, ShippingMethod shippingMethod) { var orderImportDraft = DefaultOrderImportDraftWithLineItemByProductId(draft, productId); var amountEuro10 = Money.FromDecimal("EUR", 10); var shippingRate = TestingUtility.GetShippingRate(); var shippingInfoImportDraft = new ShippingInfoImportDraft { Price = amountEuro10, ShippingRate = shippingRate, ShippingMethodName = shippingMethod.Name, ShippingMethod = shippingMethod.ToKeyResourceIdentifier(), TaxCategory = taxCategory.ToKeyResourceIdentifier() }; orderImportDraft.ShippingInfo = shippingInfoImportDraft; return(orderImportDraft); }
/// <summary> /// Creates a test shipping method draft. /// </summary> /// <returns>ShippingMethodDraft</returns> public static ShippingMethodDraft GetTestShippingMethodDraft(Project.Project project, TaxCategory taxCategory, Zone zone) { Reference taxCategoryReference = new Reference(); taxCategoryReference.Id = taxCategory.Id; taxCategoryReference.ReferenceType = Common.ReferenceType.TaxCategory; string name = string.Concat("Test Shipping Method ", Helper.GetRandomString(10)); string key = Helper.GetRandomString(10); ZoneRate zoneRate = Helper.GetTestZoneRate(project, zone); ShippingMethodDraft shippingMethodDraft = new ShippingMethodDraft(name, taxCategoryReference, new List <ZoneRate>() { zoneRate }); shippingMethodDraft.Description = "Created by commercetools.NET"; shippingMethodDraft.Key = key; return(shippingMethodDraft); }
public IActionResult ImportTaxCodes() { //ensure that Avalara tax provider is active if (!_taxPluginManager.IsPluginActive(AvalaraTaxDefaults.SystemName)) { return(Categories()); } if (!_permissionService.Authorize(StandardPermissionProvider.ManageTaxSettings)) { return(AccessDeniedView()); } //get Avalara pre-defined system tax codes (only active) var systemTaxCodes = _avalaraTaxManager.GetSystemTaxCodes(true); if (!systemTaxCodes?.Any() ?? true) { _notificationService.ErrorNotification(_localizationService.GetResource("Plugins.Tax.Avalara.TaxCodes.Import.Error")); return(Categories()); } //get existing tax categories var existingTaxCategories = _taxCategoryService.GetAllTaxCategories().Select(taxCategory => taxCategory.Name).ToList(); //remove duplicates var taxCodesToImport = systemTaxCodes.Where(taxCode => !existingTaxCategories.Contains(taxCode.taxCode)).ToList(); var importedTaxCodesNumber = 0; foreach (var taxCode in taxCodesToImport) { if (string.IsNullOrEmpty(taxCode?.taxCode)) { continue; } //create new tax category var taxCategory = new TaxCategory { Name = taxCode.taxCode }; _taxCategoryService.InsertTaxCategory(taxCategory); //save description and type if (!string.IsNullOrEmpty(taxCode.description)) { _genericAttributeService.SaveAttribute(taxCategory, AvalaraTaxDefaults.TaxCodeDescriptionAttribute, taxCode.description); } if (!string.IsNullOrEmpty(taxCode.taxCodeTypeId)) { _genericAttributeService.SaveAttribute(taxCategory, AvalaraTaxDefaults.TaxCodeTypeAttribute, taxCode.taxCodeTypeId); } importedTaxCodesNumber++; } //successfully imported var successMessage = _localizationService.GetResource("Plugins.Tax.Avalara.TaxCodes.Import.Success"); _notificationService.SuccessNotification(string.Format(successMessage, importedTaxCodesNumber)); return(Categories()); }
public static OrderImportDraft DefaultOrderImportDraftWithCustomLineItem(OrderImportDraft draft, TaxCategory taxCategory) { var orderImportDraft = DefaultOrderImportDraft(draft); var customLineItemDraft = new CustomLineItemDraft { Name = new LocalizedString() { { "en", TestingUtility.RandomString(10) } }, Slug = TestingUtility.RandomString(10), Quantity = TestingUtility.RandomInt(1, 10), Money = Money.FromDecimal("EUR", TestingUtility.RandomInt(100, 10000)), TaxCategory = taxCategory.ToKeyResourceIdentifier() }; orderImportDraft.CustomLineItems = new List <CustomLineItemDraft> { customLineItemDraft }; return(orderImportDraft); }
/// <summary> /// Updates the tax category /// </summary> /// <param name="taxCategory">Tax category</param> public virtual async Task UpdateTaxCategoryAsync(TaxCategory taxCategory) { await _taxCategoryRepository.UpdateAsync(taxCategory); }
/// <summary> /// Inserts a tax category /// </summary> /// <param name="taxCategory">Tax category</param> public virtual async Task InsertTaxCategoryAsync(TaxCategory taxCategory) { await _taxCategoryRepository.InsertAsync(taxCategory); }
/// <summary> /// Updates the tax category /// </summary> /// <param name="taxCategory">Tax category</param> public virtual void UpdateTaxCategory(TaxCategory taxCategory) { _taxCategoryRepository.Update(taxCategory); }
public void Init() { _client = new Client(Helper.GetConfiguration()); Task <Response <Project.Project> > projectTask = _client.Project().GetProjectAsync(); projectTask.Wait(); Assert.IsTrue(projectTask.Result.Success); _project = projectTask.Result.Result; _testCustomers = new List <Customer>(); for (int i = 0; i < 5; i++) { CustomerDraft customerDraft = Helper.GetTestCustomerDraft(); Task <Response <CustomerCreatedMessage> > customerTask = _client.Customers().CreateCustomerAsync(customerDraft); customerTask.Wait(); Assert.IsTrue(customerTask.Result.Success); CustomerCreatedMessage customerCreatedMessage = customerTask.Result.Result; Assert.NotNull(customerCreatedMessage.Customer); Assert.NotNull(customerCreatedMessage.Customer.Id); _testCustomers.Add(customerCreatedMessage.Customer); } _testCarts = new List <Cart>(); Task <Response <Cart> > cartTask; for (int i = 0; i < 5; i++) { CartDraft cartDraft = Helper.GetTestCartDraft(_project, _testCustomers[i].Id); cartTask = _client.Carts().CreateCartAsync(cartDraft); cartTask.Wait(); Assert.IsTrue(cartTask.Result.Success); Cart cart = cartTask.Result.Result; Assert.NotNull(cart.Id); _testCarts.Add(cart); } ProductTypeDraft productTypeDraft = Helper.GetTestProductTypeDraft(); Task <Response <ProductType> > productTypeTask = _client.ProductTypes().CreateProductTypeAsync(productTypeDraft); productTypeTask.Wait(); Assert.IsTrue(productTypeTask.Result.Success); _testProductType = productTypeTask.Result.Result; Assert.NotNull(_testProductType.Id); TaxCategoryDraft taxCategoryDraft = Helper.GetTestTaxCategoryDraft(_project); Task <Response <TaxCategory> > taxCategoryTask = _client.TaxCategories().CreateTaxCategoryAsync(taxCategoryDraft); taxCategoryTask.Wait(); Assert.IsTrue(taxCategoryTask.Result.Success); _testTaxCategory = taxCategoryTask.Result.Result; Assert.NotNull(_testTaxCategory.Id); Task <Response <ZoneQueryResult> > zoneQueryResultTask = _client.Zones().QueryZonesAsync(); zoneQueryResultTask.Wait(); if (zoneQueryResultTask.Result.Success && zoneQueryResultTask.Result.Result.Results.Count > 0) { _testZone = zoneQueryResultTask.Result.Result.Results[0]; _createdTestZone = false; } else { ZoneDraft zoneDraft = Helper.GetTestZoneDraft(); Task <Response <Zone> > zoneTask = _client.Zones().CreateZoneAsync(zoneDraft); zoneTask.Wait(); Assert.IsTrue(zoneTask.Result.Success); _testZone = zoneTask.Result.Result; _createdTestZone = true; } Assert.NotNull(_testZone.Id); ShippingMethodDraft shippingMethodDraft = Helper.GetTestShippingMethodDraft(_project, _testTaxCategory, _testZone); Task <Response <ShippingMethod> > shippingMethodTask = _client.ShippingMethods().CreateShippingMethodAsync(shippingMethodDraft); shippingMethodTask.Wait(); Assert.IsTrue(shippingMethodTask.Result.Success); _testShippingMethod = shippingMethodTask.Result.Result; Assert.NotNull(_testShippingMethod.Id); ProductDraft productDraft = Helper.GetTestProductDraft(_project, _testProductType.Id, _testTaxCategory.Id); Task <Response <Product> > productTask = _client.Products().CreateProductAsync(productDraft); productTask.Wait(); Assert.IsTrue(productTask.Result.Success); _testProduct = productTask.Result.Result; Assert.NotNull(_testProduct.Id); int quantity = 1; AddLineItemAction addLineItemAction = new AddLineItemAction(_testProduct.Id, _testProduct.MasterData.Current.MasterVariant.Id); addLineItemAction.Quantity = quantity; cartTask = _client.Carts().UpdateCartAsync(_testCarts[0], addLineItemAction); cartTask.Wait(); Assert.IsTrue(cartTask.Result.Success); _testCarts[0] = cartTask.Result.Result; Assert.NotNull(_testCarts[0].Id); Assert.NotNull(_testCarts[0].LineItems); Assert.AreEqual(_testCarts[0].LineItems.Count, 1); Assert.AreEqual(_testCarts[0].LineItems[0].ProductId, _testProduct.Id); Assert.AreEqual(_testCarts[0].LineItems[0].Variant.Id, _testProduct.MasterData.Current.MasterVariant.Id); Assert.AreEqual(_testCarts[0].LineItems[0].Quantity, quantity); OrderFromCartDraft orderFromCartDraft = Helper.GetTestOrderFromCartDraft(_testCarts[0]); Task <Response <Order> > orderTask = _client.Orders().CreateOrderFromCartAsync(orderFromCartDraft); orderTask.Wait(); Assert.IsTrue(orderTask.Result.Success); _testOrder = orderTask.Result.Result; Assert.NotNull(_testOrder.Id); cartTask = _client.Carts().GetCartByIdAsync(_testCarts[0].Id); cartTask.Wait(); Assert.IsTrue(cartTask.Result.Success); _testCarts[0] = cartTask.Result.Result; Assert.NotNull(_testCarts[0].Id); }
/// <summary> /// Deletes a tax category /// </summary> /// <param name="taxCategory">Tax category</param> public void DeleteTaxCategory([FromBody] TaxCategory taxCategory) { _taxCategoryService.DeleteTaxCategory(taxCategory); }
public static TaxCategory ToEntity(this TaxCategoryModel model, TaxCategory entity) { MapperFactory.Map(model, entity); return(entity); }
/// <summary> /// Inserts a tax category /// </summary> /// <param name="taxCategory">Tax category</param> public void InsertTaxCategory([FromBody] TaxCategory taxCategory) { _taxCategoryService.InsertTaxCategory(taxCategory); }
public void Init() { _client = new Client(Helper.GetConfiguration()); Task <Response <Project.Project> > projectTask = _client.Project().GetProjectAsync(); projectTask.Wait(); Assert.IsTrue(projectTask.Result.Success); _project = projectTask.Result.Result; Assert.IsTrue(_project.Languages.Count > 0, "No Languages"); Assert.IsTrue(_project.Currencies.Count > 0, "No Currencies"); _testCustomers = new List <Customer>(); _testCarts = new List <Cart>(); CustomerDraft customerDraft; Task <Response <CustomerCreatedMessage> > customerTask; CustomerCreatedMessage customerCreatedMessage; CartDraft cartDraft; Cart cart; Task <Response <Cart> > cartTask; for (int i = 0; i < 5; i++) { customerDraft = Helper.GetTestCustomerDraft(); customerTask = _client.Customers().CreateCustomerAsync(customerDraft); customerTask.Wait(); Assert.IsTrue(customerTask.Result.Success); customerCreatedMessage = customerTask.Result.Result; Assert.NotNull(customerCreatedMessage.Customer); Assert.NotNull(customerCreatedMessage.Customer.Id); _testCustomers.Add(customerCreatedMessage.Customer); cartDraft = Helper.GetTestCartDraft(_project, customerCreatedMessage.Customer.Id); cartTask = _client.Carts().CreateCartAsync(cartDraft); cartTask.Wait(); Assert.NotNull(cartTask.Result); Assert.IsTrue(cartTask.Result.Success, "CreateCartAsync failed"); cart = cartTask.Result.Result; Assert.NotNull(cart.Id); Console.Error.WriteLine(string.Format("CartManagerTest - Information Only - Init TestCartDraft TaxMode: {0}", cartDraft.TaxMode == null ? "(default)" : cart.TaxMode.ToString())); _testCarts.Add(cart); } //customer/cart with external tax mode enabled customerDraft = Helper.GetTestCustomerDraft(); customerTask = _client.Customers().CreateCustomerAsync(customerDraft); customerTask.Wait(); Assert.IsTrue(customerTask.Result.Success); customerCreatedMessage = customerTask.Result.Result; Assert.NotNull(customerCreatedMessage.Customer); Assert.NotNull(customerCreatedMessage.Customer.Id); _testCustomers.Add(customerCreatedMessage.Customer); cartDraft = Helper.GetTestCartDraftUsingExternalTaxMode(_project, customerCreatedMessage.Customer.Id); cartTask = _client.Carts().CreateCartAsync(cartDraft); cartTask.Wait(); Assert.NotNull(cartTask.Result); Assert.IsTrue(cartTask.Result.Success, "CreateCartAsync failed"); cart = cartTask.Result.Result; Assert.NotNull(cart.Id); Console.Error.WriteLine(string.Format("CartManagerTest - Information Only - Init TestCartDraft TaxMode: {0}", cart.TaxMode)); _testCarts.Add(cart); ProductTypeDraft productTypeDraft = Helper.GetTestProductTypeDraft(); Task <Response <ProductType> > testProductTypeTask = _client.ProductTypes().CreateProductTypeAsync(productTypeDraft); testProductTypeTask.Wait(); Assert.IsTrue(testProductTypeTask.Result.Success, "CreateProductType failed"); _testProductType = testProductTypeTask.Result.Result; Assert.NotNull(_testProductType.Id); TaxCategoryDraft taxCategoryDraft = Helper.GetTestTaxCategoryDraft(_project); Task <Response <TaxCategory> > taxCategoryTask = _client.TaxCategories().CreateTaxCategoryAsync(taxCategoryDraft); taxCategoryTask.Wait(); Assert.IsTrue(taxCategoryTask.Result.Success, "CreateTaxCategory failed"); _testTaxCategory = taxCategoryTask.Result.Result; Assert.NotNull(_testTaxCategory.Id); Task <Response <ZoneQueryResult> > zoneQueryResultTask = _client.Zones().QueryZonesAsync(); zoneQueryResultTask.Wait(); Assert.IsTrue(zoneQueryResultTask.Result.Success); if (zoneQueryResultTask.Result.Result.Results.Count > 0) { _testZone = zoneQueryResultTask.Result.Result.Results[0]; _createdTestZone = false; } else { ZoneDraft zoneDraft = Helper.GetTestZoneDraft(); Task <Response <Zone> > zoneTask = _client.Zones().CreateZoneAsync(zoneDraft); zoneTask.Wait(); Assert.IsTrue(zoneTask.Result.Success, "CreateZone failed"); _testZone = zoneTask.Result.Result; _createdTestZone = true; } Assert.NotNull(_testZone.Id); foreach (string country in _project.Countries) { Location location = _testZone.Locations .Where(l => l.Country.Equals(country, StringComparison.OrdinalIgnoreCase)) .FirstOrDefault(); if (location == null) { location = new Location(); location.Country = country; AddLocationAction addLocationAction = new AddLocationAction(location); Task <Response <Zone> > updateZoneTask = _client.Zones().UpdateZoneAsync(_testZone, addLocationAction); updateZoneTask.Wait(); Assert.IsTrue(updateZoneTask.Result.Success, "UpdateZone failed"); _testZone = updateZoneTask.Result.Result; } } Assert.NotNull(_testZone.Locations.Count > 0); ShippingMethodDraft shippingMethodDraft = Helper.GetTestShippingMethodDraft(_project, _testTaxCategory, _testZone); Task <Response <ShippingMethod> > shippingMethodTask = _client.ShippingMethods().CreateShippingMethodAsync(shippingMethodDraft); shippingMethodTask.Wait(); Assert.IsTrue(shippingMethodTask.Result.Success, "CreateShippingMethod failed"); _testShippingMethod = shippingMethodTask.Result.Result; Assert.NotNull(_testShippingMethod.Id); ProductDraft productDraft = Helper.GetTestProductDraft(_project, _testProductType.Id, _testTaxCategory.Id); Task <Response <Product> > testProductTask = _client.Products().CreateProductAsync(productDraft); testProductTask.Wait(); Assert.IsTrue(testProductTask.Result.Success, "CreateProduct failed"); _testProduct = testProductTask.Result.Result; Assert.NotNull(_testProduct.Id); PaymentDraft paymentDraft = Helper.GetTestPaymentDraft(_project, _testCustomers[0].Id); Task <Response <Payment> > paymentTask = _client.Payments().CreatePaymentAsync(paymentDraft); paymentTask.Wait(); Assert.IsTrue(paymentTask.Result.Success, "CreatePayment failed"); _testPayment = paymentTask.Result.Result; Assert.NotNull(_testPayment.Id); TypeDraft typeDraft = Helper.GetTypeDraft(_project); Task <Response <Type> > typeTask = _client.Types().CreateTypeAsync(typeDraft); typeTask.Wait(); Assert.IsTrue(typeTask.Result.Success, "CreateType failed"); _testType = typeTask.Result.Result; }
/// <summary> /// Updates the tax category /// </summary> /// <param name="taxCategory">Tax category</param> public void UpdateTaxCategory([FromBody] TaxCategory taxCategory) { _taxCategoryService.UpdateTaxCategory(taxCategory); }
public static TaxCategory ToEntity(this TaxCategoryModel model, TaxCategory destination) { return(Mapper.Map(model, destination)); }
protected virtual List <TaxTotal> GetTaxesTotales(XDocument xdoc) { var taxes = xdoc.Root.Elements().Where(e => e.Name.LocalName == "TaxTotal").ToArray(); List <TaxTotal> _taxesTotales = new List <TaxTotal>(); bool error = false; foreach (var tax in taxes) { List <TaxSubtotal> _subtotals = new List <TaxSubtotal>(); string _taxAmount = string.Empty; var subtotals = tax.Elements().Where(e => e.Name.LocalName == "TaxSubtotal").ToArray(); foreach (var subtotal in subtotals) { //TaxCategory _categories string _schemeId = string.Empty; string _percent = string.Empty; var category = subtotal.Elements().Where(e => e.Name.LocalName == "TaxCategory").SingleOrDefault(); if (category == null) { error = true; break; } var schemeId = category.Elements().Where(e => e.Name.LocalName == "TaxScheme").SingleOrDefault()? .Elements().Where(e => e.Name.LocalName == "ID").SingleOrDefault(); if (schemeId == null || schemeId.Value == string.Empty) { error = true; break; } var percent = subtotal.Elements().Where(e => e.Name.LocalName == "Percent").SingleOrDefault(); if (percent == null || percent.Value == string.Empty) { error = true; break; } _schemeId = schemeId.Value; _percent = percent.Value; TaxCategory c = new TaxCategory { SchemeID = _schemeId, Percent = _percent }; string _subtotalTaxAmount = string.Empty; var subTotaltaxAmount = subtotal.Elements().Where(e => e.Name.LocalName == "TaxAmount").SingleOrDefault(); if (subTotaltaxAmount == null || subTotaltaxAmount.Value == string.Empty) { error = true; break; } _subtotalTaxAmount = subTotaltaxAmount.Value; TaxSubtotal s = new TaxSubtotal { TaxCategory = c, TaxAmount = _subtotalTaxAmount }; _subtotals.Add(s); } if (error) { break; } var taxAmount = tax.Elements().Where(e => e.Name.LocalName == "TaxAmount").SingleOrDefault(); if (taxAmount == null || taxAmount.Value == string.Empty) { error = true; break; } _taxAmount = taxAmount.Value; TaxTotal t = new TaxTotal { TaxesSubtotals = _subtotals, TaxAmount = _taxAmount }; _taxesTotales.Add(t); } if (error) { _taxesTotales.Clear(); } return(_taxesTotales); //TaxesTotales = new List<TaxTotal>(_taxesTotales); }
public static TaxCategory ToEntity(this TaxCategoryModel model, TaxCategory destination) { return(model.MapTo(destination)); }
public CreateTaxCategoryViewModel(IViewModelsFactory <ITaxCategoryOverviewStepViewModel> overviewVmFactory, TaxCategory item) { var parameters = new[] { new KeyValuePair <string, object>("item", item), new KeyValuePair <string, object>("isWizardMode", true) }; RegisterStep(overviewVmFactory.GetViewModelInstance(parameters)); }
public static TaxCategoryModel ToModel(this TaxCategory entity) { return(entity.MapTo <TaxCategory, TaxCategoryModel>()); }
/// <summary> /// Deletes a tax category /// </summary> /// <param name="taxCategory">Tax category</param> public virtual void DeleteTaxCategory(TaxCategory taxCategory) { _taxCategoryRepository.Delete(taxCategory); }