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 List <RepresentativeListing> List() { if (PrimaveraEngine.InitializeCompany() == false) { throw new DatabaseConnectionException(); } var representativeList = new List <RepresentativeListing>(); var representativeInfo = PrimaveraEngine.Consulta(new SqlBuilder().Columns(sqlVendedor).FromTable("VENDEDORES")); if (representativeInfo == null || representativeInfo.Vazia()) { return(representativeList); } while (!representativeInfo.NoFim()) { representativeList.Add(new RepresentativeListing { Identificador = TypeParser.String(representativeInfo.Valor(fieldVendedor)), Nome = TypeParser.String(representativeInfo.Valor(fieldNome)), Comissao = TypeParser.Double(representativeInfo.Valor(fieldComissao)) }); representativeInfo.Seguinte(); } return(representativeList); }
public static List <WarehouseProduct> GetWarehouses(string productId) { if (PrimaveraEngine.InitializeCompany() == false) { throw new DatabaseConnectionException(); } var warehouseList = new List <WarehouseProduct>(); var warehouseInfo = PrimaveraEngine.Consulta(new SqlBuilder() .FromTable("ARTIGOARMAZEM") .Columns(sqlColumnsAggregate) .Where("ARTIGOARMAZEM.Artigo", Comparison.Equals, productId) .LeftJoin("ARMAZENS", "Armazem", Comparison.Equals, "ARTIGOARMAZEM", "Armazem") .GroupBy(new string[] { "ARTIGOARMAZEM.Artigo", "ARMAZENS.Armazem" })); if (warehouseInfo == null || warehouseInfo.Vazia()) { return(warehouseList); } while (!warehouseInfo.NoFim()) { warehouseList.Add(new WarehouseProduct { Localizacao = GetAddress(warehouseInfo), Stock = TypeParser.Double(warehouseInfo.Valor("Stock")), Descricao = TypeParser.String(warehouseInfo.Valor("Descricao")), Identificador = TypeParser.String(warehouseInfo.Valor("Armazem")) }); warehouseInfo.Seguinte(); } return(warehouseList); }
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 ProductListing GenerateListing(StdBELista productInfo) { var productId = TypeParser.String(productInfo.Valor("Artigo")); var productUnit = TypeParser.String(productInfo.Valor("UnidadeVenda")); return(new ProductListing() { Unidade = productUnit, Identificador = productId, PrecoMedio = FindLowest(productId, productUnit), Stock = TypeParser.Double(productInfo.Valor("Stock")), IVA = TypeParser.Double(productInfo.Valor("Iva")), Descricao = TypeParser.String(productInfo.Valor("Descricao")) }); }
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); }
private static Proposals GenerateListing(StdBELista proposalInfo, string id) { var proposalsLines = ProposalLinesIntegration.List(id, proposalInfo.Valor("NumProposta")); return(new Proposals() { idOportunidade = TypeParser.String(proposalInfo.Valor("IdOportunidade")), ProposalNumber = proposalInfo.Valor("NumProposta"), Description = TypeParser.String(proposalInfo.Valor("Descricao")), PaymentMethod = TypeParser.String(proposalInfo.Valor("ModoPagamento")), PaymentCondition = TypeParser.String(proposalInfo.Valor("CondPagamento")), Cost = TypeParser.Double(proposalInfo.Valor("Custo")), Value = TypeParser.Double(proposalInfo.Valor("Valor")), DiscountValue = TypeParser.Double(proposalInfo.Valor("ValorDesconto")), Rentability = TypeParser.Double(proposalInfo.Valor("Rentabilidade")), Margin = TypeParser.Double(proposalInfo.Valor("Margem")), Observations = TypeParser.String(proposalInfo.Valor("Observacoes")), EntityDiscount = TypeParser.Double(proposalInfo.Valor("DescontoEntidade")), Totalize = proposalInfo.Valor("NaoTotalizadora"), ProposalsLines = proposalsLines }); }
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")) }); }
private static ProposalsLine GenerateListing(StdBELista proposalLineInfo) { return(new ProposalsLine() { idOportunidade = TypeParser.String(proposalLineInfo.Valor("IdOportunidade")), ProposalNumber = proposalLineInfo.Valor("NumProposta"), Line = proposalLineInfo.Valor("Linha"), Article = TypeParser.String(proposalLineInfo.Valor("Artigo")), Description = TypeParser.String(proposalLineInfo.Valor("Descricao")), Quantity = TypeParser.Double(proposalLineInfo.Valor("Quantidade")), Unit = TypeParser.String(proposalLineInfo.Valor("Unidade")), FactorConv = TypeParser.Double(proposalLineInfo.Valor("FactorConv")), CostPrice = TypeParser.Double(proposalLineInfo.Valor("PrecoCusto")), SellsPrice = TypeParser.Double(proposalLineInfo.Valor("PrecoVenda")), Discount1 = TypeParser.Double(proposalLineInfo.Valor("Desconto1")), Discount2 = TypeParser.Double(proposalLineInfo.Valor("Desconto2")), Discount3 = TypeParser.Double(proposalLineInfo.Valor("Desconto3")), Discount = TypeParser.Double(proposalLineInfo.Valor("Desconto")), DiscountValue = TypeParser.Double(proposalLineInfo.Valor("ValorDesconto")), Rentability = TypeParser.Double(proposalLineInfo.Valor("Rentabilidade")), Margin = TypeParser.Double(proposalLineInfo.Valor("Margem")), Observations = TypeParser.String(proposalLineInfo.Valor("Observacoes")), }); }
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 }; }