Example #1
0
        private List <Entity> GetPriceListitem(Entity entity, Entity priceList, List <Entity> effectivePriceList)
        {
            var productId = CommonHandler.GetEntityReferenceIdSafe(entity, productFieldName);

            var priceLevelItemConditionList = new List <ConditionExpression>
            {
                new ConditionExpression("pricelevelid", ConditionOperator.Equal, priceList.Id),
                new ConditionExpression("productid", ConditionOperator.Equal, productId)
            };

            EntityCollection priceLevelItemCollection = CommonHandler.RetrieveRecordsByConditions("productpricelevel", priceLevelItemConditionList, _organizationService, null, OrderType.Ascending,
                                                                                                  new[] { "amount" });

            if (priceLevelItemCollection != null && priceLevelItemCollection.Entities.Count > 0)
            {
                effectivePriceList.Add(priceLevelItemCollection.Entities[0]);
            }

            return(effectivePriceList);
        }
Example #2
0
        //Created By : Jerome Anthony Gerero, Created On : 01/06/2017

        /*Purpose: Send e-mail notification to branches that the default price list has been changed
         * Event/Message:
         *      Post/Update: Default Price List = gsc_default
         *      Post/Create: Default Price List = gsc_default
         * Primary Entity: Sales Return Detail
         */



        //Created By: Leslie Baliguat
        public void CheckIfThereIsExistingDefaultPriceList(Entity priceList)
        {
            if (!priceList.GetAttributeValue <Boolean>("gsc_default"))
            {
                return;
            }
            var transactionType = priceList.Contains("gsc_transactiontype") ? priceList.GetAttributeValue <OptionSetValue>("gsc_transactiontype").Value : 0;

            var productConditionList = new List <ConditionExpression>
            {
                new ConditionExpression("gsc_default", ConditionOperator.Equal, true),
                new ConditionExpression("gsc_transactiontype", ConditionOperator.Equal, transactionType)
            };

            EntityCollection priceListCollection = CommonHandler.RetrieveRecordsByConditions("pricelevel", productConditionList, _organizationService, null, OrderType.Ascending,
                                                                                             new[] { "gsc_default" });

            if (priceListCollection != null && priceListCollection.Entities.Count > 0)
            {
                throw new InvalidPluginExecutionException("Cannot create default price list because there is already an existing default price list.");
            }
        }