/// <summary> /// Preloads uniSelector and selects actual data. /// </summary> protected void PreloadUniSelector(bool offerGlobalProducts) { // Get the active products var products = SKUInfoProvider.GetSKUs().Column("SKUID") .WhereIn("SKUID", SKUTaxClassInfoProvider.GetSKUTaxClasses().Column("SKUID").WhereEquals("TaxClassID", mTaxClassId)) .WhereNull("SKUOptionCategoryID"); // Ordinary user can see only product from departments he can access if (!cu.IsGlobalAdministrator && !cu.IsAuthorizedPerResource(ModuleName.ECOMMERCE, EcommercePermissions.PRODUCTS_ACCESSALLDEPARTMENTS)) { products.Where(new WhereCondition().WhereNull("SKUDepartmentID") .Or() .WhereIn("SKUDepartmentID", UserDepartmentInfoProvider.GetUserDepartments().Column("DepartmentID").WhereEquals("UserID", cu.UserID))); } // Restrict site var includeGlobal = offerGlobalProducts && (cu.IsGlobalAdministrator || cu.IsAuthorizedPerResource(ModuleName.ECOMMERCE, EcommercePermissions.ECOMMERCE_MODIFYGLOBAL)); products.OnSite(mCurrentSiteId, includeGlobal); if (!DataHelper.DataSourceIsEmpty(products)) { mCurrentValues = TextHelper.Join(";", DataHelper.GetStringValues(products.Tables[0], "SKUID")); } if (!RequestHelper.IsPostBack()) { uniSelector.Value = mCurrentValues; } }
protected void AddTaxClassToProduct() { // Prepare the parameters // string where = "SKUName LIKE '%%'"; SKUInfo product = null; // Get the product DataSet products = SKUInfoProvider.GetSKUs(null, null); if (!DataHelper.DataSourceIsEmpty(products)) { int nb = products.Tables[0].Rows.Count; for (int i = 0; i < nb; i++) { //product = new SKUInfo(products.Tables[0].Rows[0]); DataRow row = products.Tables[0].Rows[i]; product = new SKUInfo(row); // Get the tax class TaxClassInfo taxClass = TaxClassInfoProvider.GetTaxClassInfo("TVA_EU21", SiteContext.CurrentSiteName); TaxClassInfo taxClass1 = TaxClassInfoProvider.GetTaxClassInfo("VAT", SiteContext.CurrentSiteName); if ((product != null) && (taxClass != null)) { // Add tax class to product SKUTaxClassInfoProvider.AddTaxClassToSKU(taxClass.TaxClassID, product.SKUID); SKUTaxClassInfoProvider.AddTaxClassToSKU(taxClass1.TaxClassID, product.SKUID); } } } }
/// <summary> /// Saves selected items. No permission checks are performed. /// </summary> public void SaveItems() { // Remove old items string newValues = ValidationHelper.GetString(uniSelector.Value, null); string items = DataHelper.GetNewItemsInList(newValues, currentValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); // Add all new items to user foreach (string item in newItems) { int taxClassId = ValidationHelper.GetInteger(item, 0); SKUTaxClassInfoProvider.RemoveTaxClassFromSKU(taxClassId, ProductID); } } // Add new items items = DataHelper.GetNewItemsInList(currentValues, newValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); // Add all new items to user foreach (string item in newItems) { int taxClassId = ValidationHelper.GetInteger(item, 0); SKUTaxClassInfoProvider.AddTaxClassToSKU(taxClassId, ProductID); } } // Show message ShowChangesSaved(); }
protected void uniSelector_OnSelectionChanged(object sender, EventArgs e) { if (mTaxClassInfoObj == null) { return; } // Check permissions if ((cu == null) || (!cu.IsAuthorizedPerResource(ModuleName.ECOMMERCE, EcommercePermissions.ECOMMERCE_MODIFY) && !cu.IsAuthorizedPerResource(ModuleName.ECOMMERCE, EcommercePermissions.PRODUCTS_MODIFY))) { RedirectToAccessDenied(ModuleName.ECOMMERCE, "EcommerceModify OR ModifyProducts"); } else { // Remove old items string newValues = ValidationHelper.GetString(uniSelector.Value, null); string items = DataHelper.GetNewItemsInList(newValues, mCurrentValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); // Remove all old items from tax class foreach (string item in newItems) { int skuId = ValidationHelper.GetInteger(item, 0); SKUTaxClassInfoProvider.RemoveTaxClassFromSKU(mTaxClassId, skuId); } } // Add new items items = DataHelper.GetNewItemsInList(mCurrentValues, newValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); // Add all new items to tax class foreach (string item in newItems) { int skuId = ValidationHelper.GetInteger(item, 0); SKUTaxClassInfoProvider.AddTaxClassToSKU(mTaxClassId, skuId); } } // Show message ShowChangesSaved(); } }
public void PriceCalculatedWithDiscountsAndTaxes(string skuName, double skuPrice, double listPrice, decimal expectedPrice, decimal expectedListPrice, decimal expectedDiscount, decimal expectedtax) { var cart = CreateEmptyShoppingCartWithBillingAddress(); var sku = CreateSKUInfo(skuPrice, listPrice, skuName); SKUTaxClassInfoProvider.AddTaxClassToSKU(Factory.TaxClassDefault.TaxClassID, sku.SKUID); var calculatedPrice = mPricingService.CalculatePrice(sku, cart, true, true); var expectedResult = new ProductPrice { Discount = expectedDiscount, ListPrice = expectedListPrice, Price = expectedPrice, Tax = expectedtax }; AssertPrice(calculatedPrice, expectedResult); }
/// <summary> /// Preloads uniSelector and selects actual data. /// </summary> protected void PreloadUniSelector(bool offerGlobalProducts) { // Get the active products var products = SKUInfoProvider.GetSKUs().Column("SKUID") .WhereIn("SKUID", SKUTaxClassInfoProvider.GetSKUTaxClasses().Column("SKUID").WhereEquals("TaxClassID", mTaxClassId)) .WhereNull("SKUOptionCategoryID"); // Restrict site var includeGlobal = offerGlobalProducts && (cu.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) || cu.IsAuthorizedPerResource(ModuleName.ECOMMERCE, EcommercePermissions.ECOMMERCE_MODIFYGLOBAL)); products.OnSite(mCurrentSiteId, includeGlobal); if (!DataHelper.DataSourceIsEmpty(products)) { mCurrentValues = TextHelper.Join(";", DataHelper.GetStringValues(products.Tables[0], "SKUID")); } if (!RequestHelper.IsPostBack()) { uniSelector.Value = mCurrentValues; } }
protected void RemoveTaxClassFromProduct() { // Prepare the parameters // string where = "SKUName LIKE N'MyNew%'"; SKUInfo product = null; // Get the tax class TaxClassInfo taxClass = TaxClassInfoProvider.GetTaxClassInfo("VAT", SiteContext.CurrentSiteName); // TaxClassInfo taxClass1 = TaxClassInfoProvider.GetTaxClassInfo("VAT", CMSContext.CurrentSiteName); // Get the product DataSet products = SKUInfoProvider.GetSKUs(null, null); if (!DataHelper.DataSourceIsEmpty(products)) { // product = new SKUInfo(products.Tables[0].Rows[0]); // } int nb = products.Tables[0].Rows.Count; for (int i = 0; i < nb; i++) { DataRow row = products.Tables[0].Rows[i]; product = new SKUInfo(row); if ((product != null) && (taxClass != null)) { // Get the tax class added to product SKUTaxClassInfo skuTaxClass = SKUTaxClassInfoProvider.GetSKUTaxClassInfo(taxClass.TaxClassID, product.SKUID); // Remove tax class from product SKUTaxClassInfoProvider.DeleteSKUTaxClassInfo(skuTaxClass); } // } } } }
public void InsertDefaultSKUs() { mFakeFactory.InitSKUs().InsertDB(); SKUTaxClassInfoProvider.AddTaxClassToSKU(mFakeFactory.TaxClassDefault.TaxClassID, mFakeFactory.SKUWithTaxes.SKUID); }