public ReportHeaderFormat GetReportInformation(Document document, string template)
        {
            DataSet result = new DataSet();

            // quitamos temporalmente el location del Documento, para q no busque por ese filtro
            Location loc_doc = document.Location;
            document.Location = null;

            //Obtiene los datos del documento a procesar cuando el reporte es de tipo documento
            document = Factory.DaoDocument().Select(new Document { DocID = document.DocID }).First(); //.SelectById(document);
            document.Company = Factory.DaoCompany().SelectById(document.Company);

            document.Location = loc_doc;
            //Convert Object To DataSet


            if (template == WmsSetupValues.HAZMAT_REPORT)
                return ProcessHeaderAndDetailsForHAZMAT(document);
            
            else
            { //DEFAULT

                //Si es Shipment hace un tratamiento especial del document
                if (document.DocType.DocTypeID == SDocType.SalesShipment)
                    return ProcessHeaderAndDetailsForShipment(document);

                else if (document.DocType.DocTypeID == SDocType.CountTask)
                    return ProcessHeaderAndDetailsForCounting(document);

                else
                    return ProcessHeaderAndDetails(document);
            }

        }
        public IList <int> GetInspectionVendors(Entities.Trace.Document document)
        {
            string sQuery = "SELECT     MIN(Master.Account.AccountID) " +
                            "FROM         Master.Account RIGHT OUTER JOIN Trace.Label INNER JOIN " +
                            "Master.Product ON Trace.Label.ProductID = Master.Product.ProductID LEFT OUTER JOIN " +
                            "Master.ProductAccountRelation ON Master.ProductAccountRelation.AccTypeID = 2 " +
                            "AND Master.Product.ProductID = Master.ProductAccountRelation.ProductID ON " +
                            "Master.Account.AccountID = Master.ProductAccountRelation.AccountID " +
                            "WHERE     (Trace.Label.Notes = 'REPAIR') AND Master.Account.AccountCode NOT LIKE 'W-%' AND Master.Account.CompanyID = :co1 AND Trace.Label.PrintingLot = :id1 " +
                            "GROUP BY Label.ProductID  ";


            StringBuilder sql = new StringBuilder(sQuery);

            Parms = new List <Object[]>();
            Parms.Add(new Object[] { "id1", document.DocNumber });
            Parms.Add(new Object[] { "co1", document.Company.CompanyID });


            IQuery query = Factory.Session.CreateSQLQuery(sql.ToString());

            SetParameters(query);

            return(query.List <int>());
        }
Example #3
0
        public Document CreateNewDocument(Document data, Boolean autocommit)
        {

            //Start Transaction
            Factory.IsTransactional = true;

            //Asigna el consecutivo obtenido a el documento
            if (string.IsNullOrEmpty(data.DocNumber))
                data.DocNumber = GetNextDocSequence(data.Company, data.DocType).CodeSequence;

            //Informacion del Documento
            Account defaultAccount = WType.GetAccount(new Account { AccountCode = WmsSetupValues.DEFAULT });
            data.Customer = (data.Customer == null) ? defaultAccount : data.Customer;
            data.Vendor = (data.Vendor == null) ? defaultAccount : data.Vendor;

            data.DocStatus = (data.DocStatus == null) ? WType.GetStatus(new Status { StatusID = DocStatus.New }) : data.DocStatus;
            
            if (data.DocConcept == null)
                data.DocConcept = WType.GetDefaultConcept(data.DocType.DocClass);
            
            data.CreationDate = DateTime.Now;
            data.CreatedBy = (data.CreatedBy != null) ? data.CreatedBy : "";
            data.PickMethod = data.DocType.PickMethod;

            //Salva el documento nuevo y lo retorna
            data = Factory.DaoDocument().Save(data);

            if (autocommit)
                Factory.Commit();

            data.DocumentLines = new List<DocumentLine>();
            return data;

        }
Example #4
0
        public IList<Document> Select(Document data)
        {

                IList<Document> datos = new List<Document>();
                try
                {
                    datos = GetHsql(data).List<Document>();
                    //if (!Factory.IsTransactional)
                    //    Factory.Commit();
                }
                            
                catch (Exception e)
                {
                    NHibernateHelper.WriteEventLog(WriteLog.GetTechMessage(e));
                }
                return datos;
           
        }
Example #5
0
        public Dictionary<int,object[]> GetDocumentSuggestedBins(Document document, Location location, PickMethod pickMethod, short binDirection)
        {
            string result = "";
            string firstBin = "";
            IList<ProductStock> list = Factory.DaoLabel().GetDocumentSuggestedBins(document, location, pickMethod);
            IList<Bin> resultBin = new List<Bin>();
            Dictionary<int, object[]> resultDictionary = new Dictionary<int, object[]>();


            foreach (Product product in list.Select(p => p.Product).Distinct())
            {

                if (list == null || list.Count == 0)
                {
                    if (!resultDictionary.ContainsKey(product.ProductID))
                        resultDictionary.Add(product.ProductID, new object[] { "NO STOCK", WmsSetupValues.MaxBinRank, firstBin });
                }

                IList<ZoneBinRelation> listBin = GetAssignedBinsList(product, location);


                foreach (ProductStock ps in list.Where(f=>f.Product.ProductID == product.ProductID).OrderBy(f => f.Bin.Rank))
                {

                    if (binDirection == BinType.In_Out)
                    {
                        result += ps.Bin.BinCode + " (";

                        if (ps.PackStock + ps.Stock > 0)
                            result += (ps.PackStock + ps.Stock).ToString();

                        result += ")\n";

                        resultBin.Add(ps.Bin);

                        if (string.IsNullOrEmpty(firstBin))
                            firstBin = ps.Bin.BinCode;
                    }
                    else
                    {

                        if (listBin != null && listBin.Any(f => f.Bin.BinID == ps.Bin.BinID && f.BinType != binDirection))
                            continue;

                        if (binDirection == BinType.Exclude_Out && ps.BinType == BinType.Out_Only)
                            continue;

                        if (binDirection == BinType.Exclude_In && ps.BinType == BinType.In_Only)
                            continue;


                        result += ps.Bin.BinCode + " (";

                        if (ps.PackStock + ps.Stock > 0)
                            result += (ps.PackStock + ps.Stock).ToString();

                        result += ")\n";

                        resultBin.Add(ps.Bin);

                        if (string.IsNullOrEmpty(firstBin))
                            firstBin = ps.Bin.BinCode;
                    }

                    if (!resultDictionary.ContainsKey(product.ProductID))
                        resultDictionary.Add(product.ProductID, new object[] { result, resultBin[0].Rank, firstBin });
                }
               
            }

            return resultDictionary;
        }
Example #6
0
        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;
        }
Example #7
0
 public Label ChangeLabelLocationV2(Label labelSource, Label labelDest, Document document)
 {
     return TranMngr.ChangeLabelLocationV2(labelSource, labelDest, document);
 }
Example #8
0
        public IList<Label> GetDocumentLabelAvailable(Document data, Label searchLabel)
        {
            if (data.DocType != null && data.DocType.DocTypeID == SDocType.WarehouseTransferReceipt)
            {
                //Get the posting shipment
                Document shipment;
                try
                {
                    shipment = Factory.DaoDocument().Select(
                        new Document { DocNumber = data.CustPONumber, Company = data.Company }).First();
                }
                catch {
                    return null;   
                }

                return Factory.DaoLabel().GetDocumentLabelAvailableFromTransfer(data, shipment, null);
            }
            else
                return Factory.DaoLabel().GetDocumentLabelAvailable(data, searchLabel); 
        }
Example #9
0
 public IList<ProductStock> GetDocumentStock(Document document, bool printed)
 { return Factory.DaoLabel().GetDocumentStock(document, printed); }
Example #10
0
 public IList<Product> GetDocumentProduct(Document data, Product product)
 { return DocMngr.GetDocumentProduct(data, product); }
Example #11
0
 public IList<Document> GetCrossDockSalesOrders(Document data)
 {
     return DocMngr.GetCrossDockSalesOrders(data);
 }
Example #12
0
 public IList<Unit> GetDocumentProductUnit(Document document, Product product)
 {
     return BasicMngr.GetDocumentProductUnit(document, product);
     //return GetProductUnit(product);
 }
Example #13
0
 public void ResetInspectionLine(Document document, Label label, string username, bool cancelDocument)
 {
     TranMngr.ResetInspectionLine(document, label, username, cancelDocument);
 }
Example #14
0
 public void ConfirmInspectionDocument(Document document, string appPath, string username)
 {
     TranMngr.ConfirmInspectionDocument(document, appPath, username);
 }
Example #15
0
 public bool IsTrackRequiredInDocument(Document document, Node node)
 {
     return DocMngr.IsTrackRequiredInDocument(document, node);
 }
Example #16
0
 public Document CreateNewDocumentTask(IList<Document> docList, Document taskDoc)
 { return DocMngr.CreateNewTaskDocument(docList, taskDoc); }
Example #17
0
 public Boolean ValidateReceiptDocumentTrackingOptions(Document data, Node node, Boolean autoThrow)
 {
     return BasicMngr.ValidateReceiptDocumentTrackingOptions(data, node, autoThrow);
 }
Example #18
0
 public Boolean AssociateUserDocument(Document document, IList<SysUser> userList)
 { DocMngr.AssociateUserDocument(document, userList); return true; }
Example #19
0
        public void PrintKitAssemblyLabels(Document ssDocument, int qtyType)
        {
            ssDocument.DocumentLines = Factory.DaoDocumentLine().Select(
                new DocumentLine { Document = new Document { DocID = ssDocument.DocID } });

            // el documento debe tener lineas 
            if (ssDocument.DocumentLines == null || ssDocument.DocumentLines.Count == 0)
                return;
            else
                BasicMngr.PrintKitAssemblyLabels(ssDocument, qtyType);
        }
Example #20
0
 public IList<Document> GetPendingDocument(Document document, int daysAgo, int records)
 { return Factory.DaoDocument().SelectPending(document, daysAgo, records); }
Example #21
0
 public void CreateLocationTransfer(Document trfDoc)
 {
     ErpMngr.CreateLocationTransfer(trfDoc);
 }
Example #22
0
        //public IList<Account> GetDocumentAccount(Document document, short accountType, bool pending)
        //{
        //    return Factory.DaoDocument().GetDocumentAccount(document, accountType, pending);
        //}

        public IList<ShowData> GetDocumentAccount(Document document, short accountType, bool pending)
        {
            return Factory.DaoDocument().GetDocumentAccount(document, accountType, pending);
        }
Example #23
0
 public Document SaveDocument(Document data) { return Factory.DaoDocument().Save(data); }
Example #24
0
 public DocumentPackage CreateNewPackage(Document document, SysUser picker, bool isOpen, DocumentPackage parent, string packageType)
 {
     return TranMngr.CreateNewPackage(document, picker, isOpen, parent, packageType);
 }
Example #25
0
 public void DeleteDocument(Document data) { Factory.DaoDocument().Delete(data); }
Example #26
0
        /*
        public void SendMailNotification(string msgCode, Company company, SysUser user)
        {
            string message = "";
            string subject = "";
            string userTo = "";

            switch (msgCode)
            {
                case "PICKING":
                    userTo = GetCompanyOption(company, "MSGPICKTO");
                    if (string.IsNullOrEmpty(userTo))
                    {
                        CreateNotification(subject, message, userTo);
                    }
                    break;

                default:
                    return;
            }
        }


        private void CreateNotification(string subject, SysUser user, string mailTo)
        {
            try
            {
                MessagePool messageRecord = new MessagePool();
                messageRecord.CreatedBy = user.UserName;
                messageRecord.CreationDate = DateTime.Now;
                messageRecord.MailTo = mailTo;
                messageRecord.MailFrom = (String)GetContextValue("EMAILFROM");
                messageRecord.Subject = "WMS Process: " + subject + ", By: " + messageRecord.CreatedBy + ", Date: " + DateTime.Today.ToShortDateString();

                string msg = (String)GetContextValue("RESULTMESSAGE");
                msg = msg.Replace("\n", "<br>");
                msg = "<b>" + messageRecord.Subject + "</b><br><br>" + msg;
                messageRecord.Message = msg;

                Factory.DaoMessagePool().Save(message);
            }
            catch { Factory.Rollback(); }
        }
         * */


        public IList<Unit> GetDocumentProductUnit(Document document, Product product)
        {
            try
            {
                IList<DocumentLine> lines = Factory.DaoDocumentLine().Select(new DocumentLine
                {
                    Document = new Document { DocID = document.DocID },
                    Product = new Product { ProductID = product.ProductID }
                });

                return lines.Select(f => f.Unit).Distinct().ToList();

            }
            catch { return null; }

        }
Example #27
0
 //Usado para obtener documentos a procesar, debe pasarse el filtro que se deb manejar
 public IList<Document> GetDocument(Document document)
 {
     return Factory.DaoDocument().Select(document).Take(WmsSetupValues.NumRegs).ToList();
 }
Example #28
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ssDocument"></param>
        /// <param name="qtyType">1-QtyOrder (Order), 2-QtyAllocates (Shipment)</param>
        public void PrintKitAssemblyLabels(Document ssDocument, int qtyType)
        {

            if (!ssDocument.DocumentLines.Any(f => f.Note == "2"))
                return;


            IList<Label> list = new List<Label>();


            double qtyToUse = 0;
            int unitsPerPack = 0;
            int numLabels = 0;

            foreach (DocumentLine line in ssDocument.DocumentLines
                .Where(f => f.Note == "2" && f.Product.Category != null && f.Product.Category.ExplodeKit > 0))
            {
                
                qtyToUse = (qtyType == 1) ? line.Quantity : line.QtyAllocated;
                
                unitsPerPack = (line.Product.UnitsPerPack > 0) ? line.Product.UnitsPerPack : 1;

                numLabels = line.Product.Category.ExplodeKit == ExplodeKit.Caterpillar ? 1 : 2;

                for (int i = 0; i < (qtyToUse * numLabels) / unitsPerPack; i++) //Imprime 2 labels por cada KIT
                    list.Add(new Label
                    {
                        Product = line.Product,
                        LabelCode = line.Product.ProductCode,
                        LabelType = new DocumentType { DocTypeID = LabelType.ProductLabel },
                        CurrQty = unitsPerPack, //1
                        StartQty = unitsPerPack //1
                    });

                // CAA [2010/06/25]
                // Se imprimen los labels de los componentes de CaterpillarKit (los originales NO los substitutos)
                if (line.Product.Category.ExplodeKit == ExplodeKit.CaterpillarKit)
                {
                    Product parentKit;

                    foreach (DocumentLine lineComp in ssDocument.DocumentLines
                        .Where(f => f.Note == "1" && f.LinkDocLineNumber == line.LineNumber ))
                    {

                        try
                        {
                            parentKit = Factory.DaoKitAssemblyFormula().Select(
                                new KitAssemblyFormula { Component = lineComp.Product, DirectProduct = new Product { Category = new ProductCategory { ExplodeKit = ExplodeKit.Caterpillar } } })
                                .Select(f => f.DirectProduct)
                                //.Where(f => f.Category.ExplodeKit == ExplodeKit.Caterpillar)
                                .First();

                            qtyToUse = (qtyType == 1) ? lineComp.Quantity : lineComp.QtyAllocated;

                            unitsPerPack = (parentKit.UnitsPerPack > 0) ? parentKit.UnitsPerPack : 1;

                            numLabels = 1; //Solo Catterpillar components


                            for (int i = 0; i < (qtyToUse * numLabels) / unitsPerPack; i++) //Imprime 2 labels por cada KIT

                                list.Add(new Label
                                {
                                    Product = parentKit,
                                    LabelCode = parentKit.ProductCode,
                                    LabelType = new DocumentType { DocTypeID = LabelType.ProductLabel },
                                    CurrQty = unitsPerPack, //1
                                    StartQty = unitsPerPack //1
                                });

                        }
                        catch { continue; }

                    }
                }
            }



            if (list.Count > 0)
            {

                //template Generica de Producto
                //Removido oct 27 / 2009
                //LabelTemplate defTemplate = Factory.DaoLabelTemplate().Select(
                    //new LabelTemplate { Header = WmsSetupValues.ProductLabelTemplate }).First();

                LabelTemplate defTemplate = null; //Para que tome el del producto por defecto

                //Path de Applicacion
                string appPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), WmsSetupValues.WebServer);

                //Print Function.
                ReportMngr.PrintLabelsFromFacade(new Printer { PrinterName = WmsSetupValues.DEFAULT },
                    defTemplate, list, appPath);
            }
        }
Example #29
0
 public Document CreateNewDocument(Document data, Boolean autocommit)
 { return DocMngr.CreateNewDocument(data, autocommit); }
Example #30
0
        public Boolean ValidateDocument(Document data, Boolean autoThrow)
        {
            if (data == null)
            {
                if (autoThrow)
                {
                    Factory.Rollback();
                    throw new Exception("Document required to execute the process.");
                }
                else
                    return false;
            }

            return true;

        }
Example #31
0
 public Boolean UpdateDocument(Document data)
 { return Factory.DaoDocument().Update(data); }