public Boolean GetErpShippingDocumentsSince(Company company, DateTime sinceDate) { if (company == null) { ExceptionMngr.WriteEvent("GetErpShippingDocumentsSince Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); bool useRemain = GetCompanyOption(company, "USEREMQTY").Equals("T"); ProcessDocuments(ErpFactory.Documents().GetShippingDocumentsSince(sinceDate, 2, useRemain), company); ProcessDocuments(ErpFactory.Documents().GetShippingDocumentsSince(sinceDate, 4, false), company); //Get BackOrders if (GetCompanyOption(company, "GETBO").Equals("T")) { Console.WriteLine("Processing BackOrders"); ProcessDocuments(ErpFactory.Documents().GetShippingDocumentsSince(sinceDate, 5, false), company); } return(true); }
//SHIPPING METHGODS public Boolean GetErpAllShippingMethods(Company company) { if (company == null) { ExceptionMngr.WriteEvent("GetErpAllShippingMethods Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); ProcessShippingMethods(ErpFactory.References().GetAllShippingMethods()); return(true); }
public Boolean GetErpProductById(Company company, string code) { if (company == null) { ExceptionMngr.WriteEvent("GetErpProductById Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); ProcessProducts(ErpFactory.References().GetProductById(code)); return(true); }
public Boolean GetErpReceivingDocumentsLastXDays(Company company, int days) { if (company == null) { ExceptionMngr.WriteEvent("GetErpReceivingDocumentsLastXDays Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); ProcessDocuments(ErpFactory.Documents().GetReceivingDocumentsLastXDays(days), company); return(true); }
public Boolean GetErpLocationsSince(Company company, DateTime sinceDate) { if (company == null) { ExceptionMngr.WriteEvent("GetErpLocationsSince Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); ProcessLocations(ErpFactory.References().GetLocationsSince(sinceDate)); return(true); }
public Boolean GetErpKitAssemblyDocumentsSince(Company company, DateTime sinceDate) { if (company == null) { ExceptionMngr.WriteEvent("GetErpAllKitAssemblyDocumentsSince Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); ProcessDocuments(ErpFactory.Documents().GetKitAssemblyDocumentsSince(sinceDate), company); return(true); }
public void GetErpLocationTransferDocumentsSince(Company company, DateTime sinceDate) { if (company == null) { ExceptionMngr.WriteEvent("GetErpLocationTransferDocumentsSince Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return; } SetConnectMngr(company); ProcessDocuments(ErpFactory.Documents().GetLocationTransferDocumentsSince(sinceDate), company); return; }
public void GetErpAllLocationTransferDocuments(Company company) { if (company == null) { ExceptionMngr.WriteEvent("GetErpAllLocationTransferDocuments Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return; } SetConnectMngr(company); //ProcessDocuments(ErpFactory.Documents().GetAllReceivingDocuments()); //return true; ProcessDocuments(ErpFactory.Documents().GetLocationTransferDocumentsSince(DateTime.Today.AddDays(-1 * this.historicDays)), company); return; }
public Boolean GetErpShippingDocumentById(Company company, string code) { if (company == null) { ExceptionMngr.WriteEvent("GetErpShippingDocumentById Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); bool useRemain = GetCompanyOption(company, "USEREMQTY").Equals("T"); ProcessDocuments(ErpFactory.Documents().GetShippingDocumentById(code, 2, useRemain), company); return(true); }
public void TestConnection(Company company) { if (ErpFactory == null) { SetConnectMngr(company); } try { ErpFactory.References().TestConnection(company); } catch (Exception ex) { throw new Exception(WriteLog.GetTechMessage(ex)); } }
// ACCOUNTS public Boolean GetErpAllAccounts(Company company) { if (company == null) { ExceptionMngr.WriteEvent("GetErpAllAccounts Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); //Customers ProcessErpAccounts(ErpFactory.References().GetAllCustomers()); //Vendors ProcessErpAccounts(ErpFactory.References().GetAllVendors()); return(true); }
public Boolean GetErpReceivingDocumentsSince(Company company, DateTime sinceDate) { if (company == null) { ExceptionMngr.WriteEvent("GetErpReceivingDocumentsSince Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); ProcessDocuments(ErpFactory.Documents().GetReceivingDocumentsSince(sinceDate), company); Console.WriteLine("GetPurchaseReturns"); try { ProcessDocuments(ErpFactory.Documents().GetPurchaseReturnsSince(sinceDate), company); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(true); }
internal void UpdateSalesDocumentBatch(Company company, string docNumber, string batchNo) { { //Revisa si se debe enviar el recibo al ERP, es decir si esta en true la opcion de conexion a ERP bool ErpConnected = GetCompanyOption(company, "WITHERPSH").Equals("T"); //Valida que la conexion al ERP exista if (ErpConnected) { if (company.ErpConnection == null) { throw new Exception("Please setup Erp Connection."); } SetConnectMngr(company); ErpFactory.Documents().UpdateSalesDocumentBatch(docNumber, batchNo); } } }
public Boolean GetErpAllReceivingDocuments(Company company) { if (company == null) { ExceptionMngr.WriteEvent("GetErpAllReceivingDocuments Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); Console.WriteLine("Running RecDoc"); //ProcessDocuments(ErpFactory.Documents().GetAllReceivingDocuments()); //return true; ProcessDocuments(ErpFactory.Documents().GetReceivingDocumentsSince(DateTime.Today.AddDays(-1 * this.historicDays)), company); ProcessDocuments(ErpFactory.Documents().GetPurchaseReturnsSince(DateTime.Today.AddDays(-1 * this.historicDays)), company); return(true); }
internal int SaveUpdateErpDocumentLine(DocumentLine docLine, bool removeLine) { //Si el sistema esta conectado a un ERP Crea actualiza la linea en el ERP bool ErpConnected = GetCompanyOption(docLine.Document.Company, "WITHERP").Equals("T"); //Valida que la conexion al ERP exista if (ErpConnected) { if (docLine.Document.Company.ErpConnection == null) { throw new Exception("Please setup Erp Connection."); } SetConnectMngr(docLine.Document.Company); } if (ErpConnected) { return(ErpFactory.Documents().SaveUpdateErpDocumentLine(docLine, removeLine)); } return(0); }
public Boolean GetErpAllShippingDocuments(Company company) { if (company == null) { ExceptionMngr.WriteEvent("GetErpAllShippingDocuments Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); bool useRemain = GetCompanyOption(company, "USEREMQTY").Equals("T"); //ProcessDocuments(ErpFactory.Documents().GetAllShippingDocuments()); ProcessDocuments(ErpFactory.Documents().GetShippingDocumentsSince( DateTime.Today.AddDays(-1 * this.historicDays), 2, useRemain), company); //Si quiere mas documentos manda los otros tipos de documento 2,3,5 //ProcessDocuments(ErpFactory.Documents().GetShippingDocumentsSince( //DateTime.Today.AddDays(-1 * WmsSetupValues.HistoricDays), 6)); //Back Orders if (GetCompanyOption(company, "GETBO").Equals("T")) { ProcessDocuments(ErpFactory.Documents().GetShippingDocumentsSince( DateTime.Today.AddDays(-1 * WmsSetupValues.HistoricDays), 5, false), company); } //RETURNS ProcessDocuments(ErpFactory.Documents().GetShippingDocumentsSince( DateTime.Today.AddDays(-1 * this.historicDays), 4, false), company); return(true); }
public IList <ProductStock> GetStockComparation(ProductStock data, Company company) { if (company == null) { ExceptionMngr.WriteEvent("GetStockComparation Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(null); } SetConnectMngr(company); bool detailed = false; //Obtiene el Stock del ERP para lo mismo loaction - bin IList <ProductStock> erpStock = ErpFactory.Documents().GetErpStock(data, detailed); if (erpStock == null || erpStock.Count == 0) { throw new Exception("No ERP Stock to compare."); } IList <ProductStock> wmsAvailStock = Factory.DaoLabel().GetNodeStock(data, new Node { NodeID = NodeType.Stored }, new Status { StatusID = EntityStatus.Active }); IList <ProductStock> wmsPickedStock = Factory.DaoLabel().GetNodeStock(data, new Node { NodeID = NodeType.Picked }, new Status { StatusID = EntityStatus.Locked }); if (wmsAvailStock == null || wmsAvailStock.Count == 0) { throw new Exception("No WMS Stock to compare."); } //Adicionando el Picking wmsAvailStock = (from avail in wmsAvailStock join pick in wmsPickedStock on avail.Product.ProductID equals pick.Product.ProductID into gj from sub in gj.DefaultIfEmpty() select new ProductStock { Product = avail.Product, Stock = avail.Stock, PackStock = (sub == null) ? 0 : sub.Stock, Bin = new Bin { Location = data.Bin.Location }, }).ToList(); //Comparando Contra el ERP entragando un solo resultado wmsAvailStock = (from erp in erpStock join avail in wmsAvailStock on erp.Product.ProductID equals avail.Product.ProductID into gj from sub in gj.DefaultIfEmpty() select new ProductStock { Product = erp.Product, Stock = erp.Stock, //ERP On Hand PackStock = (sub == null) ? 0 : sub.Stock, //WMS Available MaxStock = (sub == null) ? 0 : sub.PackStock, //WMS Picking AuxQty1 = (sub == null) ? 0 : sub.Stock + sub.PackStock, MinStock = (sub == null) ? -1 * erp.Stock : sub.Stock + sub.PackStock - erp.Stock, //Diference Bin = new Bin { Location = data.Bin.Location }, }).Where(f => f.MinStock != 0).ToList(); return(wmsAvailStock); }
// PRODUCTS public Boolean GetErpAllProducts(Company company) { if (company == null) { ExceptionMngr.WriteEvent("GetErpAllProducts Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return(false); } SetConnectMngr(company); //Llama primero a las categorias GetErpAllCategories(company); /* * IList<ProductCategory> catList = Factory.DaoProductCategory().Select(new ProductCategory()); * * * foreach (ProductCategory cat in catList) * { * Console.WriteLine(cat.ErpCode.Replace("'", "''")); * ProcessProducts(ErpFactory.References().GetProductsByQuery("LTRIM(RTRIM(ITMCLSCD))='"+ cat.ErpCode.Replace("'","''") +"'")); * } * * * //Los que no tienen categoria * ProcessProducts(ErpFactory.References().GetProductsByQuery("LTRIM(RTRIM(ITMCLSCD))=''")); */ // CAA [2010/07/19] // ciclo de n registros solo para GP bool cycle = false; switch (company.ErpConnection.ConnectionType.RowID) { case CnnType.GPeConnect: cycle = true; break; case CnnType.Everest: cycle = false; break; case CnnType.UnoEE: cycle = false; break; default: cycle = false; break; } IList <Product> list; bool canContinue = true; int record = 0; int step = 50; if (cycle) { while (canContinue) { Console.WriteLine(record.ToString() + " to " + (record + step).ToString()); list = ErpFactory.References().GetProductsByQuery(" (DEX_ROW_ID > " + record.ToString() + " AND DEX_ROW_ID <= " + (record + step).ToString() + ")"); if (list == null || list.Count == 0) { canContinue = false; } else { ProcessProducts(list); record += step; } } } else { list = ErpFactory.References().GetProductsByQuery(""); ProcessProducts(list); } return(true); }
public string CreateCustomer(Account customer) { SetConnectMngr(customer.Company); return(ErpFactory.Documents().CreateCustomer(customer)); }
public String CreateSalesOrder(Document document, string docPrefix, string batch) { SetConnectMngr(document.Company); return(ErpFactory.Documents().CreateSalesOrder(document, docPrefix, batch)); }
//Obtiene la info del stock del ERP y actualiza el inventario //Detallado o global dejando todo en MAIN public void UpdateWMSStockFromERP(Company company, bool detailed) { if (company == null) { ExceptionMngr.WriteEvent("GetStockComparation Company " + company.Name, ListValues.EventType.Fatal, null, null, ListValues.ErrorCategory.Business); return; } SetConnectMngr(company); //bool detailed = true; //indica si obtiene el stock a nivel de BIN ProductStock data; Node storedNode = WType.GetNode(new Node { NodeID = NodeType.Stored }); IList <ProductStock> erpStock; IList <Location> locationList = Factory.DaoLocation().Select(new Location { Company = company }); Console.WriteLine("Locations: " + locationList.Count.ToString()); foreach (Location location in locationList) { if (location.LocationID == 107 || location.LocationID == 103) { continue; } try { data = new ProductStock { Bin = new Bin { Location = location } }; erpStock = ErpFactory.Documents().GetErpStock(data, detailed); if (erpStock == null || erpStock.Count == 0) { continue; } Console.WriteLine("Location: " + location.Name + " => " + erpStock.Count + " records"); //Console.ReadKey(); foreach (ProductStock ps in erpStock.Where(f => f.Stock > 0)) { try { UpdateStock(ps, storedNode, "Stock Update From ERP"); } catch (Exception ex) { Console.WriteLine("UpdateStock: " + ex.Message); } } } catch (Exception ex) { Console.WriteLine("GetErpStock: " + ex.Message); } } }
public string CreatePurchaseOrder(Document document) { SetConnectMngr(document.Company); return(ErpFactory.Documents().CreatePurchaseOrder(document)); }
private void ProcessKitAssembly(IList <KitAssembly> list, Company company) { if (list == null) { return; } KitAssembly curRecord = null; foreach (KitAssembly e in list) { try { curRecord = new KitAssembly(); curRecord.Product = e.Product; //Evalua si el elemento ya existe IList <KitAssembly> exList = Factory.DaoKitAssembly().Select(curRecord, 0); e.ModDate = DateTime.Now; e.ModifiedBy = WmsSetupValues.SystemUser; if (exList.Count == 0) { e.CreatedBy = WmsSetupValues.SystemUser; e.CreationDate = DateTime.Now; Factory.DaoKitAssembly().Save(e); } else { e.RowID = exList.First().RowID; e.CreatedBy = exList.First().CreatedBy; e.CreationDate = exList.First().CreationDate; Factory.DaoKitAssembly().Update(e); } //Elimna las formulas para ese producto y las crea de nuevo foreach (KitAssemblyFormula kaf in Factory.DaoKitAssemblyFormula() .Select(new KitAssemblyFormula { KitAssembly = new KitAssembly { Product = new Product { ProductID = e.Product.ProductID } } })) { Factory.DaoKitAssemblyFormula().Delete(kaf); } //Procesa el assembly Formula que le corresponde // CAA [2010/07/19] // condición busqueda kit padre string query = ""; switch (company.ErpConnection.ConnectionType.RowID) { case CnnType.GPeConnect: query = " ITEMNMBR = '" + e.Product.ProductCode + "' "; break; case CnnType.Everest: query = " KIT_CODE = '" + e.Product.ProductCode + "' "; break; case CnnType.UnoEE: query = " (formula.f134_id_cia = " + e.Product.Company.ErpCode + ") AND itmPadre.f120_id = '" + e.Product.ProductCode + "'"; break; default: query = ""; break; } ProcessKitAssemblyFormula(ErpFactory.References().GetKitAssemblyFormula(query)); } catch (Exception ex) { //Factory.Rollback(); ExceptionMngr.WriteEvent("ProcessKitAssembly:" + curRecord.Product.ProductCode, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Business); //throw; } } }
public string CreateCustomerAddress(AccountAddress address) { SetConnectMngr(address.Account.Company); return(ErpFactory.Documents().CreateCustomerAddress(address)); }