/// <summary> /// Reversa lista de NodeTrace (qty selected) /// </summary> /// <param name="nodes"></param> /// OBSOLETE public void ReverseReceiptNodeTraceByQty(DocumentBalance docBalance, int quantity, SysUser user) { List <NodeTrace> nodes = Factory.DaoNodeTrace().Select( new NodeTrace { Document = docBalance.Document, Node = docBalance.Node, Label = new Label { Product = docBalance.Product, Printed = false, Unit = docBalance.Unit } }).Take(quantity).ToList(); if (quantity > nodes.Count) { throw new Exception("There are not enough quantities to complete the transaction"); } Node labelNode = Factory.DaoNode().Select(new Node { NodeID = NodeType.Voided }).First(); ReverseNodeTrace(nodes, user.UserName, labelNode, null, null); //0 = Manual retail product. }
public Boolean ValidateBalanceQuantityInDocument(DocumentLine validationLine, Node node, Boolean autoThrow, bool isCrossDock) //bool isCrossDock, Adicionada en SEP/17/2009 para manejar el balance en cross dock sin tener en cuenta BO Quantities { DocumentBalance docBal = new DocumentBalance { Document = validationLine.Document, Product = validationLine.Product, Unit = validationLine.Unit, Node = node }; docBal = Factory.DaoDocumentBalance().GeneralBalance(docBal, isCrossDock).First(); //Multiplica la cantidad por la unidad base para hacer la resta //La unidad del documento de Balance es la unidad Basica if (docBal == null || docBal.BaseQtyPending < validationLine.Quantity * validationLine.Unit.BaseAmount) { if (autoThrow) { Factory.Rollback(); //throw new Exception("Current balance for document is " + (docBal.QtyPending / validationLine.Unit.BaseAmount).ToString() + " and you are trying to receive " + ((int)validationLine.Quantity).ToString() + "."); throw new Exception("Current balance for product " + docBal.Product.ProductCode + " in document " + docBal.Document.DocNumber + " is " + docBal.QtyPending.ToString() + " (" + docBal.Unit.Name + ")" + " and you are trying to process " + ((int)validationLine.Quantity).ToString() + " (" + docBal.Unit.Name + ")."); } else { return(false); } } return(true); }
void View_LoadSetup(object sender, EventArgs e) { //Seting Values View.Model.TrackData = View.Model.Product.ProductTrack .Where(f => f.TrackOption.DataType.DataTypeID != SDataTypes.ProductQuality).ToList(); View.PickQty.Text = ""; try { //Debe sacar del balance del documento para ese producto the QTY Remain y la unidad. DocumentBalance prdBal = service.GetDocumentBalance( new DocumentBalance { Product = View.Model.Product, Document = View.Model.Document, Node = View.Model.Node }, false).First(); View.Model.CurQtyPending = (int)prdBal.QtyPending; View.Model.CurUnit = prdBal.Unit; } catch { } //View.Model.QtyToTrack = View.Model.CurQtyPending; SetupManualTrackOption(); }
//Recibe el Balance que debe ser removido del nodo public void ParamRecord(DocumentBalance actualRecord, Object parent, bool reload) { try { //reload pregunta si debe irse a preguntar por el balance para ese producto nuevamente. if (reload) { try { View.Model.Record = service.GetDocumentPostingBalance(actualRecord) .Where(f => f.Product.ProductID == actualRecord.Product.ProductID) .First(); } catch { throw new Exception(Util.GetResourceLanguage("NO_QUANTITIES_AVAILABLE_TO_REVERSE")); } } else { View.Model.Record = actualRecord; } View.Model.ParentWindow = parent; LoadTransactions(View.Model.Record); } catch (Exception ex) { throw new Exception(Util.GetResourceLanguage("PROBLEM_LOADING_BALANCE") + "\n" + ex.Message); } }
private void LoadPrintLines(Document document) { View.StkLine.Visibility = Visibility.Visible; View.Model.Document = document; DocumentBalance docBalance = new DocumentBalance { Document = document, Node = View.Model.Node }; View.Model.LinesToPrint = service.GetDocumentBalance(docBalance, false); //#########Receiving Balance if (document.DocType.DocTypeID == SDocType.ReceivingTask) { View.Model.LinesToPrint = service.GetDocumentBalanceForEmpty(docBalance); } else { View.Model.LinesToPrint = service.GetDocumentBalance(docBalance, false); } if (View.Model.LinesToPrint != null && View.Model.LinesToPrint.Count > 0) { EnablePrintModule(); } else { View.StkPrintFinish.Visibility = Visibility.Visible; } }
//Carga los movimientos a los que se hacen referencia private void LoadTransactions(DocumentBalance actualRecord) { //Solo Muestra Labesl con cantidades fijas a remover View.BrdManual.Visibility = Visibility.Collapsed; NodeTrace pattern = new NodeTrace { Node = actualRecord.Node, Label = new WpfFront.WMSBusinessService.Label { Product = actualRecord.Product //Printed = true, //Unit = actualRecord.Unit } }; //Cuando se desea cancelar la linea de un Shipment. //JM - Marzo 9 / 2010 if (actualRecord.DocumentLine != null && actualRecord.DocumentLine.LineNumber > 0) { pattern.PostingDocLineNumber = actualRecord.DocumentLine.LineNumber; pattern.PostingDocument = actualRecord.Document; } else { pattern.PostingDocument = new Document { DocID = -1 }; pattern.Document = actualRecord.Document; } // lista de labels printed View.Model.LstPrinted = service.GetNodeTrace(pattern).ToList(); View.ListPrinted.Items.Refresh(); // qtys manuales y printed View.Model.QtyPrintedOld = View.Model.LstPrinted.Sum(f => f.Quantity);//Sum(f=>f.Label.CurrQty); View.Model.QtyManualOld = int.Parse(actualRecord.QtyPending.ToString()) - View.Model.LstPrinted.Count(); // solo si hay disponibilidad se habilitan las tablas //if (View.Model.QtyManualOld == 0) //View.BrdManual.Visibility = Visibility.Collapsed; if (View.Model.QtyPrintedOld == 0) { View.BrdPrinted.Visibility = Visibility.Collapsed; } //Si el documento es de receiving oculta el Bin de restock if (View.Model.Record.Document.DocType.DocClass.DocClassID == SDocClass.Receiving) { View.StkUcBin.Visibility = Visibility.Collapsed; } }
public bool IsOrderBalanceCompleted(DocumentBalance docBalance) { string sQuery = "select product.ProductID, Sum(l.Quantity - l.QtyCancel - l.QtyBackOrder)*unit.BaseAmount - Isnull(n.Quantity,0) as QtyPending " + " from Trace.DocumentLine as l " + " INNER JOIN Trace.Document doc ON l.DocID = doc.DocID " + " INNER JOIN Trace.Node node ON node.NodeID = :id2 " + " INNER JOIN Master.Product product ON l.ProductID = product.ProductID " + " INNER JOIN Master.Unit unit ON l.UnitID = unit.UnitID LEFT OUTER JOIN " + " ( select l.ProductID, Isnull(Sum(x.Quantity * ISNULL(u.BaseAmount,1)),0) as Quantity from Trace.NodeTrace x " + " INNER JOIN Trace.Label l ON x.LabelID = l.LabelID LEFT JOIN Master.Unit u ON u.UnitID = x.UnitID " + " Where x.NodeID = :id2 and x.DocID = :id1 AND x.Quantity > 0 AND x.IsDebit = 0 " + " Group BY l.ProductID ) as n On l.ProductID = n.ProductID Where l.DocID = :id1 AND l.LineNumber > 0 "; StringBuilder sql = new StringBuilder(sQuery); Parms = new List <Object[]>(); Parms.Add(new Object[] { "id1", docBalance.Document.DocID }); if (docBalance.Node != null && docBalance.Node.NodeID != 0) { Parms.Add(new Object[] { "id2", docBalance.Node.NodeID }); } if (docBalance != null) { if (docBalance.Product != null && docBalance.Product.ProductID != 0) { sql.Append(" and l.ProductID = :id3 "); Parms.Add(new Object[] { "id3", docBalance.Product.ProductID }); } sql.Append(" and ( l.LineStatusID = :id4 Or l.LineStatusID = :id5 ) "); Parms.Add(new Object[] { "id4", DocStatus.New }); Parms.Add(new Object[] { "id5", DocStatus.InProcess }); sql.Append(" and product.StatusID = :id6 "); Parms.Add(new Object[] { "id6", EntityStatus.Active }); sql.Append(" Group By product.ProductID,n.Quantity, unit.BaseAmount "); sql.Append(" Having Sum(l.Quantity - l.QtyCancel - l.QtyBackOrder) - Isnull(n.Quantity,0) > 0"); } IQuery query = Factory.Session.CreateSQLQuery(sql.ToString()); SetParameters(query); IList <Object[]> retBalance = query.List <Object[]>(); if (!Factory.IsTransactional) { Factory.Commit(); } return(retBalance.Count > 0 ? false : true); }
/// <summary> /// Entrega lo que esta pendiente por recibir de un Documento contra un NodeTrace En unidad Basica /// </summary> /// <param name="data"></param> /// <returns></returns> public IList <DocumentBalance> PostingBalance(DocumentBalance docBalance) { string sQuery = "select n.docID, cast(0 as bigint) as Line, n.NodeID, n.ProductID, n.UnitID, " + " Isnull(n.Quantity,0) as Quantity, Isnull(unpost.Quantity,0) as QtyPending, 0 as UnitPrice " + " From ( select x.DocID, l.ProductID, l.UnitID, x.NodeID, Isnull(Sum(x.Quantity),0) as Quantity from Trace.NodeTrace x " + " INNER JOIN Trace.Label l ON l.LabelID = x.LabelID " + " Where x.NodeID = :id2 and x.DocID = :id1 and x.Quantity > 0 " + " Group BY l.ProductID, l.UnitID, x.DocID, x.NodeID ) as n INNER JOIN " + " ( select l.ProductID, l.UnitID, Isnull(Sum(x.Quantity),0) as Quantity from Trace.NodeTrace x " + " INNER JOIN Trace.Label l ON l.LabelID = x.LabelID " + " Where x.NodeID = :id2 and x.DocID = :id1 And x.PostingDocumentID IS NULL and x.Quantity > 0 " + " Group BY l.ProductID, l.UnitID ) as unpost On n.ProductID = unpost.ProductID " + " AND n.UnitID = unpost.UnitID Where n.DocID = :id1"; StringBuilder sql = new StringBuilder(sQuery); Parms = new List <Object[]>(); Parms.Add(new Object[] { "id1", docBalance.Document.DocID }); if (docBalance.Node != null && docBalance.Node.NodeID != 0) { Parms.Add(new Object[] { "id2", docBalance.Node.NodeID }); } else if (docBalance.Node != null && !string.IsNullOrEmpty(docBalance.Node.Name)) { docBalance.Node = Factory.DaoNode().Select(docBalance.Node).First(); Parms.Add(new Object[] { "id2", docBalance.Node.NodeID }); } if (docBalance != null) { if (docBalance.Product != null && docBalance.Product.ProductID != 0) { sql.Append(" and n.ProductID = :id3 "); Parms.Add(new Object[] { "id3", docBalance.Product.ProductID }); } sql.Append(" Group By n.docID, n.NodeID, n.productid, n.unitid, n.Quantity, unpost.Quantity"); } IQuery query = Factory.Session.CreateSQLQuery(sql.ToString()); SetParameters(query); IList <DocumentBalance> retBalance = GetBalanceObject(query.List <Object[]>(), docBalance.Location); if (!Factory.IsTransactional) { Factory.Commit(); } return(retBalance); }
public IList <DocumentBalance> DocumentBalanceForEmpty(DocumentBalance docBalance) { string sQuery = "select n.DocID, cast(0 as bigint) as Line, n.NodeID, l.ProductID, l.UnitID, " + " Isnull(Sum(n.Quantity),0) as Quantity, 0.0 as QtyPending, 0 as UnitPrice " + " from Trace.NodeTrace n INNER JOIN Trace.Label l ON n.LabelID = l.LabelID " + " Where n.NodeID = :id2 and n.DocID = :id1 And n.Quantity > 0 "; StringBuilder sql = new StringBuilder(sQuery); Parms = new List <Object[]>(); Parms.Add(new Object[] { "id1", docBalance.Document.DocID }); if (docBalance.Node != null && docBalance.Node.NodeID != 0) { Parms.Add(new Object[] { "id2", docBalance.Node.NodeID }); } else if (docBalance.Node != null && !string.IsNullOrEmpty(docBalance.Node.Name)) { docBalance.Node = Factory.DaoNode().Select(docBalance.Node).First(); Parms.Add(new Object[] { "id2", docBalance.Node.NodeID }); } if (docBalance != null) { if (docBalance.Product != null && docBalance.Product.ProductID != 0) { sql.Append(" and n.ProductID = :id3 "); Parms.Add(new Object[] { "id3", docBalance.Product.ProductID }); } sql.Append(" Group By n.docID, n.NodeID, l.ProductID, l.UnitID"); } IQuery query = Factory.Session.CreateSQLQuery(sql.ToString()); SetParameters(query); IList <DocumentBalance> retBalance = GetBalanceObject(query.List <Object[]>(), docBalance.Location); if (!Factory.IsTransactional) { Factory.Commit(); } return(retBalance); }
private IList <DocumentBalance> GetBalanceObject(IList <Object[]> retList, Location location) { if (retList == null || retList.Count == 0) { return(new List <DocumentBalance>()); } IList <DocumentBalance> retBalance = new List <DocumentBalance>(); DocumentBalance curBalance; Document document = Factory.DaoDocument().SelectById(new Document { DocID = (int)retList[0][0] }); Node node = Factory.DaoNode().SelectById(new Node { NodeID = (int)(int)retList[0][2] }); foreach (Object[] obj in retList) { curBalance = new DocumentBalance(); curBalance.Document = document; curBalance.DocumentLine = ((Int64)obj[1] == 0) ? null : Factory.DaoDocumentLine().SelectById(new DocumentLine { LineID = (Int64)obj[1] }); curBalance.Node = node; curBalance.Product = Factory.DaoProduct().SelectById(new Product { ProductID = (int)obj[3] }); curBalance.Unit = Factory.DaoUnit().SelectById(new Unit { UnitID = (int)obj[4] }); curBalance.Quantity = Double.Parse(obj[5].ToString()); curBalance.QtyPending = Double.Parse(obj[6].ToString()); try { curBalance.UnitPrice = Double.Parse(obj[7].ToString()); } catch { } curBalance.Location = location; retBalance.Add(curBalance); } return(retBalance); }
//Encargada de obtener el cruce entre el purchase document y los sales document //Involucrados en el proceso cross dock; private void OnCrossDockPreview(object sender, EventArgs e) { View.BtnStep1.IsEnabled = false; //Obteniendo el Balance DocumentBalance docBalance = new DocumentBalance { Document = View.Model.Document, Node = View.Model.Node, Location = App.curLocation }; ProcessWindow pw = new ProcessWindow(""); pw.Show(); try { //Obteniendo el cruce de documentos. View.Model.CrossDockBalance = service.GetCrossDockBalance(docBalance, View.Model.AssignedDocs.ToList()) .Where(f => !string.IsNullOrEmpty(f.Notes)) .OrderBy(f => f.Notes).ToList(); //Mostrando el Warning de not suppied if apply if (View.Model.CrossDockBalance != null && View.Model.CrossDockBalance.Where(f => f.Notes == "Qty not supplied").Count() > 0) { View.TxtWarning.Visibility = Visibility.Visible; } //Ocultando el expander superior View.ExpDocs.IsExpanded = false; //Visible the second panel View.ExpResult.IsExpanded = true; View.ExpResult.Visibility = Visibility.Visible; pw.Close(); } catch (Exception ex) { pw.Close(); Util.ShowError("Problem generating the Cross Dock preview.\n" + ex.Message); } }
/// <summary> /// Recibe un documento de recibo por completo, (lo que tenga pendiente por recibr) /// </summary> /// <param name="document"></param> /// <param name="destLocation"></param> public void ReceiptAtOnce(Document document, Bin destLocation, Node recNode) { Factory.IsTransactional = true; //Valida si el docuemnto no es nulo Rules.ValidateDocument(document, true); //Node recNode = WType.GetNode(new Node { NodeID = NodeType.Stored }); DocumentBalance docBal = new DocumentBalance { Document = document, Node = recNode }; IList <DocumentBalance> balanceList = Factory.DaoDocumentBalance().BalanceByUnit(docBal); //Recorre las lineas del documento y las recibe usando ReceiveProduct if (balanceList == null || balanceList.Count == 0) { throw new Exception("Document " + document.DocNumber + " not contains product to receive."); } DocumentLine curLine; foreach (DocumentBalance line in balanceList.Where(f => f.QtyPending > 0)) { //Define Document, Product, Unit and Qty to send to receiving transaction curLine = new DocumentLine { Document = document, Product = line.Product, Unit = line.Unit, Quantity = line.QtyPending, QtyPending = line.QtyPending, //Logistic factor CreatedBy = document.ModifiedBy, Note = "" //document.Notes }; ReceiveProduct(curLine, new Unit(), destLocation, recNode); } }
private void RefreshBalance(Document document) { DocumentBalance docBalance = new DocumentBalance { Document = document, Node = View.Model.Node, Location = App.curLocation }; //#########Receiving Balance if (View.Model.DocumentLines == null || View.Model.DocumentLines.Count == 0) { View.Model.DocumentBalance = service.GetDocumentBalanceForEmpty(docBalance); } else { View.Model.DocumentBalance = service.GetDocumentBalance(docBalance, true); } View.DgDocumentBalance.Items.Refresh(); //Mostrar o no el mensaje del balance bool showMessage = false; foreach (DocumentBalance docBal in View.Model.DocumentBalance) { if (docBal.QtyPending > 0) { showMessage = true; break; } } //Si hay saldo pendiente por recibir. View.StkPendingMsg.Visibility = showMessage ? Visibility.Visible : Visibility.Collapsed; //Si nada esta recibido, dejar el boton bloqueado. if (View.Model.DocumentBalance.Any(f => f.QtyProcessed > 0)) { View.Model.AnyReceived = true; } }
private void AdjustShipmentDocumentByReverse(DocumentBalance actualRecord, List <WpfFront.WMSBusinessService.Label> labelList) { //Create Document Line with Unpick Product try { service.SaveDocumentLine(new DocumentLine { Document = actualRecord.Document, CreatedBy = App.curUser.UserName, CreationDate = DateTime.Now, Date1 = DateTime.Now, IsDebit = true, LineStatus = new Status { StatusID = EntityStatus.Active }, Note = "Unpicked product after shipment creation.", Product = actualRecord.Product, Quantity = labelList.Sum(f => f.BaseCurrQty), Unit = actualRecord.Product.BaseUnit, Location = actualRecord.Location }); } catch { } }
private void dgPostingBalance_MouseDoubleClick(object sender, MouseButtonEventArgs e) { DocumentBalance balance = ((DataGridControl)sender).SelectedItem as DocumentBalance; RemoveFromNode(sender, new DataEventArgs <DocumentBalance>(balance)); }
public void PickAtOnce(Document document, Label sourceLocation, Node node, SysUser picker) { Factory.IsTransactional = true; //Node node = WType.GetNode(new Node { NodeID = NodeType.Picked }); DocumentBalance docBal = new DocumentBalance { Document = document, Node = node }; IList <DocumentBalance> balanceList = Factory.DaoDocumentBalance().BalanceByUnit(docBal); //Recorre las lineas del documento y las pickea usando PickProduct, pero solo si el balance //existe en la location indicada para todo lo pendiente. if (balanceList == null || balanceList.Count == 0) { throw new Exception("Document " + document.DocNumber + " not contains product pending to pick."); } DocumentLine curLine; string fullExistence = ""; foreach (DocumentBalance line in balanceList.Where(f => f.QtyPending > 0)) { //Define Document, Product, Unit and Qty to send to receiving transaction curLine = new DocumentLine { Document = document, Product = line.Product, Unit = line.Unit, Quantity = line.QtyPending, CreatedBy = picker.UserName }; fullExistence += CheckForStockInLocation(curLine, sourceLocation); } //Si alguno no tiene existencia no puede ejecutar el PickAtOnce if (!string.IsNullOrEmpty(fullExistence)) { ExceptionMngr.WriteEvent("PickAtOnce:", ListValues.EventType.Error, null, null, ListValues.ErrorCategory.Business); throw new Exception(fullExistence); } //Ejecutando el Picking despues de que se confirma la existencia foreach (DocumentBalance line in balanceList) { //Define Document, Product, Unit and Qty to send to receiving transaction curLine = new DocumentLine { Document = document, Product = line.Product, Unit = line.Unit, Quantity = line.QtyPending }; Label packageLabel = new Label { LabelID = -1 }; PickProduct(curLine, sourceLocation, node, packageLabel, picker, null); } }
public void RefreshBalance(Document document) { DocumentBalance docBalance = new DocumentBalance { Document = document, Node = View.Model.Node, Location = App.curLocation }; //#########Receiving Balance if (View.Model.DocumentLines == null || View.Model.DocumentLines.Count == 0) { View.Model.DocumentBalance = service.GetDocumentBalanceForEmpty(docBalance); } else { View.Model.DocumentBalance = service.GetDocumentBalance(docBalance, false); View.Model.DocumentBalance = (from balance in View.Model.DocumentBalance join lines in View.Model.DocumentLines.Where(f => f.Note == "1" || (f.Quantity > 0 && f.LineNumber != 0)) on balance.Product.ProductID equals lines.Product.ProductID select balance).ToList(); } View.DgDocumentBalance.Items.Refresh(); //El boton de Recibir todo se muestra si hay balance View.BtnReceiveAtOnce.IsEnabled = false; //View.Model.AllPicked = true; View.Model.AllPicked = false; /*if (View.Model.DocumentBalance.Any(f => f.QtyPending > 0)) { View.BtnReceiveAtOnce.IsEnabled = true; View.Model.AllPicked = false; }*/ if (View.Model.DocumentBalance.Any(f => f.Product.ErpTrackOpt == 1 && f.QtyPending == 0)) { View.BtnReceiveAtOnce.IsEnabled = true; View.Model.AllPicked = true; } //##########Posting Balance View.Model.PendingToPostList = service.GetDocumentPostingBalance(docBalance); //El boton de Posting todo se muestra si hay balance //View.BtnConfirmOrder.IsEnabled = false; //if (View.Model.AllPicked) //{ // View.BtnConfirmOrder.IsEnabled = true; //} }
//Encargada de obtener el cruce entre el purchase document y los sales document //Involucrados en el proceso cross dock; private void OnCrossDockPreview(object sender, EventArgs e) { View.BtnStep1.IsEnabled = false; //Obteniendo el Balance DocumentBalance docBalance = new DocumentBalance { Document = View.Model.Document, Node = View.Model.Node, Location = App.curLocation }; ProcessWindow pw = new ProcessWindow(""); pw.Show(); try { //Obteniendo el cruce de documentos. View.Model.CrossDockBalance = service.GetCrossDockBalance(docBalance, View.Model.AssignedDocs.ToList()) .Where(f => !string.IsNullOrEmpty(f.Notes)) .OrderBy(f => f.Notes).ToList(); //Mostrando el Warning de not suppied if apply if (View.Model.CrossDockBalance != null && View.Model.CrossDockBalance.Where(f => f.Notes == "Qty not supplied").Count() > 0) View.TxtWarning.Visibility = Visibility.Visible; //Ocultando el expander superior View.ExpDocs.IsExpanded = false; //Visible the second panel View.ExpResult.IsExpanded = true; View.ExpResult.Visibility = Visibility.Visible; pw.Close(); } catch (Exception ex) { pw.Close(); Util.ShowError("Problem generating the Cross Dock preview.\n"+ ex.Message); } }
private void RefreshBalance(Document document) { DocumentBalance docBalance = new DocumentBalance { Document = document, Node = View.Model.Node, Location = App.curLocation }; //#########Receiving Balance if (View.Model.DocumentLines == null || View.Model.DocumentLines.Count == 0) View.Model.DocumentBalance = service.GetDocumentBalanceForEmpty(docBalance); else View.Model.DocumentBalance = service.GetDocumentBalance(docBalance, true); View.DgDocumentBalance.Items.Refresh(); //Mostrar o no el mensaje del balance bool showMessage = false; foreach (DocumentBalance docBal in View.Model.DocumentBalance) { if (docBal.QtyPending > 0) { showMessage = true; break; } } //Si hay saldo pendiente por recibir. View.StkPendingMsg.Visibility = showMessage ? Visibility.Visible : Visibility.Collapsed; //Si nada esta recibido, dejar el boton bloqueado. if (View.Model.DocumentBalance.Any(f => f.QtyProcessed > 0)) View.Model.AnyReceived = true; }
/// <summary> /// Get Print file string to print /// </summary> /// <param name="labels">List of labels to print</param> /// <param name="template">Template to use for the printing</param> /// <returns></returns> public String ProcessPrintingLine(DocumentBalance printLine, LabelTemplate template, String printLot, Node node, Bin bin, UserByRol userByRol) { string result = ""; Status status = WType.GetStatus(new Status { StatusID = EntityStatus.Active }); //Active //Obteniendo el listado de TAGS que se deben reemplazar en el template IList <LabelMapping> labelmappings = Factory.DaoLabelMapping().Select( new LabelMapping { LabelType = template.LabelType }); //Template base //int i; IList <Label> labelList = new List <Label>(); //Tipo De impresion //1. Normal Imprime standar, sin logistica //2. Logistic (Notes tiene data) - imprime normal mas la Logistica Unit logisticUnit = null; if (printLine.Notes != null && printLine.Notes.Contains("Logistic")) { string[] dataLogistic = printLine.Notes.Split(':'); //El primer elemento contiene la unidad logistica. logisticUnit = Factory.DaoUnit().SelectById(new Unit { UnitID = int.Parse(dataLogistic[1]) }); //3. Only print Logistic (notes tiene "ONLYPACK") - no imprime la normal (si las crea), solo imprime las logisticas //if (printLine.Notes.Contains("ONLYPACK")) //printOnlyLogistic = true; } //CReating Document Line to Send DocumentLine prnLine = new DocumentLine { Product = printLine.Product, Document = printLine.Document, Unit = printLine.Unit, Quantity = printLine.Quantity }; //Crea las etiquetas de la cantidad de producto a recibir Logisticas y sus Hijas double logisticFactor = (logisticUnit != null) ? (double)(logisticUnit.BaseAmount / printLine.Unit.BaseAmount) : 1; labelList = CreateProductLabels(logisticUnit, prnLine, node, bin, logisticFactor, printLot, "", DateTime.Now) .Where(f => f.FatherLabel == null).ToList(); //Reemplazando el Header if (template.Header != null) { result += ReplaceTemplate(labelmappings, template.Header, labelList[0]) + Environment.NewLine; } //Reemplazando el Body if (template.Body != null) { foreach (Label label in labelList) { result += ReplaceTemplate(labelmappings, template.Body, label) + Environment.NewLine; } } return(result); }
public void ReverseReceiptNodeTraceByQty(DocumentBalance docBalance, int quantity, SysUser user) { try { SetService(); SerClient.ReverseReceiptNodeTraceByQty(docBalance, quantity, user); } finally { SerClient.Close(); if (SerClient.State == CommunicationState.Faulted) SerClient.Abort(); } }
public IList<DocumentBalance> GetDocumentBalanceForEmpty(DocumentBalance docBalance) { try { SetService(); return SerClient.GetDocumentBalanceForEmpty(docBalance); } finally { SerClient.Close(); if (SerClient.State == CommunicationState.Faulted) SerClient.Abort(); } }
public IList<DocumentBalance> GetCrossDockBalance(DocumentBalance purchaseBalance, IList<Document> salesDocs) { try { SetService(); return SerClient.GetCrossDockBalance(purchaseBalance, salesDocs.ToList()); } finally { SerClient.Close(); if (SerClient.State == CommunicationState.Faulted) SerClient.Abort(); } }
// public Document CreateNewDocumentTask(IList<Document> docList, Document taskDoc) //{ //try { //SetService(); return SerClient.CreateNewDocumentTask(docList, taskDoc); } //finally //{ //SerClient.Close(); //if (SerClient.State == CommunicationState.Faulted) //{SerClient.Abort();} //} //} public IList<DocumentBalance> GetDocumentBalance(DocumentBalance docBalance, bool isCrossDock) { try { SetService(); return SerClient.GetDocumentBalance(docBalance, isCrossDock); } finally { SerClient.Close(); if (SerClient.State == CommunicationState.Faulted) SerClient.Abort(); } }
public IList <DocumentBalance> DetailedBalance(DocumentBalance docBalance, bool isCrossDock) { string sQuery = ""; if (isCrossDock) //No se debe tener en cuenta el back order { sQuery = "SELECT l.DocID, l.LineID, node.NodeID, l.ProductID, l.UnitID, SUM(l.Quantity - l.QtyCancel) AS Quantity, " + "SUM(l.Quantity - l.QtyCancel) - ISNULL(n.Quantity/u.BaseAmount,0) AS QtyPending, Max(l.UnitPrice) as UnitPrice "; } else { sQuery = "SELECT l.DocID, l.LineID, node.NodeID, l.ProductID, l.UnitID, SUM(l.Quantity - l.QtyCancel - l.QtyBackOrder) AS Quantity, " + "SUM(l.Quantity - l.QtyCancel - l.QtyBackOrder) - ISNULL(n.Quantity/u.BaseAmount,0) AS QtyPending, Max(l.UnitPrice) as UnitPrice "; } sQuery += "FROM Trace.DocumentLine AS l " + "INNER JOIN Master.Product AS p ON l.ProductID = p.ProductID " + "INNER JOIN Master.Unit AS u ON l.UnitID = u.UnitID " + "INNER JOIN Trace.Node node ON node.NodeID = :id2 " + "LEFT OUTER JOIN ( " + " SELECT lbl.ProductID, ISNULL(SUM(x.Quantity * ISNULL(un.BaseAmount,1)) ,0) AS Quantity, x.DocLineID " + " FROM Trace.NodeTrace AS x " + " INNER JOIN Trace.Label AS lbl ON x.LabelID = lbl.LabelID " + " LEFT OUTER JOIN Master.Unit AS un ON lbl.UnitID = un.UnitID " + " WHERE x.NodeID = :id2 AND x.DocID = :id1 And x.Quantity > 0 " + " GROUP BY lbl.ProductID, x.DocLineID " + ") AS n " + "ON n.ProductID = l.ProductID AND l.LineID = n.DocLineID " + "WHERE (l.DocID = :id1 ) "; StringBuilder sql = new StringBuilder(sQuery); Parms = new List <Object[]>(); Parms.Add(new Object[] { "id1", docBalance.Document.DocID }); Parms.Add(new Object[] { "id2", docBalance.Node.NodeID }); if (docBalance != null) { if (docBalance.Product != null && docBalance.Product.ProductID != 0) { sql.Append(" and p.ProductID = :id3 "); Parms.Add(new Object[] { "id3", docBalance.Product.ProductID }); } sql.Append(" and ( l.LineStatusID = :id4 Or l.LineStatusID = :id5 ) "); Parms.Add(new Object[] { "id4", DocStatus.New }); Parms.Add(new Object[] { "id5", DocStatus.InProcess }); sql.Append(" and p.StatusID = :id6 "); Parms.Add(new Object[] { "id6", EntityStatus.Active }); sql.Append("GROUP BY l.DocID, l.LineID, node.NodeID, l.ProductID, l.UnitID, u.BaseAmount, n.Quantity "); } IQuery query = Factory.Session.CreateSQLQuery(sql.ToString()); SetParameters(query); IList <DocumentBalance> retBalance = GetBalanceObject(query.List <Object[]>(), docBalance.Location); if (!Factory.IsTransactional) { Factory.Commit(); } return(retBalance); }
/// <summary> /// Entrega lo que esta pendiente por recibir de un Documento contra un NodeTrace En unidad Basica /// </summary> /// <param name="data"></param> /// <returns></returns> public IList <DocumentBalance> GeneralBalance(DocumentBalance docBalance, bool isCrossDock) { string sQuery = ""; if (isCrossDock) //No se debe tener en cuenta el back order { sQuery = "select doc.docID, cast(0 as bigint) as Line, node.NodeID, product.ProductID, unit.UnitID, " + " Sum(l.Quantity - l.QtyCancel) as Quantity, " + " Sum(l.Quantity - l.QtyCancel) - Isnull(n.Quantity/unit.BaseAmount,0) as QtyPending, Max(l.UnitPrice) as UnitPrice, Min(l.Sequence) as Seq "; } else { sQuery = "select doc.docID, cast(0 as bigint) as Line, node.NodeID, product.ProductID, unit.UnitID, " + " Sum(l.Quantity - l.QtyCancel - l.QtyBackOrder) as Quantity, " + " Sum(l.Quantity - l.QtyCancel - l.QtyBackOrder) - Isnull(n.Quantity/unit.BaseAmount,0) as QtyPending, Max(l.UnitPrice) as UnitPrice, Min(l.Sequence) as Seq "; } sQuery += " from Trace.DocumentLine as l " + " INNER JOIN Trace.Document doc ON l.DocID = doc.DocID " + " INNER JOIN Trace.Node node ON node.NodeID = :id2 " + " INNER JOIN Master.Product product ON l.ProductID = product.ProductID " + " INNER JOIN Master.Unit unit ON l.UnitID = unit.UnitID LEFT OUTER JOIN " + " ( select lb.ProductID, Isnull(Sum(x.Quantity * ISNULL(u.BaseAmount,1)),0) as Quantity from Trace.NodeTrace x " + " INNER JOIN Trace.Label lb ON x.LabelID = lb.LabelID LEFT JOIN Master.Unit u ON u.UnitID = x.UnitID " //lb.UnitID + " Where x.NodeID = :id2 and x.DocID = :id1 AND x.Quantity > 0 AND x.IsDebit = 0 " + " Group BY lb.ProductID ) as n On l.ProductID = n.ProductID Where l.DocID = :id1 "; StringBuilder sql = new StringBuilder(sQuery); Parms = new List <Object[]>(); Parms.Add(new Object[] { "id1", docBalance.Document.DocID }); if (docBalance.Node != null && docBalance.Node.NodeID != 0) { Parms.Add(new Object[] { "id2", docBalance.Node.NodeID }); } else if (docBalance.Node != null && !string.IsNullOrEmpty(docBalance.Node.Name)) { docBalance.Node = Factory.DaoNode().Select(docBalance.Node).First(); Parms.Add(new Object[] { "id2", docBalance.Node.NodeID }); } if (docBalance != null) { if (docBalance.Product != null && docBalance.Product.ProductID != 0) { sql.Append(" and l.ProductID = :id3 "); Parms.Add(new Object[] { "id3", docBalance.Product.ProductID }); } sql.Append(" and ( l.LineStatusID = :id4 Or l.LineStatusID = :id5 ) "); Parms.Add(new Object[] { "id4", DocStatus.New }); Parms.Add(new Object[] { "id5", DocStatus.InProcess }); sql.Append(" and product.StatusID = :id6 "); Parms.Add(new Object[] { "id6", EntityStatus.Active }); sql.Append(" Group By doc.docID, node.NodeID, product.ProductID, unit.UnitID, unit.BaseAmount, n.Quantity"); //unit.BaseAmount, sql.Append(" Order By Seq"); } IQuery query = Factory.Session.CreateSQLQuery(sql.ToString()); SetParameters(query); IList <DocumentBalance> retBalance = GetBalanceObject(query.List <Object[]>(), docBalance.Location); if (!Factory.IsTransactional) { Factory.Commit(); } return(retBalance); }
private void OnAddingToPrint(object sender, EventArgs e) { try { int qtyPerPack = 0; View.ProcessResult.Text = ""; Unit baseUnit = null; //Validating Product if (View.TxtProduct.Product == null) { Util.ShowError("Product not selected."); return; } //Validating Unit if (View.ComboUnit.SelectedIndex == -1) { Util.ShowError("UoM not Selected."); return; } View.Model.CheckAllRules(); if (!View.Model.IsValid()) { Util.ShowError("Error validating data. Please check data and try again."); return; } if (string.IsNullOrEmpty(View.TxtPrintQty.Text) || !(int.Parse(View.TxtPrintQty.Text) > 0)) { Util.ShowError("Number of packs not valid."); return; } if (string.IsNullOrEmpty(View.TxtQtyPerPack.Text) || !(int.Parse(View.TxtQtyPerPack.Text) > 0)) { Util.ShowError("Units per pack not valid."); return; } //check if logistic unit can contain pack unit Unit logisticUnit = View.Model.PackUnit; if (logisticUnit != null) { baseUnit = View.ComboUnit.SelectedItem as Unit; if (logisticUnit.BaseAmount <= baseUnit.BaseAmount) { Util.ShowError("Pack Unit can not contain the current UoM."); View.LogisticUnit.SelectedIndex = -1; View.Model.PackUnit = null; return; } if ((logisticUnit.BaseAmount % baseUnit.BaseAmount) != 0) { Util.ShowError("UoM " + baseUnit.Name + " can not be contained in Pack Unit " + logisticUnit.Name + "."); View.LogisticUnit.SelectedIndex = -1; View.Model.PackUnit = null; return; } } if (logisticUnit == null && View.TxtQtyPerPack.Text != "") { try { logisticUnit = service.GetUnit(new Unit { Company = App.curCompany, Name = WmsSetupValues.CustomUnit }).First(); } catch { Util.ShowError("Unit Custom not defined."); return; } logisticUnit.BaseAmount = double.Parse(View.TxtQtyPerPack.Text); } try { if (!string.IsNullOrEmpty(View.TxtQtyPerPack.Text)) { qtyPerPack = int.Parse(View.TxtQtyPerPack.Text); } } catch { Util.ShowError("Units per pack not valid."); return; } string notes = ""; if (logisticUnit != null) { notes = "Pack:" + logisticUnit.UnitID.ToString() + ":" + logisticUnit.Name; } //if (View.ChkOnlyLogistic.IsChecked == true) // notes += ",ONLYPACK"; View.StkLine.Visibility = Visibility.Visible; //Define Document, Product, Unit and Qty to send to receiving transaction DocumentBalance printLine = new DocumentBalance { Product = View.TxtProduct.Product, Unit = (Unit)View.ComboUnit.SelectedItem, Quantity = int.Parse(View.TxtPrintQty.Text) * int.Parse(View.TxtQtyPerPack.Text), //Cantidad a imprimir la division del Units sobre el Qty per pack QtyPending = (qtyPerPack > 0) ? qtyPerPack : 1, QtyProcessed = int.Parse(View.TxtPrintQty.Text), Notes = notes //Indica que se deben imprimir solo logisticas, de lo contrario imprime todo //Logistica y Basica }; if (View.Model.LinesToPrint == null) { View.Model.LinesToPrint = new List <DocumentBalance>(); } View.Model.LinesToPrint.Add(printLine); //Update Process Result //View.ProcessResult.Text = "Line Added to Print List."; View.ToPrintLines.Items.Refresh(); View.TxtPrintQty.Text = "0"; //Acomoda el panel para nuevos datos limpia //View.Model.Products = null; View.Model.ProductUnits = null; View.Model.PackingUnits = null; View.Model.PackUnit = null; //View.ChkOnlyLogistic.IsChecked = false; //View.ChkOnlyLogistic.Visibility = Visibility.Collapsed; View.TxtProduct.Text = ""; View.TxtProduct.Product = null; View.TxtProduct.ProductDesc = ""; View.TxtQtyPerPack.Text = ""; //Enable Print Module EnablePrintModule(); } catch (Exception ex) { Util.ShowError(ex.Message); } }
public void RefreshBalance(Document document) { AllReceived = true; DocumentBalance docBalance = new DocumentBalance { Document = document, Node = View.Model.Node, Location = App.curLocation }; //#########Receiving Balance if (View.Model.DocumentLines == null || IsDirectReceipt) View.Model.DocumentBalance = service.GetDocumentBalanceForEmpty(docBalance); else View.Model.DocumentBalance = service.GetDocumentBalance(docBalance, false); View.DgDocumentBalance.Items.Refresh(); //El boton de Recibir todo se muestra si hay balance View.BtnReceiveAtOnce.IsEnabled = false; if (View.Model.DocumentBalance.Any(f => f.QtyPending > 0)) { View.BtnReceiveAtOnce.IsEnabled = true; AllReceived = false; } //Si algun producto recibido para habilitar el boton de impresion. View.Model.AnyReceived = View.Model.DocumentBalance.Any(f => f.QtyProcessed > 0); //##########Posting Balance View.Model.PendingToPostList = service.GetDocumentPostingBalance(docBalance); View.DgPostingBalance.Items.Refresh(); //El boton de Posting solo se muestra si hay balance View.BtnCreateReceipt.IsEnabled = false; View.StkPosting.Visibility = Visibility.Collapsed; if (View.Model.PendingToPostList.Any(f => f.QtyPending > 0)) { View.BtnCreateReceipt.IsEnabled = true; View.StkPosting.Visibility = Visibility.Visible; AllPosted = false; } //Refresh Qty Pending If product is selected //Update Pending quantity 21 marzo 09 try { if (View.Model.Product != null) { View.Model.CurQtyPending = int.Parse(View.Model.DocumentBalance .Where(f => f.Product.ProductID == View.Model.Product.ProductID && f.Unit.UnitID == ((Unit)View.ComboUnit.SelectedItem).UnitID) .First().QtyPending.ToString()); View.Model.AllowReceive = true; if (View.Model.Document.IsFromErp == true) View.Model.AllowReceive = (View.Model.CurQtyPending > 0) ? true : false; } } catch { } //Marzo 21, si todo esta recibido y es un ERP documet cambia el estatus a Completed. //Si tiene Any Received cambia el status a In Process //Completed if (AllReceived && View.Model.Document.IsFromErp == true && View.Model.DocumentBalance.Any(f => f.QtyProcessed > 0) //garantiza que al menos uno este procesado && View.Model.Document.DocStatus.StatusID != DocStatus.Completed) { View.Model.Document.DocStatus = new Status { StatusID = DocStatus.Completed }; View.Model.Document.ModDate = DateTime.Now; View.Model.Document.ModifiedBy = App.curUser.UserName; service.UpdateDocument(View.Model.Document); } //In Process if (!AllReceived && View.Model.AnyReceived && View.Model.Document.DocStatus.StatusID != DocStatus.InProcess) { View.Model.Document.DocStatus = new Status { StatusID = DocStatus.InProcess }; View.Model.Document.ModDate = DateTime.Now; View.Model.Document.ModifiedBy = App.curUser.UserName; service.UpdateDocument(View.Model.Document); } //Muestra el posting panel solo si permite parcial o si ha recibido completo. View.PanelPosting.Visibility = Visibility.Visible; if (!AllReceived && Util.GetConfigOption("PARTIALREC").Equals("F") && View.Model.Document.AllowPartial != true) View.PanelPosting.Visibility = Visibility.Collapsed; //Hidden Tracking y Others View.TabItemTrackOption.Visibility = Visibility.Collapsed; //Evaluar si la orden tiene producto para hacerle Tracking if(View.Model.DocumentLines.Select(f=>f.Product).Any( f=> f.ProductTrack != null && f.ProductTrack.Count > 0 && f.ProductTrack.Where(z => z.TrackOption.DataType.DataTypeID != SDataTypes.ProductQuality).Count() > 0 )) { View.TabItemTrackOption.Visibility = Visibility.Visible; LoadTrackOptionsControl(); } /* foreach (DocumentBalance db in View.Model.DocumentBalance) { //Se adiciono que el track option no sea de calidad de producto if (db.Product.ProductTrack != null && db.Product.ProductTrack.Count > 0 && db.Product.ProductTrack.Where(f => f.TrackOption.DataType.DataTypeID != SDataTypes.ProductQuality).Count() > 0) //&& db.QtyProcessed > 0 { View.TabItemTrackOption.Visibility = Visibility.Visible; LoadTrackOptionsControl(); break; } } * */ RefreshReceipts(); }
private void ProcessPrintingLine(DocumentBalance printLine, String printLot, Node node, Bin bin, UserByRol userByRol) { //Tipo De impresion //1. Normal Imprime standar, sin logistica //2. Logistic (Notes tiene data) - imprime normal mas la Logistica Unit logisticUnit = null; //bool printOnlyLogistic = false; if (printLine.Notes != null && printLine.Notes.Contains("Pack")) { string[] dataLogistic = printLine.Notes.Split(':'); //El elemento [1] contiene la unidad logistica, si es cero es custom. if (dataLogistic[2].Equals(WmsSetupValues.CustomUnit)) { try { //trata de encontrar una unidad con ese baseamount logisticUnit = Factory.DaoUnit().Select( new Unit { BaseAmount = printLine.QtyPending, Company = userByRol.Location.Company, ErpCodeGroup = printLine.Unit.ErpCodeGroup } ).First(); } catch { //Obtiene la custom logisticUnit = Factory.DaoUnit().SelectById(new Unit { UnitID = int.Parse(dataLogistic[1]) }); } } else // Si no es Custom { logisticUnit = Factory.DaoUnit().SelectById(new Unit { UnitID = int.Parse(dataLogistic[1]) }); } } //Se ingresa para poder sacar el dato de la company if (printLine.Document == null) { printLine.Document = new Document { Company = userByRol.Location.Company } } ; //CReating Document Line to Send DocumentLine prnLine = new DocumentLine { Product = printLine.Product, Document = printLine.Document, Unit = printLine.Unit, Quantity = printLine.Quantity, CreatedBy = userByRol.User.UserName }; if (logisticUnit != null) { logisticUnit.BaseAmount = printLine.QtyPending; } //Obteniendo el factor logistico antes de enviar a crear los labels double logisticFactor = (logisticUnit != null) ? printLine.QtyPending : 1; //Manda a Crear los Labels IList <Label> resultList = CreateProductLabels(logisticUnit, prnLine, node, bin, logisticFactor, printLot, "", DateTime.Now) .Where(f => f.FatherLabel == null).ToList(); foreach (Label lbl in resultList) { this.listOfLabels.Add(lbl); } }