private static Opportunity GenerateListing(StdBELista opportunityInfo) { return(new Opportunity() { Entity = TypeParser.String(opportunityInfo.Valor("Entidade")), Campaign = TypeParser.String(opportunityInfo.Valor("Campanha")), SellCycle = TypeParser.String(opportunityInfo.Valor("CicloVenda")), ExpirationDate = TypeParser.Date(opportunityInfo.Valor("DataExpiracao")), RealDateOrdered = TypeParser.Date(opportunityInfo.Valor("DataRealEncomenda")), Description = TypeParser.String(opportunityInfo.Valor("Descricao")), MarginOV = TypeParser.Double(opportunityInfo.Valor("MargemOV")), ProposedValueOV = TypeParser.Double(opportunityInfo.Valor("MargemPercOV")), Origin = TypeParser.String(opportunityInfo.Valor("Origem")), Seller = TypeParser.String(opportunityInfo.Valor("Vendedor")), CreatedBy = TypeParser.String(opportunityInfo.Valor("CriadoPor")), RealBillingDate = TypeParser.Date(opportunityInfo.Valor("DataRealFacturacao")), ClosureDate = TypeParser.Date(opportunityInfo.Valor("DataFecho")), LossMotive = TypeParser.String(opportunityInfo.Valor("MotivoPerda")), OpportunityId = TypeParser.String(opportunityInfo.Valor("Oportunidade")), Currency = TypeParser.String(opportunityInfo.Valor("Moeda")), Identificador = TypeParser.String(opportunityInfo.Valor("ID")), Brief = TypeParser.String(opportunityInfo.Valor("Resumo")), Zone = TypeParser.String(opportunityInfo.Valor("Zona")), Status = opportunityInfo.Valor("EstadoVenda"), EntityType = TypeParser.String(opportunityInfo.Valor("TipoEntidade")), TotalValueOV = TypeParser.Double(opportunityInfo.Valor("ValorTotalOV")) }); }
public static Warehouse Get(string warehouseId) { if (PrimaveraEngine.InitializeCompany() == false) { throw new DatabaseConnectionException(); } var warehouseInfo = PrimaveraEngine.Consulta(new SqlBuilder() .FromTable("ARMAZENS") .Columns(sqlColumnsFull) .Where("Armazem", Comparison.Equals, warehouseId)); if (warehouseInfo == null || warehouseInfo.Vazia()) { throw new NotFoundException("armazém", false); } return(new Warehouse { Localizacao = GetAddress(warehouseInfo), Descricao = TypeParser.String(warehouseInfo.Valor("Descricao")), Telefone = TypeParser.String(warehouseInfo.Valor("Telefone")), Identificador = TypeParser.String(warehouseInfo.Valor("Armazem")), DataModificacao = TypeParser.Date(warehouseInfo.Valor("DataUltimaActualizacao")) }); }
public static CustomerInfo View(string sessionId, string customerId) { if (PrimaveraEngine.InitializeCompany() == false) { throw new DatabaseConnectionException(); } var customerInfo = PrimaveraEngine.Consulta(new SqlBuilder() .FromTable("CLIENTES") .Columns(sqlColumnsFull) .Where("Cliente", Comparison.Equals, customerId)); if (customerInfo == null || customerInfo.Vazia()) { throw new NotFoundException("cliente", false); } var responsavelId = TypeParser.String(customerInfo.Valor("Vendedor")); var distritoId = TypeParser.String(customerInfo.Valor("Distrito")); /*if (responsavelId.Equals(sessionId) == false) * { * return null; * }*/ return(new CustomerInfo() { Identificador = TypeParser.String(customerInfo.Valor("Cliente")), Nome = TypeParser.String(customerInfo.Valor("Nome")), Estado = TypeParser.String(customerInfo.Valor("Situacao")), Debito = TypeParser.Double(customerInfo.Valor("TotalDeb")), NumContribuinte = TypeParser.String(customerInfo.Valor("NumContrib")), Pendentes = TypeParser.Double(customerInfo.Valor("EncomendasPendentes")), DataCriacao = TypeParser.Date(customerInfo.Valor("DataCriacao")), DataModificacao = TypeParser.Date(customerInfo.Valor("DataUltimaActualizacao")), EnderecoWeb = TypeParser.String(customerInfo.Valor("EnderecoWeb")), Particular = TypeParser.Boolean(customerInfo.Valor("PessoaSingular")), Telefone = TypeParser.String(customerInfo.Valor("Fac_Tel")), Telefone2 = TypeParser.String(customerInfo.Valor("Fac_Fax")), Telemovel = TypeParser.String(customerInfo.Valor("Telefone2")), Responsavel = UserIntegration.Reference(responsavelId), Localizacao = new Address { Pais = TypeParser.String(customerInfo.Valor("Pais")), Morada = TypeParser.String(customerInfo.Valor("Fac_Mor")), Distrito = LocationIntegration.DistritoReference(distritoId), CodigoPostal = TypeParser.String(customerInfo.Valor("Fac_Cp")), Localidade = TypeParser.String(customerInfo.Valor("Fac_Local")) } }); }
private static LeadListing GenerateListing(StdBELista queryObject) { return(new LeadListing() { Identificador = TypeParser.String(queryObject.Valor("Entidade")), Nome = TypeParser.String(queryObject.Valor("Nome")), Email = TypeParser.String(queryObject.Valor("Email")), Activo = TypeParser.Boolean(queryObject.Valor("Activo")), TipoTerceiro = TypeParser.String(queryObject.Valor("TipoTerceiro")), DataCriacao = TypeParser.Date(queryObject.Valor("DataCriacao")), DataModificacao = TypeParser.Date(queryObject.Valor("DataUltAct")), Telefone = TypeParser.String(queryObject.Valor("Telemovel")) }); }
private static ActivityListing GenerateListing(StdBELista queryResult) { return(new ActivityListing { Tipo = TypeReference(queryResult), DataFim = TypeParser.Date(queryResult.Valor("DataFim")), Resumo = TypeParser.String(queryResult.Valor("Resumo")), Estado = TypeParser.Integer(queryResult.Valor("Estado")), Identificador = TypeParser.String(queryResult.Valor("Id")), DataInicio = TypeParser.Date(queryResult.Valor("DataInicio")), Prioridade = TypeParser.Integer(queryResult.Valor("Prioridade")), DataModificacao = TypeParser.Date(queryResult.Valor("DataUltAct")) }); }
public static Opportunity View(string sessionId, string opportunityId) { if (PrimaveraEngine.InitializeCompany() == false) { throw new DatabaseConnectionException(); } var opportunityInfo = PrimaveraEngine.Consulta(new SqlBuilder() .FromTable("CABECOPORTUNIDADESVENDA") .Columns(sqlColumnsListing) .Where("ID", Comparison.Equals, opportunityId)); if (opportunityInfo == null || opportunityInfo.Vazia()) { throw new NotFoundException("oportunidade", true); } /*if (opportunityInfo.get_Vendedor() != sessionId) * { * return null; * }*/ return(new Opportunity() { Entity = TypeParser.String(opportunityInfo.Valor("Entidade")), Campaign = TypeParser.String(opportunityInfo.Valor("Campanha")), SellCycle = TypeParser.String(opportunityInfo.Valor("CicloVenda")), ExpirationDate = TypeParser.Date(opportunityInfo.Valor("DataExpiracao")), RealDateOrdered = TypeParser.Date(opportunityInfo.Valor("DataRealEncomenda")), Description = TypeParser.String(opportunityInfo.Valor("Descricao")), MarginOV = TypeParser.Double(opportunityInfo.Valor("MargemOV")), ProposedValueOV = TypeParser.Double(opportunityInfo.Valor("MargemPercOV")), Origin = TypeParser.String(opportunityInfo.Valor("Origem")), Seller = TypeParser.String(opportunityInfo.Valor("Vendedor")), CreatedBy = TypeParser.String(opportunityInfo.Valor("CriadoPor")), RealBillingDate = TypeParser.Date(opportunityInfo.Valor("DataRealFacturacao")), ClosureDate = TypeParser.Date(opportunityInfo.Valor("DataFecho")), LossMotive = TypeParser.String(opportunityInfo.Valor("MotivoPerda")), OpportunityId = TypeParser.String(opportunityInfo.Valor("Oportunidade")), Currency = TypeParser.String(opportunityInfo.Valor("Moeda")), Identificador = TypeParser.String(opportunityInfo.Valor("ID")), Brief = TypeParser.String(opportunityInfo.Valor("Resumo")), Zone = TypeParser.String(opportunityInfo.Valor("Zona")), Status = opportunityInfo.Valor("EstadoVenda"), EntityType = TypeParser.String(opportunityInfo.Valor("TipoEntidade")), TotalValueOV = TypeParser.Double(opportunityInfo.Valor("ValorTotalOV")) }); }
public static List <CustomerListing> List(string sessionId) { if (PrimaveraEngine.InitializeCompany() == false) { throw new DatabaseConnectionException(); } var customerList = new List <CustomerListing>(); var customerInfo = PrimaveraEngine.Consulta(new SqlBuilder().FromTable("CLIENTES").Columns(sqlColumnsListing)); if (customerInfo == null || customerInfo.Vazia()) { return(customerList); } while (!customerInfo.NoFim()) { customerList.Add(new CustomerListing() { Nome = TypeParser.String(customerInfo.Valor("Nome")), Identificador = TypeParser.String(customerInfo.Valor("Cliente")), Estado = TypeParser.String(customerInfo.Valor("Situacao")), Debito = TypeParser.Double(customerInfo.Valor("TotalDeb")), Pendentes = TypeParser.Double(customerInfo.Valor("EncomendasPendentes")), DataCriacao = TypeParser.Date(customerInfo.Valor("DataCriacao")), DataModificacao = TypeParser.Date(customerInfo.Valor("DataUltimaActualizacao")), Telefone = TypeParser.String(customerInfo.Valor("Fac_Tel")) }); customerInfo.Seguinte(); } customerList.Sort(delegate(CustomerListing lhs, CustomerListing rhs) { if (lhs.Nome == null || rhs.Nome == null) { return(-1); } return(lhs.Nome.CompareTo(rhs.Nome)); }); return(customerList); }
public static List <ContactListing> List(string sessionId) { if (PrimaveraEngine.InitializeCompany() == false) { throw new DatabaseConnectionException(); } var contactList = new List <ContactListing>(); var contactInfo = PrimaveraEngine.Consulta(new SqlBuilder().FromTable("CONTACTOS").Columns(sqlColumnsListing)); if (contactInfo == null || contactInfo.Vazia()) { return(contactList); } while (!contactInfo.NoFim()) { contactList.Add(new ContactListing() { Identificador = TypeParser.String(contactInfo.Valor("Contacto")), Nome = TypeParser.String(contactInfo.Valor("PrimeiroNome")) + " " + contactInfo.Valor("UltimoNome"), Email = TypeParser.String(contactInfo.Valor("Email")), Telefone = TypeParser.String(contactInfo.Valor("Telemovel")), DataModificacao = TypeParser.Date(contactInfo.Valor("DataUltContacto")), }); contactInfo.Seguinte(); } contactList.Sort(delegate(ContactListing lhs, ContactListing rhs) { if (lhs.Nome == null || rhs.Nome == null) { return(-1); } return(lhs.Nome.CompareTo(rhs.Nome)); }); return(contactList); }
public static List<QuoteListing> List() { if (PrimaveraEngine.InitializeCompany() == false) { throw new DatabaseConnectionException(); } var query = new SqlBuilder() .FromTable("CabecDoc") .Columns(sqlQuoteListing) .Where("TipoDoc", Comparison.Equals, "ECL") .Where("Serie", Comparison.Equals, QuotesConstants.serie); query.AddOrderBy("NumDoc", Sorting.Descending); var queryObject = PrimaveraEngine.Consulta(query); if (queryObject == null || queryObject.Vazia()) { return null; } var queryResult = new List<QuoteListing>(); while (!queryObject.NoFim()) { queryResult.Add(new QuoteListing { NumEncomenda = TypeParser.Integer(queryObject.Valor("NumDoc")), Cliente = TypeParser.String(queryObject.Valor("Entidade")), NomeCliente = TypeParser.String(queryObject.Valor("Nome")), TotalDocumento = TypeParser.Double(queryObject.Valor("TotalDocumento")), Data = TypeParser.Date(queryObject.Valor("Data")) }); queryObject.Seguinte(); } return queryResult; }
public static Product View(string productId) { if (PrimaveraEngine.InitializeCompany() == false) { throw new DatabaseConnectionException(); } var productInfo = PrimaveraEngine.Consulta(new SqlBuilder() .FromTable("ARTIGO") .Columns(sqlColumnsFull) .Where("ARTIGO.Artigo", Comparison.Equals, productId) .LeftJoin("FAMILIAS", "Familia", Comparison.Equals, "ARTIGO", "Familia")); if (productInfo == null || productInfo.Vazia()) { throw new NotFoundException("produto", false); } var productUnit = TypeParser.String(productInfo.Valor("UnidadeVenda")); var priceList = GeneratePrices(productId, productUnit); return(new Product() { Unidade = productUnit, PrecoMedio = CalculateAverage(priceList), Precos = GeneratePrices(productId, productUnit), IVA = TypeParser.Double(productInfo.Valor("Iva")), Stock = TypeParser.Double(productInfo.Valor("Stock")), Armazens = WarehouseIntegration.GetWarehouses(productId), Desconto = TypeParser.Double(productInfo.Valor("Desconto")), Descricao = TypeParser.String(productInfo.Valor("Descricao")), Identificador = TypeParser.String(productInfo.Valor("Artigo")), CodigoBarras = TypeParser.String(productInfo.Valor("CodBarras")), Categoria = CategoryIntegration.GenerateReference(productInfo), UltimaEntrada = TypeParser.Date(productInfo.Valor("DataUltEntrada")), UltimaSaida = TypeParser.Date(productInfo.Valor("DataUltSaida")) }); }
public static QuoteInfo View(string sessionId, string quoteId) { if (PrimaveraEngine.InitializeCompany() == false) { throw new DatabaseConnectionException(); } var quoteInfo = PrimaveraEngine.Consulta(new SqlBuilder() .FromTable("CabecDoc") .Columns(sqlQuoteColumns) .Where("TipoDoc", Comparison.Equals, QuotesConstants.tipoDoc) .Where("NumDoc", Comparison.Equals, quoteId) .Where("Serie", Comparison.Equals, QuotesConstants.serie)); if (quoteInfo == null || quoteInfo.Vazia()) { throw new NotFoundException("encomenda", true); } if (TypeParser.String(quoteInfo.Valor("Responsavel")) != sessionId) { return null; } List<OrderInfo> quoteProducts = new List<OrderInfo>(); var productsInfo = PrimaveraEngine.Consulta(new SqlBuilder() .FromTable("LinhasDoc") .Columns(sqlProductsColumns) .Where("IdCabecDoc", Comparison.Equals, quoteInfo.Valor("Id"))); while (!productsInfo.NoFim()) { quoteProducts.Add(new OrderInfo { Quantidade = TypeParser.Integer(productsInfo.Valor("Quantidade")), Preco = TypeParser.Double(productsInfo.Valor("PrecUnit")), Desconto = TypeParser.Double(productsInfo.Valor("Desconto1")), Iva = TypeParser.Double(productsInfo.Valor("TaxaIva")), Unidade = TypeParser.String(productsInfo.Valor("Unidade")), Produto = new Reference(TypeParser.String(productsInfo.Valor("Artigo")), TypeParser.String(productsInfo.Valor("Descricao"))) }); productsInfo.Seguinte(); } return new QuoteInfo { NumEncomenda = TypeParser.Integer(quoteInfo.Valor("NumDoc")), Cliente = TypeParser.String(quoteInfo.Valor("Entidade")), NomeCliente = TypeParser.String(quoteInfo.Valor("Nome")), EnderecoEntrega = new Address { Morada = TypeParser.String(quoteInfo.Valor("Morada")), CodigoPostal = TypeParser.String(quoteInfo.Valor("CodPostal")), Localidade = TypeParser.String(quoteInfo.Valor("Localidade")), Distrito = LocationIntegration.DistritoReference(TypeParser.String(quoteInfo.Valor("Distrito"))), Pais = TypeParser.String(quoteInfo.Valor("Pais")) }, Data = TypeParser.Date(quoteInfo.Valor("Data")), IdOportunidade = TypeParser.String(quoteInfo.Valor("IdOportunidade")), TotalDesc = TypeParser.Double(quoteInfo.Valor("TotalDesc")), TotalIva = TypeParser.Double(quoteInfo.Valor("TotalIva")), TotalMerc = TypeParser.Double(quoteInfo.Valor("TotalMerc")), TotalDocumento = TypeParser.Double(quoteInfo.Valor("TotalDocumento")), NumContribuinte = TypeParser.String(quoteInfo.Valor("NumContribuinte")), Produtos = quoteProducts }; }