Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Bloco de código
titleExemplo 2
collapsetrue
#include "msobject.ch"
#include "totvs.framework.treports.integratedprovider.th"

namespace custom.financeiro.fornecedores.integratedprovider

@totvsFrameworkTReportsIntegratedProvider(active=.T.)
class SA2TReportsBusinessObject from totvs.framework.treports.integratedprovider.IntegratedProvider
    public method new() as object
    public method getAreas() as array
    public method getDescription() as character
    public method getData() as object
    public method getSchema() as object
endclass

method new() as object class SA2TReportsBusinessObject
	_Super:new()
	self:setDisplayName("Fornecedores")
return self

method getDescription() as character class SA2TReportsBusinessObject
return "Fornecedores do Protheus"

method getAreas() as array class SA2TReportsBusinessObject
return {"Financeiro", "Contas a pagar"}

method getData(nPage as numeric, oFilter as object) as object class SA2TReportsBusinessObject
	local cQuery as character
	local cAlias as character

	cQuery := "SELECT A2_NOME, A2_COD FROM " + RetSqlName('SA2') + " WHERE D_E_L_E_T_ = ' '"
	
	//Só será possível adicionar filtro após a implementação do TReports pois o mesmo irá pelo body da requisição
	if oFilter:hasFilter()
	    cQuery += " AND " + oFilter:getSQLExpression()
	endif

	cAlias := MPSysOpenQuery(cQuery)

	while !(cAlias)->(Eof())
	    self:oData:appendData({"Nome": (cAlias)->A2_NOME, "Código": (cAlias)->A2_COD})
	    (cAlias)->(DBSkip())
	enddo

	(cAlias)->(DBCloseArea())
return self:oData

method getSchema() as object class SA2TReportsBusinessObject
	self:oSchema:addProperty("Nome", "Nome do Fornecedor", "C", "Fornecedor", "A2_NOME")
	self:oSchema:addProperty("Código", "Código do Fornecedor", "C", "Cod do Fornecedor", "A2_COD")
return self:oSchema
Bloco de código
titleExemplo 3
collapsetrue
#include "msobject.ch"
#include "totvs.framework.treports.integratedprovider.th"

namespace custom.materiais.produtos.integratedprovider

@totvsFrameworkTReportsIntegratedProvider(active=.T.)
class SB1TReportsBusinessObject from totvs.framework.treports.integratedprovider.IntegratedProvider
    public method new() as object
    public method getDisplayName() as character
    public method getDescription() as character
    public method getData() as object
    public method getSchema() as object
endclass

method new() class SB1TReportsBusinessObject
_Super:new()
self:appendArea("Materiais")
self:appendArea("Faturamento")
return self

method getDisplayName() as character class SB1TReportsBusinessObject
return "Produtos"

method getDescription() as character class SB1TReportsBusinessObject
return "Produtos do Protheus"

method getData(nPage as numeric, oFilter as object) as object class SB1TReportsBusinessObject
local cQuery as character
local cAlias as character

cQuery := "SELECT B1_COD, B1_DESC, B1_TIPO, B1_UM FROM " + RetSQLName("SB1") + " WHERE D_E_L_E_T_ = ' '"

//Só será possível adicionar filtro após a implementação do TReports pois o mesmo irá pelo body da requisição
if oFilter:hasFilter()
    cQuery += " AND " + oFilter:getSQLExpression()
endif

cAlias := MPSysOpenQuery(cQuery)

while !(cAlias)->(Eof())
    self:oData:appendData({"Codigo": (cAlias)->B1_COD, "Descricao": (cAlias)->B1_DESC, "Tipo": (cAlias)->B1_TIPO, "Unidade": (cAlias)->B1_UM})
    (cAlias)->(DBSkip())
enddo

(cAlias)->(DBCloseArea())

return self:oData

method getSchema() as object class SB1TReportsBusinessObject
self:oSchema:addProperty("Codigo", "Código", "string", "Código", "B1_COD")
self:oSchema:addProperty("Descricao", "Descrição", "string", "Descricao","B1_DESC")
self:oSchema:addProperty("Tipo", "Tipo", "string", "Tipo","B1_TIPO")
self:oSchema:addProperty("Unidade", "Unidade de medida", "string", "Unidade","B1_UM")
return self:oSchema