コード例 #1
0
        //[DataMember]
        //public virtual IList<Label> Labels { get; set; }


        public override Boolean Equals(object obj)
        {
            if ((obj == null) || (obj.GetType() != this.GetType()))
            {
                return(false);
            }
            NodeTrace castObj = (NodeTrace)obj;

            return((castObj != null) &&
                   (this.RowID == castObj.RowID));
        }
コード例 #2
0
ファイル: BasicMngr.cs プロジェクト: erwin-hamid/LogPro
        public void SaveNodeTrace(NodeTrace nodeTrace)
        {
            //nodeTrace.RowID = 0;
            nodeTrace.CreationDate = DateTime.Now;
            nodeTrace.CreatedBy = (nodeTrace.CreatedBy == null) ? "" : nodeTrace.CreatedBy;
            nodeTrace.FatherLabel = nodeTrace.Label.FatherLabel;

            if (nodeTrace.Unit == null)
                nodeTrace.Unit = nodeTrace.Label.Unit; //Added: Dec05/2009

            if (nodeTrace.Bin == null)
                nodeTrace.Bin = (nodeTrace.Label != null) ? nodeTrace.Label.Bin : null;
            nodeTrace.Status = new Status { StatusID = EntityStatus.Active };

            Factory.DaoNodeTrace().Save(nodeTrace);
           
        }
コード例 #3
0
ファイル: BasicMngr.cs プロジェクト: erwin-hamid/LogPro
        public Boolean ValidateReceiptDocumentTrackingOptions(Document data, Node node, Boolean autoThrow)
        {
            //Hace que traiga las lineas in lazy = true
            Factory.IsTransactional = true;

            //Validate company is linked to ERP
            /*
            if (Factory.DaoConfigOptionByCompany()
                        .Select(new ConfigOptionByCompany
                        {
                            ConfigOption = new ConfigOption { Code = "WITHERP" },
                            Company = data.Company,
                        }
                        ).FirstOrDefault().Value == "F")
                return true;
            */

            //Saco los productos del document que requieren track options
            IList<Product> productList;
            if (data.IsFromErp == true)
                productList = Factory.DaoDocumentLine().Select(new DocumentLine { Document = data })
                    .Select(f => f.Product).Where(f => f.ProductTrack != null && f.ProductTrack.Count > 0)
                    .Distinct().ToList();
            else
                productList = Factory.DaoDocumentBalance().PostingBalance(
                    new DocumentBalance { Document = data, Location = data.Location, Node = node })
                    .Select(f => f.Product).ToList();


            if (productList == null || productList.Count == 0)
                return true; //No tiene track option ninguno de los productos


            //Busca si todos los items tienen el track que necesitan.
            string errorMsg = "";
            NodeTrace pattern = null;
            foreach (Product product in productList)
            {
                if (product.ProductTrack == null || product.ProductTrack.Count == 0) //product.ErpTrackOpt == 0 ||
                    continue;

                //Para las que no son unique //LOTES/FECHAS etc.
                foreach (ProductTrackRelation pt in product.ProductTrack.Where(f => f.TrackOption.IsUnique != true && f.TrackOption.DataType.DataTypeID != SDataTypes.ProductQuality))
                {
                    if (Factory.DaoNodeTrace().GetRecordWithoutTrackOption(data, pt, node).Count > 0)
                    {
                        //errorMsg += "Product " + pt.Product.Name + " require " + pt.TrackOption.DisplayName + ".\n";
                        errorMsg += "Some " + pt.TrackOption.DisplayName + " for product " + product.ProductCode + " are missing.\n";
                        continue;
                    }
                }

                //Para productos unique, los labels de tipo 1002 deben tener X hijos de tipo 1005
                foreach (ProductTrackRelation pt in product.ProductTrack.Where(f => f.IsUnique == true))
                {
                    pattern = new NodeTrace
                    {
                        Document = data,
                        Label = new Label { Product = product, LabelType = new DocumentType { DocTypeID = LabelType.ProductLabel } },
                        Node = node
                    };


                    if (Factory.DaoNodeTrace().Select(pattern).Select(f => f.Label).Sum(f => f.CurrQty) > 0)
                    {
                        //errorMsg += "Product " + pt.Product.Name + " require " + pt.TrackOption.DisplayName + ".\n";
                        errorMsg += "Some " + pt.TrackOption.DisplayName + " for product " + product.ProductCode + " are missing.\n";
                        continue;
                    }
                }



            }

            if (!string.IsNullOrEmpty(errorMsg))
                if (autoThrow)
                {
                    Factory.Rollback();
                    throw new Exception(errorMsg + "Please enter data before process.");
                }
                else
                    return false;


            Factory.Commit();
            Factory.IsTransactional = false;
            return true;
        }
コード例 #4
0
ファイル: Control.cs プロジェクト: erwin-hamid/LogPro
 public void DeleteNodeTrace(NodeTrace data) { Factory.DaoNodeTrace().Delete(data); }
コード例 #5
0
ファイル: Control.cs プロジェクト: erwin-hamid/LogPro
 public void UpdateNodeTrace(NodeTrace data) { Factory.DaoNodeTrace().Update(data); }
コード例 #6
0
ファイル: Control.cs プロジェクト: erwin-hamid/LogPro
 public NodeTrace SaveNodeTrace(NodeTrace data) { return Factory.DaoNodeTrace().Save(data); }
コード例 #7
0
ファイル: Control.cs プロジェクト: erwin-hamid/LogPro
 public IList<NodeTrace> GetNodeTrace(NodeTrace data) { return Factory.DaoNodeTrace().Select(data); }
コード例 #8
0
        public void PickCrossDockProduct(Document purchase, IList<DocumentBalance> crossDockBalance, SysUser picker)
        {
            Factory.IsTransactional = true;

            Node storedNode = WType.GetNode(new Node { NodeID = NodeType.Stored });
            Node node = WType.GetNode(new Node { NodeID = NodeType.Picked });
            Status status = WType.GetStatus(new Status { StatusID = EntityStatus.Active });
            DocumentType labelType = WType.GetLabelType(new DocumentType { DocTypeID = LabelType.ProductLabel });

            Bin pickingBin = WType.GetBin(new Bin { Location = purchase.Location, BinCode = DefaultBin.PICKING });

            Dictionary<Document,Label> packageLabel = new Dictionary<Document,Label>();
            Status locked = WType.GetStatus(new Status { StatusID = EntityStatus.Locked });

           
            try
            {
                //Solo toma las lineas de sales y deja quietas las del docuemnto de purchasing
                foreach (DocumentBalance line in crossDockBalance.Where(f => f.Document.DocType.DocClass.DocClassID == SDocClass.Shipping))
                {
                    //Valida si el documento no es nulo
                    Rules.ValidateDocument(line.Document, true);


                    if (line.Document.DocType.DocTypeID != SDocType.PickTicket)
                    {
                        //Valida si el producto esta en ese documento
                        DocumentLine docLine = new DocumentLine
                        {
                            Document = line.Document,
                            Product = line.Product,
                            LineStatus = new Status { StatusID = DocStatus.New },
                            Unit = line.Unit,
                            Quantity = line.QtyProcessed //Quatity processed que es la que hace el cruce con el CrossDock
                        };

                        Rules.ValidateProductInDocument(docLine, true);

                        //Valida si hay saldo pendiente por procesar
                        try { Rules.ValidateBalanceQuantityInDocument(docLine, node, true, true); }
                        catch { continue; }
                    }

                    //Toma el producto del nodetrace
                    //Obtiene los labels que va a mover
                    NodeTrace sourceTrace = new NodeTrace
                    {
                        Document = purchase,
                        //Dec 7/09 no se puede forzar a que sea la misma unidad del balance //Unit = line.Unit,
                        Label = new Label { Product = line.Product, Node = storedNode, Status = status },
                        Status = status,
                        Node = storedNode
                    };

                    //Obtiene las transacciones del node trace para ese documento especifico de Purchase.                
                    IList<Label> labelList = Factory.DaoNodeTrace().Select(sourceTrace).Select(f => f.Label)
                        //.Take(int.Parse(line.QtyProcessed.ToString()))
                        .ToList();


                    if (labelList.Sum(f=>f.CurrQty*f.Unit.BaseAmount) < line.QtyProcessed * line.Unit.BaseAmount)
                    {
                        Factory.Rollback();
                        throw new Exception("No quantity available in the purchase document " + purchase.DocNumber
                            + " for product " + line.Product.FullDesc + ".\nQty Available: " + labelList.Sum(f => f.CurrQty * f.Unit.BaseAmount).ToString()
                            + " Qty Requested: " + (line.QtyProcessed * line.Unit.BaseAmount).ToString()+" in Doc# " + line.Document.DocNumber );
                    }


                    //Package Label para el Despacho
                    if (!packageLabel.ContainsKey(line.Document))
                        packageLabel.Add(line.Document, GetPackageLabel(new Label { LabelID = -1 }, line.Document, picker).PackLabel);


                    //Debe piquear la cantidad necesaria para suplir el SO con los labels 
                    //recibidos.

                    double crQtyBal = line.QtyProcessed*line.Unit.BaseAmount; //LLevada  a la unidad basica

                    foreach (Label curLabel in labelList)
                    {
                        if (crQtyBal <= 0)
                            break;

                        //Si el Qty del label menor que lo pendiente mando todo el label
                        if (curLabel.CurrQty*curLabel.Unit.BaseAmount <= crQtyBal)
                        {
                            //Si el destino es logitico lo hace su padre, si no es producto suelto en BIN
                            curLabel.ModifiedBy = purchase.ModifiedBy;
                            curLabel.Node = node;
                            curLabel.LastBin = curLabel.Bin;
                            curLabel.Bin = pickingBin;
                            curLabel.ModDate = DateTime.Now;

                            curLabel.FatherLabel = null;
                            curLabel.FatherLabel = packageLabel[line.Document];
                            curLabel.Status = locked;

                            SaveNodeTrace(new NodeTrace
                            {
                                Node = node,
                                Label = curLabel,
                                Quantity = curLabel.CurrQty,
                                Bin = pickingBin,
                                IsDebit = false,
                                CreatedBy = purchase.ModifiedBy,
                                Document = line.Document,
                                // 07 Marzo 2009
                                // En el comenttario se pone el # del PO de cross dock, 
                                // este dato sirve en caso de reversion del crossdock process
                                Comment = purchase.DocNumber
                            });

                           
                            curLabel.ShippingDocument = line.Document;
                            Factory.DaoLabel().Update(curLabel);
                            crQtyBal -= curLabel.CurrQty * curLabel.Unit.BaseAmount;
                        }

                        //Si no: disminuyo el Qty del label y hago un Increase
                        else
                        {
                            //Si el destino es logitico lo hace su padre, si no es producto suelto en BIN
                            curLabel.ModifiedBy = purchase.ModifiedBy;
                            curLabel.ModDate = DateTime.Now;
                            curLabel.CurrQty -= crQtyBal;
                            Factory.DaoLabel().Update(curLabel);

                            //Increase The Pick Node

                            Node pickNode = WType.GetNode(new Node { NodeID = NodeType.Picked });

                            DocumentLine crdLine = new DocumentLine {
                                Document = line.Document,
                                Product = line.Product,
                                Quantity = crQtyBal,
                                CreatedBy = purchase.ModifiedBy
                            };

                            Label pickedLabel = IncreaseQtyIntoBin(crdLine, pickNode, Rules.GetBinForNode(pickNode, purchase.Location), 
                                "Picking Dest", true, DateTime.Now, null, curLabel);
                           
                            pickedLabel.FatherLabel = packageLabel[line.Document];
                            pickedLabel.Status = locked;
                            pickedLabel.ShippingDocument = line.Document;
                            
                            Factory.DaoLabel().Update(pickedLabel);

                            //Factory.Commit();
                        }

                    }



                    /*
                    //Acutualiza la ubicacion Nuevo Bin
                    foreach (Label curLabel in labelList)
                    {
                        //Si el destino es logitico lo hace su padre, si no es producto suelto en BIN
                        curLabel.ModifiedBy = purchase.ModifiedBy;
                        curLabel.Node = node;
                        curLabel.LastBin = curLabel.Bin;
                        curLabel.Bin = pickingBin;

                        SaveNodeTrace(new NodeTrace
                        {
                            Node = node,
                            Label = curLabel,
                            Quantity = curLabel.CurrQty,
                            Bin = pickingBin,
                            IsDebit = false,
                            CreatedBy = purchase.ModifiedBy,
                            Document = line.Document,
                            // 07 Marzo 2009
                            // En el comenttario se pone el # del PO de cross dock, 
                            // este dato sirve en caso de reversion del crossdock process
                            Comment = purchase.DocNumber
                        });

                        curLabel.FatherLabel = null;
                        Factory.DaoLabel().Update(curLabel);
                    }
                     */

                }

                Factory.Commit();


                //Actualiza el estado de los documentos de shiiping a CrossDock
                foreach (Document doc in crossDockBalance.Where(f => f.Document.DocType.DocClass.DocClassID == SDocClass.Shipping).Select(f => f.Document).Distinct())
                {
                    doc.CrossDocking = true;
                    Factory.DaoDocument().Update(doc);
                }

                Factory.Commit();

            }
            catch (Exception ex)
            {
                Factory.Rollback();
                ExceptionMngr.WriteEvent("PickCrossDockProduct:", ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business);
                throw new Exception(WriteLog.GetTechMessage(ex));
            }
        }
コード例 #9
0
        public Document ConfirmReplenishmentOrder(Document document)
        {

            if (document.DocStatus.StatusID != DocStatus.New && document.DocStatus.StatusID != DocStatus.InProcess)
                throw new Exception("Document was cancelled or already confirmed.");

            Factory.IsTransactional = true;

            Status active = WType.GetStatus(new Status { StatusID = EntityStatus.Active });
            Node voidNode = WType.GetNode(new Node { NodeID = NodeType.Voided });
            Node storedNode = WType.GetNode(new Node { NodeID = NodeType.Stored });

            try
            {

                //1. Update the old labels to void.
                NodeTrace pattern = new NodeTrace
                {
                    Document = document,
                    Node = new Node { NodeID = NodeType.Stored },
                    PostingDocument = new Document { DocID = 0 } //0 mean Null
                };

                IList<NodeTrace> tracelList = Factory.DaoNodeTrace().Select(pattern);

                foreach (NodeTrace nodeTrace in tracelList)
                {

                    nodeTrace.PostingDate = DateTime.Now;
                    nodeTrace.PostingDocument = document;
                    nodeTrace.PostingUserName = document.ModifiedBy;
                    nodeTrace.ModifiedBy = document.ModifiedBy;
                    nodeTrace.ModDate = DateTime.Now;
                    nodeTrace.Label.Status = active;
                    nodeTrace.Node = voidNode;

                    nodeTrace.Label.ModDate = DateTime.Now;
                    nodeTrace.Label.ModifiedBy = WmsSetupValues.SystemUser;
                    Factory.DaoLabel().Update(nodeTrace.Label);


                    //Create nodetrace to Void transaction
                    //Registra el movimiento del nodo
                    if (nodeTrace.IsDebit == false)
                        SaveNodeTrace(
                            new NodeTrace
                            {
                                Node = storedNode,
                                Document = document,
                                Label = nodeTrace.Label,
                                Quantity = nodeTrace.Label.CurrQty,
                                IsDebit = nodeTrace.IsDebit,
                                CreatedBy = document.ModifiedBy,
                                PostingDocument = document,
                                PostingUserName = document.ModifiedBy,
                                Comment = "Confirmed Replenishment, Order# " + document.DocNumber
                            });

                }


                Factory.Commit();

                //Actualizar el status del documento source a completed
                document.DocStatus = WType.GetStatus(new Status { StatusID = DocStatus.Completed });
                document.Comment = "Order Completed On " + DateTime.Now;
                Factory.DaoDocument().Update(document);

                Factory.Commit();
                return document;
            }

            catch (Exception ex)
            {
                Factory.Rollback();
                ExceptionMngr.WriteEvent("ConfirmReplenishmentOrder:", ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business);
                return null;
            }
        }
コード例 #10
0
        public Document ConfirmKitAssemblyOrder(Document document, Location location)
        {

            if (document.DocStatus.StatusID != DocStatus.New && document.DocStatus.StatusID != DocStatus.InProcess)
                throw new Exception("Document was cancelled or already confirmed.");


            Factory.IsTransactional = true;

            Status inactive = WType.GetStatus(new Status { StatusID = EntityStatus.Inactive });

            Node voidNode = WType.GetNode(new Node { NodeID = NodeType.Voided });

            //Process Node // El Kit debe quear en Stored Node
            Node storedNode = WType.GetNode(new Node { NodeID = NodeType.Stored });


            //validando que si exista un Producto a Crear y que tenga cantidad
            IList<DocumentLine> documentLine = Factory.DaoDocumentLine().Select(new DocumentLine { Document = document })
                    .Where(f => f.LinkDocLineNumber == -1).ToList();

            if (documentLine == null || documentLine.Count == 0)
                throw new Exception("Kit/Assembly product not found.");


            try
            {

                //1. Update the old labels to void.
                NodeTrace pattern = new NodeTrace
                {
                    Document = document,
                    Node = new Node { NodeID = NodeType.Process },
                    PostingDocument = new Document { DocID = 0 }, //0 mean Null
                };

                IList<NodeTrace> tracelList = Factory.DaoNodeTrace().Select(pattern);

                IList<Label> ListaComponentes = new List<Label>(); //Contiene los componentes principales para asignar el label code
                IList<Label> ListaFinal = new List<Label>(); //Contiene los labels creados para modificar el label code

                foreach (NodeTrace nodeTrace in tracelList)
                {

                    nodeTrace.PostingDate = DateTime.Now;
                    nodeTrace.PostingDocument = document;
                    nodeTrace.PostingUserName = document.ModifiedBy;
                    nodeTrace.ModifiedBy = document.ModifiedBy;
                    nodeTrace.ModDate = DateTime.Now;



                    //Update Label to Void Node
                    nodeTrace.Label.Node = voidNode;
                    nodeTrace.Label.Status = inactive;
                    nodeTrace.Label.LastBin = nodeTrace.Label.Bin;
                    //nodeTrace.Label.Bin = bin;
                    nodeTrace.Label.CurrQty = 0;

                    Factory.DaoLabel().Update(nodeTrace.Label);

                    //Si el componente es principal, lo adiciono al listado para asignar el label code
                    if (nodeTrace.Label.Product.UpcCode == "10")
                        ListaComponentes.Add(nodeTrace.Label);

                    //Create nodetrace to Void transaction
                    //Registra el movimiento del nodo
                    SaveNodeTrace(
                        new NodeTrace
                        {
                            Node = voidNode,
                            Document = document,
                            Label = nodeTrace.Label,
                            Quantity = nodeTrace.Label.CurrQty,
                            IsDebit = nodeTrace.IsDebit,
                            CreatedBy = document.ModifiedBy,
                            PostingDocument = document,
                            PostingUserName = document.ModifiedBy,
                            Comment = "Decrease Kit/Assembly Component, Order# " + document.DocNumber
                        });

                }

                //2. Increase the inventory with the kit/assembly created.
                //Crear las labels del nuevo producto creado, en que BIN?

                foreach (DocumentLine docLine in documentLine)
                {

                    //Evalua si el producto tiene default BIN y lo crea en ese BIN
                    string kitAsmBin;
                    try { kitAsmBin = GetProductDefaultBinLabel(docLine.Product, location, BinType.Out_Only).Bin.BinCode; }
                    catch
                    {
                        //Bin donde se almacena el new label
                        kitAsmBin = GetCompanyOption(document.Company, "BINKITASM");
                        if (string.IsNullOrEmpty(kitAsmBin))
                            kitAsmBin = DefaultBin.MAIN;

                    }

                    Bin bin = Factory.DaoBin().Select(new Bin { BinCode = kitAsmBin, Location = location })
                        .Where(f=>f.BinCode == kitAsmBin).First();

                    //Create the new labels with new product
                    double logisticFactor = 1; //debe imprimir un label por cada Assembly.
                    ListaFinal = CreateProductLabels(null, docLine, storedNode, bin, logisticFactor, document.DocNumber,
                        "Increase Kit/Assembly Component, Order# " + document.DocNumber, DateTime.Now);

                    //Actualiza el documento con el Bin donde se creo el producto
                    docLine.BinAffected = bin.BinCode;
                    Factory.DaoDocumentLine().Update(docLine);

                    //Actualizo los labelcode con los seriales de los componentes principales
                    int control = 0;
                    foreach (Label Componente in ListaFinal)
                    {
                        Componente.LabelCode = ListaComponentes[control].LabelCode;
                        Factory.DaoLabel().Update(Componente);
                        control++;
                    }
                }

                Factory.Commit();

                //Actualizar el status del documento source a completed
                document.DocStatus = WType.GetStatus(new Status { StatusID = DocStatus.Completed });
                document.Comment = "Order Completed On " + DateTime.Now;
                Factory.DaoDocument().Update(document);

                Factory.Commit();
                return document;
            }

            catch (Exception ex)
            {
                Factory.Rollback();
                ExceptionMngr.WriteEvent("ConfirmKitAssemblyOrder:", ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business);
                return null;
            }
        }
コード例 #11
0
        //Permite reversar un documento IA que fue posteado en el ERP, 
        //solo se reversa si en el ERP no lo ha posteado
        public void ReverseInventoryAdjustment(Document data)
        {

            //if (data.Company.ErpConnection == null)
            //    throw new Exception("Please setup Erp Connection.");

            Factory.IsTransactional = true;

            //SetConnectMngr(data.Company);

            Node storedNode = new Node { NodeID = NodeType.Stored };
            Node voidNode = WType.GetNode(new Node { NodeID = NodeType.Voided });

            try
            {


                //Update document status to Cancelled
                Status cancelled = WType.GetStatus(new Status { StatusID = DocStatus.Cancelled });
                Status inactive = WType.GetStatus(new Status { StatusID = EntityStatus.Inactive });
                Status active = WType.GetStatus(new Status { StatusID = EntityStatus.Active });

                data.DocStatus = cancelled;
                Factory.DaoDocument().Update(data);

                //Pasa las lineas del documento a Cancelled                
                IList<DocumentLine> docLines = Factory.DaoDocumentLine().Select(new DocumentLine { Document = data });

                foreach (DocumentLine dl in docLines)
                {
                    dl.LineStatus = cancelled;
                    Factory.DaoDocumentLine().Update(dl);
                }

                //update NodeTrace
                NodeTrace qNodeTrace = new NodeTrace { PostingDocument = data };

                //Busca todo los registros de ese documento y los reversa
                IList<NodeTrace> nodeTraceList = Factory.DaoNodeTrace().Select(qNodeTrace);


                Label curLabel;

                foreach (NodeTrace trace in nodeTraceList)
                {

                    //Reverse labels que se generaron con el ajuste, si son negativos 
                    //Pasan de nuevo a stored, si son positivos pasan a void.
                    curLabel = trace.Label;
                    curLabel.Node = (trace.IsDebit == true) ? storedNode : voidNode;
                    curLabel.CurrQty = (trace.IsDebit == true) ? curLabel.CurrQty : 0;
                    curLabel.Status = (trace.IsDebit == true) ? active : inactive;
                    curLabel.ModDate = DateTime.Now;
                    curLabel.ModifiedBy = data.ModifiedBy;
                    Factory.DaoLabel().Update(curLabel);


                    //Crear un trace que tenga la transaccion del posting eliminado en el nodo void
                    //Registra el movimiento del nodo
                    SaveNodeTrace(
                        new NodeTrace
                        {
                            Node = (trace.IsDebit == true) ? storedNode : voidNode,
                            Document = trace.Document,
                            Label = trace.Label,
                            Quantity = trace.Quantity,
                            IsDebit = !trace.IsDebit,
                            CreatedBy = trace.CreatedBy,
                            PostingDocument = trace.PostingDocument,
                            PostingUserName = trace.PostingUserName,
                            Status = active, // inactive,
                            Comment = trace.PostingDocument.DocNumber + " Reversed",
                            ModDate = DateTime.Now,
                            ModifiedBy = data.ModifiedBy,
                            PostingDate = trace.PostingDate,
                        });

                    //Factory.DaoNodeTrace().Delete(trace);


                }

                Factory.Commit();

            }
            catch (Exception ex)
            {
                Factory.Rollback();
                ExceptionMngr.WriteEvent("ReverseInventoryAdjustment #" + data.DocNumber, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Persistence);
                throw;
                //return;
            }
        }
コード例 #12
0
        //Permite reversar un documento que fue creado y enviado al ERP
        //solo se reversa si en el ERP no lo ha posteado
        public void ReverseShipmentDocument(Document data, Bin binRestore)
        {
            Factory.IsTransactional = true;

            //Revisa si se debe enviar el recibo al ERP, es decir si esta en true la opcion de conexion a ERP
            bool ErpConnected = GetCompanyOption(data.Company, "WITHERPSH").Equals("T");

            Node releaseNode = new Node { NodeID = NodeType.Released };
            Node storeNode = new Node { NodeID = NodeType.Stored };

            try
            {


                //Update document status to Cancelled
                Status cancelled = WType.GetStatus(new Status { StatusID = DocStatus.Cancelled });
                Status inactive = WType.GetStatus(new Status { StatusID = EntityStatus.Inactive });
                Status active = WType.GetStatus(new Status { StatusID = EntityStatus.Active });


                //Cancelacion del Assembly Order en caso de que haya conexion al ERP y la opcion
                // ERPASMORDER este en True para esa compania
                // 22 Mayo de 2007, Mande el resultado a Notes para poder enviarlo en el mail
                // COMENTARIADO EL 3 Junio de 2009 - Se quita el envio a GP
                /*
                if (GetCompanyOption(data.Company, "SHOWCOMP").Equals("T") && GetCompanyOption(data.Company, "ERPASMORDER").Equals("T"))
                {
                    SetConnectMngr(data.Company);
                    data.Comment += "\n\n" + ErpFactory.Documents().CancelKitAssemblyOrderBasedOnSalesDocument(data);
                }
                */

                data.DocStatus = cancelled;
                Factory.DaoDocument().Update(data);

                //Pasa las lineas del documento a Cancelled                
                IList<DocumentLine> docLines = Factory.DaoDocumentLine().Select(new DocumentLine { Document = data });

                foreach (DocumentLine dl in docLines)
                {
                    dl.LineStatus = cancelled;
                    Factory.DaoDocumentLine().Update(dl);
                }

                //update NodeTrace
                NodeTrace qNodeTrace = new NodeTrace { PostingDocument = data };

                //Busca todo los registros de ese documento y los reversa
                IList<NodeTrace> nodeTraceList = Factory.DaoNodeTrace().Select(qNodeTrace);

                Node voidNode = WType.GetNode(new Node { NodeID = NodeType.Voided });

                Label curLabel;

                foreach (NodeTrace trace in nodeTraceList)
                {

                    //Crear un trace que tenga la transaccion del posting eliminado en el nodo void
                    //Registra el movimiento del nodo
                    if (trace.Node.NodeID == NodeType.Released)
                    {

                        trace.Node = voidNode;
                        trace.Status = inactive;
                        trace.ModDate = DateTime.Now;
                        trace.ModifiedBy = data.ModifiedBy;
                        trace.Comment = "Released: " + trace.PostingDocument.DocNumber + " Reversed";
                        Factory.DaoNodeTrace().Update(trace);
                        
                        SaveNodeTrace(
                            new NodeTrace
                            {
                                Node = storeNode,
                                Document = trace.Document,
                                Label = trace.Label,
                                Quantity = trace.Quantity,
                                IsDebit = trace.IsDebit,
                                CreatedBy = trace.CreatedBy,
                                //PostingDocument = trace.PostingDocument,
                                //PostingUserName = trace.PostingUserName,
                                Status = active,
                                Comment = "Stock: " + trace.PostingDocument.DocNumber + " Reversed",
                                CreationDate= DateTime.Now,
                                //ModifiedBy = data.ModifiedBy,
                                //PostingDate = trace.PostingDate,
                            });
                        
                    }


                    //Reversa el trace original para poderlo postear nuevamente o reversarlo a stored
                    if (trace.Node.NodeID == NodeType.Picked)
                    {
                        //trace.DocumentLine = null;
                        //trace.PostingDate = null;
                        //trace.PostingDocument = null;
                        //trace.PostingUserName = null;
                        trace.ModifiedBy = data.ModifiedBy;
                        trace.ModDate = DateTime.Now;
                        trace.Node = voidNode;
                        trace.Comment = "Picked: " + trace.PostingDocument.DocNumber + " Reversed";
                        Factory.DaoNodeTrace().Update(trace);
                    }

                    //Recorre los Packages de ese shipment y reversa los labels HIjos
                    //Poner en Void los package Labels de ese documento.
                    IList<DocumentPackage> packList = Factory.DaoDocumentPackage().Select(new DocumentPackage { PostingDocument = data });
                    IList<Label> labelList;
                    foreach (DocumentPackage curPack in packList)
                    {
                        labelList = Factory.DaoLabel().Select(new Label { FatherLabel = curPack.PackLabel });

                        foreach (Label lbl in labelList)
                        {
                            //Reverse labels to node trace stored
                            lbl.Bin = binRestore;
                            lbl.Node = storeNode;
                            lbl.ModDate = DateTime.Now;
                            lbl.ModifiedBy = data.ModifiedBy;
                            lbl.Status = active;
                            lbl.ShippingDocument = null;
                            lbl.FatherLabel = null;

                            Factory.DaoLabel().Update(lbl);


                            //Reversando los Hijos en caso de que ese label tenga Hijos
                            try
                            {
                                lbl.ChildLabels = Factory.DaoLabel().Select(new Label { FatherLabel = lbl });

                                if (lbl.ChildLabels != null && lbl.ChildLabels.Count > 0)

                                    foreach (Label child in lbl.ChildLabels)
                                    {
                                        child.Bin = binRestore;
                                        child.Node = storeNode;
                                        child.ModDate = DateTime.Now;
                                        child.ModifiedBy = data.ModifiedBy;
                                        child.Status = active;
                                        child.ShippingDocument = null;

                                        Factory.DaoLabel().Update(child);
                                    }
                            }
                            catch { }                            



                        }


                        curPack.PackLabel.Status = inactive;
                        curPack.PackLabel.Node = voidNode;
                        Factory.DaoLabel().Update(curPack.PackLabel);
                    }

                }

                

                #region Restoring QtyShipped - JM Ene21/2010
                //reversando el ShippedQty to the Original Order Qher is a MergedOrder

                try
                {
                    Document mergedDoc = Factory.DaoDocument().Select(new Document { DocNumber = data.CustPONumber, Company = data.Company }).First();

                    mergedDoc.PostingDocument = "";
                    mergedDoc.Priority = 0;
                    Factory.DaoDocument().Update(mergedDoc);

                    if (mergedDoc.DocType.DocTypeID == SDocType.MergedSalesOrder)
                    {

                        DocumentLine mergedLine;
                        DocumentLine oriLine;

                        //1. Toma las lineas del Shipped
                        foreach (DocumentLine shipLine in docLines)
                        {
                            try
                            {
                                //2. Busca las lineas del merged y luego la original
                                mergedLine = Factory.DaoDocumentLine().Select(new DocumentLine
                                {
                                    Document = new Document { DocNumber = shipLine.LinkDocNumber, Company = data.Company },
                                    LineNumber = shipLine.LinkDocLineNumber
                                }).First();


                                //2. Busca las lineas del merged original
                                oriLine = Factory.DaoDocumentLine().Select(new DocumentLine
                                {
                                    Document = new Document { DocNumber = mergedLine.LinkDocNumber, Company = data.Company },
                                    LineNumber = mergedLine.LinkDocLineNumber
                                }).First();

                                //3. Actualiza el QtyShipped.
                                oriLine.QtyShipped -= shipLine.Quantity;
                                oriLine.ModDate = DateTime.Now;
                                oriLine.QtyBackOrder = 0;
                                oriLine.QtyAllocated = 0;
                                oriLine.QtyCancel = 0;
                                //
                                Factory.DaoDocumentLine().Update(oriLine);
                            }
                            catch (Exception ex)
                            {
                                ExceptionMngr.WriteEvent("Updating ShipQty:" + data.DocNumber + ", Line:" + shipLine.LineNumber, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business);
                                continue;
                            }

                        }
                    }
                }
                catch (Exception ex)
                {
                    ExceptionMngr.WriteEvent("Updating ShipQty:" + data.DocNumber, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business);
                }


                #endregion



                Factory.Commit();



            }
            catch (Exception ex)
            {
                Factory.Rollback();
                ExceptionMngr.WriteEvent("ReverseSalesShipment #" + data.DocNumber, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Persistence);
                throw;
            }
        }
コード例 #13
0
        //Cuando las lineas no requieren de hacer link con un Documento en el ERP
        private Object[] SalesLinesForTask(Document shipTask, Document ssDocument)
        {
            Object[] result = new Object[2];

            try
            {
                //Node releaseNode = new Node { NodeID = NodeType.Released };
                Node pickNode = new Node { NodeID = NodeType.Picked };


                //Armar las lineas del documento de Recibo
                IList<DocumentLine> ssDocLines = new List<DocumentLine>();

                //Obtiene los nodetrace records a recorrer, 
                //los que no han sido posteados para esa tarea de recibo
                NodeTrace qNodeTrace = new NodeTrace { Document = shipTask, PostingDocument = new Document { DocID = 0 }, Node = pickNode };
                IList<NodeTrace> nodeTraceList = Factory.DaoNodeTrace().Select(qNodeTrace);
                Status status = WType.GetStatus(new Status { StatusID = DocStatus.New });

                DocumentLine ssLine;
                Double line = 0;

                //Leva el conteo del acumulado a recibir
                IDictionary<UnitProductRelation, Double[]> shipmentBalance = new Dictionary<UnitProductRelation, Double[]>();
                UnitProductRelation curUnitProduct;

                //Consolidar las lineas de la misma unidad y hacer una sola linea
                foreach (NodeTrace nodeTrace in nodeTraceList)
                {
                    if (nodeTrace.Label.Product == null)
                        continue;

                    //Armando el consolidado
                    curUnitProduct = Factory.DaoUnitProductRelation().Select(
                        new UnitProductRelation
                        {
                            Unit = nodeTrace.Label.Unit,
                            Product = nodeTrace.Label.Product
                        }).First();

                    if (shipmentBalance.ContainsKey(curUnitProduct))
                        shipmentBalance[curUnitProduct][1] += nodeTrace.Quantity;
                    else
                    {
                        line += 1;
                        shipmentBalance.Add(curUnitProduct, new Double[2] { line, nodeTrace.Quantity });
                    }


                    //Update Node Trace
                    nodeTrace.Document = shipTask;
                    nodeTrace.PostingDate = DateTime.Now;
                    nodeTrace.PostingDocument = ssDocument;
                    nodeTrace.PostingDocLineNumber = (Int32)line;
                    nodeTrace.PostingUserName = ssDocument.CreatedBy;
                    nodeTrace.ModifiedBy = ssDocument.CreatedBy;
                    nodeTrace.ModDate = DateTime.Now;

                    Factory.DaoNodeTrace().Update(nodeTrace);
                }



                //Recorre la coleccion de balance para adicionar las demas lineas del recibo
                foreach (UnitProductRelation unitProductRel in shipmentBalance.Keys)
                {
                    //Si hay cantidad (elemento 1)
                    if (shipmentBalance[unitProductRel][1] > 0)
                    {

                        //Crea una linea para el documento de recibo obteniedo la info del balance
                        ssLine = new DocumentLine
                        {
                            Product = unitProductRel.Product,
                            Quantity = shipmentBalance[unitProductRel][1],
                            Unit = unitProductRel.Unit,
                            Document = ssDocument,
                            CreationDate = DateTime.Now,
                            IsDebit = false,
                            LineNumber = (Int32)shipmentBalance[unitProductRel][0],
                            LineStatus = status,
                            Location = ssDocument.Location,
                            UnitBaseFactor = unitProductRel.Unit.BaseAmount,
                            CreatedBy = ssDocument.CreatedBy,
                            Date1 = DateTime.Now
                        };

                        ssDocLines.Add(ssLine);
                    }
                }

                result[0] = ssDocLines;
                result[1] = nodeTraceList;

                return result;

            }
            catch (Exception ex)
            {
                //Factory.Rollback();
                ExceptionMngr.WriteEvent("SalesLinesForTask", ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business);
                //throw;
                return null;
            }
        }
コード例 #14
0
ファイル: DocumentMngr.cs プロジェクト: erwin-hamid/LogPro
        private void ReversePickedProduct(Document data)
        {

            //Node releaseNode = new Node { NodeID = NodeType.Released };
            Node storeNode = new Node { NodeID = NodeType.Stored };
            Bin binRestore = WType.GetBin(new Bin {BinCode = DefaultBin.MAIN, Location = data.Location});

            //Update document status to Cancelled
            Status cancelled = WType.GetStatus(new Status { StatusID = DocStatus.Cancelled });
            Status inactive = WType.GetStatus(new Status { StatusID = EntityStatus.Inactive });
            Status active = WType.GetStatus(new Status { StatusID = EntityStatus.Active });

            //update NodeTrace
            NodeTrace qNodeTrace = new NodeTrace { Document = data };

            //Busca todo los registros de ese documento y los reversa
            IList<NodeTrace> nodeTraceList = Factory.DaoNodeTrace().Select(qNodeTrace);

            Node voidNode = WType.GetNode(new Node { NodeID = NodeType.Voided });

            //Label curLabel;

            foreach (NodeTrace trace in nodeTraceList)
            {
                //Reversa el trace original para poderlo postear nuevamente o reversarlo a stored
                if (trace.Node.NodeID == NodeType.Picked)
                {
                    trace.ModifiedBy = data.ModifiedBy;
                    trace.ModDate = DateTime.Now;
                    trace.Node = voidNode;
                    trace.Comment = "Picked: " + trace.Document.DocNumber + " Reversed";
                    Factory.DaoNodeTrace().Update(trace);

                    // CAA
                    // Vuelve a Stock node
                    SaveNodeTrace(
                        new NodeTrace
                        {
                            Node = storeNode,
                            Document = trace.Document,
                            Label = trace.Label,
                            Quantity = trace.Quantity,
                            IsDebit = trace.IsDebit,
                            CreatedBy = trace.CreatedBy,
                            Status = active,
                            Comment = "Stock: " + trace.Document.DocNumber + " Reversed",
                            CreationDate = DateTime.Now
                        });
                }

                //Recorre los Packages de ese document y reversa los labels HIjos
                //Poner en Void los package Labels de ese documento.
                IList<DocumentPackage> packList = Factory.DaoDocumentPackage().Select(new DocumentPackage { Document = data });
                IList<Label> labelList;
                foreach (DocumentPackage curPack in packList)
                {
                    labelList = Factory.DaoLabel().Select(new Label { FatherLabel = curPack.PackLabel });

                    foreach (Label lbl in labelList)
                    {
                        //Reverse labels to node trace stored
                        lbl.Bin = binRestore;
                        lbl.Node = storeNode;
                        lbl.ModDate = DateTime.Now;
                        lbl.ModifiedBy = data.ModifiedBy;
                        lbl.Status = active;
                        lbl.ShippingDocument = null;
                        lbl.FatherLabel = null;

                        Factory.DaoLabel().Update(lbl);


                        //Reversando los Hijos en caso de que ese label tenga Hijos
                        try
                        {
                            lbl.ChildLabels = Factory.DaoLabel().Select(new Label { FatherLabel = lbl });

                            if (lbl.ChildLabels != null && lbl.ChildLabels.Count > 0)

                                foreach (Label child in lbl.ChildLabels)
                                {
                                    child.Bin = binRestore;
                                    child.Node = storeNode;
                                    child.ModDate = DateTime.Now;
                                    child.ModifiedBy = data.ModifiedBy;
                                    child.Status = active;
                                    child.ShippingDocument = null;

                                    Factory.DaoLabel().Update(child);
                                }
                        }
                        catch { }
                    }

                    curPack.PackLabel.Status = inactive;
                    curPack.PackLabel.Node = voidNode;
                    Factory.DaoLabel().Update(curPack.PackLabel);
                }
            }
        }