Пример #1
0
        public void testReceivingBarcodesNoBarcode()
        {
            CswNbtMetaDataNodeType ChemicalNT   = TestData.CswNbtResources.MetaData.getNodeType("Chemical");
            CswNbtObjClassChemical ChemicalNode = TestData.CswNbtResources.Nodes.makeNodeFromNodeTypeId(ChemicalNT.NodeTypeId);

            CswNbtObjClassUnitOfMeasure GramNode = TestData.CswNbtResources.Nodes.GetNode(new CswPrimaryKey("nodes", 26745));

            CswNbtMetaDataNodeType SizeNT = TestData.CswNbtResources.MetaData.getNodeType("Size");
            CswNbtObjClassSize     Size   = TestData.CswNbtResources.Nodes.makeNodeFromNodeTypeId(SizeNT.NodeTypeId, OnAfterMakeNode : delegate(CswNbtNode NewNode)
            {
                CswNbtObjClassSize AsSize       = NewNode;
                AsSize.Material.RelatedNodeId   = ChemicalNode.NodeId;
                AsSize.UnitCount.Value          = 5;
                AsSize.InitialQuantity.Quantity = 10;
                AsSize.InitialQuantity.UnitId   = GramNode.NodeId;
            }, OverrideUniqueValidation: true);

            CswNbtActReceiving ReceivingAction = new CswNbtActReceiving(TestData.CswNbtResources, ChemicalNode.NodeId);

            CswNbtMetaDataNodeType  ContainerNT      = TestData.CswNbtResources.MetaData.getNodeType("Container");
            CswNbtObjClassContainer InitialContainer = ReceivingAction.makeContainer(null);
            JObject ContainerAddProps = ReceivingAction.getContainerAddProps(InitialContainer);

            int NumContainers = 2;
            CswNbtReceivingDefinition ReceiptDef = new CswNbtReceivingDefinition()
            {
                ContainerNodeId     = InitialContainer.NodeId,
                ContainerNodeTypeId = ContainerNT.NodeTypeId,
                ContainerProps      = ContainerAddProps,
                MaterialNodeId      = ChemicalNode.NodeId,
                Quantities          = new Collection <CswNbtAmountsGridQuantity>()
                {
                    new CswNbtAmountsGridQuantity()
                    {
                        NumContainers = NumContainers,
                        Quantity      = 10,
                        SizeName      = Size.NodeName,
                        SizeNodeId    = Size.NodeId,
                        UnitNodeId    = GramNode.NodeId,
                        ContainerIds  = new Collection <string>()
                        {
                            InitialContainer.NodeId.ToString()
                        }
                    }
                }
            };

            CswNbtMetaDataNodeTypeProp BarcodeNTP = ContainerNT.getNodeTypePropByObjectClassProp(CswNbtObjClassContainer.PropertyName.Barcode);
            string Before = BarcodeNTP.Sequence.getCurrent();

            ReceivingAction.receiveMaterial(ReceiptDef);
            string After = BarcodeNTP.Sequence.getCurrent();

            Assert.AreNotEqual(Before, After, "Creating containers in receiving with no custom barcodes specified did not consume sequence values when it should have");
        }
        /// <summary>
        /// Simulates clicking "Finish" on the Receiving Wizard
        /// </summary>
        private CswNbtReceivingDefinition FinishWizard()
        {
            CswNbtMetaDataNodeType  ContainerNT      = TestData.CswNbtResources.MetaData.getNodeType("Container");
            CswNbtObjClassContainer InitialContainer = _ReceivingAction.makeContainer(null);
            JObject ContainerAddProps = _ReceivingAction.getContainerAddProps(InitialContainer);

            CswNbtObjClassUnitOfMeasure GramNode = TestData.CswNbtResources.Nodes.GetNode(new CswPrimaryKey("nodes", 26745));     //TODO: don't hardcode this Gram

            //CREATES 16 CONTAINERS
            CswNbtReceivingDefinition ReceiptDef = new CswNbtReceivingDefinition()
            {
                ContainerNodeId     = InitialContainer.NodeId,
                ContainerNodeTypeId = ContainerNT.NodeTypeId,
                ContainerProps      = ContainerAddProps,
                MaterialNodeId      = _FirstChemicalNode.NodeId,
                Quantities          = new Collection <CswNbtAmountsGridQuantity>()
                {
                    new CswNbtAmountsGridQuantity()
                    {
                        NumContainers = 11,
                        Quantity      = 10,
                        SizeName      = _SizeOne.NodeName,
                        SizeNodeId    = _SizeOne.NodeId,
                        UnitNodeId    = GramNode.NodeId,
                        ContainerIds  = new Collection <string>()
                        {
                            InitialContainer.NodeId.ToString()
                        }
                    },
                    new CswNbtAmountsGridQuantity()
                    {
                        NumContainers = 5,
                        Quantity      = 100,
                        SizeName      = _SizeTwo.NodeName,
                        SizeNodeId    = _SizeTwo.NodeId,
                        UnitNodeId    = GramNode.NodeId
                    }
                }
            };

            //This should create out receipt lot and finalize the initial container
            int nodesProcessed = 0;

            _ReceivingAction.receiveContainers(ReceiptDef, ref nodesProcessed, 1);

            return(ReceiptDef);
        }
Пример #3
0
        protected override bool onButtonClick( NbtButtonData ButtonData )
        {
            if( null != ButtonData.NodeTypeProp )
            {
                bool HasPermission = false;
                string OCPPropName = ButtonData.NodeTypeProp.getObjectClassPropName();
                switch( OCPPropName )
                {
                    case PropertyName.Request:
                        if( _CswNbtResources.Permit.can( CswEnumNbtActionName.Submit_Request ) )
                        {
                            // Case CIS-52280
                            if( Obsolete.Checked == CswEnumTristate.True )
                            {
                                throw new CswDniException( CswEnumErrorType.Warning, "Can't request Material " + TradeName + " because it is obsolete.", "Material is obsolete" );
                            }

                            HasPermission = true;
                            CswNbtActRequesting RequestAct = new CswNbtActRequesting( _CswNbtResources );

                            CswNbtObjClassRequestItem RequestItem = RequestAct.makeMaterialRequestItem( this, ButtonData );

                            ButtonData.Data["requestaction"] = ButtonData.SelectedText;
                            //ButtonData.Data["requestaction"] = OCPPropName;
                            //Case 31298: Default Option Text "Request" != "Request By Bulk"
                            if( ButtonData.SelectedText == "Request" )
                            {
                                ButtonData.SelectedText = CswEnumRequestOption.Bulk;
                            }
                            ButtonData.Data["titleText"] = ButtonData.SelectedText + " for " + TradeName.Text;
                            ButtonData.Data["requestItemProps"] = RequestAct.getRequestItemAddProps( RequestItem.Node );
                            ButtonData.Data["requestItemNodeTypeId"] = RequestItem.NodeTypeId;
                            ButtonData.Data["relatednodeid"] = NodeId.ToString();
                            ButtonData.Action = CswEnumNbtButtonAction.request;
                        }
                        break;
                    case PropertyName.Receive:
                        if( _CswNbtResources.Permit.can( CswEnumNbtActionName.Receiving ) )
                        {
                            // Case CIS-52280
                            if( Obsolete.Checked == CswEnumTristate.True )
                            {
                                throw new CswDniException( CswEnumErrorType.Warning, "Can't receive Material " + TradeName + " because it is obsolete.", "Material is obsolete" );
                            }

                            HasPermission = true;
                            CswNbtActReceiving Act = new CswNbtActReceiving( _CswNbtResources, NodeId );
                            _CswNbtResources.setAuditActionContext( CswEnumNbtActionName.Receiving );

                            Action<CswNbtNode> After = delegate( CswNbtNode NewNode )
                                {
                                    CswNbtObjClassContainer newContainer = NewNode;
                                    //Case 29436
                                    if( newContainer.isLocationInAccessibleInventoryGroup( _CswNbtResources.CurrentNbtUser.DefaultLocationId ) )
                                    {
                                        newContainer.Location.SelectedNodeId = _CswNbtResources.CurrentNbtUser.DefaultLocationId;
                                    }
                                    newContainer.Owner.RelatedNodeId = _CswNbtResources.CurrentNbtUser.UserId;
                                    DateTime ExpirationDate = getDefaultExpirationDate( DateTime.Now );
                                    if( DateTime.MinValue != ExpirationDate )
                                    {
                                        newContainer.ExpirationDate.DateTimeValue = ExpirationDate;
                                    }
                                    //Container.postChanges( false );
                                };
                            CswNbtObjClassContainer Container = Act.makeContainer( After );

                            ButtonData.Data["state"] = new JObject();
                            ButtonData.Data["state"]["materialId"] = NodeId.ToString();
                            ButtonData.Data["state"]["materialNodeTypeId"] = NodeTypeId;
                            ButtonData.Data["state"]["tradeName"] = TradeName.Text;
                            ButtonData.Data["state"]["nodeName"] = NodeName;

                            Int32 ContainerLimit = CswConvert.ToInt32( _CswNbtResources.ConfigVbls.getConfigVariableValue( CswEnumNbtConfigurationVariables.container_receipt_limit.ToString() ) );
                            ButtonData.Data["state"]["containerlimit"] = ContainerLimit;
                            ButtonData.Data["state"]["containerNodeId"] = Container.NodeId.ToString();
                            ButtonData.Data["state"]["containerNodeTypeId"] = Container.NodeTypeId;
                            bool customBarcodes = CswConvert.ToBoolean( _CswNbtResources.ConfigVbls.getConfigVariableValue( CswEnumNbtConfigurationVariables.custom_barcodes.ToString() ) );
                            ButtonData.Data["state"]["customBarcodes"] = customBarcodes;
                            ButtonData.Data["state"]["nodetypename"] = this.NodeType.NodeTypeName;
                            ButtonData.Data["state"]["containerAddLayout"] = Act.getContainerAddProps( Container );

                            onReceiveButtonClick( ButtonData );
                            _setCofAData( ButtonData );
                            ButtonData.Action = CswEnumNbtButtonAction.receive;
                        }
                        break;
                    case CswNbtObjClass.PropertyName.Save:
                        HasPermission = true;
                        break;
                }
                HasPermission = HasPermission || onPropertySetButtonClick( ButtonData );
                if( false == HasPermission )
                {
                    throw new CswDniException( CswEnumErrorType.Warning, "You do not have permission to the " + OCPPropName + " action.", "You do not have permission to the " + OCPPropName + " action." );
                }
            }

            return true;
        }