public virtual PocoEntity Parse(WType type) { PocoEntity result = this.factory.GetPocoEntity(); // this attribute is always set, otherwise we would not be here result.DbFactory = (IWormDbFactory)type.GetAttribute<WormDbFactoryAttribute>().DbFactoryType.CreateInstance(); result.PocoClassName = type.Name; result.PocoNamespace = type.Namespace; result.PocoFilename = String.Format("{0}{1}{2}.cs", type.Namespace.Replace(".", Path.DirectorySeparatorChar.ToString()) , Path.DirectorySeparatorChar , type.Name ); result.TableName = this.GetTableName(type); this.AddProperties(result, type); result.WormClassName = String.Format("Worm{0}", type.Name); result.WormNamespace = String.Format("{0}.Db", result.PocoNamespace); result.WormFilename = String.Format("{0}{1}.cs", this.NamespaceAsPathAssumingUseOfRootNamespace(result.WormNamespace) , result.WormClassName ); return result; }
protected string GetTableName(WType type) { WormTableAttribute attr = type.GetAttribute<WormTableAttribute>(); if (attr != default(WormTableAttribute)) { return attr.TableName; } return type.Name; }
protected void AddProperties(PocoEntity result, WType type) { PropertyToPocoField converter = this.factory.GetPropertyToPocoField(); foreach (WProperty property in type.GetProperties()) { if (property.GetAttribute<WormIgnoreAttribute>() == default(WormIgnoreAttribute)) { result.Fields.Add(converter.Parse(property)); } } }
public virtual IEnumerable<WType> GetTypes(Func<WType, bool> predicate) { WType w; foreach (Type t in this.assembly.GetTypes()) { w = new WType(t); if (predicate(w)) { yield return w; } } }
/// <summary> /// Recolecta= producto, sin etiqueta (recibo manual) toma de los labels virtuales para cada unidad basica de producto /// </summary> /// <param name="line"></param> /// <param name="sourceLocation"></param> /// <param name="node"></param> /// <param name="packageLabel"></param> /// <param name="picker"></param> public void PickProduct(DocumentLine line, Label sourceLocation, Node destNode, Label packageLabel, SysUser picker, Bin destBin) { Factory.IsTransactional = true; Node storedNode = WType.GetNode(new Node { NodeID = NodeType.Stored }); Status status = WType.GetStatus(new Status { StatusID = EntityStatus.Active }); Status locked = WType.GetStatus(new Status { StatusID = EntityStatus.Locked }); DocumentType labelType = WType.GetLabelType(new DocumentType { DocTypeID = LabelType.ProductLabel }); if (destBin == null) { destBin = Rules.GetBinForNode(destNode, sourceLocation.Bin.Location); } try { //Valida si el docuemnto no es nulo Rules.ValidateDocument(line.Document, true); Rules.ValidateBinStatus(sourceLocation.Bin, true); //Validar si las locations son iguales Rules.ValidatePickLocation(line.Document.Location, sourceLocation.Bin.Location, true); if (sourceLocation.LabelType.DocTypeID == LabelType.ProductLabel) { //Valida que este activo Rules.ValidateActiveStatus(sourceLocation.Status, true); //Validar que no este vod Rules.ValidateVoided(sourceLocation.Node, 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.Quantity, CreatedBy = picker.UserName }; Rules.ValidateProductInDocument(docLine, true); //Valida si hay saldo pendiente por procesar Rules.ValidateBalanceQuantityInDocument(docLine, destNode, true, false); } //Evaluacion de tipo de source, Bin or Label DateTime recDate = DateTime.Now; if (Rules.ValidateIsBinLabel(sourceLocation, false)) { IList <Label> tranLabel = DecreaseQtyFromBin(sourceLocation, line, "Picking Source Product", true, storedNode); try { recDate = (DateTime)tranLabel.Where(f => f.ReceivingDate != null).OrderBy(f => f.ReceivingDate).First().ReceivingDate; } catch { recDate = DateTime.Now; } } //SI el ajustes es sobre un Label else if (Rules.ValidateIsProductLabel(sourceLocation, false)) { DecreaseQtyFromLabel(sourceLocation, line, "Picking Source Product", true, storedNode, true); try { recDate = (sourceLocation.ReceivingDate == null) ? DateTime.Now : (DateTime)sourceLocation.ReceivingDate; } catch { recDate = DateTime.Now; } } //Creando el package para ingresar la mercancia. if (packageLabel != null) { line.Document.Location = sourceLocation.Bin.Location; //Revalidando que el location sea correcto try { packageLabel = GetPackageLabel(packageLabel, line.Document, picker).PackLabel; } catch (Exception ex) { Factory.Rollback(); throw new Exception("Package label could not be created.\n" + ex.Message); } } //Increasing the Record of Product on Dest Bin. Label pickedLabel = IncreaseQtyIntoBin(line, destNode, destBin, "Picking Dest Product", true, recDate, null, sourceLocation); pickedLabel.FatherLabel = packageLabel; pickedLabel.Status = locked; pickedLabel.ShippingDocument = line.Document; Factory.DaoLabel().Update(pickedLabel); Factory.Commit(); } catch (Exception ex) { Factory.Rollback(); ExceptionMngr.WriteEvent("PickProduct:", ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business); throw new Exception(WriteLog.GetTechMessage(ex)); } }
private IList <Document> GetLocationTransferDocuments(string sWhere) { IList <Document> list = new List <Document>(); DocumentClass docClass = new DocumentClass(); Document tmpData = null; try { /* * 401 0 En elaboración * 401 1 Aprobado * 401 2 Parcial * 401 3 Cumplido * 401 9 Anulado */ sWhere = string.IsNullOrEmpty(sWhere) ? "" : " AND " + sWhere; Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString); Query = GetErpQuery("TRANSFER"); DataSet ds = ReturnDataSet(Query, null, "TRANSFER", Command.Connection); if (ds == null || ds.Tables.Count == 0) { return(null); } DocumentConcept docConcept = WType.GetDefaultConcept(new DocumentClass { DocClassID = SDocClass.Receiving }); DocumentType docType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.InTransitShipment }); Status docStatus = WType.GetStatus(new Status { StatusID = DocStatus.New }); Account defAccount = WType.GetAccount(new Account { AccountCode = WmsSetupValues.DEFAULT }); SysUser user = WType.GetUser(new SysUser { UserName = WmsSetupValues.AdminUser }); Company company = CurCompany; //En el dataset, Tables: 1 - DocumentHeader foreach (DataRow dr in ds.Tables[0].Rows) { try { //Map Properties tmpData = new Document(); tmpData.Date1 = DateTime.Parse(dr["f450_id_fecha"].ToString()); tmpData.DocNumber = dr["numero_doc"].ToString(); tmpData.DocStatus = docStatus; //GetReceivingStatus(int.Parse(dr["POSTATUS"].ToString())); tmpData.DocType = docType; tmpData.PickMethod = docType.PickMethod; tmpData.DocConcept = docConcept; tmpData.Vendor = defAccount; //Vendor Account; tmpData.Customer = defAccount; tmpData.CreatedBy = WmsSetupValues.SystemUser; tmpData.Reference = dr["f450_docto_alterno"].ToString(); tmpData.UserDef1 = dr["co_salida"].ToString(); //CO Origen - SALIDA tmpData.UserDef2 = dr["bodega_salida"].ToString(); //Bodega Origen - SALIDA //try { tmpData.LastChange = DateTime.Parse(dr["f450_ts"].ToString()); } //catch { } tmpData.IsFromErp = true; tmpData.CrossDocking = false; tmpData.Location = WType.GetLocation(new Location { ErpCode = dr["bodega_entrada"].ToString(), Company = company }); //location; tmpData.Company = CurCompany; //Asignacion de Lines tmpData.DocumentLines = GetLocationTransferDocumentLines(tmpData, company, dr["f450_rowid_docto"].ToString()); if (tmpData.DocumentLines != null && tmpData.DocumentLines.Count > 0) { //El location debe ser el de la primera linea if (tmpData.Location == null) { tmpData.Location = tmpData.DocumentLines[0].Location; } list.Add(tmpData); } } catch (Exception ex) { ExceptionMngr.WriteEvent("GetLocationTransferDocuments: " + tmpData.DocNumber, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); } } //retornar la lista return(list); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetLocationTransferDocuments", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(null); } }
private IList <DocumentLine> GetKitAssemblyDocumentLines(Document doc) { DocumentLine tmpData; IList <DocumentLine> list = new List <DocumentLine>(); Status lineStatus = WType.GetStatus(new Status { StatusID = DocStatus.New }); int curLine = 1; string curMaster = ""; Query = GetErpQuery("KITDOC_LINE").Replace("__DOCUMENT", doc.ErpMaster.ToString()); DataSet ds = ReturnDataSet(Query, null, "KITDOC_LINE", Command.Connection); if (ds == null || ds.Tables.Count == 0) { return(null); } if (ds.Tables[0].Select("rowid=0").Length == 0) { return(null); } try { foreach (DataRow dr in ds.Tables[0].Rows) { tmpData = new DocumentLine(); tmpData.Date1 = doc.Date1; tmpData.LineNumber = int.Parse(dr["rowid"].ToString()); //curLine++; tmpData.Sequence = tmpData.LineNumber; tmpData.LinkDocLineNumber = int.Parse(dr["row_padre"].ToString()); tmpData.Note = dr["type"].ToString(); //TODO: Revisar el Status en GP para traer el equivalente tmpData.LineStatus = lineStatus; tmpData.Document = doc; tmpData.IsDebit = false; tmpData.Quantity = double.Parse(dr["f470_cant_base"].ToString(), ListValues.DoubleFormat()); tmpData.CreatedBy = WmsSetupValues.SystemUser; tmpData.CreationDate = DateTime.Now; curMaster = "Location"; tmpData.Location = doc.Location; //WType.GetLocation(new Location { Company = CurCompany, ErpCode = dr["LOCNCODE"].ToString() }); try { curMaster = "Product"; tmpData.Product = WType.GetProduct(new Product { Company = CurCompany, ProductCode = dr["item_id"].ToString() });; curMaster = "Unit"; tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["unit_id"].ToString(), ErpCodeGroup = tmpData.Product.BaseUnit.ErpCodeGroup }); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetKitAssemblyDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); continue; //{ // //Pone el Default Product // tmpData.Product = WType.GetProduct(new Product { Company = CurCompany, ProductCode = WmsSetupValues.DEFAULT }); // tmpData.LineDescription = "Unknown: " + dr["ITEMNMBR"].ToString() + ", " + dr["ITEMDESC"].ToString(); // curMaster = "Unit"; // tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["UOFM"].ToString() }); } list.Add(tmpData); } return((list.Count > 0) ? list : null); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetKitAssemblyDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); throw; //return null; } }
public WalkType(Vector3 target, WType type) { WType = type; justMove = true; moveTarget = target; }
/// <summary> /// Piquea un producto a una orden teneindo en cuanta las tracking options. /// </summary> /// <param name="label"></param> /// <param name="qtyToPick"></param> /// <param name="node"></param> /// <param name="picker"></param> public Label PickProductWithTrack(Document document, Label label, double qtyToPick, Node destNode, SysUser picker, Label packLabel) { //Debe piquear de producto suelto, teniendo en cuanta el Track del Label. Factory.IsTransactional = true; Node storedNode = WType.GetNode(new Node { NodeID = NodeType.Stored }); Status status = WType.GetStatus(new Status { StatusID = EntityStatus.Active }); Status locked = WType.GetStatus(new Status { StatusID = EntityStatus.Locked }); //DocumentType labelType = WType.GetLabelType(new DocumentType { DocTypeID = LabelType.ProductLabel }); Bin destBin = Rules.GetBinForNode(destNode, document.Location); try { //Valida si el docuemnto no es nulo Rules.ValidateDocument(document, true); Rules.ValidateBinStatus(label.Bin, true); //Valida si el producto esta en ese documento DocumentLine docLine = new DocumentLine { Document = document, Product = label.Product, LineStatus = new Status { StatusID = DocStatus.New }, Unit = label.Unit, Quantity = qtyToPick, CreatedBy = picker.UserName }; if (document.DocType.DocTypeID != SDocType.PickTicket) { Rules.ValidateProductInDocument(docLine, true); //Valida si hay saldo pendiente por procesar Rules.ValidateBalanceQuantityInDocument(docLine, destNode, true, false); } //Evaluacion de tipo de source, Bin or Label DateTime recDate = DateTime.Now; //if (Rules.ValidateIsBinLabel(sourceLocation, false)) //{ IList <Label> tranLabel = DecreaseQtyFromBin(label, docLine, "Picking Source Track", true, storedNode); try { recDate = (DateTime)tranLabel.Where(f => f.ReceivingDate != null).OrderBy(f => f.ReceivingDate).First().ReceivingDate; } catch { recDate = DateTime.Now; } //} // //SI el ajustes es sobre un Label //else if (Rules.ValidateIsProductLabel(sourceLocation, false)) //{ // DecreaseQtyFromLabel(sourceLocation, line, "Picking Source", true, storedNode); // try { recDate = (sourceLocation.ReceivingDate == null) ? DateTime.Now : (DateTime)sourceLocation.ReceivingDate; } // catch { recDate = DateTime.Now; } //} //Creando el package para ingresar la mercancia. if (packLabel == null) { packLabel = new Label { LabelID = -1 } } ; document.Location = label.Bin.Location; //Revalidando que el location sea correcto try { packLabel = GetPackageLabel(packLabel, document, picker).PackLabel; } catch (Exception ex) { Factory.Rollback(); throw new Exception("Package label could not be created.\n" + ex.Message); } //Increasing the Record of Product on Dest Bin. //Oct 09 /2009 Se adiciona el track option. Label pickedLabel = IncreaseQtyIntoBin(docLine, destNode, destBin, "Picking Dest Track", true, recDate, label.TrackOptions, label); pickedLabel.FatherLabel = packLabel; pickedLabel.Status = locked; pickedLabel.ShippingDocument = document; Factory.DaoLabel().Update(pickedLabel); Factory.Commit(); return(pickedLabel); } catch (Exception ex) { Factory.Rollback(); ExceptionMngr.WriteEvent("PickProductWithTrack:", ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business); throw new Exception(WriteLog.GetTechMessage(ex)); } }
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)); } }
public IList <ProductStock> GetErpStock(ProductStock data, bool detailed) { IList <ProductStock> result = new List <ProductStock>(); try { Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString); Command.Connection.Open(); string sQuery, table, sWhere = ""; if (detailed) { sQuery = "SELECT * FROM IV00112 WHERE (QUANTITY > 0 OR ATYALLOC > 0) "; //IV00112 Tabla detallada de produto por BIN table = "IV00112"; } else { sQuery = "SELECT * FROM IV00102 WHERE RCRDTYPE = 2 AND QTYONHND > 0 "; table = "IV00102"; } if (data.Product != null && data.Product.ProductID != 0) { sWhere += " AND ITEMNMBR = '" + data.Product.ProductCode + "'"; } if (data.Bin != null && data.Bin.BinID != 0 && detailed) { sWhere += " AND BIN = '" + data.Bin.BinCode + "'"; } if (data.Bin != null && data.Bin.Location != null && data.Bin.Location.LocationID != 0) { sWhere += " AND LOCNCODE = '" + data.Bin.Location.ErpCode + "'"; } ds = ReturnDataSet(sQuery + sWhere, "", table, Command.Connection); if (ds == null || ds.Tables[0] == null || ds.Tables[0].Rows.Count == 0) { return(null); } //Creado el Ilist De ProductStock ProductStock record; foreach (DataRow dr in ds.Tables[0].Rows) { try { record = new ProductStock(); record.Product = WType.GetProduct(new Product { Company = CurCompany, ProductCode = dr["ITEMNMBR"].ToString() });; if (detailed) { record.Bin = new Bin { BinCode = dr["BIN"].ToString(), Location = data.Bin.Location }; record.Stock = double.Parse(dr["QUANTITY"].ToString()); record.PackStock = double.Parse(dr["ATYALLOC"].ToString()); } else { record.Bin = new Bin { BinCode = DefaultBin.MAIN, Location = data.Bin.Location }; record.Stock = double.Parse(dr["QTYONHND"].ToString()); record.PackStock = double.Parse(dr["ATYALLOC"].ToString()); } result.Add(record); } catch { } } return(result); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetErpStock", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(null); } }
/// <summary> /// Crea a new label package for a specific document, this package will contain product picked for the order. /// </summary> /// <param name="line"></param> /// <param name="picker"></param> /// <returns></returns> public DocumentPackage CreateNewPackage(Document document, SysUser picker, bool isOpen, DocumentPackage parent, string packageType) { Factory.IsTransactional = true; 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.CustomerLabel }); Unit logisticUnit = WType.GetUnit(new Unit { Company = document.Company, Name = WmsSetupValues.CustomUnit }); Bin destLocation = WType.GetBin(new Bin { Location = document.Location, BinCode = DefaultBin.PICKING }); int sequence = Factory.DaoDocumentPackage().Select(new DocumentPackage { Document = document, //PostingDocument = new Document {DocID = -1 } }).Count + 1; //Generate new logistig labels located in MAIN //Labels shouldbe activated the next transaction try { //Funcion para obtener siguiente Label //DocumentTypeSequence initSequence = GetNextDocSequence(document.Company, labelType); Label packLabel = new Label(); packLabel.Node = node; packLabel.Bin = destLocation; packLabel.CreatedBy = picker.UserName; packLabel.Status = status; packLabel.LabelType = labelType; packLabel.CreationDate = DateTime.Now; packLabel.Printed = false; packLabel.Unit = logisticUnit; packLabel.IsLogistic = true; packLabel.LabelCode = ""; // initSequence.NumSequence.ToString() + GetRandomHex(picker.UserName, initSequence.NumSequence); packLabel.Notes = "Package label for Document # " + document.DocNumber; packLabel.ShippingDocument = document; //Added on 14/ENE/09 if (parent != null && parent.PackLabel != null && parent.PackLabel.LabelID != 0) { try { packLabel.FatherLabel = parent.PackLabel; } catch { } } //Creado el document Package Asociado al Label DocumentPackage docPack = new DocumentPackage { Document = document, CreatedBy = picker.UserName, CreationDate = DateTime.Now, IsClosed = !isOpen, PackLabel = packLabel, Picker = picker, StartTime = DateTime.Now, EndTime = DateTime.Now, Sequence = (short)sequence, Dimension = "", ShipToName = document.Customer.Name, //Added on 14/ENE/09 ParentPackage = (parent != null && parent.PackID != 0) ? parent : null, PackageType = packageType }; //Address Line for package 16/oct/09 DocumentAddress ShipTo_address = null; try { ShipTo_address = Factory.DaoDocumentAddress().Select( new DocumentAddress { Document = document, AddressType = AddressType.Shipping }) .Where(f => f.DocumentLine == null).First(); docPack.AddressLine1 = ShipTo_address.AddressLine1 + " " + ShipTo_address.AddressLine2; docPack.AddressLine2 = ShipTo_address.City + ", " + ShipTo_address.State + " " + ShipTo_address.ZipCode; docPack.AddressLine3 = ShipTo_address.Country; } catch { } packLabel.DocumentPackages = new List <DocumentPackage> { docPack }; packLabel = Factory.DaoLabel().Save(packLabel); packLabel.LabelCode = packLabel.LabelID.ToString(); //Registra el movimiento del nodo SaveNodeTrace( new NodeTrace { Node = node, Document = document, Label = packLabel, Quantity = packLabel.CurrQty, IsDebit = false, CreatedBy = picker.UserName } ); //initSequence.NumSequence; //Factory.DaoDocumentTypeSequence().Update(initSequence); Factory.Commit(); //actualizando el documento try { if (string.IsNullOrEmpty(document.UserDef3)) { //document.UserDef3 = picker.UserName; Factory.DaoDocument().Update(document); } } catch { } return(docPack); } catch { throw; } }
private Status GetShippingStatus(int p) { return(WType.GetStatus(new Status { StatusID = DocStatus.New })); }
public IList <Document> GetShippingDocuments(string sWhere, int docType, bool useRemain) { IList <Document> list = new List <Document>(); DocumentClass docClass = new DocumentClass(); Document tmpData = null; string pos = "0"; try { sWhere = ""; Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString); Query = GetErpQuery("SALESORDER"); //Console.WriteLine(Query); DataSet ds = ReturnDataSet(Query, null, "SALESORDER", Command.Connection); pos = "1"; if (ds.Tables.Count == 0) { return(null); } DocumentConcept docConcept = WType.GetDefaultConcept(new DocumentClass { DocClassID = SDocClass.Shipping }); //Definiendo los tipos de documento de shipping DocumentType soType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.SalesOrder }); DocumentType siType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.SalesInvoice }); DocumentType bkType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.BackOrder }); DocumentType returnType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.Return }); //Status docStatus = WType.GetStatus(new Status { StatusID = DocStatus.New }); Account defAccount = WType.GetAccount(new Account { AccountCode = WmsSetupValues.DEFAULT }); SysUser user = WType.GetUser(new SysUser { UserName = WmsSetupValues.AdminUser }); Company company = CurCompany; // WType.GetDefaultCompany(); Status cancelled = WType.GetStatus(new Status { StatusID = DocStatus.Cancelled }); //En el dataset, Tables: 1 - DocumentHeader, 2 - DocumentLine, 3 - DocumentComments foreach (DataRow dr in ds.Tables[0].Rows) { try { //Map Properties tmpData = new Document(); tmpData.Date1 = DateTime.Parse(dr["f430_id_fecha"].ToString()); tmpData.Date2 = DateTime.Parse(dr["f430_fecha_entrega"].ToString()); tmpData.Date3 = DateTime.Parse(dr["f430_fecha_ts_cumplido"].ToString()); tmpData.DocNumber = dr["documento"].ToString(); tmpData.ErpMaster = int.Parse(dr["f430_rowid"].ToString()); tmpData.DocStatus = GetShippingStatus(0); tmpData.Comment = dr["f430_notas"].ToString(); tmpData.SalesPersonName = dr["f200_razon_social"].ToString(); //LAs ordenes con status void en GP, salen como canceladas. try { if (int.Parse(dr["f430_ind_estado"].ToString()) == 9) //9 Anulado. { tmpData.DocStatus = cancelled; } } catch { } tmpData.CreatedBy = dr["f430_usuario_creacion"].ToString(); tmpData.CustPONumber = dr["f430_num_docto_referencia"].ToString(); tmpData.DocConcept = docConcept; tmpData.Vendor = defAccount; tmpData.Customer = WType.GetAccount( new Account { AccountCode = dr["id_cliente"].ToString(), BaseType = new AccountType { AccountTypeID = AccntType.Customer }, Company = company }); try { if (!string.IsNullOrEmpty(dr["id_ruta"].ToString())) { tmpData.ShippingMethod = WType.GetShippingMethod( new ShippingMethod { ErpCode = dr["id_ruta"].ToString(), Company = company }); } } catch { } //tmpData.User = user; tmpData.IsFromErp = true; tmpData.CrossDocking = false; tmpData.Company = CurCompany; tmpData.Reference = dr["f430_referencia"].ToString(); //tmpData.Notes = dr["BACHNUMB"].ToString(); //Asignacion de Address tmpData.DocumentAddresses = GetShippingDocumentAddress(tmpData, null, dr); DocumentAddress billAddress = null; if (!string.IsNullOrEmpty(dr["f430_id_sucursal_fact"].ToString())) { billAddress = GetBillAddress(tmpData, dr["f430_id_sucursal_fact"].ToString(), dr["id_cliente"].ToString(), AccntType.Customer); } if (billAddress != null) { tmpData.DocumentAddresses.Add(billAddress); } tmpData.DocType = soType; tmpData.PickMethod = soType.PickMethod; //Asignacion de Lines - Seguen el tipo de orden tmpData.DocumentLines = GetShippingDocumentLines(tmpData, company, dr["f430_rowid"].ToString(), useRemain); if (tmpData.DocumentLines != null && tmpData.DocumentLines.Count > 0) { if (tmpData.Location == null) { tmpData.Location = tmpData.DocumentLines[0].Location; } list.Add(tmpData); } } catch (Exception ex) { ExceptionMngr.WriteEvent("GetShippingDocuments: " + tmpData.DocNumber, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); } } //retornar la lista return(list); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetShippingDocuments:" + pos + ":", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(null); } }
private IList <DocumentLine> GetShippingDocumentLines(Document doc, Company company, string docID, bool useRemain) { DocumentLine tmpData; IList <DocumentLine> list = new List <DocumentLine>(); Status lineStatus = WType.GetStatus(new Status { StatusID = DocStatus.New }); int curLine = 0; string curMaster = ""; try { Query = GetErpQuery("SALESORDER_LINE").Replace("__DOCUMENT", docID); DataSet ds = ReturnDataSet(Query, null, "SALESORDER_LINE", Command.Connection); if (ds == null || ds.Tables.Count == 0) { return(null); } foreach (DataRow dr in ds.Tables[0].Rows) { tmpData = new DocumentLine(); tmpData.Date1 = doc.Date1; curMaster = ""; try { tmpData.Date2 = DateTime.Parse(dr["f431_fecha_entrega"].ToString()); } catch { } try { tmpData.Date3 = DateTime.Parse(dr["f431_fecha_cumplido"].ToString()); } catch { } tmpData.LineNumber = int.Parse(dr["f431_rowid"].ToString()); tmpData.Sequence = tmpData.LineNumber; curLine = tmpData.LineNumber; //TODO: Revisar el Status en GP para traer el equivalente tmpData.LineStatus = GetShippingStatus(0); tmpData.Document = doc; tmpData.IsDebit = false; if (useRemain) { tmpData.Quantity = double.Parse(dr["f431_cant_facturada_base"].ToString(), new NumberFormatInfo { NumberDecimalSeparator = Separator }); } else { tmpData.Quantity = double.Parse(dr["f431_cant_facturada_base"].ToString(), ListValues.DoubleFormat()); } //tmpData.QtyCancel = double.Parse(dr["QTYCANCE"].ToString(), ListValues.DoubleFormat()); //tmpData.QtyBackOrder = double.Parse(dr["QTYTBAOR"].ToString(), ListValues.DoubleFormat()); //tmpData.QtyPending = tmpData.Quantity - tmpData.QtyCancel - double.Parse(dr["QTYPRINV"].ToString(), ListValues.DoubleFormat()); //tmpData.QtyAllocated = double.Parse(dr["ATYALLOC"].ToString(), ListValues.DoubleFormat()); tmpData.CreatedBy = WmsSetupValues.SystemUser; tmpData.CreationDate = DateTime.Now; curMaster = "Location:" + dr["cod_bodega"].ToString(); tmpData.Location = WType.GetLocation(new Location { Company = company, ErpCode = dr["cod_bodega"].ToString() }); try { curMaster = "Product:" + dr["f121_rowid_item"].ToString(); tmpData.Product = WType.GetProduct(new Product { Company = company, ProductCode = dr["f121_rowid_item"].ToString() }); tmpData.LineDescription = dr["f120_descripcion"].ToString(); curMaster = "Uom:" + dr["f431_id_unidad_medida"].ToString(); tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["f431_id_unidad_medida"].ToString(), ErpCodeGroup = tmpData.Product.BaseUnit.ErpCodeGroup }); } catch { //Pone el Default Product tmpData.Product = WType.GetProduct(new Product { Company = doc.Location.Company, ProductCode = WmsSetupValues.DEFAULT }); tmpData.LineDescription = "Unknown: " + dr["f121_rowid_item"].ToString() + ", " + dr["f120_descripcion"].ToString(); curMaster = "Uom:" + dr["f431_id_unidad_medida"].ToString(); tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["f431_id_unidad_medida"].ToString() }); } //Manage Prices curMaster = "Prices Product:" + dr["f121_rowid_item"].ToString(); tmpData.UnitPrice = double.Parse(dr["f431_precio_unitario_base"].ToString(), ListValues.DoubleFormat()); tmpData.ExtendedPrice = double.Parse(dr["subtotal"].ToString(), ListValues.DoubleFormat()); //Asignacion de Address curMaster = "Address Doc:" + doc.DocNumber; //tmpData.DocumentLineAddresses = GetShippingDocumentAddress(tmpData.Document, tmpData, dr); list.Add(tmpData); } return((list.Count > 0) ? list : null); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetShippingDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return(null); } }
public GraphPoint(int x, int y) { this.wType = default(WType); this.x = x; this.y = y; }
private IList <Document> GetKitAssemblyDocuments(String sWhere) { //retorna la lista de Documentos de Assembly Document tmpData = null; try { Command.Connection = new SqlConnection(CurCompany.ErpConnection.CnnString); // BM00101 - KitAssemblyHeader DataSet ds = ReturnDataSet("SELECT h.*,d.LOCNCODE FROM BM10200 h INNER JOIN BM10300 d ON h.TRX_ID=d.TRX_ID AND d.Parent_Component_ID=-1 WHERE h.BM_Trx_Status=3 AND h.USERDEF1 <> 'WMSEXPRESS'", sWhere, "BM10200", Command.Connection); if (ds == null || ds.Tables.Count == 0) { return(null); } List <Document> list = new List <Document>(); Status status = WType.GetStatus(new Status { StatusID = DocStatus.New }); Account defAccount = WType.GetAccount(new Account { AccountCode = WmsSetupValues.DEFAULT }); SysUser user = WType.GetUser(new SysUser { UserName = WmsSetupValues.AdminUser }); Company company = CurCompany; DocumentConcept docConcept = WType.GetDefaultConcept(new DocumentClass { DocClassID = SDocClass.Inventory }); DocumentType docType = WType.GetDocumentType(new DocumentType { DocTypeID = SDocType.KitAssemblyTask }); foreach (DataRow dr in ds.Tables[0].Rows) { try { //Map Properties tmpData = new Document(); tmpData.Date1 = DateTime.Parse(dr["TRXDATE"].ToString()); //Tran date tmpData.Date2 = DateTime.Parse(dr["BM_Start_Date"].ToString()); //BM_Start_Date tmpData.Date3 = DateTime.Parse(dr["PSTGDATE"].ToString()); //PSTGDATE tmpData.DocNumber = dr["TRX_ID"].ToString(); tmpData.CreatedBy = dr["USER2ENT"].ToString(); try { tmpData.Location = WType.GetLocation(new Location { Company = CurCompany, ErpCode = dr["LOCNCODE"].ToString() }); } catch { } tmpData.DocStatus = status; tmpData.DocConcept = docConcept; tmpData.Vendor = defAccount; tmpData.Customer = defAccount; tmpData.IsFromErp = true; tmpData.CrossDocking = false; tmpData.Company = CurCompany; tmpData.Reference = dr["REFRENCE"].ToString(); tmpData.DocType = docType; tmpData.PickMethod = docType.PickMethod; //Asignacion de Lines - Seguen el tipo de orden tmpData.DocumentLines = GetKitAssemblyDocumentLines(tmpData); if (tmpData.DocumentLines != null && tmpData.DocumentLines.Count > 0) { list.Add(tmpData); } } catch (Exception ex) { ExceptionMngr.WriteEvent("GetKitAssemblyDocuments: " + tmpData.DocNumber, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); } } return(list); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetKitAssemblyDocuments:", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); return(null); } }
/// <summary> /// Recibe producto, con etiqueta (recibo capturado por scanner generalmente) /// </summary> /// <param name="document">Task Document in Process</param> /// <param name="label">Label de transaccion </param> public Label PickLabel(Document document, Label label, Node node, Label packageLabel, SysUser picker, Bin destBin) { Factory.IsTransactional = true; //Node node = WType.GetNode(new Node { NodeID = NodeType.Picked }); try { if (label.LabelID == 0) { try { label = Factory.DaoLabel().Select(label).First(); } catch { throw new Exception("Label " + label.LabelCode + " does not exists."); } } //Check if already picked if (label.Node.NodeID == NodeType.Picked || label.Node.NodeID == NodeType.Released) { throw new Exception("Label " + label.LabelCode + " already picked."); } if (destBin == null) { destBin = Rules.GetBinForNode(node, label.Bin.Location); } Status locked = WType.GetStatus(new Status { StatusID = EntityStatus.Locked }); //Valida si el docuemnto no es nulo Rules.ValidateDocument(document, true); //Valida si el label es un label de producto, //TODO: alarma cuand o suceda el evento de que no es un label de producto Rules.ValidateIsProductLabel(label, true); Rules.ValidateBinStatus(label.Bin, true); //Valida si el status es Activo Rules.ValidateActiveStatus(label.Status, true); //Valida si el label esta en el nodo que debe estar (Ruta de Nodos) //TODO: alarma cuand o suceda el evento de que no es un label de producto Rules.ValidateNodeRoute(label, node, true); //revisa si el label tiene zero Qty Rules.ValidateLabelQuantity(label, true); //Validar si las locations son iguales Rules.ValidatePickLocation(document.Location, label.Bin.Location, true); //label.ChildLabels = Factory.DaoLabel().Select( // new Label { FatherLabel = label, Status = new Status { StatusID = EntityStatus.Active } }); if (document.IsFromErp == true) { //Valida si el producto esta en ese documento //Se debe ejecutar proceso para saber si la company permite //recibir producto no existente en el docuemnto DocumentLine docLine = new DocumentLine { Document = document, Product = label.Product, LineStatus = new Status { StatusID = DocStatus.New }, Unit = label.Unit, Quantity = label.StockQty, //label.CurrQty, CreatedBy = document.ModifiedBy }; Rules.ValidateProductInDocument(docLine, true); //Valida si hay saldo pendiente por recibir //Calcula el Current Qty y Valida si esa cantidad aun esta pendiente en el documento //Double quantity = (label.IsLogistic == true) ? Factory.DaoLabel().SelectCurrentQty(label, null, true) : label.CurrQty; Rules.ValidateBalanceQuantityInDocument(docLine, node, true, false); } if (packageLabel != null) { try { packageLabel = GetPackageLabel(packageLabel, document, picker).PackLabel; } catch (Exception ex) { Factory.Rollback(); throw new Exception("Package label could not be created.\n" + ex.Message); } } //Actualiza Label with new data label.Node = node; label.LastBin = label.Bin; label.Bin = destBin; label.ModifiedBy = picker.UserName; label.ModDate = DateTime.Now; label.ShippingDocument = document; label.Printed = true; label.Status = locked; //Registra el movimiento del label en el nodo SaveNodeTrace(new NodeTrace { Node = node, Document = document, Label = label, Quantity = label.CurrQty, IsDebit = false }); label.LabelSource = label.FatherLabel; label.FatherLabel = packageLabel; Factory.DaoLabel().Update(label); //Actualiza Los Hijos (si existen) try { label.ChildLabels = Factory.DaoLabel().Select(new Label { FatherLabel = label }); if (label.ChildLabels != null && label.ChildLabels.Count > 0) { foreach (Label curLabel in label.ChildLabels) { curLabel.Node = node; curLabel.LastBin = label.LastBin; curLabel.Bin = label.Bin; curLabel.ModifiedBy = picker.UserName; curLabel.ModDate = DateTime.Now; curLabel.ShippingDocument = document; curLabel.Status = locked; SaveNodeTrace(new NodeTrace { Node = node, Document = document, Label = curLabel, Quantity = curLabel.CurrQty, IsDebit = false, CreatedBy = document.CreatedBy }); Factory.DaoLabel().Update(curLabel); } } } catch { } Factory.Commit(); return(label); } catch (Exception ex) { Factory.Rollback(); ExceptionMngr.WriteEvent("PickLabel:", ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.Business); throw new Exception(WriteLog.GetTechMessage(ex)); } }
private IList <DocumentLine> GetKitAssemblyDocumentLines(Document doc) { DocumentLine tmpData; IList <DocumentLine> list = new List <DocumentLine>(); Status lineStatus = WType.GetStatus(new Status { StatusID = DocStatus.New }); int curLine = 1; string curMaster = ""; // BM10300 - KitAssembly Document Lines DataSet ds = ReturnDataSet("SELECT * FROM BM10300 WHERE 1=1 ", "TRX_ID='" + doc.DocNumber + "'", "BM10300", Command.Connection); if (ds == null || ds.Tables.Count == 0) { return(null); } try { foreach (DataRow dr in ds.Tables[0].Rows) { tmpData = new DocumentLine(); tmpData.Date1 = doc.Date1; tmpData.LineNumber = int.Parse(dr["Component_ID"].ToString()); //curLine++; tmpData.Sequence = tmpData.LineNumber; tmpData.LinkDocLineNumber = int.Parse(dr["Parent_Component_ID"].ToString()); tmpData.Note = dr["BM_Component_Type"].ToString(); //TODO: Revisar el Status en GP para traer el equivalente tmpData.LineStatus = lineStatus; tmpData.Document = doc; tmpData.IsDebit = false; tmpData.Quantity = double.Parse(dr["Extended_Standard_Quantity"].ToString(), ListValues.DoubleFormat()); tmpData.CreatedBy = WmsSetupValues.SystemUser; tmpData.CreationDate = DateTime.Now; curMaster = "Location"; tmpData.Location = WType.GetLocation(new Location { Company = CurCompany, ErpCode = dr["LOCNCODE"].ToString() }); try { curMaster = "Product"; tmpData.Product = WType.GetProduct(new Product { Company = CurCompany, ProductCode = dr["ITEMNMBR"].ToString() });; curMaster = "Unit"; tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["UOFM"].ToString(), ErpCodeGroup = tmpData.Product.BaseUnit.ErpCodeGroup }); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetKitAssemblyDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); continue; //{ // //Pone el Default Product // tmpData.Product = WType.GetProduct(new Product { Company = CurCompany, ProductCode = WmsSetupValues.DEFAULT }); // tmpData.LineDescription = "Unknown: " + dr["ITEMNMBR"].ToString() + ", " + dr["ITEMDESC"].ToString(); // curMaster = "Unit"; // tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["UOFM"].ToString() }); } list.Add(tmpData); } return((list.Count > 0) ? list : null); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetKitAssemblyDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); throw; //return null; } }