USE [TryNFeOnline]
GO
ALTER TABLE [dbo].[CamposFinanceiroDominio] DROP CONSTRAINT [fk_emitente]
GO
ALTER TABLE [dbo].[EmitenteSeguradora] ALTER COLUMN [senha] [varchar] (500) COLLATE Latin1_General_CI_AS NULL
GO
ALTER TABLE [dbo].[EmailConta] ADD 
[clientId] [varchar] (max) COLLATE Latin1_General_CI_AS NULL,
[clientSecret] [varchar] (max) COLLATE Latin1_General_CI_AS NULL,
[tokenAcess] [varchar] (max) COLLATE Latin1_General_CI_AS NULL,
[tokenRefresh] [varchar] (max) COLLATE Latin1_General_CI_AS NULL,
[expiresInSeconds] [int] NULL,
[expiresTokenDateTime] [datetime] NULL,
[geracaoDateTime] [datetime] NULL
GO
ALTER TABLE [dbo].[EmitenteSeguradora] ALTER COLUMN [usuario] [varchar] (500) COLLATE Latin1_General_CI_AS NULL
GO
ALTER TABLE [dbo].[OperadorConfiguracoes] ADD 
[idnDesmarcarLiquidacaoContasReceber] [bit] NULL,
[idnDesmarcarLiquidacaoContasPagar] [bit] NULL
GO
CREATE TABLE [dbo].[CteOrdemCargaReboques]
(
	[id] [int] IDENTITY (1,1) NOT NULL,
	[idOrdemCarga] [int] NOT NULL,
	[idVeiculoReboque] [int] NOT NULL,
	CONSTRAINT [PK_CteOrdemCargaReboques] PRIMARY KEY CLUSTERED
	(
		[id] ASC
	) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY  = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[CteOrdemCargaNFProduto]
(
	[id] [int] IDENTITY (1,1) NOT NULL,
	[idOrdemCargaNF] [int] NULL,
	[idOrdemCarga] [int] NULL,
	[descricaoProd] [varchar] (100) COLLATE Latin1_General_CI_AS NULL,
	[qtde] [decimal] (18,4) NULL,
	[ucom] [varchar] (6) COLLATE Latin1_General_CI_AS NULL,
	[vuncom] [decimal] (18,4) NULL,
	[vprod] [decimal] (18,4) NULL,
	[idProduto] [int] NULL,
	[idProdutoClassificacao] [int] NULL,
	CONSTRAINT [PK_CteOrdemCargaNFProduto] PRIMARY KEY CLUSTERED
	(
		[id] ASC
	) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY  = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[CteOrdemCargaNF]
(
	[id] [int] IDENTITY (1,1) NOT NULL,
	[idOrdemCarga] [int] NULL,
	[modelo] [varchar] (4) COLLATE Latin1_General_CI_AS NULL,
	[numeroNF] [int] NULL,
	[serie] [varchar] (100) COLLATE Latin1_General_CI_AS NULL,
	[nfeChave] [varchar] (60) COLLATE Latin1_General_CI_AS NULL,
	[nfeProt] [varchar] (60) COLLATE Latin1_General_CI_AS NULL,
	[valorTotalNF] [decimal] (18,4) NULL,
	[idEmitenteNF] [int] NULL,
	[emitenteRazao] [varchar] (60) COLLATE Latin1_General_CI_AS NULL,
	[emitenteCnpjCpf] [varchar] (25) COLLATE Latin1_General_CI_AS NULL,
	[emitenteInscricaoEstadual] [varchar] (25) COLLATE Latin1_General_CI_AS NULL,
	[idDestinatarioNF] [int] NULL,
	[destinatarioRazao] [varchar] (60) COLLATE Latin1_General_CI_AS NULL,
	[destinatarioCnpjCpf] [varchar] (25) COLLATE Latin1_General_CI_AS NULL,
	[destinatarioInscricaoEstadual] [varchar] (25) COLLATE Latin1_General_CI_AS NULL,
	[idNotaFiscal] [int] NULL,
	[idEnderecoParceiroEmitenteNF] [int] NULL,
	[idEnderecoParceiroDestinatarioNF] [int] NULL,
	[pesoBruto] [decimal] (18,4) NULL,
	[pesoLiquido] [decimal] (18,4) NULL,
	CONSTRAINT [PK_CteOrdemCargaNF] PRIMARY KEY CLUSTERED
	(
		[id] ASC
	) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY  = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[CteOrdemCargaFaturada]
(
	[id] [int] IDENTITY (1,1) NOT NULL,
	[idNotaFiscal] [int] NULL,
	[idCteOrdemCarga] [int] NULL,
	CONSTRAINT [PK_CteOrdemCargaFaturada] PRIMARY KEY CLUSTERED
	(
		[id] ASC
	) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY  = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[CteOrdemCarga]
(
	[id] [int] IDENTITY (1,1) NOT NULL,
	[idVeiculo] [int] NULL,
	[qPeso] [decimal] (18,4) NULL,
	[status] [varchar] (20) COLLATE Latin1_General_CI_AS NULL,
	[dataEmissao] [datetime] NULL,
	[idOperador] [int] NULL,
	[idEmitente] [int] NULL,
	[qPesoLiquido] [decimal] (18,4) NULL,
	CONSTRAINT [PK_CteOrdemCarga] PRIMARY KEY CLUSTERED
	(
		[id] ASC
	) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY  = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[TempCamposFinanceiroDominio]
(
	[id] [int] IDENTITY (1,1) NOT NULL,
	[idEmitente] [int] NOT NULL,
	[codigoEmitente] [varchar] (20) COLLATE Latin1_General_CI_AS NOT NULL,
	[contaReceita] [varchar] (50) COLLATE Latin1_General_CI_AS NULL,
	[contaDespesa] [varchar] (50) COLLATE Latin1_General_CI_AS NULL,
	[cfop] [varchar] (500) COLLATE Latin1_General_CI_AS NULL,
	[idReceitaDespesa] [int] NOT NULL

) ON [PRIMARY]
GO

SET IDENTITY_INSERT [dbo].[TempCamposFinanceiroDominio] ON
INSERT INTO [dbo].[TempCamposFinanceiroDominio] ([id],[idEmitente],[codigoEmitente],[contaReceita],[contaDespesa],[cfop],[idReceitaDespesa]) SELECT [id],ISNULL([idEmitente],0),[codigoEmitente],[contaReceita],[contaDespesa],[cfop],0 FROM [dbo].[CamposFinanceiroDominio]
SET IDENTITY_INSERT [dbo].[TempCamposFinanceiroDominio] OFF
GO

DROP TABLE [dbo].[CamposFinanceiroDominio]
GO
EXEC sp_rename N'[dbo].[TempCamposFinanceiroDominio]',N'CamposFinanceiroDominio', 'OBJECT'
GO

ALTER TABLE [dbo].[CamposFinanceiroDominio] ADD CONSTRAINT [PK_CamposFinanceiroDominio] PRIMARY KEY CLUSTERED
	(
		[id] ASC
	) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY  = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE [dbo].[CteOrdemCarga] ADD CONSTRAINT [FK_CteOrdemCarga_emitente] FOREIGN KEY
	(
		[idEmitente]
	)
	REFERENCES [dbo].[emitente]
	(
		[id]
	)
GO

ALTER TABLE [dbo].[CteOrdemCarga] ADD CONSTRAINT [FK_CteOrdemCarga_veiculo] FOREIGN KEY
	(
		[idVeiculo]
	)
	REFERENCES [dbo].[veiculo]
	(
		[id]
	)
GO

ALTER TABLE [dbo].[CteOrdemCargaFaturada] ADD CONSTRAINT [FK_CteOrdemCargaFaturada_CteOrdemCarga] FOREIGN KEY
	(
		[idCteOrdemCarga]
	)
	REFERENCES [dbo].[CteOrdemCarga]
	(
		[id]
	)
GO

ALTER TABLE [dbo].[CteOrdemCargaFaturada] ADD CONSTRAINT [FK_CteOrdemCargaFaturada_notafiscal] FOREIGN KEY
	(
		[idNotaFiscal]
	)
	REFERENCES [dbo].[notafiscal]
	(
		[id]
	)
GO

ALTER TABLE [dbo].[CteOrdemCargaNF] ADD CONSTRAINT [FK_CteOrdemCargaNF_CteOrdemCarga] FOREIGN KEY
	(
		[idOrdemCarga]
	)
	REFERENCES [dbo].[CteOrdemCarga]
	(
		[id]
	)
GO

ALTER TABLE [dbo].[CteOrdemCargaNF] ADD CONSTRAINT [FK_CteOrdemCargaNF_EnderecoParceiroDestinatarioNF] FOREIGN KEY
	(
		[idEnderecoParceiroDestinatarioNF]
	)
	REFERENCES [dbo].[EnderecoParceiro]
	(
		[id]
	)
GO

ALTER TABLE [dbo].[CteOrdemCargaNF] ADD CONSTRAINT [FK_CteOrdemCargaNF_EnderecoParceiroEmitente] FOREIGN KEY
	(
		[idEnderecoParceiroEmitenteNF]
	)
	REFERENCES [dbo].[EnderecoParceiro]
	(
		[id]
	)
GO

ALTER TABLE [dbo].[CteOrdemCargaNF] ADD CONSTRAINT [FK_CteOrdemCargaNF_notafiscal] FOREIGN KEY
	(
		[idNotaFiscal]
	)
	REFERENCES [dbo].[notafiscal]
	(
		[id]
	)
GO

ALTER TABLE [dbo].[CteOrdemCargaNF] ADD CONSTRAINT [FK_CteOrdemCargaNF_parceiroDestinatario] FOREIGN KEY
	(
		[idDestinatarioNF]
	)
	REFERENCES [dbo].[parceiro]
	(
		[id]
	)
GO

ALTER TABLE [dbo].[CteOrdemCargaNF] ADD CONSTRAINT [FK_CteOrdemCargaNF_parceiroRemetente] FOREIGN KEY
	(
		[idEmitenteNF]
	)
	REFERENCES [dbo].[parceiro]
	(
		[id]
	)
GO

ALTER TABLE [dbo].[CteOrdemCargaNFProduto] ADD CONSTRAINT [FK_CteOrdemCargaNFProduto_CteOrdemCarga] FOREIGN KEY
	(
		[idOrdemCarga]
	)
	REFERENCES [dbo].[CteOrdemCarga]
	(
		[id]
	)
GO

ALTER TABLE [dbo].[CteOrdemCargaNFProduto] ADD CONSTRAINT [FK_CteOrdemCargaNFProduto_CteOrdemCargaNF] FOREIGN KEY
	(
		[idOrdemCargaNF]
	)
	REFERENCES [dbo].[CteOrdemCargaNF]
	(
		[id]
	)
GO

ALTER TABLE [dbo].[CteOrdemCargaNFProduto] ADD CONSTRAINT [FK_CteOrdemCargaNFProduto_produto] FOREIGN KEY
	(
		[idProduto]
	)
	REFERENCES [dbo].[produto]
	(
		[id]
	)
GO

ALTER TABLE [dbo].[CteOrdemCargaNFProduto] ADD CONSTRAINT [FK_CteOrdemCargaNFProduto_ProdutoClassificacao] FOREIGN KEY
	(
		[idProdutoClassificacao]
	)
	REFERENCES [dbo].[ProdutoClassificacao]
	(
		[id]
	)
GO

ALTER TABLE [dbo].[CteOrdemCargaReboques] ADD CONSTRAINT [FK_CteOrdemCargaReboques_CteOrdemCarga] FOREIGN KEY
	(
		[idOrdemCarga]
	)
	REFERENCES [dbo].[CteOrdemCarga]
	(
		[id]
	)
GO

ALTER TABLE [dbo].[CteOrdemCargaReboques] ADD CONSTRAINT [FK_CteOrdemCargaReboques_veiculo] FOREIGN KEY
	(
		[idVeiculoReboque]
	)
	REFERENCES [dbo].[veiculo]
	(
		[id]
	)
GO

ALTER TABLE [dbo].[CamposFinanceiroDominio] ADD CONSTRAINT [fk_receitaDespesa] FOREIGN KEY
	(
		[idReceitaDespesa]
	)
	REFERENCES [dbo].[ReceitaDespesa]
	(
		[id]
	)
GO
ALTER TABLE [dbo].[CamposFinanceiroDominio] ADD CONSTRAINT [fk_emitente] FOREIGN KEY
	(
		[idEmitente]
	)
	REFERENCES [dbo].[emitente]
	(
		[id]
	)
GO
update MenuItens set ordem = 14 where id = 237;
update MenuItens set ordem = 15 where id = 238;
update MenuItens set ordem = 16 where id = 239;
update MenuItens set ordem = 17 where id = 246;
update MenuItens set ordem = 18 where id = 247;
update MenuItens set ordem = 19 where id = 248;
update MenuItens set ordem = 19 where id = 263;
update MenuItens set ordem = 19 where id = 264;
update MenuItens set ordem = 25 where id = 399;

SET IDENTITY_INSERT [dbo].[MenuItens] ON 
GO
INSERT [dbo].[MenuItens] ( [id], [idMenu], [descricao], [idTela], [idMenuItemPai], [ordem], [idnVisivel], [md5], [imagem]) VALUES ( 539, 1, N'Troca de Numerário', 247, 58, 12, 1, NULL, N'')
GO
INSERT [dbo].[MenuItens] ( [id], [idMenu], [descricao], [idTela], [idMenuItemPai], [ordem], [idnVisivel], [md5], [imagem]) VALUES ( 540, 1, N'Consultar Troca de Numerários', 246, 58, 13, 1, NULL, N'')
GO
SET IDENTITY_INSERT [dbo].[MenuItens] OFF
GO

update MenuItens set ordem = 16 where id = 505;
update MenuItens set ordem = 17 where id = 506;
update MenuItens set ordem = 18 where id = 507;
update MenuItens set ordem = 19 where id = 508;
update MenuItens set ordem = 20 where id = 509;
update MenuItens set ordem = 21 where id = 521;

SET IDENTITY_INSERT [dbo].[MenuItens] ON 
GO
INSERT [dbo].[MenuItens] ( [id], [idMenu], [descricao], [idTela], [idMenuItemPai], [ordem], [idnVisivel], [md5], [imagem]) VALUES ( 541, 2, N'Troca de Numerário', 247, 453, 14, 1, NULL, N'')
GO
INSERT [dbo].[MenuItens] ( [id], [idMenu], [descricao], [idTela], [idMenuItemPai], [ordem], [idnVisivel], [md5], [imagem]) VALUES ( 542, 2, N'Consultar Trocas de Numerário', 246, 453, 15, 1, NULL, N'')
GO
SET IDENTITY_INSERT [dbo].[MenuItens] OFF
GO

SET IDENTITY_INSERT [dbo].[Telas] ON 
GO
INSERT INTO [dbo].[Telas]
           ([id]
		   ,[descricao]
           ,[controle]
           ,[imagem]
           ,[parametrosControle]
           ,[teclaAtalho1]
           ,[teclaAtalho2]
           ,[idnPermiteAbrirVarias]
           ,[qtdVezesAberta]
           ,[dataUltimaAbertura]
           ,[idnRestricaoAcesso]
           ,[idnBloquearAcessoPlanoBasico])
     VALUES
           (445
		   ,'Sugestão de Compras PSI'
           ,'Cadastros.ucConsSugestaoCompraLG, Cadastros, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
           ,null
           ,null
           ,null
           ,null
           ,null
           ,null
           ,null
           ,null
           ,1)
GO

INSERT INTO [dbo].[Telas]
           ([id]
		   ,[descricao]
           ,[controle]
           ,[imagem]
           ,[parametrosControle]
           ,[teclaAtalho1]
           ,[teclaAtalho2]
           ,[idnPermiteAbrirVarias]
           ,[qtdVezesAberta]
           ,[dataUltimaAbertura]
           ,[idnRestricaoAcesso]
           ,[idnBloquearAcessoPlanoBasico])
     VALUES
           (446
		   ,'Geração de Arquivo Financeiro Domínio'
           ,'Cadastros.ucGeracaoArquivosDominio, Cadastros, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
           ,null
           ,null
           ,null
           ,null
           ,null
           ,null
           ,null
           ,null
           ,1)
GO
SET IDENTITY_INSERT [dbo].[Telas] OFF
GO

SET IDENTITY_INSERT [dbo].[MenuItens] ON 
GO
INSERT [dbo].[MenuItens] ( [id], [idMenu], [descricao], [idTela], [idMenuItemPai], [ordem], [idnVisivel], [md5], [imagem]) VALUES ( 543, 1, N'Arquivo Financeiro Domínio', 446, 78, 5, 1, NULL, N'')
GO
INSERT [dbo].[MenuItens] ( [id], [idMenu], [descricao], [idTela], [idMenuItemPai], [ordem], [idnVisivel], [md5], [imagem]) VALUES ( 544, 1, N'Sugestão de Compra PSI', 445, 273, 8, 1, NULL, N'')
GO
SET IDENTITY_INSERT [dbo].[MenuItens] OFF
GO
INSERT [dbo].[Reports] ([descricao], [idReportsGrupo], [xml]) VALUES (N'Ordem de Carga', 4, N'<XtraReportsLayoutSerializer SerializerVersion="22.2.6.0" Ref="1" ControlType="DevExpress.XtraReports.UI.XtraReport, DevExpress.XtraReports.v22.2, Version=22.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Name="XtraReport" SnapGridSize="25" ReportUnit="TenthsOfAMillimeter" Margins="98, 103, 100.541664, 111.125153" PaperKind="A4" PageWidth="2100" PageHeight="2970" Version="22.2" DataMember="Emitente" DataSource="#Ref-0" Dpi="254"><Parameters><Item1 Ref="4" Description="Emitente" ValueSourceSettings="#Ref-2" ValueInfo="1" AllowNull="true" Name="idEmitente" Type="#Ref-3" /><Item2 Ref="6" Description="Considerar Fantasia" ValueInfo="False" Name="idnConsiderarFantasiaEmitente" Type="#Ref-5" /><Item3 Ref="9" Visible="false" Description="Período" ValueSourceSettings="#Ref-7" Name="periodo" Type="#Ref-8" /><Item4 Ref="10" Description="Código Ordem Carga" ValueInfo="7" Name="idOrdemCarga" Type="#Ref-3" /></Parameters><Bands><Item1 Ref="11" ControlType="TopMarginBand" Name="TopMargin" HeightF="100.541664" Dpi="254" /><Item2 Ref="12" ControlType="DetailBand" Name="Detail" HeightF="0" Dpi="254"><HierarchyPrintOptions Ref="13" Indent="50.8" /></Item2><Item3 Ref="14" ControlType="BottomMarginBand" Name="BottomMargin" HeightF="111.125153" Dpi="254" /><Item4 Ref="15" ControlType="DetailReportBand" Name="DetailReport" Level="0" DataMember="OCNFP" DataSource="#Ref-0" Dpi="254"><Bands><Item1 Ref="16" ControlType="DetailBand" Name="Detail1" HeightF="0" Dpi="254"><HierarchyPrintOptions Ref="17" Indent="50.8" /></Item1><Item2 Ref="18" ControlType="ReportHeaderBand" Name="ReportHeader1" HeightF="254" Dpi="254"><Controls><Item1 Ref="19" ControlType="XRTable" Name="table1" SizeF="1899,60.854248" LocationFloat="0,193.145752" Dpi="254" Padding="2,2,0,0,96"><Rows><Item1 Ref="20" ControlType="XRTableRow" Name="tableRow1" Weight="1" Dpi="254"><Cells><Item1 Ref="21" ControlType="XRTableCell" Name="tableCell1" Weight="2.1486529806549406" Multiline="true" Text="Produto" Dpi="254" /><Item2 Ref="22" ControlType="XRTableCell" Name="tableCell2" Weight="0.30891814992202765" Multiline="true" Text="Un. Medida" Dpi="254" /><Item3 Ref="23" ControlType="XRTableCell" Name="tableCell3" Weight="0.584754524070711" Multiline="true" Text="Quantidade" Dpi="254" /></Cells></Item1></Rows></Item1></Controls></Item2><Item3 Ref="24" ControlType="GroupFooterBand" Name="GroupFooter1" HeightF="60.854248" Dpi="254"><Controls><Item1 Ref="25" ControlType="XRTable" Name="table2" SizeF="1899,60.854248" LocationFloat="0,0" Dpi="254" Padding="2,2,0,0,96"><Rows><Item1 Ref="26" ControlType="XRTableRow" Name="tableRow2" Weight="1" Dpi="254"><Cells><Item1 Ref="27" ControlType="XRTableCell" Name="tableCell4" Weight="2.1486529806549406" Multiline="true" Text="Produto" Dpi="254"><ExpressionBindings><Item1 Ref="28" EventName="BeforePrint" PropertyName="Text" Expression="[OCNFP].[descricaoProd]" /></ExpressionBindings></Item1><Item2 Ref="29" ControlType="XRTableCell" Name="tableCell5" Weight="0.30891814992202765" Multiline="true" Text="Un. Medida" Dpi="254"><Summary Ref="30" Running="Group" /><ExpressionBindings><Item1 Ref="31" EventName="BeforePrint" PropertyName="Text" Expression="[OCNFP].[ucom]" /></ExpressionBindings></Item2><Item3 Ref="32" ControlType="XRTableCell" Name="tableCell6" Weight="0.584754524070711" TextFormatString="{0:N2}" Multiline="true" Text="Quantidade" Dpi="254"><Summary Ref="33" Running="Group" /><ExpressionBindings><Item1 Ref="34" EventName="BeforePrint" PropertyName="Text" Expression="sumSum([OCNFP].[qtde])" /></ExpressionBindings></Item3></Cells></Item1></Rows></Item1></Controls></Item3><Item4 Ref="35" ControlType="GroupHeaderBand" Name="GroupHeader1" HeightF="0" Dpi="254"><GroupFields><Item1 Ref="36" FieldName="descricaoProd" /><Item2 Ref="37" FieldName="ucom" /></GroupFields></Item4></Bands></Item4><Item5 Ref="38" ControlType="ReportHeaderBand" Name="ReportHeader" HeightF="254.000061" Dpi="254"><Controls><Item1 Ref="39" ControlType="XRLabel" Name="label4" Multiline="true" Text="Páginas:" SizeF="130.874634,58.42" LocationFloat="1647.29126,0" Dpi="254" Padding="5,5,0,0,254" /><Item2 Ref="40" ControlType="XRPageInfo" Name="pageInfo1" SizeF="97.9171143,58.42" LocationFloat="1778.16589,0" Dpi="254" Padding="5,5,0,0,254" /><Item3 Ref="41" ControlType="XRLabel" Name="label3" Multiline="true" Text="label3" SizeF="389.853638,58.42" LocationFloat="1257.43762,0" Dpi="254" Padding="5,5,0,0,254"><ExpressionBindings><Item1 Ref="42" EventName="BeforePrint" PropertyName="Text" Expression="''Data: '' + Now()" /></ExpressionBindings></Item3><Item4 Ref="43" ControlType="XRLabel" Name="label2" Multiline="true" Text="label2" SizeF="1605.3125,185.31424" LocationFloat="293.6875,68.6858139" Dpi="254" Padding="5,5,0,0,254"><ExpressionBindings><Item1 Ref="44" EventName="BeforePrint" PropertyName="Text" Expression="''Endereço:'' + [Emitente].[logradouro] + '', '' + [Emitente].[numero] + Iif(IsNullOrEmpty([Emitente].[complemento]),'''','' - '' + [Emitente].[complemento]) +  NewLine() +&#xA;''Bairro: '' + [Emitente].[bairro] + '' - CEP: '' + [Emitente].[cep] + NewLine() +&#xA;''Telefone: '' + [Emitente].[telefone] + Iif(IsNullOrEmpty([Emitente].[celular]), '''' ,'' / '' + [Emitente].[celular]) + NewLine() +&#xA;Iif(IsNullOrEmpty([Emitente].[email]),'''',''Email: '' + [Emitente].[email])" /></ExpressionBindings></Item4><Item5 Ref="45" ControlType="XRLabel" Name="label1" Multiline="true" Text="label1" SizeF="963.7501,58.42" LocationFloat="293.6875,0" Dpi="254" Padding="5,5,0,0,254"><ExpressionBindings><Item1 Ref="46" EventName="BeforePrint" PropertyName="Text" Expression="Iif(?idnConsiderarFantasiaEmitente, [Emitente].[fantasiaEmitente],[Emitente].[razaoEmitente] )" /></ExpressionBindings></Item5><Item6 Ref="47" ControlType="XRPictureBox" Name="pictureBox1" Sizing="ZoomImage" SizeF="254,254" LocationFloat="25.4000168,0" Dpi="254"><ExpressionBindings><Item1 Ref="48" EventName="BeforePrint" PropertyName="ImageSource" Expression="[Emitente].[logotipo]" /></ExpressionBindings></Item6></Controls></Item5><Item6 Ref="49" ControlType="DetailReportBand" Name="DetailReport1" Level="1" DataMember="OCNF" DataSource="#Ref-0" Dpi="254"><Bands><Item1 Ref="50" ControlType="DetailBand" Name="Detail2" HeightF="0" Dpi="254"><HierarchyPrintOptions Ref="51" Indent="50.8" /></Item1><Item2 Ref="52" ControlType="GroupHeaderBand" Name="GroupHeader2" HeightF="0" Dpi="254"><GroupFields><Item1 Ref="53" FieldName="destinatarioRazao" /></GroupFields></Item2><Item3 Ref="54" ControlType="GroupFooterBand" Name="GroupFooter2" HeightF="60.854248" Dpi="254"><Controls><Item1 Ref="55" ControlType="XRTable" Name="table4" SizeF="1899,60.854248" LocationFloat="0,0" Dpi="254" Padding="2,2,0,0,96"><Rows><Item1 Ref="56" ControlType="XRTableRow" Name="tableRow4" Weight="1" Dpi="254"><Cells><Item1 Ref="57" ControlType="XRTableCell" Name="tableCell8" Weight="2.1486529806549406" Multiline="true" Text="Destinatário" Dpi="254"><ExpressionBindings><Item1 Ref="58" EventName="BeforePrint" PropertyName="Text" Expression="[destinatarioRazao]" /></ExpressionBindings></Item1></Cells></Item1></Rows></Item1></Controls></Item3><Item4 Ref="59" ControlType="ReportHeaderBand" Name="ReportHeader2" HeightF="254" Dpi="254"><Controls><Item1 Ref="60" ControlType="XRTable" Name="table3" SizeF="1899,60.854248" LocationFloat="0,193.145676" Dpi="254" Padding="2,2,0,0,96"><Rows><Item1 Ref="61" ControlType="XRTableRow" Name="tableRow3" Weight="1" Dpi="254"><Cells><Item1 Ref="62" ControlType="XRTableCell" Name="tableCell7" Weight="2.1486529806549406" Multiline="true" Text="Destinatário" Dpi="254" /></Cells></Item1></Rows></Item1></Controls></Item4></Bands></Item6></Bands><ParameterPanelLayoutItems><Item1 Ref="63" LayoutItemType="Parameter" Parameter="#Ref-4" /><Item2 Ref="64" LayoutItemType="Parameter" Parameter="#Ref-6" /><Item3 Ref="65" LayoutItemType="Parameter" Parameter="#Ref-9" /><Item4 Ref="66" LayoutItemType="Parameter" Parameter="#Ref-10" /></ParameterPanelLayoutItems><ComponentStorage><Item1 Ref="0" ObjectType="DevExpress.DataAccess.Sql.SqlDataSource,DevExpress.DataAccess.v22.2" Name="sqlDataSource1" Base64=" " /></ComponentStorage><ObjectStorage><Item1 Ref="2" ObjectType="DevExpress.XtraReports.Parameters.DynamicListLookUpSettings, DevExpress.Printing.v22.2.Core" DataSource="#Ref-0" DataMember="Emitentes" ValueMember="id" DisplayMember="razaosocial" SortMember="id" SortOrder="Ascending" /><Item2 ObjectType="DevExpress.XtraReports.Serialization.ObjectStorageInfo, DevExpress.XtraReports.v22.2" Ref="3" Content="System.Int32" Type="System.Type" /><Item3 ObjectType="DevExpress.XtraReports.Serialization.ObjectStorageInfo, DevExpress.XtraReports.v22.2" Ref="5" Content="System.Boolean" Type="System.Type" /><Item4 Ref="7" ObjectType="DevExpress.XtraReports.Parameters.RangeParametersSettings, DevExpress.Printing.v22.2.Core" StartParameter="#Ref-67" EndParameter="#Ref-68" /><Item5 ObjectType="DevExpress.XtraReports.Serialization.ObjectStorageInfo, DevExpress.XtraReports.v22.2" Ref="8" Content="System.DateTime" Type="System.Type" /><Item6 Ref="67" ObjectType="DevExpress.XtraReports.Parameters.RangeStartParameter, DevExpress.Printing.v22.2.Core" ValueInfo="2025-08-15" Name="periodo_Start"><ExpressionBindings><Item1 Ref="69" PropertyName="Value" Expression="LocalDateTimeThisMonth()" /></ExpressionBindings></Item6><Item7 Ref="68" ObjectType="DevExpress.XtraReports.Parameters.RangeEndParameter, DevExpress.Printing.v22.2.Core" ValueInfo="2025-08-15" Name="periodo_End"><ExpressionBindings><Item1 Ref="70" PropertyName="Value" Expression="AddDays(LocalDateTimeNextMonth(),-1)" /></ExpressionBindings></Item7></ObjectStorage></XtraReportsLayoutSerializer>')
GO

INSERT INTO [dbo].[configuracaoNovo]
           ([nomeParametro]
           ,[descricaoSimplificada]
           ,[descricaoDetalhada]
           ,[tipoValor]
           ,[valor]
           ,[grupo]
           ,[subgrupo]
           ,[tamanhoValorMaximo]
           ,[idnParametroMultilinhas]
           ,[idnParametroRadio]
           ,[idnParametroSelecaoPasta]
           ,[idnPermiteAlteracaoApenasPorAdmins]
           ,[idnCampoSenha]
           ,[tabelaSelecao]
           ,[filtroSelecao]
           ,[validacaoRegularExpression]
		   ,[idnPermiteSelecaoMultiplaOpcoes])
     VALUES
           ('idnCadastrarProdutosSistemaOrdemCargaCte'
           ,'Cadastrar Produtos da Ordem de Carga de CTe'
           ,''
           ,'bool'
           ,null
           ,'Ordem de Carga'
           ,'Ordem de Carga - CTe'
           ,NULL
           ,0
           ,0
           ,0
           ,0
           ,0
           ,null
           ,null
           ,nULL
		   ,null)
GO
SET IDENTITY_INSERT [dbo].[TELAS] ON 
GO
insert into Telas ([id], [descricao], [controle], [idnPermiteAbrirVarias], [idnRestricaoAcesso], [idnBloquearAcessoPlanoBasico]) values (447,'Monitoramento Ordem de Carga','Cadastros.ucConsCteOrdemCarga, Cadastros, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null',0,0,1)
GO
insert into Telas ([id], [descricao], [controle], [idnPermiteAbrirVarias], [idnRestricaoAcesso], [idnBloquearAcessoPlanoBasico]) values (448,'Cadastrar Ordem de Carga','Cadastros.ucCadCTeOrdemCarga, Cadastros, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null',0,0,1)
GO
SET IDENTITY_INSERT [dbo].[TELAS] OFF
GO
SET IDENTITY_INSERT [dbo].[MenuItens] ON 
GO
insert into MenuItens ([id],[idMenu],[descricao],[idTela],[idMenuItemPai],[ordem],[idnVisivel]) values (545,2,'Monitoramento - Ordem de Carga', 447,164,9,1)
GO
insert into MenuItens ([id],[idMenu],[descricao],[idTela],[idMenuItemPai],[ordem],[idnVisivel]) values (546,1,'Monitoramento - Ordem de Carga', 447,22,13,1)
GO
SET IDENTITY_INSERT [dbo].[MenuItens] OFF 
GO
IF OBJECT_ID('dbo.RelacaoUltVendasParceiroPorFilial', 'TF') IS NOT NULL
	DROP FUNCTION dbo.RelacaoUltVendasParceiroPorFilial;
GO
CREATE FUNCTION [dbo].[RelacaoUltVendasParceiroPorFilial]
(
	@idnPedidoInf bit,
	@idnVendasInf bit

)
RETURNS @Resultado TABLE
(
	rzsocialEmitente varchar(200),
	idEmitente int,
	rzsocial varchar(200),
	parceiro_id int,
	nomeFantasia varchar(200),
	data_Emissao datetime,
	valorTotal decimal(18,4),
	contadorLinhas int,
	idNotaFiscal int,
	cidade varchar(500),
	estado varchar(100),
	telefone varchar(25),
	vendedor varchar(500),
	representante varchar(500),
	telefoneRepresentante varchar(25)
)
AS
BEGIN
	declare @idnPedido bit = 0
	declare @idnVendas bit = 0
	if(@idnPedidoInf > 0)
		set @idnPedido = @idnPedidoInf

	if(@idnVendasInf > 0)
		set @idnvendas = @idnVendasInf
	if(@idnVendas > 0)
		BEGIN
			insert into @Resultado select nfe.razaosocial, nfe.idemitente, nfd.razaosocial, nfd.idParceiro, nfd.fantasia,
			nf.dataEmissao, nft.icmstotalnota,
			ROW_NUMBER() OVER (PARTITION BY nfd.idParceiro, nfe.idEmitente ORDER BY nf.dataEmissao DESC) AS rn,
			nf.id, ci.descricao, ci.uf, pa.telefone, pv.razaosocial, pr.razaosocial, pr.telefone
			from notafiscal nf
			inner join nfDestinatario nfd on nfd.idNotaFiscal = nf.id
			inner join NFTotal nft on nft.idNotaFiscal = nf.id
			inner join parceiro pa on pa.id = nfd.idParceiro
			inner join cidade ci on ci.id = pa.idCidade
			inner join nfEmitente nfe on nfe.idNotaFiscal = nf.id
			left join parceiro pv on pv.id = nf.idVendedor
			left join parceiro pr on pr.id = nf.idRepresentante
			where (nf.idnCancelada is null or nf.idnCancelada = 0)
		END
	IF(@idnPedido > 0)
		BEGIN
			insert into @Resultado select em.razaosocial, em.id,pa.razaosocial, pe.idParceiro, pa.fantasia, pe.dataPedido, pe.valorPedido, 
			ROW_NUMBER() OVER (PARTITION BY pe.idParceiro, em.id ORDER BY pe.dataPedido DESC) AS rn,
			pe.id, ci.descricao, ci.uf, pa.telefone, pv.razaosocial, pr.razaosocial, pr.telefone
			from pedido pe
			inner join pedidoProduto pp on pp.idPedido = pe.id
			inner join parceiro pa on pa.id = pe.idParceiro
			inner join cidade ci on ci.id = pa.idCidade
			inner join emitente em on em.id = pe.idEmitente
			left join parceiro pv on pv.id = pe.idParceiroVendedor
			left join parceiro pr on pr.id = pe.idRepresentante
			where (pe.idnCancelado is null or pe.idnCancelado = 0)
		END
RETURN
END
GO
INSERT [dbo].[Dashboard] ([descricao], [idDashboardGrupo], [xml]) VALUES (N'Relação de Ultimas Vendas por Parceiro Por Filial', 1, N'<Dashboard CurrencyCulture="pt-BR"><Title Text="Dashboard" /><DataSources><SqlDataSource Name="Fonte de dados SQL 1" ComponentName="dashboardSqlDataSource1"><Connection Name="localhost_Weirich_Connection" ProviderKey="MSSqlServer"><Parameters><Parameter Name="server" Value="localhost\sql2022" /><Parameter Name="database" Value="NASERVICO" /><Parameter Name="useIntegratedSecurity" Value="True" /><Parameter Name="read only" Value="1" /><Parameter Name="generateConnectionHelper" Value="false" /><Parameter Name="userid" Value="" /><Parameter Name="password" Value="" /></Parameters></Connection><Query Type="CustomSqlQuery" Name="Query"><Parameter Name="idnPedidoInf" Type="DevExpress.DataAccess.Expression">(System.Int32)(?idnPedido)</Parameter><Parameter Name="idnVendasInf" Type="DevExpress.DataAccess.Expression">(System.Int32)(?idnVendas)</Parameter><Sql>select re.*, nf.tipoDocumento from RelacaoUltVendasParceiroPorFilial(@idnPedidoInf,@idnVendasInf) re
left join notafiscal nf on nf.id = re.idnotafiscal
left join operacao op on op.id = nf.idoperacao
where (nf.nfecstat in (100,150))
and (nf.nfeTpAmb &lt;&gt; 2)
and (op.idnCompraVenda = 1)
</Sql></Query><Query Type="CustomSqlQuery" Name="Query_1"><Sql>select "NFProduto"."idNotaFiscal", "NFProduto"."idProduto",
       "NFProduto"."descricao", "NFProduto"."ucom",
       "NFProduto"."qcom", "NFProduto"."vuncom", "NFProduto"."vprod",
       coalesce("NFProduto"."vfrete",0) as vfrete, coalesce("NFProduto"."vseg",0) as vseg, coalesce("NFProduto"."vdesc",0) as vdesc,
       coalesce("NFProduto"."voutro",0) as voutro
  from "dbo"."NFProduto" "NFProduto"
inner join notafiscal nf on nf.id = "NFProduto"."idnotafiscal"
inner join operacao op on op.id = nf.idoperacao
where (nf.nfecstat in (100,150))
and (nf.nfeTpAmb &lt;&gt; 2)
and (op.idnCompraVenda = 1)
</Sql></Query><Query Type="CustomSqlQuery" Name="Query_2"><Sql>select nt.icmstotalnota, nfd.razaosocial as rzsocial, nfe.razaosocial as rzsocialEmitente
from notafiscal nf
inner join nftotal nt on nt.idnotafiscal = nf.id
inner join nfemitente nfe on nfe.idnotafiscal = nf.id
inner join nfdestinatario nfd on nfd.idnotafiscal = nf.id
inner join operacao op on op.id = nf.idoperacao
where (nf.nfecstat in (100,150))
and (nf.nfeTpAmb &lt;&gt; 2)
and (op.idnCompraVenda = 1)</Sql></Query><ResultSchema><DataSet Name="Fonte de dados SQL 1"><View Name="Query"><Field Name="rzsocialEmitente" Type="String" /><Field Name="rzsocial" Type="String" /><Field Name="parceiro_id" Type="Int32" /><Field Name="nomeFantasia" Type="String" /><Field Name="data_Emissao" Type="DateTime" /><Field Name="valorTotal" Type="Decimal" /><Field Name="contadorLinhas" Type="Int32" /><Field Name="idNotaFiscal" Type="Int32" /><Field Name="cidade" Type="String" /><Field Name="estado" Type="String" /><Field Name="telefone" Type="String" /><Field Name="vendedor" Type="String" /><Field Name="representante" Type="String" /><Field Name="telefoneRepresentante" Type="String" /><Field Name="tipoDocumento" Type="Int32" /></View><View Name="Query_1"><Field Name="idNotaFiscal" Type="Int32" /><Field Name="idProduto" Type="Int32" /><Field Name="descricao" Type="String" /><Field Name="ucom" Type="String" /><Field Name="qcom" Type="Decimal" /><Field Name="vuncom" Type="Decimal" /><Field Name="vprod" Type="Decimal" /><Field Name="vfrete" Type="Decimal" /><Field Name="vseg" Type="Decimal" /><Field Name="vdesc" Type="Decimal" /><Field Name="voutro" Type="Decimal" /></View><View Name="Query_2"><Field Name="icmstotalnota" Type="Decimal" /><Field Name="rzsocial" Type="String" /><Field Name="rzsocialEmitente" Type="String" /></View></DataSet></ResultSchema><ConnectionOptions CloseConnection="true" DbCommandTimeout="2500" /><CalculatedFields><CalculatedField Name="valorTotalFInal" Expression="[vprod]+[voutro]+[vfrete]+[vseg]-[vdesc]" DataType="Auto" DataMember="Query_1" /><CalculatedField Name="EntradaSaida" Expression="Iif([tipoDocumento] == 0, ''Entrada'' , ''Saida'')" DataType="Auto" DataMember="Query" /></CalculatedFields></SqlDataSource></DataSources><Parameters><Parameter Name="idnPedido" Type="System.Boolean" Value="false" Description="Pedidos" /><Parameter Name="idnVendas" Type="System.Boolean" Value="true" Description="Vendas" /></Parameters><Items><Grid ComponentName="gridDashboardItem1" Name="Relação de Ultimas Vendas por Parceiro" DataSource="dashboardSqlDataSource1" DataMember="Query" FilterString="[DataItem5] = 1" IsMasterFilterCrossDataSource="true"><InteractivityOptions MasterFilterMode="Multiple" /><DataItems><Dimension DataMember="rzsocial" DefaultId="DataItem1" /><Dimension DataMember="data_Emissao" DateTimeGroupInterval="DayMonthYear" DefaultId="DataItem3" /><Dimension DataMember="parceiro_id" DefaultId="DataItem4"><NumericFormat FormatType="Number" Precision="0" Unit="Ones" /></Dimension><Dimension DataMember="valorTotal" DefaultId="DataItem2"><NumericFormat FormatType="Currency" Unit="Ones" /></Dimension><Dimension DataMember="idNotaFiscal" DefaultId="DataItem0"><NumericFormat FormatType="Number" Precision="0" Unit="Ones" /></Dimension><Dimension DataMember="contadorLinhas" DefaultId="DataItem5" /><Dimension DataMember="vendedor" DefaultId="DataItem6" /><Dimension DataMember="telefone" DefaultId="DataItem7" /><Dimension DataMember="representante" DefaultId="DataItem8" /><Dimension DataMember="telefoneRepresentante" DefaultId="DataItem9" /></DataItems><HiddenDimensions><Dimension DefaultId="DataItem5" /></HiddenDimensions><GridColumns><GridDimensionColumn Name="Código Nota Fiscal"><Dimension DefaultId="DataItem0" /></GridDimensionColumn><GridDimensionColumn Name="Data Emissão"><Dimension DefaultId="DataItem3" /></GridDimensionColumn><GridDimensionColumn Name="Código Parceiro"><Dimension DefaultId="DataItem4" /></GridDimensionColumn><GridDimensionColumn Name="Razão Social"><Dimension DefaultId="DataItem1" /></GridDimensionColumn><GridDimensionColumn Name="Valor Total"><Dimension DefaultId="DataItem2" /></GridDimensionColumn><GridDimensionColumn Name="Vendedor"><Dimension DefaultId="DataItem6" /></GridDimensionColumn><GridDimensionColumn Name="Telefone Vendedor"><Dimension DefaultId="DataItem7" /></GridDimensionColumn><GridDimensionColumn Name="Representante"><Dimension DefaultId="DataItem8" /></GridDimensionColumn><GridDimensionColumn Name="Telefone Representante"><Dimension DefaultId="DataItem9" /></GridDimensionColumn></GridColumns><GridOptions /><ColumnFilterOptions /></Grid><ComboBox ComponentName="comboBoxDashboardItem1" Name="Filtro de Parceiros (Código / Razão Social)" DataSource="dashboardSqlDataSource1" DataMember="Query" IsMasterFilterCrossDataSource="true" EnableSearch="true" ComboBoxType="Checked"><DataItems><Dimension DataMember="parceiro_id" DefaultId="DataItem0" /><Dimension DataMember="rzsocial" DefaultId="DataItem1" /></DataItems><FilterDimensions><Dimension DefaultId="DataItem0" /><Dimension DefaultId="DataItem1" /></FilterDimensions></ComboBox><Grid ComponentName="gridDashboardItem2" Name="Relação de Produtos" DataSource="dashboardSqlDataSource1" DataMember="Query_1"><InteractivityOptions MasterFilterMode="Multiple" /><DataItems><Dimension DataMember="descricao" DefaultId="DataItem2" /><Dimension DataMember="ucom" DefaultId="DataItem3" /><Dimension DataMember="idNotaFiscal" DefaultId="DataItem0"><NumericFormat FormatType="Number" Precision="0" Unit="Ones" /></Dimension><Dimension DataMember="idProduto" DefaultId="DataItem1"><NumericFormat FormatType="Number" Precision="0" Unit="Ones" /></Dimension><Dimension DataMember="qcom" DefaultId="DataItem4"><NumericFormat FormatType="Number" Unit="Ones" /></Dimension><Dimension DataMember="vuncom" DefaultId="DataItem5"><NumericFormat FormatType="Currency" Unit="Ones" /></Dimension><Dimension DataMember="valorTotalFInal" DefaultId="DataItem6"><NumericFormat FormatType="Currency" Unit="Ones" /></Dimension></DataItems><GridColumns><GridDimensionColumn Name="Código Nota Fiscal"><Dimension DefaultId="DataItem0" /></GridDimensionColumn><GridDimensionColumn Name="Código Produto"><Dimension DefaultId="DataItem1" /></GridDimensionColumn><GridDimensionColumn Name="Descrição"><Dimension DefaultId="DataItem2" /></GridDimensionColumn><GridDimensionColumn Name="Un. Com."><Dimension DefaultId="DataItem3" /></GridDimensionColumn><GridDimensionColumn Name="Quantidade"><Dimension DefaultId="DataItem4" /></GridDimensionColumn><GridDimensionColumn Name="Valor Un."><Dimension DefaultId="DataItem5" /></GridDimensionColumn><GridDimensionColumn Name="Valor Total"><Dimension DefaultId="DataItem6" /></GridDimensionColumn></GridColumns><GridOptions /><ColumnFilterOptions /></Grid><ComboBox ComponentName="comboBoxDashboardItem2" Name="Filtro de Cidades" DataSource="dashboardSqlDataSource1" DataMember="Query" IsMasterFilterCrossDataSource="true" EnableSearch="true" ComboBoxType="Checked"><DataItems><Dimension DataMember="cidade" DefaultId="DataItem0" /></DataItems><FilterDimensions><Dimension DefaultId="DataItem0" /></FilterDimensions></ComboBox><ComboBox ComponentName="comboBoxDashboardItem3" Name="Filtro de Estados" DataSource="dashboardSqlDataSource1" DataMember="Query" IsMasterFilterCrossDataSource="true" EnableSearch="true" ComboBoxType="Checked"><DataItems><Dimension DataMember="estado" DefaultId="DataItem0" /></DataItems><FilterDimensions><Dimension DefaultId="DataItem0" /></FilterDimensions></ComboBox><RangeFilter ComponentName="rangeFilterDashboardItem1" Name="Filtro de Data" ShowCaption="true" DataSource="dashboardSqlDataSource1" DataMember="Query" SelectedDateTimePeriodIndex="Últimos 30 Dias"><DataItems><Measure DataMember="valorTotal" DefaultId="DataItem0" /><Dimension DataMember="data_Emissao" DateTimeGroupInterval="DayMonthYear" DefaultId="DataItem1" /></DataItems><Argument DefaultId="DataItem1" /><Series><Simple SeriesType="Line"><Value DefaultId="DataItem0" /></Simple></Series><DateTimePeriods><DateTimePeriod Name="Últimos 30 Dias"><StartLimit><FlowDateTimePeriodLimit Interval="Day" Offset="-30" /></StartLimit><EndLimit><FlowDateTimePeriodLimit Interval="Day" /></EndLimit></DateTimePeriod><DateTimePeriod Name="Entre 1 ano e 5 anos atrás"><StartLimit><FlowDateTimePeriodLimit Offset="-1" /></StartLimit><EndLimit><FlowDateTimePeriodLimit Offset="-5" /></EndLimit></DateTimePeriod><DateTimePeriod Name="Entre 6 meses e 12 meses atrás"><StartLimit><FlowDateTimePeriodLimit Interval="Month" Offset="-6" /></StartLimit><EndLimit><FlowDateTimePeriodLimit Interval="Month" Offset="-12" /></EndLimit></DateTimePeriod><DateTimePeriod Name="Entre 3 meses e 9 meses atrás"><StartLimit><FlowDateTimePeriodLimit Interval="Month" Offset="-3" /></StartLimit><EndLimit><FlowDateTimePeriodLimit Interval="Month" Offset="-9" /></EndLimit></DateTimePeriod><DateTimePeriod Name="Este Ano"><StartLimit><FlowDateTimePeriodLimit /></StartLimit><EndLimit><FlowDateTimePeriodLimit Offset="1" /></EndLimit></DateTimePeriod></DateTimePeriods></RangeFilter><Gauge ComponentName="gaugeDashboardItem1" Name="Total de Vendas" DataSource="dashboardSqlDataSource1" DataMember="Query"><DataItems><Measure DataMember="valorTotal" DefaultId="DataItem0"><NumericFormat FormatType="Currency" Unit="Ones" IncludeGroupSeparator="true" CustomFormatString="" /></Measure></DataItems><GaugeElement Name="Valor Total"><ActualValue DefaultId="DataItem0" /><AbsoluteVariationNumericFormat /><PercentVariationNumericFormat /><PercentOfTargetNumericFormat /></GaugeElement></Gauge><Gauge ComponentName="gaugeDashboardItem2" Name="Total de Produtos" DataSource="dashboardSqlDataSource1" DataMember="Query_1"><DataItems><Measure DataMember="valorTotalFInal" DefaultId="DataItem0"><NumericFormat FormatType="Currency" Unit="Ones" IncludeGroupSeparator="true" CustomFormatString="" /></Measure></DataItems><GaugeElement Name="Valor Total dos Produtos Vendidos"><ActualValue DefaultId="DataItem0" /><AbsoluteVariationNumericFormat /><PercentVariationNumericFormat /><PercentOfTargetNumericFormat /></GaugeElement></Gauge><ComboBox ComponentName="comboBoxDashboardItem4" Name="Tipo Documento (E/S)" DataSource="dashboardSqlDataSource1" DataMember="Query" IsMasterFilterCrossDataSource="true" EnableSearch="true" ComboBoxType="Checked"><DataItems><Dimension DataMember="EntradaSaida" DefaultId="DataItem1" /></DataItems><FilterDimensions><Dimension DefaultId="DataItem1" /></FilterDimensions></ComboBox><ComboBox ComponentName="comboBoxDashboardItem5" Name="Filial" DataSource="dashboardSqlDataSource1" DataMember="Query"><DataItems><Dimension DataMember="rzsocialEmitente" DefaultId="DataItem0" /></DataItems><FilterDimensions><Dimension DefaultId="DataItem0" /></FilterDimensions></ComboBox><Gauge ComponentName="gaugeDashboardItem3" Name="Total Vendas Cliente" DataSource="dashboardSqlDataSource1" DataMember="Query_2"><DataItems><Measure DataMember="icmstotalnota" DefaultId="DataItem0"><NumericFormat FormatType="Currency" Unit="Ones" IncludeGroupSeparator="true" /></Measure></DataItems><GaugeElement Name="Valor Vendido"><TargetValue DefaultId="DataItem0" /><AbsoluteVariationNumericFormat /><PercentVariationNumericFormat /><PercentOfTargetNumericFormat /></GaugeElement></Gauge><Gauge ComponentName="gaugeDashboardItem4" Name="Quantidade Vendas Cliente" DataSource="dashboardSqlDataSource1" DataMember="Query_2"><DataItems><Measure DataMember="icmstotalnota" SummaryType="Count" DefaultId="DataItem0"><NumericFormat FormatType="Number" Precision="0" Unit="Ones" /></Measure></DataItems><GaugeElement Name="Quantidade Vendida"><TargetValue DefaultId="DataItem0" /><AbsoluteVariationNumericFormat /><PercentVariationNumericFormat /><PercentOfTargetNumericFormat /></GaugeElement></Gauge></Items><LayoutTree><LayoutGroup Orientation="Vertical" Weight="100"><LayoutItem DashboardItem="rangeFilterDashboardItem1" Weight="12.154031287605294" /><LayoutGroup Weight="7.3405535499398313"><LayoutItem DashboardItem="comboBoxDashboardItem1" Weight="33.1578947368421" /><LayoutItem DashboardItem="comboBoxDashboardItem5" Weight="14.868421052631579" /><LayoutItem DashboardItem="comboBoxDashboardItem4" Weight="15.657894736842104" /><LayoutItem DashboardItem="comboBoxDashboardItem2" Weight="18.355263157894736" /><LayoutItem DashboardItem="comboBoxDashboardItem3" Weight="17.960526315789473" /></LayoutGroup><LayoutGroup Weight="44.04332129963899"><LayoutItem DashboardItem="gridDashboardItem1" Weight="50" /><LayoutItem DashboardItem="gridDashboardItem2" Weight="50" /></LayoutGroup><LayoutGroup Weight="36.462093862815884"><LayoutItem DashboardItem="gaugeDashboardItem1" Weight="25.723684210526315" /><LayoutItem DashboardItem="gaugeDashboardItem2" Weight="24.276315789473685" /><LayoutItem DashboardItem="gaugeDashboardItem3" Weight="27.763157894736842" /><LayoutItem DashboardItem="gaugeDashboardItem4" Weight="22.236842105263158" /></LayoutGroup></LayoutGroup></LayoutTree></Dashboard>')
GO
INSERT [dbo].[Dashboard] ([descricao], [idDashboardGrupo], [xml]) VALUES (N'Relação de ultimas vendas por parceiro', 1, N'<Dashboard CurrencyCulture="pt-BR"><Title Text="Dashboard" /><DataSources><SqlDataSource Name="Fonte de dados SQL 1" ComponentName="dashboardSqlDataSource1"><Connection Name="localhost_Weirich_Connection" ProviderKey="MSSqlServer"><Parameters><Parameter Name="server" Value="187.73.187.252,5003" /><Parameter Name="database" Value="TryNFeOnline" /><Parameter Name="useIntegratedSecurity" Value="False" /><Parameter Name="read only" Value="1" /><Parameter Name="generateConnectionHelper" Value="false" /><Parameter Name="userid" Value="" /><Parameter Name="password" Value="" /></Parameters></Connection><Query Type="CustomSqlQuery" Name="Query"><Parameter Name="idnPedidoInf" Type="DevExpress.DataAccess.Expression">(System.Int32)(?idnPedido)</Parameter><Parameter Name="idnVendasInf" Type="DevExpress.DataAccess.Expression">(System.Int32)(?idnVendas)</Parameter><Sql>select re.*, nf.tipoDocumento from RelacaoUltVendasParceiro(@idnPedidoInf,@idnVendasInf) re
left join notafiscal nf on nf.id = re.idnotafiscal
where nf.nfecstat in (100,150)
</Sql></Query><Query Type="CustomSqlQuery" Name="Query_1"><Sql>select "NFProduto"."idNotaFiscal", "NFProduto"."idProduto",
       "NFProduto"."descricao", "NFProduto"."ucom",
       "NFProduto"."qcom", "NFProduto"."vuncom", "NFProduto"."vprod",
       coalesce("NFProduto"."vfrete",0) as vfrete, coalesce("NFProduto"."vseg",0) as vseg, coalesce("NFProduto"."vdesc",0) as vdesc,
       coalesce("NFProduto"."voutro",0) as voutro
  from "dbo"."NFProduto" "NFProduto"</Sql></Query><ResultSchema><DataSet Name="Fonte de dados SQL 1"><View Name="Query"><Field Name="rzsocial" Type="String" /><Field Name="parceiro_id" Type="Int32" /><Field Name="nomeFantasia" Type="String" /><Field Name="data_Emissao" Type="DateTime" /><Field Name="valorTotal" Type="Decimal" /><Field Name="contadorLinhas" Type="Int32" /><Field Name="idNotaFiscal" Type="Int32" /><Field Name="cidade" Type="String" /><Field Name="estado" Type="String" /><Field Name="telefone" Type="String" /><Field Name="vendedor" Type="String" /><Field Name="representante" Type="String" /><Field Name="telefoneRepresentante" Type="String" /><Field Name="tipoDocumento" Type="Int32" /></View><View Name="Query_1"><Field Name="idNotaFiscal" Type="Int32" /><Field Name="idProduto" Type="Int32" /><Field Name="descricao" Type="String" /><Field Name="ucom" Type="String" /><Field Name="qcom" Type="Decimal" /><Field Name="vuncom" Type="Decimal" /><Field Name="vprod" Type="Decimal" /><Field Name="vfrete" Type="Decimal" /><Field Name="vseg" Type="Decimal" /><Field Name="vdesc" Type="Decimal" /><Field Name="voutro" Type="Decimal" /></View></DataSet></ResultSchema><ConnectionOptions CloseConnection="true" DbCommandTimeout="2500" /><CalculatedFields><CalculatedField Name="valorTotalFInal" Expression="[vprod]+[voutro]+[vfrete]+[vseg]-[vdesc]" DataType="Auto" DataMember="Query_1" /><CalculatedField Name="EntradaSaida" Expression="Iif([tipoDocumento] == 0, ''Entrada'' , ''Saida'')" DataType="Auto" DataMember="Query" /></CalculatedFields></SqlDataSource></DataSources><Parameters><Parameter Name="idnPedido" Type="System.Boolean" Value="false" Description="Pedidos" /><Parameter Name="idnVendas" Type="System.Boolean" Value="true" Description="Vendas" /></Parameters><Items><Grid ComponentName="gridDashboardItem1" Name="Relação de Ultimas Vendas por Parceiro" DataSource="dashboardSqlDataSource1" DataMember="Query" FilterString="[DataItem5] = 1" IsMasterFilterCrossDataSource="true"><InteractivityOptions MasterFilterMode="Multiple" /><DataItems><Dimension DataMember="rzsocial" DefaultId="DataItem1" /><Dimension DataMember="data_Emissao" DateTimeGroupInterval="DayMonthYear" DefaultId="DataItem3" /><Dimension DataMember="parceiro_id" DefaultId="DataItem4"><NumericFormat FormatType="Number" Precision="0" Unit="Ones" /></Dimension><Dimension DataMember="valorTotal" DefaultId="DataItem2"><NumericFormat FormatType="Currency" Unit="Ones" /></Dimension><Dimension DataMember="idNotaFiscal" DefaultId="DataItem0"><NumericFormat FormatType="Number" Precision="0" Unit="Ones" /></Dimension><Dimension DataMember="contadorLinhas" DefaultId="DataItem5" /><Dimension DataMember="vendedor" DefaultId="DataItem6" /><Dimension DataMember="telefone" DefaultId="DataItem7" /><Dimension DataMember="representante" DefaultId="DataItem8" /><Dimension DataMember="telefoneRepresentante" DefaultId="DataItem9" /></DataItems><HiddenDimensions><Dimension DefaultId="DataItem5" /></HiddenDimensions><GridColumns><GridDimensionColumn Name="Código Nota Fiscal"><Dimension DefaultId="DataItem0" /></GridDimensionColumn><GridDimensionColumn Name="Data Emissão"><Dimension DefaultId="DataItem3" /></GridDimensionColumn><GridDimensionColumn Name="Código Parceiro"><Dimension DefaultId="DataItem4" /></GridDimensionColumn><GridDimensionColumn Name="Razão Social"><Dimension DefaultId="DataItem1" /></GridDimensionColumn><GridDimensionColumn Name="Valor Total"><Dimension DefaultId="DataItem2" /></GridDimensionColumn><GridDimensionColumn Name="Vendedor"><Dimension DefaultId="DataItem6" /></GridDimensionColumn><GridDimensionColumn Name="Telefone Vendedor"><Dimension DefaultId="DataItem7" /></GridDimensionColumn><GridDimensionColumn Name="Representante"><Dimension DefaultId="DataItem8" /></GridDimensionColumn><GridDimensionColumn Name="Telefone Representante"><Dimension DefaultId="DataItem9" /></GridDimensionColumn></GridColumns><GridOptions /><ColumnFilterOptions /></Grid><ComboBox ComponentName="comboBoxDashboardItem1" Name="Filtro de Parceiros (Código / Razão Social)" DataSource="dashboardSqlDataSource1" DataMember="Query" IsMasterFilterCrossDataSource="true" EnableSearch="true" ComboBoxType="Checked"><DataItems><Dimension DataMember="parceiro_id" DefaultId="DataItem0" /><Dimension DataMember="rzsocial" DefaultId="DataItem1" /></DataItems><FilterDimensions><Dimension DefaultId="DataItem0" /><Dimension DefaultId="DataItem1" /></FilterDimensions></ComboBox><Grid ComponentName="gridDashboardItem2" Name="Relação de Produtos" DataSource="dashboardSqlDataSource1" DataMember="Query_1"><InteractivityOptions MasterFilterMode="Multiple" /><DataItems><Dimension DataMember="descricao" DefaultId="DataItem2" /><Dimension DataMember="ucom" DefaultId="DataItem3" /><Dimension DataMember="idNotaFiscal" DefaultId="DataItem0"><NumericFormat FormatType="Number" Precision="0" Unit="Ones" /></Dimension><Dimension DataMember="idProduto" DefaultId="DataItem1" /><Dimension DataMember="qcom" DefaultId="DataItem4"><NumericFormat FormatType="Number" Unit="Ones" /></Dimension><Dimension DataMember="vuncom" DefaultId="DataItem5"><NumericFormat FormatType="Currency" Unit="Ones" /></Dimension><Dimension DataMember="valorTotalFInal" DefaultId="DataItem6"><NumericFormat FormatType="Currency" Unit="Ones" /></Dimension></DataItems><GridColumns><GridDimensionColumn Name="Código Nota Fiscal"><Dimension DefaultId="DataItem0" /></GridDimensionColumn><GridDimensionColumn Name="Código Produto"><Dimension DefaultId="DataItem1" /></GridDimensionColumn><GridDimensionColumn Name="Descrição"><Dimension DefaultId="DataItem2" /></GridDimensionColumn><GridDimensionColumn Name="Un. Com."><Dimension DefaultId="DataItem3" /></GridDimensionColumn><GridDimensionColumn Name="Quantidade"><Dimension DefaultId="DataItem4" /></GridDimensionColumn><GridDimensionColumn Name="Valor Un."><Dimension DefaultId="DataItem5" /></GridDimensionColumn><GridDimensionColumn Name="Valor Total"><Dimension DefaultId="DataItem6" /></GridDimensionColumn></GridColumns><GridOptions /><ColumnFilterOptions /></Grid><ComboBox ComponentName="comboBoxDashboardItem2" Name="Filtro de Cidades" DataSource="dashboardSqlDataSource1" DataMember="Query" IsMasterFilterCrossDataSource="true" EnableSearch="true" ComboBoxType="Checked"><DataItems><Dimension DataMember="cidade" DefaultId="DataItem0" /></DataItems><FilterDimensions><Dimension DefaultId="DataItem0" /></FilterDimensions></ComboBox><ComboBox ComponentName="comboBoxDashboardItem3" Name="Filtro de Estados" DataSource="dashboardSqlDataSource1" DataMember="Query" IsMasterFilterCrossDataSource="true" EnableSearch="true" ComboBoxType="Checked"><DataItems><Dimension DataMember="estado" DefaultId="DataItem0" /></DataItems><FilterDimensions><Dimension DefaultId="DataItem0" /></FilterDimensions></ComboBox><RangeFilter ComponentName="rangeFilterDashboardItem1" Name="Filtro de Data" ShowCaption="true" DataSource="dashboardSqlDataSource1" DataMember="Query" SelectedDateTimePeriodIndex="Últimos 30 Dias"><DataItems><Measure DataMember="valorTotal" DefaultId="DataItem0" /><Dimension DataMember="data_Emissao" DateTimeGroupInterval="DayMonthYear" DefaultId="DataItem1" /></DataItems><Argument DefaultId="DataItem1" /><Series><Simple SeriesType="Line"><Value DefaultId="DataItem0" /></Simple></Series><DateTimePeriods><DateTimePeriod Name="Últimos 30 Dias"><StartLimit><FlowDateTimePeriodLimit Interval="Day" Offset="-30" /></StartLimit><EndLimit><FlowDateTimePeriodLimit Interval="Day" /></EndLimit></DateTimePeriod><DateTimePeriod Name="Entre 1 ano e 5 anos atrás"><StartLimit><FlowDateTimePeriodLimit Offset="-1" /></StartLimit><EndLimit><FlowDateTimePeriodLimit Offset="-5" /></EndLimit></DateTimePeriod><DateTimePeriod Name="Entre 6 meses e 12 meses atrás"><StartLimit><FlowDateTimePeriodLimit Interval="Month" Offset="-6" /></StartLimit><EndLimit><FlowDateTimePeriodLimit Interval="Month" Offset="-12" /></EndLimit></DateTimePeriod><DateTimePeriod Name="Entre 3 meses e 9 meses atrás"><StartLimit><FlowDateTimePeriodLimit Interval="Month" Offset="-3" /></StartLimit><EndLimit><FlowDateTimePeriodLimit Interval="Month" Offset="-9" /></EndLimit></DateTimePeriod></DateTimePeriods></RangeFilter><Gauge ComponentName="gaugeDashboardItem1" Name="Total de Vendas" DataSource="dashboardSqlDataSource1" DataMember="Query"><DataItems><Measure DataMember="valorTotal" DefaultId="DataItem0"><NumericFormat FormatType="Currency" Unit="Ones" /></Measure></DataItems><GaugeElement Name="Valor Total"><ActualValue DefaultId="DataItem0" /><AbsoluteVariationNumericFormat /><PercentVariationNumericFormat /><PercentOfTargetNumericFormat /></GaugeElement></Gauge><Gauge ComponentName="gaugeDashboardItem2" Name="Total de Produtos" DataSource="dashboardSqlDataSource1" DataMember="Query_1"><DataItems><Measure DataMember="valorTotalFInal" DefaultId="DataItem0"><NumericFormat FormatType="Currency" Unit="Ones" /></Measure></DataItems><GaugeElement Name="Valor Total dos Produtos Vendidos"><ActualValue DefaultId="DataItem0" /><AbsoluteVariationNumericFormat /><PercentVariationNumericFormat /><PercentOfTargetNumericFormat /></GaugeElement></Gauge><ComboBox ComponentName="comboBoxDashboardItem4" Name="Tipo Documento (E/S)" DataSource="dashboardSqlDataSource1" DataMember="Query" IsMasterFilterCrossDataSource="true" EnableSearch="true" ComboBoxType="Checked"><DataItems><Dimension DataMember="EntradaSaida" DefaultId="DataItem1" /></DataItems><FilterDimensions><Dimension DefaultId="DataItem1" /></FilterDimensions></ComboBox></Items><LayoutTree><LayoutGroup Orientation="Vertical" Weight="100"><LayoutItem DashboardItem="rangeFilterDashboardItem1" Weight="22.86401925391095" /><LayoutGroup Weight="7.3405535499398313"><LayoutItem DashboardItem="comboBoxDashboardItem1" Weight="25" /><LayoutItem DashboardItem="comboBoxDashboardItem4" Weight="25" /><LayoutItem DashboardItem="comboBoxDashboardItem2" Weight="25" /><LayoutItem DashboardItem="comboBoxDashboardItem3" Weight="25" /></LayoutGroup><LayoutGroup Weight="33.574007220216608"><LayoutItem DashboardItem="gridDashboardItem1" Weight="50" /><LayoutItem DashboardItem="gridDashboardItem2" Weight="50" /></LayoutGroup><LayoutGroup Weight="36.221419975932612"><LayoutItem DashboardItem="gaugeDashboardItem1" Weight="50" /><LayoutItem DashboardItem="gaugeDashboardItem2" Weight="50" /></LayoutGroup></LayoutGroup></LayoutTree></Dashboard>')
GO
INSERT INTO VERSAO(VERSAO, VERSAOATUALIZACAO, DATAATUALIZACAO, REVISAO) VALUES(560, 818, GETDATE(),1);