コード例 #1
0
 public override void Persist()
 {
     if (setup.Current != null && string.IsNullOrEmpty(setup.Current.DfltLotSerClassID) && !IsFeatureInstalled <FeaturesSet.lotSerialTracking>())
     {
         setup.Current.DfltLotSerClassID = INLotSerClass.GetDefaultLotSerClass(this);
     }
     base.Persist();
 }
コード例 #2
0
        protected virtual void INKitSpecStkDet_CompInventoryID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            INKitSpecStkDet row = e.Row as INKitSpecStkDet;

            if (row != null)
            {
                PXSelectBase <INKitSpecStkDet> select = new PXSelect <INKitSpecStkDet,
                                                                      Where <INKitSpecStkDet.kitInventoryID, Equal <Current <INKitSpecHdr.kitInventoryID> >,
                                                                             And <INKitSpecStkDet.revisionID, Equal <Current <INKitSpecHdr.revisionID> >,
                                                                                  And <INKitSpecStkDet.compInventoryID, Equal <Required <INKitSpecStkDet.compInventoryID> >,
                                                                                       And <INKitSpecStkDet.compSubItemID, Equal <Required <INKitSpecStkDet.compSubItemID> > > > > > >(this);

                PXResultset <INKitSpecStkDet> res = select.Select(e.NewValue, row.CompSubItemID);

                if (res.Count > 0)
                {
                    InventoryItem component = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(this, row.CompInventoryID);

                    var ex = new PXSetPropertyException(Messages.KitItemMustBeUniqueAccrosSubItems);
                    ex.ErrorValue = component?.InventoryCD;
                    RaiseOnKitNotUniqueException(e, ex);
                }

                PXSelectBase <InventoryItem> selectItemWithLotSerClass = new PXSelectJoin <InventoryItem,
                                                                                           LeftJoin <INLotSerClass, On <INLotSerClass.lotSerClassID, Equal <InventoryItem.lotSerClassID> > >,
                                                                                           Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > >(this);
                foreach (PXResult <InventoryItem, INLotSerClass> kitRes in selectItemWithLotSerClass.Select(Hdr.Current.KitInventoryID))                //single record
                {
                    InventoryItem kit            = (InventoryItem)kitRes;
                    INLotSerClass kitLotSerClass = (INLotSerClass)kitRes;

                    foreach (PXResult <InventoryItem, INLotSerClass> compRes in selectItemWithLotSerClass.Select(e.NewValue))                   //single record
                    {
                        INLotSerClass compLotSerClass = (INLotSerClass)compRes;
                        InventoryItem component       = (InventoryItem)compRes;

                        //Serial number components are valid only for serial numbered kit validation:
                        if (kit.StkItem == true && kitLotSerClass.LotSerTrack != INLotSerTrack.SerialNumbered && compLotSerClass.LotSerTrack == INLotSerTrack.SerialNumbered)
                        {
                            var ex = new PXSetPropertyException(Messages.SNComponentInSNKit);
                            ex.ErrorValue = component.InventoryCD;
                            RaiseSNComponentInSNKitException(e, ex);
                        }

                        //IsUnassigned components are not supported in kits.
                        if (kit.StkItem != true && compLotSerClass.IsUnassigned)
                        {
                            var ex = new PXSetPropertyException(Messages.WhenUsedComponentInKit);
                            ex.ErrorValue = component.InventoryCD;

                            RaiseUnassignedComponentInKitException(e, ex);
                        }
                    }
                }
            }
        }
コード例 #3
0
        protected virtual void INKitSpecStkDet_CompInventoryID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            INKitSpecStkDet row = e.Row as INKitSpecStkDet;

            if (row != null)
            {
                PXSelectBase <INKitSpecStkDet> select = new PXSelect <INKitSpecStkDet,
                                                                      Where <INKitSpecStkDet.kitInventoryID, Equal <Current <INKitSpecHdr.kitInventoryID> >,
                                                                             And <INKitSpecStkDet.revisionID, Equal <Current <INKitSpecHdr.revisionID> >,
                                                                                  And <INKitSpecStkDet.compInventoryID, Equal <Required <INKitSpecStkDet.compInventoryID> >,
                                                                                       And <INKitSpecStkDet.compSubItemID, Equal <Required <INKitSpecStkDet.compSubItemID> > > > > > >(this);

                PXResultset <INKitSpecStkDet> res = select.Select(e.NewValue, row.CompSubItemID);

                if (res.Count > 0)
                {
                    InventoryItem component = InventoryItem.PK.Find(this, row.CompInventoryID);
                    var           ex        = new PXSetPropertyException(Messages.KitItemMustBeUniqueAccrosSubItems);
                    ex.ErrorValue = component?.InventoryCD;
                    RaiseOnKitNotUniqueException(e, ex);
                }

                InventoryItem kit = InventoryItem.PK.Find(this, Hdr.Current.KitInventoryID);
                if (kit != null)
                {
                    INLotSerClass kitLotSerClass = INLotSerClass.PK.Find(this, kit.LotSerClassID) ?? new INLotSerClass();

                    InventoryItem component = InventoryItem.PK.Find(this, (int?)e.NewValue);
                    if (component != null)
                    {
                        INLotSerClass compLotSerClass = INLotSerClass.PK.Find(this, component.LotSerClassID) ?? new INLotSerClass();

                        //Serial number components are valid only for serial numbered kit validation:
                        if (kit.StkItem == true && kitLotSerClass.LotSerTrack != INLotSerTrack.SerialNumbered && compLotSerClass.LotSerTrack == INLotSerTrack.SerialNumbered)
                        {
                            var ex = new PXSetPropertyException(Messages.SNComponentInSNKit);
                            ex.ErrorValue = component.InventoryCD;
                            RaiseSNComponentInSNKitException(e, ex);
                        }

                        //Manually assigned components are not supported in kits.
                        if (kit.StkItem != true && compLotSerClass.IsManualAssignRequired == true)
                        {
                            var ex = new PXSetPropertyException(Messages.WhenUsedComponentInKit);
                            ex.ErrorValue = component.InventoryCD;

                            RaiseUnassignedComponentInKitException(e, ex);
                        }
                    }
                }
            }
        }
コード例 #4
0
        protected virtual void INTran_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            if (e.Operation.Command() == PXDBOperation.Delete)
            {
                return;
            }

            INTran row = (INTran)e.Row;

            InventoryItem item      = (InventoryItem)PXSelectorAttribute.Select <INTran.inventoryID>(sender, row);
            INLotSerClass itemclass =
                (INLotSerClass)PXSelectorAttribute.Select <InventoryItem.lotSerClassID>(this.Caches[typeof(InventoryItem)], item);

            PXPersistingCheck check =
                ((INTran)e.Row).InvtMult != 0 && (
                    (item != null && item.ValMethod == INValMethod.Specific) ||
                    (itemclass != null &&
                     itemclass.LotSerTrack != INLotSerTrack.NotNumbered &&
                     itemclass.LotSerAssign == INLotSerAssign.WhenReceived &&
                     ((INTran)e.Row).Qty != 0m))
                                 ? PXPersistingCheck.NullOrBlank
                                 : PXPersistingCheck.Nothing;


            PXDefaultAttribute.SetPersistingCheck <INTran.subID>(sender, e.Row, PXPersistingCheck.Null);
            PXDefaultAttribute.SetPersistingCheck <INTran.locationID>(sender, e.Row, PXPersistingCheck.Null);
            PXDefaultAttribute.SetPersistingCheck <INTran.lotSerialNbr>(sender, e.Row, check);

            if (adjustment.Current != null && adjustment.Current.OrigModule != INRegister.origModule.PI && item != null && item.ValMethod == INValMethod.FIFO && ((INTran)e.Row).OrigRefNbr == null)
            {
                bool dropShipPO = false;
                if (row != null && row.POReceiptNbr != null && row.POReceiptLineNbr != null)
                {
                    PO.POReceiptLine pOReceiptLine = PXSelect <PO.POReceiptLine, Where <PO.POReceiptLine.receiptNbr, Equal <Required <PO.POReceiptLine.receiptNbr> >, And <PO.POReceiptLine.lineNbr, Equal <Required <PO.POReceiptLine.lineNbr> > > > > .Select(this, row.POReceiptNbr, row.POReceiptLineNbr);

                    dropShipPO = pOReceiptLine != null && (pOReceiptLine.LineType == PO.POLineType.GoodsForDropShip || pOReceiptLine.LineType == PO.POLineType.NonStockForDropShip);
                }
                if (!dropShipPO && sender.RaiseExceptionHandling <INTran.origRefNbr>(e.Row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(INTran.origRefNbr).Name)))
                {
                    throw new PXRowPersistingException(typeof(INTran.origRefNbr).Name, null, ErrorMessages.FieldIsEmpty, typeof(INTran.origRefNbr).Name);
                }
            }

            if (item != null && item.ValMethod == INValMethod.Standard && row.TranType == INTranType.Adjustment && row.InvtMult != 0 && row.BaseQty == 0m && row.TranCost != 0m)
            {
                if (sender.RaiseExceptionHandling <INTran.tranCost>(e.Row, row.TranCost, new PXSetPropertyException(Messages.StandardCostNoCostOnlyAdjust)))
                {
                    throw new PXRowPersistingException(typeof(INTran.tranCost).Name, row.TranCost, Messages.StandardCostNoCostOnlyAdjust);
                }
            }
        }
コード例 #5
0
        protected virtual void INKitSpecHdr_KitInventoryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            INKitSpecHdr row = e.Row as INKitSpecHdr;

            if (row != null)
            {
                INLotSerClass kitLotSerClass = PXSelectJoin <INLotSerClass,
                                                             InnerJoin <InventoryItem, On <InventoryItem.lotSerClassID, Equal <INLotSerClass.lotSerClassID> > >,
                                                             Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(this, row.KitInventoryID);

                if (kitLotSerClass != null)
                {
                    row.LotSerTrack = kitLotSerClass.LotSerTrack;
                }
            }
        }
コード例 #6
0
        public override void Persist()
        {
            if (itemclass.Current != null && string.IsNullOrEmpty(itemclass.Current.LotSerClassID) && !PXAccess.FeatureInstalled <FeaturesSet.lotSerialTracking>())
            {
                itemclass.Current.LotSerClassID = INLotSerClass.GetDefaultLotSerClass(this);
            }

            if (itemclass.Current != null && Groups.Cache.IsDirty)
            {
                PX.SM.UserAccess.PopulateNeighbours <INItemClass>(itemclass, Groups, typeof(SegmentValue));
                PXSelectorAttribute.ClearGlobalCache <INItemClass>();
            }
            base.Persist();
            Groups.Cache.Clear();
            GroupHelper.Clear();
        }
コード例 #7
0
        public static string GetDefaultLotSerClass(PXGraph graph)
        {
            INLotSerClass lotSerClass = PXSelect <INLotSerClass, Where <INLotSerClass.lotSerTrack, Equal <INLotSerTrack.notNumbered> > > .Select(graph);

            if (lotSerClass == null)
            {
                PXCache       cache  = graph.Caches <INLotSerClass>();
                INLotSerClass lotser = (INLotSerClass)cache.CreateInstance();
                lotser.LotSerClassID = DfltLotSerialClass;
                lotser.LotSerTrack   = INLotSerTrack.NotNumbered;
                cache.Insert(lotser);
                return(lotser.LotSerClassID);
            }
            else
            {
                return(lotSerClass.LotSerClassID);
            }
        }
コード例 #8
0
        protected virtual void INKitSpecStkDet_UOM_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            INKitSpecStkDet row = e.Row as INKitSpecStkDet;

            if (row != null)
            {
                InventoryItem component = InventoryItem.PK.Find(this, row.CompInventoryID);
                INLotSerClass lsClass   = INLotSerClass.PK.Find(this, component?.LotSerClassID);
                if (lsClass != null &&
                    lsClass.LotSerTrack == INLotSerTrack.SerialNumbered &&
                    !string.Equals(component.BaseUnit, (string)e.NewValue, StringComparison.InvariantCultureIgnoreCase))
                {
                    var ex = new PXSetPropertyException(Messages.SerialNumberedComponentMustBeInBaseUnitOnly, component.BaseUnit);
                    ex.ErrorValue = e.NewValue;
                    RaiseSerialTrackedComponentIsNotInBaseUnitException(e, ex);
                }
            }
        }
コード例 #9
0
        protected virtual void INKitSpecHdr_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            INKitSpecHdr row = e.Row as INKitSpecHdr;

            if (row != null)
            {
                InventoryItem item = KitItem.Select();
                if (item != null)
                {
                    PXUIFieldAttribute.SetEnabled <INKitSpecHdr.kitSubItemID>(sender, row, item.StkItem == true);
                    row.IsNonStock = item.StkItem != true;
                    if (row.LotSerTrack == null)
                    {
                        INLotSerClass kitLotSerClass = PXSelect <INLotSerClass, Where <INLotSerClass.lotSerClassID, Equal <Required <INLotSerClass.lotSerClassID> > > > .Select(this, item.LotSerClassID);

                        if (kitLotSerClass != null)
                        {
                            row.LotSerTrack = kitLotSerClass.LotSerTrack;
                        }
                    }
                }
            }
        }
コード例 #10
0
        protected virtual void INTran_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            InventoryItem item      = (InventoryItem)PXSelectorAttribute.Select <INTran.inventoryID>(sender, e.Row);
            INLotSerClass itemclass =
                (INLotSerClass)PXSelectorAttribute.Select <InventoryItem.lotSerClassID>(this.Caches[typeof(InventoryItem)], item);

            PXPersistingCheck check =
                ((INTran)e.Row).InvtMult != 0 && (
                    (item != null && item.ValMethod == INValMethod.Specific) ||
                    (itemclass != null &&
                     itemclass.LotSerTrack != INLotSerTrack.NotNumbered &&
                     itemclass.LotSerAssign == INLotSerAssign.WhenReceived &&
                     ((INTran)e.Row).Qty != 0m))
                                 ? PXPersistingCheck.NullOrBlank
                                 : PXPersistingCheck.Nothing;


            PXDefaultAttribute.SetPersistingCheck <INTran.subID>(sender, e.Row, PXPersistingCheck.Null);
            PXDefaultAttribute.SetPersistingCheck <INTran.locationID>(sender, e.Row, PXPersistingCheck.Null);
            PXDefaultAttribute.SetPersistingCheck <INTran.lotSerialNbr>(sender, e.Row, check);

            if (adjustment.Current != null && adjustment.Current.OrigModule != INRegister.origModule.PI && item != null && item.ValMethod == INValMethod.FIFO && ((INTran)e.Row).OrigRefNbr == null)
            {
                if (sender.RaiseExceptionHandling <INTran.origRefNbr>(e.Row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(INTran.origRefNbr).Name)))
                {
                    throw new PXRowPersistingException(typeof(INTran.origRefNbr).Name, null, ErrorMessages.FieldIsEmpty, typeof(INTran.origRefNbr).Name);
                }
            }

            if (item != null && item.ValMethod == INValMethod.Standard && ((INTran)e.Row).TranType == INTranType.Adjustment && ((INTran)e.Row).BaseQty == 0m && ((INTran)e.Row).TranCost != 0m)
            {
                if (sender.RaiseExceptionHandling <INTran.tranCost>(e.Row, ((INTran)e.Row).TranCost, new PXSetPropertyException(Messages.StandardCostNoCostOnlyAdjust)))
                {
                    throw new PXRowPersistingException(typeof(INTran.tranCost).Name, ((INTran)e.Row).TranCost, Messages.StandardCostNoCostOnlyAdjust);
                }
            }
        }
コード例 #11
0
        protected virtual void INPIDetail_PhysicalQty_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            if (e.NewValue == null)
            {
                return;
            }

            decimal       value   = (decimal)e.NewValue;
            INPIDetail    d       = (INPIDetail)e.Row;
            INLotSerClass inclass = SelectLotSerClass(d.InventoryID);

            if ((decimal?)e.NewValue < 0m)
            {
                throw new PXSetPropertyException(CS.Messages.Entry_GE, PXErrorLevel.Error, (int)0);
            }

            if (inclass != null &&
                LSRequired(inclass) &&
                inclass.LotSerTrack == INLotSerTrack.SerialNumbered &&
                value != 0m && value != 1m)
            {
                throw new PXSetPropertyException(Messages.PIPhysicalQty);
            }
        }
コード例 #12
0
 protected virtual bool LSRequired(INLotSerClass lsc_rec)
 {
     return(lsc_rec == null ? false :
            lsc_rec.LotSerTrack != INLotSerTrack.NotNumbered &&
            lsc_rec.LotSerAssign == INLotSerAssign.WhenReceived);
 }