private ICriteria GetByProductCriteria(Product product, PriceGroup priceGroup)
        {
            ICriteria crit = GetCriteria();

            ExecutePermissionValidator epv = new ExecutePermissionValidator();

            epv.ClassType     = typeof(PriceList);
            epv.KeyIdentifier = Config.SeePriceLists;

            if (PermissionManager.Check(epv) == false)
            {
                IList priceListIds    = PermissionManager.GetPermissionIdentifiers(typeof(PriceList), PermissionAction.Create);
                int[] intPriceListIds = new int[priceListIds.Count];
                for (int i = 0; i < priceListIds.Count; i++)
                {
                    intPriceListIds[i] = Convert.ToInt32(priceListIds[i]);
                }

                ICriteria critPriceList = crit.CreateCriteria("PriceGroup").CreateCriteria("PriceLists");
                critPriceList.Add(Expression.In("ID", intPriceListIds));
            }

            crit.CreateCriteria("PriceBase").CreateCriteria("Product").Add(Expression.Eq("ID", product.ID));
            if (priceGroup != null)
            {
                crit.Add(Expression.Eq("PriceGroup", priceGroup));
            }

            return(crit);
        }
Exemple #2
0
            public object Clone()
            {
                var priceGroup = new PriceGroup
                {
                    Id                  = Id,
                    Name                = Name,
                    Description         = Description,
                    Currency            = Currency,
                    DefaultAnalysisBand = (AnalysisBand)this.DefaultAnalysisBand.Clone(),
                    GroupPrices         = new List <Price>()
                };



                foreach (var price in this.GroupPrices)
                {
                    priceGroup.GroupPrices.Add((Price)price.Clone());
                }

                priceGroup.SourceLanguages = new List <Language>();
                foreach (var language in this.SourceLanguages)
                {
                    priceGroup.SourceLanguages.Add((Language)language.Clone());
                }

                priceGroup.TargetLanguages = new List <Language>();
                foreach (var language in this.TargetLanguages)
                {
                    priceGroup.TargetLanguages.Add((Language)language.Clone());
                }


                return(priceGroup);
            }
Exemple #3
0
        public List <PriceGroup> GetPriceGroups(int id = 0)
        {
            using (var cmd = GetCommand("PriceSender_GetPriceGroups"))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.AddParameter("id", id);
                var res = new List <PriceGroup>();

                cmd.ExecuteReader((r, i) =>
                {
                    if (i == 1)
                    {
                        var item = new PriceGroup
                        {
                            Id           = r.GetValue <int>("id"),
                            Name         = r.GetValue <string>("name"),
                            PriceListIds = new List <int>()
                        };
                        res.Add(item);
                    }
                    if (i == 2)
                    {
                        var idItem = r.GetValue <int>("PriceGroupId");
                        var item   = res.FirstOrDefault(x => x.Id == idItem);
                        if (item != null)
                        {
                            item.PriceListIds.Add(r.GetValue <int>("PriceListId"));
                        }
                    }
                });
                return(res);
            }
        }
Exemple #4
0
        public IList <Distributor> GetActivesByPriceGroup(PriceGroup pG, int?maxResults, IList priceListIds)
        {
            ICriteria crit = GetCriteria();

            crit.Add(Expression.Not(Expression.Eq("DistributorStatus", DistributorStatus.Disable)));

            ICriteria critPriceList = crit.CreateCriteria("PriceList");

            if (priceListIds != null)
            {
                int[] intPriceListIds = new int[priceListIds.Count];
                for (int i = 0; i < priceListIds.Count; i++)
                {
                    intPriceListIds[i] = Convert.ToInt32(priceListIds[i]);
                }

                critPriceList.Add(Expression.In("ID", intPriceListIds));
            }

            critPriceList.Add(Expression.Or(Expression.Eq("PriceListStatus", PriceListStatus.Active), Expression.Eq("PriceListStatus", PriceListStatus.New)));
            critPriceList.Add(Expression.Eq("PriceGroup", pG));


            crit.AddOrder(new Order("TimeStamp.CreatedOn", false));
            if (maxResults.HasValue)
            {
                crit.SetMaxResults(maxResults.Value);
            }

            return(crit.List <Distributor>() as IList <Distributor>);
        }
        public IList <Distributor> GetActivesByPriceGroup(PriceGroup pG, int?maxResults)
        {
            //Cache Section
            string cacheKey          = null;
            MembershipHelperUser mhu = MembershipHelper.GetUser();

            if (mhu != null)
            {
                cacheKey = string.Format("DISTRIBUTORS_{0}_{1}_{2}_{3}", mhu.UserId, typeof(Distributor).ToString(), pG.ID, maxResults);
            }

            object result = CacheManager.GetCached(typeof(Distributor), cacheKey);

            if (result == null)
            {
                ExecutePermissionValidator epv = new ExecutePermissionValidator();
                epv.ClassType     = typeof(PriceList);
                epv.KeyIdentifier = Config.SeePriceLists;

                bool  CanSeeAll    = PermissionManager.Check(epv);
                IList priceListIds = null;
                if (!CanSeeAll)
                {
                    priceListIds = PermissionManager.GetPermissionIdentifiers(typeof(PriceList), PermissionAction.Create);
                }

                IList <Distributor> d = repository.GetActivesByPriceGroup(pG, maxResults, priceListIds);

                CacheManager.AddItem(typeof(Distributor), cacheKey, d);
                result = d;
            }
            return(result as IList <Distributor>);
        }
        public void Linq8()
        {
            var productsGroupedByPriceGroup = dataSource.Products.Where(product => product != null)
                                              .GroupBy(product => DefinePriceGroup(product.UnitPrice));

            ObjectDumper.Write(productsGroupedByPriceGroup, 2);

            PriceGroup DefinePriceGroup(decimal price)
            {
                PriceGroup priceGroup = PriceGroup.None;

                if (price < 100)
                {
                    priceGroup = PriceGroup.Cheap;
                }
                else if (price >= 100 && price <= 200)
                {
                    priceGroup = PriceGroup.Medium;
                }
                else if (price > 200)
                {
                    priceGroup = PriceGroup.Expensive;
                }
                return(priceGroup);
            }
        }
Exemple #7
0
 public ExchangeManager()
 {
     _context           = new CubeDbContext(null, false);
     _defaultPriceList  = _context.PriceLists.FirstOrDefault();
     _priceGroups       = _context.PriceGroups.ToDictionary(x => x.Name);
     _defaultPriceGroup = _context.PriceGroups.FirstOrDefault(x => x.IsDefault);
 }
        private ProductCatalog CreateProductCatalog(ProductCatalogGroup catalogGroup)
        {
            var catalogDefinitionType = DefinitionType.SingleOrDefault(x => x.Name == "Product Catalogs");
            var catalogDefinition     = Definition.SingleOrDefault(x => x.DefinitionType == catalogDefinitionType);
            var catalog = catalogGroup.ProductCatalogs.SingleOrDefault(c => c.Name == _catalogName) ??
                          new ProductCatalogFactory().NewWithDefaults(catalogGroup, _catalogName, catalogDefinition.Guid);

            catalog.DisplayOnWebSite       = true;
            catalog.Deleted                = false;
            catalog.ShowPricesIncludingVAT = true;

            // Versions of CatalogFactory prior to 3.6 did not
            // add catalog to catalog group. Need to do it
            // if not already done to make sure roles and
            // permissions are created properly.
            if (!catalogGroup.ProductCatalogs.Contains(catalog))
            {
                catalogGroup.ProductCatalogs.Add(catalog);
            }

            catalog.Save();

            var priceGroup = PriceGroup.SingleOrDefault(p => p.Name == "EUR 15 pct");

            if (priceGroup != null)
            {
                catalog.PriceGroup = priceGroup;
            }

            catalog.Save();
            return(catalog);
        }
Exemple #9
0
        private Currency AddCatalogPriceGroups(ProductCatalog uCommerceCatalog, SitefinityCatalogCurrencyCulture sfCatalogCurrencyCulture)
        {
            var defaultCurrency = new Currency();

            foreach (var sfCurrency in sfCatalogCurrencyCulture.AllowedCurrencies.Currencies)
            {
                var currentCurrency = CreateCurrency(sfCurrency);
                var priceGroup      = new PriceGroup()
                {
                    Name     = sfCurrency.DisplayName,
                    Deleted  = false,
                    VATRate  = sfCurrency.ExchangeRate,
                    Currency = currentCurrency,
                };

                if (sfCurrency.IsDefault)
                {
                    uCommerceCatalog.PriceGroup = priceGroup;
                    defaultCurrency             = currentCurrency;
                }

                uCommerceCatalog.AddAllowedPriceGroup(priceGroup);
            }

            return(defaultCurrency);
        }
Exemple #10
0
        protected void LoadFields()
        {
            if (PriceGroupId != 0)
            {
                PriceGroup pg = ControllerManager.PriceGroup.GetById(PriceGroupId);

                ddlCurrency.SelectedValue = ddlCurrency.Items.FindByValue(pg.Currency.ID.ToString()).Value;
                txtDescription.Text       = pg.Description;
                txtName.Text     = pg.Name;
                lblCurrency.Text = pg.Currency.Description;
                txtDiscount.Text = pg.Discount.ToString("#0.##");

                if (pg.Adjust != null)
                {
                    txtAdjust.Text = pg.Adjust.Value.ToString("#0.##");
                }

                txtGRP.Text = pg.PriceSuggestCoef.ToString("#0.##");

                ddlCurrency.Visible = false;
                lblCurrency.Visible = true;
                if (pg.PriceAttributes.Count == 0)
                {
                    ddlCurrency.Visible = true;
                    lblCurrency.Visible = false;
                }
            }
        }
 public ChoosePrice(PriceGroup priceGroup, OperatorType operatorType, double value)
     : this()
 {
     rbPriceGroup.Active = true;
     cboPriceGroup.SetSelection((int)priceGroup);
     cboArithmeticOperations.SetSelection((int)operatorType);
     txtPriceGroupValue.Text = Number.ToEditString(value);
 }
Exemple #12
0
            private EntityDataServiceResponse <PriceGroup> GetCustomerPriceGroup(GetCustomerPriceGroupDataRequest request)
            {
                var pricingDataManager = this.GetDataManagerInstance(request.RequestContext);

                PriceGroup priceGroup = pricingDataManager.GetCustomerPriceGroup(request.CustomerPriceGroupId);

                return(new EntityDataServiceResponse <PriceGroup>(new ReadOnlyCollection <PriceGroup>(new[] { priceGroup }).AsPagedResult()));
            }
        public void Commit(PriceGroup priceGroup, bool annul = false)
        {
            Payment [] duePayments;
            Payment [] paidPayments;
            CreatePayments(out duePayments, out paidPayments);

            Commit(duePayments, paidPayments, priceGroup, annul);
        }
Exemple #14
0
        public void Commit(PriceGroup priceGroup)
        {
            Payment [] paidPayments;
            Payment [] duePayments;
            CreatePayments(out duePayments, out paidPayments);

            Commit(duePayments, paidPayments, priceGroup);
        }
        private void CellEdit(int row, PriceGroup groupColumn)
        {
            int col = grid.ColumnController.GetColumnOrdinal(Item.GetPriceGroupProperty(groupColumn));

            grid.DisableEdit = false;
            grid.BeginCellEdit(new CellEventArgs(col, row));
            currentPriceGroup = groupColumn;
        }
        public bool ItemEvaluate(Item newItem, PriceGroup priceGroup, bool updatePrice = false)
        {
            if (!CheckItemCanEvaluate(newItem))
            {
                return(false);
            }

            Item oldItem = itemId >= 0 ? Item.GetById(itemId) : null;

            if (ItemName != newItem.Name)
            {
                ItemCode  = newItem.Code;
                ItemName  = newItem.Name;
                ItemName2 = newItem.Name2;
            }

            Item = newItem;
            if (oldItem == null || newItem.Id != oldItem.Id)
            {
                ItemId      = newItem.Id;
                ItemGroupId = newItem.GroupId;
                VatGroup    = newItem.GetVATGroup();
                itemType    = newItem.Type;

                if (string.IsNullOrEmpty(newItem.MUnit))
                {
                    MesUnit [] units = MesUnit.GetByItem(newItem);
                    MUnitName = units == null?Translator.GetString("pcs.") : units [0].Name;
                }
                else
                {
                    MUnitName = newItem.MUnit;
                }

                if (oldItem == null)
                {
                    ResetQuantity();
                }
            }

            if (oldItem == null || newItem.Id != oldItem.Id || updatePrice)
            {
                UpdatePrices(newItem, priceGroup);
                VATEvaluate();
                TotalEvaluate();
            }

            var afterHandler = AfterItemEvaluate;

            if (afterHandler != null)
            {
                afterHandler(this, new AfterItemEvaluateArgs {
                    Item = newItem
                });
            }

            return(true);
        }
Exemple #17
0
        public ChooseEditItem(long locationId, PriceGroup priceGroup, string filter)
            : base(filter)
        {
            this.priceGroup = priceGroup;
            location        = Location.GetById(locationId);
            pickMode        = true;

            Initialize();
        }
        private void CellButtonPress(CellEventArgs args, PriceGroup groupColumn)
        {
            if (grid.EditedCell.IsValid)
            {
                CellEvaluate(grid.EditedCellValue.ToString(), currentPriceGroup);
            }

            CellEdit(args.Cell.Row, groupColumn);
        }
        public PriceAttribute GetPriceAttribute(PriceGroup priceGroup, PriceBase priceBase)
        {
            ICriteria crit = GetCriteria();

            crit.Add(Expression.Eq("PriceBase", priceBase));
            crit.Add(Expression.Eq("PriceGroup", priceGroup));

            return(crit.UniqueResult <PriceAttribute>());
        }
        private void BuildPriceGroupSections(TemplateBuilder builder, int sortorder)
        {
            // Assumption: Price groups are the same for all the products.
            // So all products should have entries for all the price groups.

            var priceGroups = PriceGroup.Find(x => !x.Deleted).ToList();

            BuildPriceGroupSectionForSpecificPriceGroups(builder, priceGroups, sortorder);
        }
        public ProductCatalog Catalog(string name, ProductCatalogGroup catalogGroup, PriceGroup priceGroup)
        {
            var catalog = _catalogs.Value.SingleOrDefault(x => x.Name == name) ?? new ProductCatalog();

            catalog.Name                = name;
            catalog.DisplayOnWebSite    = false;
            catalog.ProductCatalogGroup = catalogGroup;
            catalog.PriceGroup          = priceGroup;
            catalog.Deleted             = false;
            return(catalog);
        }
        public bool ItemEvaluate(Item item, PriceGroup priceGroup, bool updatePrice, ComplexProduction parent)
        {
            bool ret = ItemEvaluate(item, priceGroup, updatePrice);

            if (ret)
            {
                parent.RecalculatePrices();
            }

            return(ret);
        }
        private void AddPriceGroupSpecificField(TemplateBuilder builder, PriceGroup priceGroup)
        {
            ID priceFieldId = priceGroup.SitecoreTemplateFieldIdForVariant(FieldIds.Variant.SectionPricingId);

            var priceGroupFieldData = new PriceGroupFieldData {
                PriceFieldId = priceFieldId
            };

            _priceGroupFields[priceGroup.PriceGroupId] = priceGroupFieldData;

            builder.CreateNumberField(priceFieldId, GetPriceGroupName(priceGroup), 1, new List <KeyValuePair <string, string> >());
        }
        private void ColumnEditOver(PriceGroup column)
        {
            if (!grid.FocusedCell.IsValid)
            {
                return;
            }

            if (grid.FocusedCell.Row > 0)
            {
                CellEdit(grid.FocusedCell.Row - 1, column);
            }
        }
Exemple #25
0
    private PriceGroup priceGroup;                                                                                      // Player's price group

    /// <summary>
    /// Start this instance.
    /// </summary>
    void Start()
    {
        // Init existing items's internal state on scene start
        foreach (StackItem stackItem in AccessUtility.FindObjectsOfType <StackItem>())
        {
            stackItem.Init();
        }

        priceGroup = GetComponent <PriceGroup>();
        Debug.Assert(equipment && inventory && vendor && skills && inventoryStackGroup && equipmentStackGroup && vendorStackGroup && clickEquipInventory && priceGroup, "Wrong settings");
        priceGroup.ShowPrices(vendor.activeSelf);
    }
Exemple #26
0
        private PriceGroup CreatePriceGroup(string name, Currency currency, decimal vatRate)
        {
            var priceGroup = PriceGroup.SingleOrDefault(c => c.Name == name) ?? new PriceGroupFactory().NewWithDefaults(name);

            priceGroup.Name     = name;
            priceGroup.Currency = currency;
            priceGroup.VATRate  = vatRate;
            priceGroup.Deleted  = false;
            priceGroup.Save();

            return(priceGroup);
        }
        private void ColumnEditBelow(PriceGroup column)
        {
            if (!grid.FocusedCell.IsValid)
            {
                return;
            }

            if (grid.FocusedCell.Row + 1 < grid.Model.Count)
            {
                CellEdit(grid.FocusedCell.Row + 1, column);
            }
        }
Exemple #28
0
        public IList <Distributor> GetActivesByPriceGroup(PriceGroup pG, int?maxResults)
        {
            //Cache Section
            string cacheKey          = null;
            MembershipHelperUser mhu = MembershipHelper.GetUser();

            if (mhu != null)
            {
                cacheKey = string.Format("DISTRIBUTORS_{0}_{1}_{2}_{3}", mhu.UserId, typeof(Distributor).ToString(), pG.ID, maxResults);
            }

            object result = CacheManager.GetCached(typeof(Distributor), cacheKey);

            ICriteria crit = GetCriteria();

            if (result == null)
            {
                crit.Add(Expression.Not(Expression.Eq("DistributorStatus", DistributorStatus.Disable)));

                ICriteria critPriceList = crit.CreateCriteria("PriceList");

                ExecutePermissionValidator epv = new ExecutePermissionValidator();
                epv.ClassType     = typeof(PriceList);
                epv.KeyIdentifier = Config.SeePriceLists;

                if (PermissionManager.Check(epv) == false)
                {
                    IList priceListIds    = PermissionManager.GetPermissionIdentifiers(typeof(PriceList), PermissionAction.Create);
                    int[] intPriceListIds = new int[priceListIds.Count];
                    for (int i = 0; i < priceListIds.Count; i++)
                    {
                        intPriceListIds[i] = Convert.ToInt32(priceListIds[i]);
                    }

                    critPriceList.Add(Expression.In("ID", intPriceListIds));
                }

                critPriceList.Add(Expression.Or(Expression.Eq("PriceListStatus", PriceListStatus.Active), Expression.Eq("PriceListStatus", PriceListStatus.New)));
                critPriceList.Add(Expression.Eq("PriceGroup", pG));


                crit.AddOrder(new Order("TimeStamp.CreatedOn", false));
                if (maxResults.HasValue)
                {
                    crit.SetMaxResults(maxResults.Value);
                }

                result = crit.List <Distributor>();
                CacheManager.AddItem(typeof(Distributor), cacheKey, result);
            }
            return(result as IList <Distributor>);
        }
Exemple #29
0
 /// <summary>
 /// Raises the enable event.
 /// </summary>
 void OnEnable()
 {
     priceGroup = GetComponentInChildren <PriceGroup>(true);
     if (deleteSavedData == true)
     {
         DeleteSavedData();
     }
     if (autoSave == true)
     {
         // Load data on game start
         Load();
     }
 }
        private bool CellEvaluate(string newValue, PriceGroup groupColumn)
        {
            bool ret;
            int  row = grid.EditedCell.Row;

            Item   item     = entities [row];
            double oldPrice = item.GetPriceGroupPrice(groupColumn);
            double newPrice;

            if (Currency.TryParseExpression(newValue, out newPrice))
            {
                if (BusinessDomain.AppConfiguration.WarnPricesSaleLowerThanPurchase &&
                    item.TradeInPrice > newPrice && newPrice > 0)
                {
                    string priceGroupText = Currency.GetAllSalePriceGroups()
                                            .Where(priceGroup => priceGroup.Key == (int)groupColumn)
                                            .Select(priceGroup => priceGroup.Value)
                                            .First();

                    using (MessageYesNoRemember dialog = new MessageYesNoRemember(Translator.GetString("Sale Price Lower than Purchase Price"), string.Empty,
                                                                                  string.Format(Translator.GetString("The value you entered for \"{0}\" is lower than the purchase price. Do you want to continue?"), priceGroupText), "Icons.Question32.png")) {
                        dialog.SetButtonText(MessageButtons.Remember, Translator.GetString("Do not warn me anymore"));
                        ret = dialog.Run() == ResponseType.Yes;
                        BusinessDomain.AppConfiguration.WarnPricesSaleLowerThanPurchase = !dialog.RememberChoice;
                    }
                }
                else
                {
                    ret = true;
                }

                if (ret)
                {
                    item.SetPriceGroupPrice(groupColumn, newPrice);
                }
            }
            else
            {
                item.SetPriceGroupPrice(groupColumn, 0);
                ret = false;
            }

            if (ret && !oldPrice.IsEqualTo(newPrice) && !dirtyItems.Contains(item))
            {
                btnNew.Sensitive = true;
                dirtyItems.Add(item);
            }

            return(ret);
        }
 public ProductCatalog Catalog(string name, ProductCatalogGroup catalogGroup, PriceGroup priceGroup)
 {
     var catalog = _catalogs.Value.SingleOrDefault(x => x.Name == name) ?? new ProductCatalog();
     catalog.Name = name;
     catalog.DisplayOnWebSite = false;
     catalog.ProductCatalogGroup = catalogGroup;
     catalog.PriceGroup = priceGroup;
     catalog.Deleted = false;
     return catalog;
 }
        public PriceGroup PriceGroup(string name, Currency currency, decimal vatRate)
        {
            PriceGroup priceGroup = _priceGroups.Value
                .SingleOrDefault(x => x.Name == name);

            if (priceGroup == null)
            {
                priceGroup = new PriceGroup
                {
                    Name = name,
                    Currency = currency
                };
            }
            priceGroup.VATRate = vatRate;
            priceGroup.Deleted = false;

            return priceGroup;
        }
 public void Save(PriceGroup priceGroup)
 {
     _priceGroups.Value.Save(priceGroup);
 }
        public ShippingMethodPrice ShippingMethodPrice(PriceGroup priceGroup, decimal price)
        {
            var shippingMethodPrice = _shippingMethodPrices.Value
                .SingleOrDefault(x => x.Currency == priceGroup.Currency && x.PriceGroup == priceGroup);

            if (shippingMethodPrice == null)
                shippingMethodPrice = new ShippingMethodPrice();

            shippingMethodPrice.Currency = priceGroup.Currency;
            shippingMethodPrice.PriceGroup = priceGroup;
            shippingMethodPrice.Price = price;

            return shippingMethodPrice;
        }