Ejemplo n.º 1
0
        public IList<Unit> GetProductUnit(Product data)
        {
            IList<UnitProductRelation> unitRel = Factory.DaoUnitProductRelation().Select(new UnitProductRelation { Product = data });

            IList<Unit> list = new List<Unit>();
            foreach (UnitProductRelation uRel in unitRel)
                list.Add(uRel.Unit);
            
            return list.OrderBy(f=>f.BaseAmount).ToList();
        }
Ejemplo n.º 2
0
        public bool Execute(string workingCopyBase,
                            Entities.Branch source,
                            Entities.Branch target,
                            List<Entities.RevisionRange> ranges)
        {
            Dictionary<string, string> settings = settingsBLL.Get();

            string userName = SettingsHelper.ValidateUsername(settings);
            string password = SettingsHelper.ValidatePassword(settings);

            string workingCopyPath = target.Path(workingCopyBase);

            using (SharpSvn.SvnClient client = BusinessLogic.VersionControl.Svn.ClientHelper.Default())
            {
                client.Authentication.DefaultCredentials = new System.Net.NetworkCredential(userName, password);

                SharpSvn.SvnUriTarget svnSource = new SharpSvn.SvnUriTarget(source.Url);
                checkoutBLL.Execute(target, workingCopyBase);
                revertBLL.Execute(target, workingCopyBase);
                updateBLL.Execute(target, workingCopyBase);

                client.Conflict += (object sender, SharpSvn.SvnConflictEventArgs e) =>
                {
                    this.successful = false;
                };

                List<Entities.RevisionRange> conflictedRanges = new List<RevisionRange>();

                SharpSvn.SvnMergeArgs args = new SharpSvn.SvnMergeArgs();

                foreach (var item in ranges.OrderBy(x => x.StartRevision))
                {
                    bool success = client.Merge(workingCopyPath, svnSource, new SharpSvn.SvnRevisionRange(Convert.ToInt64(item.StartRevision), Convert.ToInt64(item.EndRevision)), args);

                    if (!this.successful)
                    {
                        revertBLL.Execute(target, workingCopyBase);
                        break;
                    }
                }
            }

            return successful;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Se encarga de serializar el objeto headr y el detalle en un dataset que pueda se deplegado
        /// por el reporting service
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        private ReportHeaderFormat ProcessHeaderAndDetails(Document document)
        {
            ReportHeaderFormat header = ProcessHeader(document);


            #region Map Details for each document Line
            // 
            //ReportDetailFormat detail;
            IList<ReportDetailFormat> detailList = new List<ReportDetailFormat>();

            //TODO: Incluir Filtro por bodega zona en este punto para solo obtener los detalles del filtro
            int sequence = 1, subSequence = 1;

            double totWeight = 0, totCases = 0, totQtyOrder = 0, totQtyPending = 0;
            
            short binDirection = BinType.In_Out; //Bin Direction to use

           if (document.DocType.DocTypeID == SDocType.ReplenishPackTask)
                    binDirection = BinType.In_Only;


            //Gettting document balance para qty pending,
            IList<DocumentBalance> docBalance = null;
            if (document.DocType.DocClass.DocClassID == SDocClass.Receiving)
            {
                docBalance = Factory.DaoDocumentBalance().DetailedBalance(new DocumentBalance
                {
                    Document = document,
                    Node = new Node { NodeID = NodeType.Received }
                }, false);
            }
            else if (document.DocType.DocClass.DocClassID == SDocClass.Shipping)
            {
                docBalance = Factory.DaoDocumentBalance().DetailedBalance(new DocumentBalance
                {
                    Document = document,
                    Node = new Node { NodeID = NodeType.Picked }
                }, document.CrossDocking == true ? true : false);
            }


            double kitTotalOrder = 0;
            foreach (DocumentLine dLine in Factory.DaoDocumentLine().Select(new DocumentLine { Document = new Document { DocID = document.DocID } }).OrderBy(f => f.LineNumber))
            {

                //Adicionado en Dec 30 2009.
                if (dLine.Product.Status.StatusID != EntityStatus.Active)
                    continue;

                //if (dLine.LineStatus.StatusID == DocStatus.Cancelled)
                    //continue;

                if (dLine.LineStatus.StatusID != DocStatus.New && dLine.LineStatus.StatusID != DocStatus.InProcess)
                    continue;

                if (dLine.Quantity <= 0 && dLine.LineNumber != 0)
                    continue;



                //Product To build, el primero en la lista
                if (string.IsNullOrEmpty(header.ProductToBuild))
                {
                    header.ProductToBuild = dLine.Product.ProductCode + ", " + dLine.Product.Name;

                    try
                    {
                        header.Barcode = GetAssignedBinsList(dLine.Product, document.Location).First().Bin.BinCode;
                    }
                    catch { header.Barcode = ""; }
                }


                //Si es el primer item del asembly se sale.
                if (document.DocType.DocTypeID == SDocType.KitAssemblyTask && dLine.LineNumber == 0)
                {
                    kitTotalOrder = dLine.Quantity;
                    continue;
                }




                IList<ReportDetailFormat> evaluatedLines = EvaluateLine(dLine, document, docBalance, binDirection, 1);


                foreach (ReportDetailFormat detail in evaluatedLines)
                {

                    if (detail.IsSubDetail != true)
                    {
                        detail.SeqLine = sequence++;
                        totWeight += detail.Weight;
                        totCases++; // += detail.Cases;
                        totQtyOrder += detail.QtyOrder;
                        totQtyPending += detail.QtyPending;
                        subSequence = 1;
                    }
                    else
                        detail.SeqLine = subSequence++;

                    detailList.Add(detail);

                }


            }

            #endregion

            // Totals
            header.TotalCases = totCases;
            header.TotalWeight = totWeight;
            header.TotalQtyOrder = (kitTotalOrder > 0) ? kitTotalOrder : totQtyOrder;
            header.TotalQtyPending = totQtyPending;


            if (document.DocType.DocTypeID == SDocType.SalesOrder || 
                document.DocType.DocTypeID == SDocType.WarehouseTransferShipment ||
                document.DocType.DocTypeID == SDocType.MergedSalesOrder)
            {
                //header.ReportDetails = detailList.OrderBy(f => f.Rank).ToList();

                //Si tiene componente organiza por componentes y luego por Rank
                if (detailList.Any(f=>f.IsSubDetail == true)) {
                
                    var sortedProducts = from p in detailList orderby p.CustNumber1, p.IsSubDetail, p.Rank select p;
                    header.ReportDetails = sortedProducts.ToList();
                
                }
                else { //Si no, solo por Rank. Aqui vienen las reglas de SORT
                
                    var sortedProducts = from p in detailList orderby p.Rank select p;
                    header.ReportDetails = sortedProducts.ToList();

                }

                
            }
            else
                header.ReportDetails = detailList.OrderBy(f => f.AuxSequence).ToList();


            return header;

        }
Ejemplo n.º 4
0
        /// <summary>
        /// Shipment document debe manejar los packages en el DEtail, the Header es el mismo
        /// que los documentos standar
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        private ReportHeaderFormat ProcessHeaderAndDetailsForShipment(Document document)
        {

            ReportHeaderFormat header = ProcessHeader(document);

           

            #region Map Details for each document Line

            // 
            //ReportDetailFormat detail;
            IList<ReportDetailFormat> detailList = new List<ReportDetailFormat>();

            //TODO: Incluir Filtro por bodega zona en este punto para solo obtener los detalles del filtro
            //int sequence = 1, subSequence = 1;
            double totWeight = 0, totCases = 0, allCases = 0, totPallet = 0, totQtyOrder = 0, totProductWeight = 0;
            double totExtendedPrice = 0;

            //Obteniendo los Packages de ese Documento.
            IList<DocumentPackage> packList = Factory.DaoDocumentPackage().Select(
                new DocumentPackage { PostingDocument = document });

            IList<Label> containedLabels;
            ReportDetailFormat detail;
            IList<ReportDetailFormat> packDetail; 
            int level = -1; // 0 = Box, 1 = pallet

            foreach (DocumentPackage pkg in packList)
            {

                header.Date2 = pkg.CreationDate.ToString();

                //Obtiene los labels Contenidos en ese package                
                containedLabels = Factory.DaoLabel().Select(new Label { FatherLabel = pkg.PackLabel })
                    .Where(f => f.StockQty > 0).ToList();
                //.Where(f=>f.CurrQty > 0).ToList();

                //Guarda los detalles de cada paquete
                packDetail = new List<ReportDetailFormat>();


                //Adicion manejo de Pallets and cases.
                /*
                if (pkg.ChildPackages == null || pkg.ChildPackages.Count == 0)
                {
                    if (pkg.ParentPackage == null)
                    {
                        level = 0; //Single box
                        totCases++;
                    }
                    else
                        level = 1; //Box inside pallet

                    allCases++;
                }
                else
                {
                    level = 2; //Pallet
                    totPallet++;
                }
                */

                if (pkg.PackageType == "P")
                {
                    level = 2; //Pallet
                    totPallet++;
                }
                else if (pkg.PackageType == "B")
                {
                    level = 1; 

                    if (pkg.ParentPackage == null)
                    {
                        level = 0; //Single box
                        totCases++;
                    }

                    allCases++;
                }
                else { allCases++; }



                //foreach (Label curLabel in containedLabels)
                foreach (Product curLabel in containedLabels.Select(f => f.Product).Distinct())
                {

                    detail = new ReportDetailFormat();


                    //Grouped By Pack - Label
                    detail.BarcodeLabel = pkg.PackLabel.Barcode;
                    detail.PackWeight = pkg.Weight;
                    detail.Dimension = pkg.Dimension;
                    detail.Pieces = pkg.Pieces;
                    detail.CreatedBy = pkg.CreatedBy;


                    //Map Data
                    detail.ProductCode = curLabel.ProductCode;
                    detail.ProductDescription = curLabel.Name;
                    detail.Unit = curLabel.BaseUnit.Name;
                    detail.ProductCost = curLabel.ProductCost;
                    //CUSTOM
                    detail.Custom1 = curLabel.Manufacturer;
                    detail.Custom2 = curLabel.Reference;


                    //Agrupo por producto dentro del package. para mostrar una sola linea
                    detail.Weight = curLabel.Weight * containedLabels.Where(f => f.Product.ProductCode == curLabel.ProductCode).Sum(f => f.StockQty * f.Unit.BaseAmount); //CurrQty
                    detail.QtyOrder = containedLabels.Where(f => f.Product.ProductCode == curLabel.ProductCode).Sum(f => f.StockQty * f.Unit.BaseAmount);
                    totQtyOrder += containedLabels.Where(f => f.Product.ProductCode == curLabel.ProductCode).Sum(f => f.StockQty * f.Unit.BaseAmount);
                    totProductWeight += detail.Weight;

                    totExtendedPrice += detail.QtyOrder * curLabel.ProductCost;

                    //Descripcion del pallet
                    //detail.PackLevel = 0;
                    if (level == 0)
                    {
                        //detail.PalletNote = "";
                        detail.LogisticNote = "SINGLE BOX " + pkg.PackLabel.LabelCode;
                    }

                    else if (level == 1)
                    {
                        //CASE INSIDE PALLET
                        //detail.PalletNote = "PALLET " + GetParentPallet(pkg);
                        detail.LogisticNote = "PALLET " + GetParentPallet(pkg) + " >> BOX " + pkg.PackLabel.LabelCode; //"PL " + pkg.ParentPackage.Sequence.ToString() + "/" + pkg.PackLabel.LabelCode;
                    }

                    else
                    {
                        //detail.PalletNote = "PALLET " + pkg.PackLabel.LabelCode;
                        detail.LogisticNote = "PALLET " + pkg.PackLabel.LabelCode + " >> W/OUT BOX";
                    }


                    //IList<ProductAccountRelation> acctItem = null;

                    ////Customer Item Number
                    //if (document.Customer.AccountCode != WmsSetupValues.DEFAULT)
                    //{
                    //    acctItem = curLabel.Product.ProductAccounts.Where(f => f.Account.AccountID == document.Customer.AccountID).ToList();
                    //    if (acctItem != null && acctItem.Count() > 0)
                    //        detail.AccountItemNumber = acctItem[0].ItemNumber;
                    //}

                    //if (detail.AccountItemNumber == null)
                    //    detail.AccountItemNumber = "";

                    //Adicinando el Detalle                    
                    packDetail.Add(detail);
                }

                //Recorre los detalles de cada Package para saber si es un detalle de Kit lo que hace que
                //Adicione un Detalle nuevo (Padre)
                foreach (ReportDetailFormat kitDetail in GetDetailsWithKitAssembly(packDetail, document, pkg))
                    detailList.Add(kitDetail);


                totWeight += pkg.Weight;
                //totCases++;

            }

            #endregion


            #region Shipment Totals
            //En un Shipment enviar el CustPOUmber
            try
            {
                header.OrigNumber = Factory.DaoDocument().Select(new Document { DocNumber = document.CustPONumber, Company = document.Company }).First().CustPONumber;
            }
            catch { }

            // Totals
            try { header.TotalExtended = double.Parse(totExtendedPrice.ToString("###,###.##")); } //totExtendedPrice; 
            catch { }

            header.TotalCases = totCases;
            header.TotalPallets = totPallet;
            header.AllCases = allCases;
            header.TotalWeight = totWeight > 0 ? totWeight : totProductWeight;
            header.TotalQtyOrder = totQtyOrder;


            header.ReportDetails = detailList.OrderBy(f => f.AuxSequence).ToList();

            #endregion

            return header;
        }
Ejemplo n.º 5
0
        private ReportHeaderFormat ProcessHeaderAndDetailsForCounting(Document document)
        {
            ReportHeaderFormat header = ProcessHeader(document);

            //Consolida todos los ajuste realizados para Confirmar la Tarea de Inventario
            //Y los muestra como Documento.
            IList<ReportDetailFormat> detailList = new List<ReportDetailFormat>();
            ReportDetailFormat detail;

            int seq = 1;
            if (document.DocStatus.StatusID == DocStatus.New || document.DocStatus.StatusID == DocStatus.InProcess)
            {
                //Si no esta posteada muestar la Executon task

                //Pattern
                IList<ProductStock> listCompleted = Factory.DaoBinByTask().GetCountInitialSummary(document);

                //Para que el doc no salga en blanco
                if (listCompleted == null || listCompleted.Count == 0) 
                    detailList.Add(new ReportDetailFormat());


                foreach (ProductStock record in listCompleted)
                {
                    detail = new ReportDetailFormat();

                    if (record.Product != null)
                    {
                        detail.ProductCode = record.Product.ProductCode;
                        detail.ProductDescription = record.Product.Name;
                    }
                    else
                    {
                        detail.ProductCode = "";
                        detail.ProductDescription = "";
                    }

                    detail.StockBin = record.Bin.BinCode;
                    detail.SeqLine = seq++;
                    detail.Rank = record.Bin.Rank;

                    detail.QtyOrder = record.Stock - record.PackStock; //DIFF
                    detail.QtyPending = record.PackStock; //Expected
                    try { detail.ProductCost = record.Product.ProductCost; }
                    catch { }
                    try { detail.ExtendedCost = record.Product.ProductCost * (record.Stock - record.PackStock); }
                    catch { }
                    detail.Date1 = record.MinDate != null ? record.MinDate.Value.ToString() : "";
                    detail.CreatedBy = document.CreatedBy;
                    detail.DocNumber = document.DocNumber;

                    detail.BarcodeLabel = record.Label != null ? "Barcode: " + record.Label.LabelCode : "";
                    // CAA [2010/07/01] tipo de conteo
                    detail.Rank = 0;


                    detailList.Add(detail);

                    var sortedProducts = from p in detailList orderby p.Rank select p;
                    header.ReportDetails = sortedProducts.ToList();

                }


            }


            else if (document.DocStatus.StatusID == DocStatus.Completed)
            {
                //Si no esta posteada muestar la Executon task

                //Pattern
                IList<CountTaskBalance> listCompleted = Factory.DaoBinByTaskExecution().GetCountSummary(document, false);

                // CAA [2010/07/09]
                // Excluye los registros buenos...  (se ocultan en el reporte)
                bool hide = false;
                try{
                    if (GetConfigOption("COUNTHIDE").Equals("T"))
                    {
                        //listCompleted = listCompleted.Where(f=> f.Difference!=0 || !string.IsNullOrEmpty(f.Comment)).ToList();
                        hide = true;
                    }
                }
                catch {}

                //Para que el doc no salga en blanco
                if (listCompleted == null || listCompleted.Count == 0)
                    detailList.Add(new ReportDetailFormat());


                foreach (CountTaskBalance record in listCompleted)
                {
                    detail = new ReportDetailFormat();
                    detail.ProductCode = record.Product.ProductCode;
                    detail.ProductDescription = record.Product.Name;
                    detail.StockBin = record.Bin.BinCode;
                    detail.QtyOrder = record.Difference; //DIFF
                    detail.QtyPending = record.QtyExpected; //Expected
                    detail.ProductCost = record.Product.ProductCost;
                    detail.ExtendedCost = record.Product.ProductCost * (detail.QtyOrder);
                    detail.Date1 = DateTime.Today.ToString();
                    detail.CreatedBy = document.CreatedBy;
                    detail.DocNumber = document.DocNumber;
                    detail.Notes = record.Comment;

                    detail.BarcodeLabel = record.Label != null ? "Barcode: " + record.Label.LabelCode : "";
                    // CAA [2010/07/01] tipo de conteo
                    detail.Rank = record.CaseType;

                    // Se ocultará en el reporte
                    if (hide && (record.Difference==0 && string.IsNullOrEmpty(record.Comment)))
                        detail.Custom1 = "T";

                    detailList.Add(detail);
                }

                header.ReportDetails = detailList.OrderBy(f => f.StockBin).ToList();

            }
            else if (document.DocStatus.StatusID == DocStatus.Posted)
            {
                //Si la tarea esta posteada muestra los ajustes de inventario.
                DocumentLine patternLine = new DocumentLine { 
                    Document = new Document { CustPONumber = document.DocNumber, Company = document.Company }
                };
                
                IList<DocumentLine> lines = Factory.DaoDocumentLine().Select(patternLine);

                // CAA [2010/07/09] Se incluyen los labels de el bin NoCount.
                IList<Label> labelsNoCount = Factory.DaoLabel().Select(new Label { Bin = new Bin { BinCode = DefaultBin.NOCOUNT }, Notes = document.DocNumber });

                //para que el doc no salga en blanco
                if ((lines == null || lines.Count == 0) && (labelsNoCount == null || labelsNoCount.Count == 0))
                    detailList.Add(new ReportDetailFormat());


                int sing = 0;
                foreach (DocumentLine record in lines)
                {
                    sing = record.IsDebit == true ? -1 : 1;

                    detail = new ReportDetailFormat();
                    detail.ProductCode = record.Product.ProductCode;
                    detail.ProductDescription = record.Product.Name;
                    detail.StockBin = record.BinAffected;
                    detail.QtyOrder = sing * record.Quantity; //DIFF
                    detail.QtyPending = record.QtyAllocated;
                    detail.ProductCost = record.Product.ProductCost;
                    detail.ExtendedCost = record.Product.ProductCost * record.Quantity * sing;
                    detail.Date1 = record.Date1 != null ? record.Date1.Value.ToString() : "";
                    detail.DocNumber = record.Document.DocNumber + ", " + record.Document.Comment;

                    detail.BarcodeLabel = "";
                    // CAA [2010/07/01] tipo de conteo
                    detail.Rank = 0;

                    detailList.Add(detail);
                }

                // NoCount Labels
                foreach (Label record in labelsNoCount)
                {
                    //sing = record.IsDebit == true ? -1 : 1;

                    detail = new ReportDetailFormat();
                    detail.ProductCode = record.Product.ProductCode;
                    detail.ProductDescription = record.Product.Name;
                    detail.StockBin = record.Bin.BinCode;
                    detail.QtyOrder = 0-record.CurrQty;  //DIFF
                    detail.QtyPending = record.CurrQty ; 
                    detail.ProductCost = record.Product.ProductCost;
                    detail.ExtendedCost= record.Product.ProductCost * record.CurrQty * -1;
                    detail.Date1 = record.ModDate != null ? record.ModDate.Value.ToString() : "";
                    detail.DocNumber = document.DocNumber;

                    detail.BarcodeLabel = "Barcode: " + record.LabelCode;
                    // CAA [2010/07/01] tipo de conteo
                    detail.Rank = 0;

                    detailList.Add(detail);
                }

                header.ReportDetails = detailList.OrderBy(f => f.StockBin).ToList();
            }



            return header;

        }
Ejemplo n.º 6
0
        public static List<Book> GetBooks(int parentId, string sort = "Title")
        {
            List<Book> result = new List<Book>();

            Catalog catalog = new Catalog();

            var q = parentId != 0 ? from book in catalog.Books where book.parentId == parentId select book : from book in catalog.Books select book;
            foreach (Book book in q)
                result.Add(book);

            if (sort == "Title")
                result = result.OrderBy(x => x.Title).ToList();
            else if (sort == "Author")
                result = result.OrderBy(x => x.Author).ToList();
            else if (sort == "Year")
                result = result.OrderBy(x => x.Year).ToList();
            else if (sort == "Pages number")
                result = result.OrderBy(x => x.PagesCount).ToList();

            foreach (Book book in result)
            {
                book.Tags = new List<string>();

                var qTag = from tag in catalog.Tags where tag.Book_Id == book.Id select tag;
                foreach (BookTag bookTag in qTag)
                    book.Tags.Add(bookTag.Name);
            }

            return result;
        }