Exemplo n.º 1
0
        /// <summary>
        /// For a given data record containing a deferral code and a default deferral term,
        /// generates a warning message when the specified deferral code is flexible, but the specified
        /// default deferral term is zero.
        /// </summary>
        /// <param name="sender">The cache containing the records.</param>
        /// <param name="row">The currently processed data record.</param>
        /// <typeparam name="DeferralCode">The DAC field type for deferral code.</param>
        /// <typeparam name="DefaultTerm">The DAC field type for default deferral term.</param>
        public static void CheckZeroDefaultTerm <DeferralCode, DefaultTerm>(PXCache sender, object row)
            where DeferralCode : IBqlField
            where DefaultTerm : IBqlField
        {
            string  deferralCodeValue = sender.GetValue <DeferralCode>(row) as string;
            decimal?defaultTermValue  = sender.GetValue <DefaultTerm>(row) as decimal?;

            bool displayWarning = false;

            if (deferralCodeValue != null)
            {
                DRDeferredCode deferralCodeRecord =
                    PXSelect <
                        DRDeferredCode,
                        Where <DRDeferredCode.deferredCodeID, Equal <Required <DRDeferredCode.deferredCodeID> > > >
                    .Select(sender.Graph, deferralCodeValue);

                if (deferralCodeRecord != null &&
                    DeferredMethodType.RequiresTerms(deferralCodeRecord) &&
                    defaultTermValue.HasValue &&
                    defaultTermValue == 0)
                {
                    displayWarning = true;
                }
            }

            sender.RaiseExceptionHandling(
                typeof(DefaultTerm).Name,
                row,
                defaultTermValue,
                displayWarning ? new PXSetPropertyException(Messages.NoDefaultTermSpecified, PXErrorLevel.Warning) : null);
        }
Exemplo n.º 2
0
        protected override void InventoryItem_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            base.InventoryItem_RowSelected(sender, e);

            var item = e.Row as InventoryItem;

            if (item == null)
            {
                return;
            }

            //Multiple Components are not supported for CashReceipt Deferred Revenue:
            DRDeferredCode dc = PXSelect <DRDeferredCode, Where <DRDeferredCode.deferredCodeID, Equal <Current <InventoryItem.deferredCode> > > > .Select(this);

            PXUIFieldAttribute.SetEnabled <POVendorInventory.isDefault>(this.VendorItems.Cache, null, true);

            //Initial State for Components:
            Components.Cache.AllowDelete = false;
            Components.Cache.AllowInsert = false;
            Components.Cache.AllowUpdate = false;

            SetDefaultTermControlsState(sender, item);

            if (item.IsSplitted == true)
            {
                Components.Cache.AllowDelete = true;
                Components.Cache.AllowInsert = true;
                Components.Cache.AllowUpdate = true;
                item.TotalPercentage         = SumComponentsPercentage();
                PXUIFieldAttribute.SetEnabled <InventoryItem.useParentSubID>(sender, item, true);
            }
            else
            {
                PXUIFieldAttribute.SetEnabled <InventoryItem.useParentSubID>(sender, item, false);
                item.UseParentSubID  = false;
                item.TotalPercentage = 100;
            }
            if (item.NonStockReceipt == true)
            {
                PXUIFieldAttribute.SetRequired <InventoryItem.postClassID>(sender, true);
            }
            else
            {
                PXUIFieldAttribute.SetRequired <InventoryItem.postClassID>(sender, false);
            }
            InventoryHelper.CheckZeroDefaultTerm <InventoryItem.deferredCode, InventoryItem.defaultTerm>(sender, item);
            PXUIFieldAttribute.SetVisible <InventoryItem.taxCalcMode>(sender, item, item.ItemType == INItemTypes.ExpenseItem);

            sender.Adjust <PXUIFieldAttribute>(item).For <InventoryItem.completePOLine>(fa => fa.Enabled = (item.TemplateItemID == null))
            .SameFor <InventoryItem.nonStockReceipt>()
            .SameFor <InventoryItem.nonStockShip>();
        }