protected virtual void SOOrderType_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }
            SOOrderType ordertype = (SOOrderType)e.Row;
            SOOrderType prevtype  = (SOOrderType)e.OldRow;

            if (ordertype.Active == true)
            {
                if (prevtype.SalesSubMask == null && ordertype.SalesSubMask == null)
                {
                    sender.SetDefaultExt <SOOrderType.salesSubMask>(ordertype);
                }
                if (prevtype.MiscSubMask == null && ordertype.MiscSubMask == null)
                {
                    sender.SetDefaultExt <SOOrderType.miscSubMask>(ordertype);
                }
                if (prevtype.FreightSubMask == null && ordertype.FreightSubMask == null)
                {
                    sender.SetDefaultExt <SOOrderType.freightSubMask>(ordertype);
                }
                if (prevtype.DiscSubMask == null && ordertype.DiscSubMask == null)
                {
                    sender.SetDefaultExt <SOOrderType.discSubMask>(ordertype);
                }
                //if (prevtype.COGSSubMask == null && ordertype.COGSSubMask == null) sender.SetDefaultExt<SOOrderType.cOGSSubMask>(ordertype);
            }

            if (ordertype.Template != ((SOOrderType)e.OldRow).Template)
            {
                SOOrderType template =
                    PXSelect <SOOrderType, Where <SOOrderType.orderType, Equal <Required <SOOrderType.orderType> > > >
                    .SelectWindowed(this, 0, 1, ordertype.Template);

                this.soordertype.Current = ordertype;

                if (template == null)
                {
                    return;
                }
                ordertype.Behavior          = template.Behavior;
                ordertype.DefaultOperation  = template.DefaultOperation;
                ordertype.RequireShipping   = template.RequireShipping;
                ordertype.RequireLocation   = template.RequireLocation;
                ordertype.RequireAllocation = template.RequireAllocation;
                ordertype.ARDocType         = template.ARDocType;
                ordertype.INDocType         = template.INDocType;
                ordertype.ShipmentPlanType  = template.ShipmentPlanType;
                ordertype.OrderPlanType     = template.OrderPlanType;

                foreach (SOOrderTypeOperation o in this.operations.View.SelectMultiBound(new object[] { ordertype }))
                {
                    this.operations.Delete(o);
                }

                foreach (SOOrderTypeOperation o in this.operations.View.SelectMultiBound(new object[] { template }))
                {
                    SOOrderTypeOperation upd = new SOOrderTypeOperation();
                    upd.OrderType           = ordertype.OrderType;
                    upd.Operation           = o.Operation;
                    upd.INDocType           = o.INDocType;
                    upd.ShipmentPlanType    = o.ShipmentPlanType;
                    upd.OrderPlanType       = o.OrderPlanType;
                    upd.AutoCreateIssueLine = o.AutoCreateIssueLine;
                    upd.Active = o.Active;
                    upd        = this.operations.Insert(upd);
                }
            }

            if (ordertype.Template == null && sender.ObjectsEqual <SOOrderType.behavior, SOOrderType.aRDocType>(e.Row, e.OldRow) == false)
            {
                foreach (SOOrderTypeOperation o in this.operations.View.SelectMultiBound(new object[] { ordertype }))
                {
                    this.operations.Delete(o);
                }
                string defaultOp = SOBehavior.DefaultOperation(ordertype.Behavior, ordertype.ARDocType);

                if (defaultOp != null)
                {
                    ordertype.DefaultOperation = defaultOp;
                    SOOrderTypeOperation def = new SOOrderTypeOperation();
                    def.OrderType = ordertype.OrderType;
                    def.Operation = ordertype.DefaultOperation;
                    this.operations.Insert(def);
                    if (ordertype.Behavior == SOBehavior.RM)
                    {
                        def           = new SOOrderTypeOperation();
                        def.OrderType = ordertype.OrderType;
                        def.Operation = SOOperation.Issue;
                        this.operations.Insert(def);
                    }
                }
            }

            if (ordertype.OrderType != ordertype.Template)
            {
                return;
            }
            if (ordertype.RequireShipping == false)
            {
                foreach (SOOrderTypeOperation op in operations.Select())
                {
                    SOOrderTypeOperation upd = PXCache <SOOrderTypeOperation> .CreateCopy(op);

                    upd.ShipmentPlanType = null;
                    this.operations.Update(upd);
                }
            }
            if (ordertype.ARDocType == ARDocType.NoUpdate)
            {
                foreach (SOOrderTypeOperation op in operations.Select())
                {
                    SOOrderTypeOperation upd = PXCache <SOOrderTypeOperation> .CreateCopy(op);

                    if (upd.INDocType == INTranType.Invoice || upd.INDocType == INTranType.DebitMemo)
                    {
                        upd.INDocType = INTranType.Issue;
                    }
                    if (upd.INDocType == INTranType.CreditMemo)
                    {
                        upd.INDocType = INTranType.Return;
                    }
                    this.operations.Update(upd);
                }
            }
        }
Ejemplo n.º 2
0
        protected virtual void SOOrderType_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }
            SOOrderType ordertype = (SOOrderType)e.Row;

            SOOrderType link = references.SelectWindowed(0, 1, ordertype.OrderType);
            bool        isTemplateUpdatable = ordertype.IsSystem == false && link == null && ordertype.OrderType != null;

            PXUIFieldAttribute.SetEnabled <SOOrderType.template>(sender, e.Row, isTemplateUpdatable);

            SOOrderTypeOperation def = this.defaultOperation.Select(ordertype.OrderType, ordertype.DefaultOperation);

            if (def == null)
            {
                def = new SOOrderTypeOperation();
            }
            PXUIFieldAttribute.SetEnabled <SOOrderType.billSeparately>(sender, e.Row, ordertype.ARDocType != ARDocType.NoUpdate);
            PXUIFieldAttribute.SetEnabled <SOOrderType.invoiceNumberingID>(sender, e.Row, ordertype.ARDocType != ARDocType.NoUpdate);


            if (ordertype.ARDocType == ARDocType.NoUpdate)
            {
                INTranType.CustomListAttribute listattr = new INTranType.SONonARListAttribute();
                PXStringListAttribute.SetList <SOOrderTypeOperation.iNDocType>(this.operations.Cache, null, listattr.AllowedValues, listattr.AllowedLabels);
            }
            else
            {
                INTranType.CustomListAttribute listattr = new INTranType.SOListAttribute();
                PXStringListAttribute.SetList <SOOrderTypeOperation.iNDocType>(this.operations.Cache, null, listattr.AllowedValues, listattr.AllowedLabels);
            }

            //SOOrder order =
            //PXSelectJoin<SOOrder,
            //	InnerJoin<INItemPlan, On<INItemPlan.refNoteID, Equal<SOOrder.noteID>>>,
            //Where<SOOrder.orderType, Equal<Required<SOOrder.orderType>>,
            //	And<Where<INItemPlan.planType, Equal<INPlanConstants.plan60>,
            //				 Or<INItemPlan.planType, Equal<INPlanConstants.plan66>,
            //				 Or<INItemPlan.planType, Equal<INPlanConstants.plan68>>>>>>>
            //.SelectWindowed(this, 0, 1, ordertype.OrderType);
            //PXUIFieldAttribute.SetEnabled<SOOrderType.requireLocation>(sender, ordertype, order == null && isTemplateUpdatable);
            //PXUIFieldAttribute.SetEnabled<SOOrderType.requireLocation>(sender, e.Row, def.INDocType != INTranType.NoUpdate && isTemplateUpdatable);
            PXUIFieldAttribute.SetEnabled <SOOrderType.requireShipping>(sender, e.Row, def.INDocType != INTranType.NoUpdate && def.INDocType != INTranType.Transfer && isTemplateUpdatable && !SOBehavior.IsPredefinedBehavior(ordertype.Behavior));
            PXUIFieldAttribute.SetEnabled <SOOrderType.aRDocType>(sender, e.Row, def.INDocType != INTranType.Transfer && isTemplateUpdatable);
            PXUIFieldAttribute.SetEnabled <SOOrderType.behavior>(sender, e.Row, isTemplateUpdatable);
            PXUIFieldAttribute.SetEnabled <SOOrderType.defaultOperation>(sender, e.Row, isTemplateUpdatable && ordertype.Behavior == SOBehavior.RM);
            PXUIFieldAttribute.SetVisible <SOOrderTypeOperation.active>(operations.Cache, null, ordertype.Behavior == SOBehavior.RM || ordertype.Behavior == SOBehavior.IN);
            PXUIFieldAttribute.SetVisible <SOOrderTypeOperation.autoCreateIssueLine>(operations.Cache, null, ordertype.Behavior == SOBehavior.RM);

            PXUIFieldAttribute.SetEnabled <SOOrderType.copyLineNotesToInvoiceOnlyNS>(sender, ordertype, ordertype.CopyLineNotesToInvoice == true);
            PXUIFieldAttribute.SetEnabled <SOOrderType.copyLineFilesToInvoiceOnlyNS>(sender, ordertype, ordertype.CopyLineFilesToInvoice == true);

            PXUIFieldAttribute.SetEnabled <SOOrderType.requireAllocation>(sender, ordertype, ordertype.RequireShipping == true);
            PXUIFieldAttribute.SetEnabled <SOOrderType.requireLotSerial>(sender, ordertype, ordertype.RequireShipping == true);
            PXUIFieldAttribute.SetEnabled <SOOrderType.copyLotSerialFromShipment>(sender, ordertype, ordertype.RequireShipping == true);

            PXUIFieldAttribute.SetEnabled <SOOrderType.useDiscountSubFromSalesSub>(sender, ordertype, ordertype.PostLineDiscSeparately == true);

            bool customerOrderEnabled = def.INDocType != null && def.INDocType != INTranType.Transfer;

            PXUIFieldAttribute.SetEnabled <SOOrderType.customerOrderIsRequired>(sender, ordertype, customerOrderEnabled);
            PXUIFieldAttribute.SetEnabled <SOOrderType.customerOrderValidation>(sender, ordertype, customerOrderEnabled && ordertype.CustomerOrderIsRequired == true);

            PXUIFieldAttribute.SetVisible <SOOrderType.recalculateDiscOnPartialShipment>(sender, e.Row, PXAccess.FeatureInstalled <FeaturesSet.inventory>() && PXAccess.FeatureInstalled <FeaturesSet.customerDiscounts>());

            bool allowUserDefinedOrderTypes = PXAccess.FeatureInstalled <FeaturesSet.userDefinedOrderTypes>();

            soordertype.AllowInsert      = allowUserDefinedOrderTypes;
            currentordertype.AllowInsert = allowUserDefinedOrderTypes;
            bool allowUpdateOrderTypes = allowUserDefinedOrderTypes || sender.GetStatus(e.Row) != PXEntryStatus.Inserted;

            soordertype.AllowUpdate      = allowUpdateOrderTypes;
            currentordertype.AllowUpdate = allowUpdateOrderTypes;

            PXUIFieldAttribute.SetVisible <SOOrderType.commitmentTracking>(sender, e.Row, CommitmentTracking);
            if (!PXAccess.FeatureInstalled <FeaturesSet.inventory>())
            {
                PXDefaultAttribute.SetDefault <SOOrderType.behavior>(sender, SOBehavior.IN);
                PXStringListAttribute.SetList <SOOrderType.behavior>(sender, null, new string[] { SOBehavior.IN, SOBehavior.QT, SOBehavior.CM },
                                                                     new string[] { Messages.INName, Messages.QTName, Messages.CMName });
            }
        }