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; }
public IList<DocumentLine> Select(DocumentLine data) { IList<DocumentLine> datos = new List<DocumentLine>(); try { datos = GetHsql(data).List<DocumentLine>(); if (!Factory.IsTransactional) Factory.Commit(); } catch (Exception e) { NHibernateHelper.WriteEventLog(WriteLog.GetTechMessage(e)); } return datos; }
public Boolean ValidateProductInDocument(DocumentLine data, Boolean autoThrow) { //Valida si el producto esta en ese documento DocumentLine tmpLine = new DocumentLine { Document = new Document { DocID = data.Document.DocID }, //data.Document, Product = new Product { ProductID = data.Product.ProductID }, LineStatus = data.LineStatus }; if (Factory.DaoDocumentLine().Select(tmpLine).Count == 0) { if (autoThrow) { Factory.Rollback(); throw new Exception("Product " + tmpLine.Product.Name + " does not exists in document " + tmpLine.Document.DocNumber + "."); } else return false; } return true; }
public DocumentLine Save(DocumentLine data) { return (DocumentLine)base.Save(data); }
/// <summary> /// Cra nuevos labels en el sistema para determinados productos, al imprimir o al recibir pro app o device. /// </summary> /// <param name="logisticUnit"></param> /// <param name="data">Document Line con los datos de los labels a crear</param> /// <param name="node"></param> /// <param name="destLocation"></param> /// <param name="logisticFactor"></param> /// <param name="printingLot"></param> /// <returns></returns> public IList<Label> CreateProductLabels(Unit logisticUnit, DocumentLine data, Node node, Bin destLocation, double logisticFactor, string printingLot, string comment, DateTime receivingDate) { //Label Type DocumentType labelType = Factory.DaoDocumentType().Select(new DocumentType { DocTypeID = LabelType.ProductLabel }).First(); //Status Status status = Factory.DaoStatus().Select(new Status { StatusID = EntityStatus.Active }).First(); bool isTransactional = Factory.IsTransactional; if (!isTransactional) Factory.IsTransactional = true; //Funcion para obtener siguiente Label //DocumentTypeSequence initSequence = GetNextDocSequence(data.Document.Company, labelType); //long numSeqLabel = initSequence.NumSequence - 1; IList<Label> labelResult = new List<Label>(); Label fatherLabel = null; string notes = (data.Document != null && data.Document.DocID > 0) ? "Doc# " + data.Document.DocNumber : ""; notes = notes + " " + data.Unit.Name; //double labelBalance = data.Quantity; int numLabels =(int)(data.Quantity/logisticFactor); if (numLabels <= 0) throw new Exception("No valid amount of labels to print."); for (int i = 0; i < numLabels; i++) { fatherLabel = new Label(); fatherLabel.Node = node; fatherLabel.Bin = destLocation; fatherLabel.Product = data.Product; fatherLabel.CreatedBy = data.CreatedBy; fatherLabel.Status = status; fatherLabel.LabelType = labelType; fatherLabel.CreationDate = DateTime.Now; fatherLabel.Printed = false; //string.IsNullOrEmpty(printingLot) ? false : true; if (data.Product.IsUniqueTrack) { fatherLabel.Unit = data.Product.BaseUnit; //La unidad que tiene ese Label //logisticUnit; fatherLabel.StartQty = logisticFactor * data.Unit.BaseAmount; //*data.Unit.BaseAmount; fatherLabel.CurrQty = logisticFactor * data.Unit.BaseAmount; //*data.Unit.BaseAmount; } else { fatherLabel.Unit = data.Unit; //La unidad que tiene ese Label //logisticUnit; fatherLabel.StartQty = logisticFactor; //*data.Unit.BaseAmount; fatherLabel.CurrQty = logisticFactor; //*data.Unit.BaseAmount; } //fatherLabel.UnitBaseFactor = logisticUnit.BaseAmount; //Siempres es 1 fatherLabel.IsLogistic = false; fatherLabel.FatherLabel = null; fatherLabel.LabelCode = ""; // (numSeqLabel + i).ToString() + GetRandomHex(data.CreatedBy, numSeqLabel + i); // (initSequence.NumSequence + i).ToString(); fatherLabel.Notes = notes; fatherLabel.PrintingLot = printingLot; //data.Note; fatherLabel.ReceivingDate = receivingDate == null ? DateTime.Now : receivingDate; fatherLabel.ReceivingDocument = data.Document.DocID > 0 ? data.Document : null; fatherLabel = Factory.DaoLabel().Save(fatherLabel); fatherLabel.LabelCode = fatherLabel.LabelID.ToString(); //Added for indentityUSE labelResult.Add(fatherLabel); //Registra el movimiento del nodo SaveNodeTrace( new NodeTrace { Node = node, Document = data.Document.DocID > 0 ? data.Document : null, Label = fatherLabel, Quantity = fatherLabel.CurrQty, IsDebit = false, CreatedBy = data.CreatedBy, Comment = comment } ); } //Ajustando la sequencia //initSequence.NumSequence += numLabels; //Factory.DaoDocumentTypeSequence().Update(initSequence); if (!isTransactional) Factory.Commit(); return labelResult; }
public DocumentLine ChangeProductUbication(Label labelSource, DocumentLine changeLine, Label labelDest, string appPath) { return TranMngr.ChangeProductUbication(labelSource, changeLine, labelDest, appPath); }
public DocumentLine SaveAdjustmentTransaction(DocumentLine data, Label label, bool commitTransaction) { return TranMngr.SaveAdjustmentTransaction(data, label, commitTransaction); }
public DocumentLine SaveUpdateDocumentLine(DocumentLine docLine, bool removeLine) { return DocMngr.SaveUpdateDocumentLine(docLine, removeLine); }
public IList<DocumentLine> GetDocumentLine(DocumentLine data) { return Factory.DaoDocumentLine().Select(data); }
public Boolean PickProduct(DocumentLine line, Label sourceLocation, Node node, Label packageLabel, SysUser picker, Bin binDest) { TranMngr.PickProduct(line, sourceLocation, node, packageLabel, picker, binDest); return true; }
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; }
private IList<ReportDetailFormat> EvaluateLine(DocumentLine dLine, Document document, IList<DocumentBalance> docBalance, short binDirection, short level) { IList<ReportDetailFormat> returnList = new List<ReportDetailFormat>(); ReportDetailFormat detail = new ReportDetailFormat(); if (level > 2) return null; if (GetCompanyOption(document.Company, "SHOWBO").Equals("F") && dLine.Quantity - dLine.QtyBackOrder - dLine.QtyCancel <= 0) return returnList; //El qty pending debe salir del balance. que se obtuvo arriba. if (docBalance != null && docBalance.Count > 0) { try { detail.QtyPending = docBalance.Where(f => f.DocumentLine.LineNumber == dLine.LineNumber).First().QtyPending; } catch { detail.QtyPending = detail.QtyOrder; } } if (document.DocType.DocClass.DocClassID == SDocClass.Shipping && GetCompanyOption(document.Company, "SHOWBO").Equals("F") && detail.QtyPending <= 0) return returnList; //Map Data detail.ProductCode = dLine.Product.ProductCode; if (string.IsNullOrEmpty(dLine.LineDescription)) detail.ProductDescription = dLine.Product.Name; else detail.ProductDescription = dLine.LineDescription; detail.AlternProduct = ""; try { if (dLine.Product.AlternProducts != null && dLine.Product.AlternProducts[0] != null) detail.AlternProduct = dLine.Product.AlternProducts[0].AlternProduct.ProductCode; } catch { } detail.Unit = dLine.Unit.Name; detail.Notes = dLine.Note; detail.AuxSequence = dLine.Sequence; detail.CreatedBy = dLine.CreatedBy; //CUSTOM detail.Custom1 = dLine.Product.Manufacturer; detail.Custom2 = dLine.Product.Reference; //Definir si es un subdetail //detail.IsSubDetail = (dLine.LinkDocLineNumber > 0) ? true : false; detail.IsSubDetail = (dLine.Note == "1") ? true : false; if (detail.IsSubDetail == true) detail.CustNumber1 = dLine.LinkDocLineNumber; else detail.CustNumber1 = dLine.LineNumber; IList<ProductAccountRelation> acctItem = null; try { detail.AssignedBins = GetAssignedBins(dLine.Product, dLine.Location, binDirection); } catch { } if (document.DocType.UseStock == true) { try { object[] objBins; if (document.DocType.DocClass.DocClassID == SDocClass.Shipping) objBins = GetSuggestedBins(dLine.Product, dLine.Location, document.PickMethod, BinType.Out_Only); //binDirection else if (document.DocType.DocTypeID == SDocType.ReplenishPackTask) { objBins = GetSuggestedBins(dLine.Product, dLine.Location, document.PickMethod, BinType.Out_Only); //binDirection string[] xBins = objBins[0].ToString().Split("\n".ToCharArray()); string binResult = ""; for (int i = 0; i < xBins.Length; i++) if (!xBins[i].Contains(dLine.Note.Trim())) binResult += xBins[i] + "\n"; objBins[0] = binResult; //objBins[2] = objBins[2].ToString().Replace(dLine.Note, "").ToString(); } else objBins = GetSuggestedBins(dLine.Product, dLine.Location, document.PickMethod, BinType.In_Out); detail.OutBin = objBins[2].ToString(); detail.Rank = objBins[1] != null ? (Int32)objBins[1] : WmsSetupValues.MaxBinRank; //Rank del OutBin detail.SuggestedBins = objBins[0].ToString(); detail.OldestBin = objBins[3].ToString(); } catch { } } //detail.QtyPending = dLine.QtyPending; detail.StockBin = dLine.Location.Name; detail.Weight = dLine.Product.Weight * dLine.Quantity; detail.Pieces = dLine.Product.UnitsPerPack > 0 ? dLine.Product.UnitsPerPack : 1; //detail.Cases = dLine.Quantity; //Si es un assembly order solo muestra cantidad para las lineas con Notes = "2" //que significan que son items a piquear., del resto no. //if (document.DocType.DocTypeID == SDocType.KitAssemblyTask) //detail.QtyOrder = (dLine.Note != null && dLine.Note == "1") ? dLine.Quantity : 0; //else detail.QtyOrder = dLine.Quantity - dLine.QtyCancel; detail.QtyBO = dLine.QtyBackOrder; //Customer Item Number if (document.Customer.AccountCode != WmsSetupValues.DEFAULT) { acctItem = dLine.Product.ProductAccounts.Where(f => f.Account.AccountID == document.Customer.AccountID).ToList(); if (acctItem != null && acctItem.Count() > 0) detail.AccountItemNumber = acctItem[0].ItemNumber; } //Vendor Item Number if (document.Vendor.AccountCode != WmsSetupValues.DEFAULT) { acctItem = dLine.Product.ProductAccounts.Where(f => f.Account.AccountID == document.Vendor.AccountID).ToList(); if (acctItem != null && acctItem.Count() > 0) detail.AccountItemNumber = acctItem[0].ItemNumber; } if (detail.AccountItemNumber == null) detail.AccountItemNumber = ""; //Aasignacion del Detalle Principal. returnList.Add(detail); ///--- FORMULACION A NIVEL DE DOCUMENTO ////Evalua si el producto tiene formula para meter los subitems y ademas si se pinden mostrar los subitems //if (dLine.Product.ProductFormula != null && dLine.Product.ProductFormula.Count > 0 // && GetCompanyOption(document.Company, "SHOWCOMP").Equals("T") && level == 1 // && document.DocType.DocClass.DocClassID == SDocClass.Shipping ) //{ // IList<ReportDetailFormat> subDetails = null; // DocumentLine subLine; // foreach (KitAssemblyFormula formula in dLine.Product.ProductFormula) // { // subLine = new DocumentLine { // Product = formula.Component, // Unit = formula.Unit, Note = "", // Location = dLine.Location, // Quantity = formula.FormulaQty * dLine.Quantity, // QtyPending = formula.FormulaQty * detail.QtyPending // }; // subDetails = EvaluateLine(subLine, document, null, binDirection, 2); // foreach (ReportDetailFormat sub in subDetails) // { // sub.IsSubDetail = true; // returnList.Add(sub); // } // } //} return returnList; }
public DocumentLine SelectById(DocumentLine data) { return (DocumentLine)base.SelectById(data); }
public Boolean Delete(DocumentLine data) { return base.Delete(data); }
public Boolean Update(DocumentLine data) { return base.Update(data); }
public void UpdateDocumentLine(DocumentLine data) { Factory.DaoDocumentLine().Update(data); }
public void DeleteDocumentLine(DocumentLine data) { Factory.DaoDocumentLine().Delete(data); }
public IList<Label> DecreaseQtyFromBin(Label fromLabel, DocumentLine line, string comment, bool saveTrace, Node node) { return TranMngr.DecreaseQtyFromBin(fromLabel, line, comment, saveTrace, node); }
public IList<Unit> GetDocumentUnit(DocumentLine data) { return DocMngr.GetDocumentUnit(data); }
public void DecreaseQtyFromLabel(Label fromLabel, DocumentLine line, string comment, bool saveTrace, Node node, bool passToPrint) { TranMngr.DecreaseQtyFromLabel(fromLabel, line, comment, saveTrace, node, passToPrint); }
public IList<Label> CreateProductLabels(Unit logisticUnit, DocumentLine data, Node node, Bin destLocation, double logisticFactor, string printingLot, DateTime receivingDate ) { return BasicMngr.CreateProductLabels(logisticUnit, data, node, destLocation, logisticFactor, printingLot, "", receivingDate); }
public Label IncreaseQtyIntoBin(DocumentLine line, Node node, Bin destBin, string comment, bool saveTrace, DateTime recDate, IList<LabelTrackOption> trackOptions, Label sourceLabel) { return TranMngr.IncreaseQtyIntoBin(line, node, destBin, comment, saveTrace, recDate, trackOptions, sourceLabel); }
public Boolean CheckAdjustmentLine(DocumentLine data, Label label) { return TranMngr.CheckAdjustmentLine(data, label); }
public void IncreaseQtyIntoLabel(Label ubicationLabel, DocumentLine data, string comment, bool saveTrace, Node node) { TranMngr.IncreaseQtyIntoLabel(ubicationLabel, data, comment, saveTrace, node); }
public Boolean ReceiveProduct(DocumentLine receivingLine, Unit logisticUnit, Bin destLocation, Node recNode) { TranMngr.ReceiveProduct(receivingLine, logisticUnit, destLocation, recNode); return true; }
public Boolean ReceiveProductAsUnique(DocumentLine line, Bin bin, Node node) { return TranMngr.ReceiveProductAsUnique(line, bin, node); }
//Dec 04 2009 para recibir seriales de una vez en proceos One By One public IList<Label> CreateProductUniqueTrackLabels(DocumentLine data, Node node, Bin destLocation, string printingLot, string comment, DateTime receivingDate) { //Label Type DocumentType labelType = Factory.DaoDocumentType().Select(new DocumentType { DocTypeID = LabelType.UniqueTrackLabel }).First(); //Status Status status = Factory.DaoStatus().Select(new Status { StatusID = EntityStatus.Active }).First(); IList<Label> labelResult = new List<Label>(); string notes = (data.Document != null && data.Document.DocID > 0) ? "Doc# " + data.Document.DocNumber : ""; notes = notes + " " + data.Unit.Name; //double labelBalance = data.Quantity; int numLabels = (int)data.Quantity; if (numLabels <= 0) throw new Exception("No valid amount of labels to print."); Label fatherLabel = null; for (int i = 0; i < numLabels; i++) { fatherLabel = new Label(); fatherLabel.Node = node; fatherLabel.Bin = destLocation; fatherLabel.Product = data.Product; fatherLabel.CreatedBy = data.CreatedBy; fatherLabel.Status = status; fatherLabel.LabelType = labelType; fatherLabel.CreationDate = DateTime.Now; fatherLabel.Printed = true; fatherLabel.Unit = data.Unit; //La unidad que tiene ese Label //logisticUnit; L fatherLabel.IsLogistic = false; fatherLabel.FatherLabel = null; fatherLabel.LabelCode = Guid.NewGuid().ToString(); fatherLabel.CurrQty = 1; //*data.Unit.BaseAmount; fatherLabel.StartQty = 1; //*data.Unit.BaseAmount; fatherLabel.Notes = notes; fatherLabel.PrintingLot = printingLot; //data.Note; fatherLabel.ReceivingDate = receivingDate == null ? DateTime.Now : receivingDate; fatherLabel.ReceivingDocument = data.Document.DocID > 0 ? data.Document : null; //Guarda y Actualiza para poder obtener su serial fatherLabel = Factory.DaoLabel().Save(fatherLabel); fatherLabel.LabelCode = '1' + fatherLabel.LabelID.ToString().PadLeft(WmsSetupValues.LabelLength-1, '0'); Factory.DaoLabel().Update(fatherLabel); labelResult.Add(fatherLabel); //Registra el movimiento del nodo SaveNodeTrace( new NodeTrace { Node = node, Document = data.Document.DocID > 0 ? data.Document : null, Label = fatherLabel, Quantity = fatherLabel.CurrQty, IsDebit = false, CreatedBy = data.CreatedBy, Comment = comment } ); } return labelResult; }
public void CancelMergerOrder(Document document, DocumentLine docLine) { DocMngr.CancelMergerOrder(document, docLine); }
//public IList<DocumentHistory> GetDocumentHistory(DocumentHistory data) { return Factory.DaoDocumentHistory().Select(data); } //public DocumentHistory SaveDocumentHistory(DocumentHistory data) { return Factory.DaoDocumentHistory().Save(data); } //public void UpdateDocumentHistory(DocumentHistory data) { Factory.DaoDocumentHistory().Update(data); } //public void DeleteDocumentHistory(DocumentHistory data) { Factory.DaoDocumentHistory().Delete(data); } public DocumentLine SaveDocumentLine(DocumentLine data) { //Averigua primero el siguiente document Line de se documento. if (data.LineNumber == 0) data.LineNumber = Factory.DaoDocument().GetNexDocLineNumber(data.Document); return Factory.DaoDocumentLine().Save(data); }
private IList<DocumentLine> GetReceivingDocumentLines(Document doc, Company company, string docID) { 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("PURCHASEORDER_LINE").Replace("__DOCUMENT", docID); DataSet ds = ReturnDataSet(Query, null, "PURCHASEORDER_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["f421_fecha_entrega"].ToString()); } catch { } //tmpData.Date3 = DateTime.Parse(dr["PRMSHPDTE"].ToString()); //tmpData.Date4 = DateTime.Parse(dr["PRMDATE"].ToString()); tmpData.LineNumber = int.Parse(dr["f421_rowid"].ToString()); tmpData.AccountItem = dr["f421_cod_item_prov"].ToString(); tmpData.Sequence = tmpData.LineNumber; curLine = tmpData.LineNumber; tmpData.Document = doc; tmpData.IsDebit = false; tmpData.Quantity = double.Parse(dr["f421_cant_pedida"].ToString(), new NumberFormatInfo { NumberDecimalSeparator = Separator }); tmpData.UnitBaseFactor = double.Parse(dr["fact_adicional"].ToString(), new NumberFormatInfo { NumberDecimalSeparator = Separator }); tmpData.CreatedBy = WmsSetupValues.SystemUser; tmpData.CreationDate = DateTime.Now; curMaster = "Status:" + dr["f421_ind_estado"].ToString(); tmpData.LineStatus = GetReceivingStatus(int.Parse(dr["f421_ind_estado"].ToString())); //doc.DocStatus; 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["f421_id_unidad_medida"].ToString(); tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["f421_id_unidad_medida"].ToString(), ErpCodeGroup = tmpData.Product.BaseUnit.ErpCodeGroup }); } catch (Exception ex) { ExceptionMngr.WriteEvent("GetReceiptDocumentLines: " + 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 = company, ProductCode = WmsSetupValues.DEFAULT }); // tmpData.LineDescription = "Unknown: " + dr["ITEMNMBR"].ToString() + ", " + dr["ITEMDESC"].ToString(); // curMaster = "Uom:" + dr["UOFM"].ToString(); // tmpData.Unit = WType.GetUnit(new Unit { ErpCode = dr["UOFM"].ToString() }); } //Unit - Price, Cost tmpData.UnitPrice = double.Parse(dr["f421_precio_unitario"].ToString(), new NumberFormatInfo { NumberDecimalSeparator = Separator }); tmpData.ExtendedPrice = double.Parse(dr["subtotal"].ToString(), new NumberFormatInfo { NumberDecimalSeparator = Separator }); //SOP POP Link //object[] sop_popLink = GetSOP_POPLink(doc.DocNumber, tmpData.LineNumber, doc.DocType.DocTypeID); //if (sop_popLink != null) //{ // tmpData.LinkDocNumber = sop_popLink[0].ToString(); // tmpData.LinkDocLineNumber = int.Parse(sop_popLink[1].ToString()); //} list.Add(tmpData); } return (list.Count > 0) ? list : null; } catch (Exception ex) { ExceptionMngr.WriteEvent("GetReceiptDocumentLines: " + doc.DocNumber + "," + curLine.ToString() + "," + curMaster, ListValues.EventType.Error, ex, null, ListValues.ErrorCategory.ErpConnection); //throw; return null; } }