'Nome       : StcPsq.par
'Tipo       : PAR
'Data       : 2008/12/09
'Versao     : 1.0a
'Descricao  : Configuracao de pesquisa de artigos

'===============================================================================
'#VER - Historia de modificacoes
'===============================================================================
'- Versao : 1.0a  2008/??/?? ---------------------------------------------------
'Correcao de nomes das colunas

'- Versao : 1.0   2008/11/17 ---------------------------------------------------
'Versao base


'===============================================================================
#DEF:IDE - Definicoes base
'===============================================================================
Identificacao                      [Ide]=Pesquisa de Artigos
##


'===============================================================================
#OPC:IDE - Opcoes
'===============================================================================
So pesquisa no inicio           [PsqIni]=1
Pesquisa imediata               [PsqIme]=1
Ordenacao da pesquisa           [PsqOrd]=+,1
Campo para focus                [CmpIni]=2

'Campos bloqueados               [CmpBlk]=Art$,Nome1$
Campos bloqueados               [CmpBlk]=
##


'===============================================================================
#GDA:IDE - Gerador de dados: artigos e acumulados (nao usa campos extra/adicionais)
'===============================================================================
'x_GDA:IDE (grupo desactivado);  GDA:IDE (grupo activada) - activar apenas um grupo GDA

Identificacao [GdaIde]=PSQ

Comando       [GdaCmd]=(SELECT +
                      +MST.[Art$]              AS [Codigo$], +
                      +MST.[Nome1$]            AS [Nome1$], +
                      +MST.[Nome2$]            AS [Nome2$], +
                      +MST.[CodBar$]           AS [CodBar$], +
                      +MST.[CodSbt$]           AS [CodSbt$], +
                      +MST.[Pv1]               AS [Pv1], +
                      +MST.[Pv2]               AS [Pv2], +
                      +MST.[Pv3]               AS [Pv3], +
                      +MST.[Pv4]               AS [Pv4], +
                      +MST.[PrcOrg]            AS [PrcOrg], +
                      +MST.[Desco$]            AS [Desco$], +
                      +MST.[CodIva]            AS [CodIva], +
                      +MST.[CtpTip]            AS [CtpTip], +
                      +MST.[TpArt]             AS [TpArt], +
                      +MST.[Unid$]             AS [Unid$], +
                      +MST.[NumDec]            AS [NumDec], +
                      +MST.[MedTip]            AS [MedTip], +
                      +MST.[Medidas$]          AS [Medidas$], +
                      +MST.[Peso]              AS [Peso], +
                      +MST.[Fcnv]              AS [Fcnv], +
                      +MST.[TipRl$]            AS [TipRl$], +
                      +MST.[Grupo$]            AS [Grupo$], +
                      +MST.[Loc$]              AS [Loc$], +
                      +MST.[Txl$]              AS [Txl$], +
                      +MST.[Pais]              AS [Pais], +
                      +MST.[RapTip]            AS [RapTip], +
                      +MST.[Penc]              AS [Penc], +
                      +MST.[Smin]              AS [Smin], +
                      +MST.[Smax]              AS [Smax], +
                      +MST.[FrnCt$]            AS [FrnCt$], +
                      +MST.[FrnUlt$]           AS [FrnUlt$], +
                      +MST.[FrnArt$]           AS [FrnArt$], +
                      +MST.[FrnDescr$]         AS [FrnDescr$], +
                      +MST.[FrnDesco$]         AS [FrnDesco$], +
                      +MST.[Aux1$]             AS [Aux1$], +
                      +MST.[Aux2$]             AS [Aux2$], +
                      +ACM.[Pmc]               AS [Pmc], +
                      +ACM.[Upc]               AS [Upc], +
                      +ACM.[Ano]               AS [Ano], +
                      +ACM.[Arz]               AS [Arz], +
                      +ACM.[QExi]              AS [QtExi], +
                      +Round(ACM.[VExi],2)     AS [VlExi], +
                      +ACM.[Qent]              AS [QtEnt], +
                      +ACM.[Qsai]              AS [QtSai], +
                      +ACM.[QEncC]             AS [QtEncC], +
                      +ACM.[QEncF]             AS [QtEncF], +
                      +ACM.[QRes]              AS [QtRes], +
                      +ACM.[QDisp]             AS [QtDisp], +
                      +ACM.[CqAct]             AS [CprQtAct], +
                      +Round(ACM.[CvAct],2)    AS [CprVlAct], +
                      +ACM.[VqAct]             AS [VndQtAct], +
                      +Round(ACM.[VvAct],2)    AS [VndVlAct], +
                      +Round(ACM.[VpmcAct],2)  AS [VndPmcAct], +
                      +Round(ACM.[Vent],2)     AS [VlEnt], +
                      +Round(ACM.[Vsai],2)     AS [VlSai], +
                      +ACM.[UltCompra$]        AS [DtUltCompra$], +
                      +ACM.[UltVenda$]         AS [DtUltVenda$], +
                      +ACM.[UltMov$]           AS [DtUltMov$], +
                      +ACM.[UltEncFrn$]        AS [DtUltEncFrn$], +
                      +0 as Zero +
                      +FROM (({TB_StcMst} MST +
                      +LEFT JOIN +
                      +    (SELECT [Art$], [Arz], [Ano], [Pmc], [Upc], +
                      +            [QEnt], [QSai], [QEncC], [QEncF], [QRes], +
                      +            [CqAct], [CvAct], [VqAct], +
                      +            [VvAct], [VpmcAct], [VEnt], [VSai], +
                      +            [Qent]-[Qsai]        AS [QExi], +
                      +            [Vent]-[Vsai]        AS [VExi], +
                      +            [Qent]-[Qsai]-[QRes] AS [QDisp], +
                      +            [UltCompra]          AS [UltCompra$], +
                      +            [UltVenda]           AS [UltVenda$], +
                      +            [UltMov]             AS [UltMov$], +
                      +            [UltEncFrn]          AS [UltEncFrn$] +
                      +     FROM   [StcAcm]  +
                      +     WHERE  [Ano] = {Ano}) +
                      +ACM ON MST.[Art$] = ACM.[Art$]) +
                      +LEFT JOIN {TB_StcMstEx} EXT ON Mst.[Art$] = EXT.[Art$]) +
                      +WHERE ACM.[Arz] = 0 OR ACM.[Arz] IS NULL) +
                      +PSQ

Adicional     [GdaAdi]=
##


'===============================================================================
#x_GDA:IDE - Gerador de dados: artigos, acumulados, campos extra/adicionais
'===============================================================================
'x_GDA:IDE (grupo desactivado);  GDA:IDE (grupo activado) - activar apenas um grupo GDA

Identificacao [GdaIde]=PSQ

Comando       [GdaCmd]=(SELECT +
                      +MST.[Art$]              AS [Codigo$], +
                      +MST.[Nome1$]            AS [Nome1$], +
                      +MST.[Nome2$]            AS [Nome2$], +
                      +MST.[CodBar$]           AS [CodBar$], +
                      +MST.[CodSbt$]           AS [CodSbt$], +
                      +MST.[Pv1]               AS [Pv1], +
                      +MST.[Pv2]               AS [Pv2], +
                      +MST.[Pv3]               AS [Pv3], +
                      +MST.[Pv4]               AS [Pv4], +
                      +MST.[PrcOrg]            AS [PrcOrg], +
                      +MST.[Desco$]            AS [Desco$], +
                      +MST.[CodIva]            AS [CodIva], +
                      +MST.[CtpTip]            AS [CtpTip], +
                      +MST.[TpArt]             AS [TpArt], +
                      +MST.[Unid$]             AS [Unid$], +
                      +MST.[NumDec]            AS [NumDec], +
                      +MST.[MedTip]            AS [MedTip], +
                      +MST.[Medidas$]          AS [Medidas$], +
                      +MST.[Peso]              AS [Peso], +
                      +MST.[Fcnv]              AS [Fcnv], +
                      +MST.[TipRl$]            AS [TipRl$], +
                      +MST.[Grupo$]            AS [Grupo$], +
                      +MST.[Loc$]              AS [Loc$], +
                      +MST.[Txl$]              AS [Txl$], +
                      +MST.[Pais]              AS [Pais], +
                      +MST.[RapTip]            AS [RapTip], +
                      +MST.[Penc]              AS [Penc], +
                      +MST.[Smin]              AS [Smin], +
                      +MST.[Smax]              AS [Smax], +
                      +MST.[FrnCt$]            AS [FrnCt$], +
                      +MST.[FrnUlt$]           AS [FrnUlt$], +
                      +MST.[FrnArt$]           AS [FrnArt$], +
                      +MST.[FrnDescr$]         AS [FrnDescr$], +
                      +MST.[FrnDesco$]         AS [FrnDesco$], +
                      +MST.[Aux1$]             AS [Aux1$], +
                      +MST.[Aux2$]             AS [Aux2$], +
                      +ACM.[Pmc]               AS [Pmc], +
                      +ACM.[Upc]               AS [Upc], +
                      +ACM.[Ano]               AS [Ano], +
                      +ACM.[Arz]               AS [Arz], +
                      +ACM.[QExi]              AS [QtExi], +
                      +Round(ACM.[VExi],2)     AS [VlExi], +
                      +ACM.[Qent]              AS [QtEnt], +
                      +ACM.[Qsai]              AS [QtSai], +
                      +ACM.[QEncC]             AS [QtEncC], +
                      +ACM.[QEncF]             AS [QtEncF], +
                      +ACM.[QRes]              AS [QtRes], +
                      +ACM.[QDisp]             AS [QtDisp], +
                      +ACM.[CqAct]             AS [CprQtAct], +
                      +Round(ACM.[CvAct],2)    AS [CprVlAct], +
                      +ACM.[VqAct]             AS [VndQtAct], +
                      +Round(ACM.[VvAct],2)    AS [VndVlAct], +
                      +Round(ACM.[VpmcAct],2)  AS [VndPmcAct], +
                      +Round(ACM.[Vent],2)     AS [VlEnt], +
                      +Round(ACM.[Vsai],2)     AS [VlSai], +
                      +ACM.[UltCompra$]        AS [DtUltCompra$], +
                      +ACM.[UltVenda$]         AS [DtUltVenda$], +
                      +ACM.[UltMov$]           AS [DtUltMov$], +
                      +ACM.[UltEncFrn$]        AS [DtUltEncFrn$], +
                      +EXT.[TipArt$]           AS [ExtTipArt$], +
                      +EXT.[EcoValor]          AS [ExtEcoValor], +
                      +EXT.[Cad01$]            AS [ExtCad01$], +
                      +EXT.[Cad02$]            AS [ExtCad02$], +
                      +EXT.[Cad03$]            AS [ExtCad03$], +
                      +EXT.[Cad04$]            AS [ExtCad04$], +
                      +EXT.[Cad05$]            AS [ExtCad05$], +
                      +EXT.[Cad06$]            AS [ExtCad06$], +
                      +EXT.[Cad07$]            AS [ExtCad07$], +
                      +EXT.[Cad08$]            AS [ExtCad08$], +
                      +EXT.[Cad09$]            AS [ExtCad09$], +
                      +EXT.[Cad10$]            AS [ExtCad10$], +
                      +0 as Zero +
                      +FROM (({TB_StcMst} MST +
                      +LEFT JOIN +
                      +    (SELECT [Art$], [Arz], [Ano], [Pmc], [Upc], [QEnt], [QSai], [QEncC], [QEncF], [QRes], +
                      +            [CqAct], [CvAct], [VqAct], [VvAct], [VpmcAct], [VEnt], [VSai], +
                      +            [Qent]-[Qsai]        AS [QExi], +
                      +            [Vent]-[Vsai]        AS [VExi], +
                      +            [Qent]-[Qsai]-[QRes] AS [QDisp], +
                      +            [UltCompra]          AS [UltCompra$], +
                      +            [UltVenda]           AS [UltVenda$], +
                      +            [UltMov]             AS [UltMov$], +
                      +            [UltEncFrn]          AS [UltEncFrn$] +
                      +     FROM   [StcAcm]  +
                      +     WHERE  [Ano] = {Ano}) +
                      +ACM ON MST.[Art$] = ACM.[Art$]) +
                      +LEFT JOIN {TB_StcMstEx} EXT ON Mst.[Art$] = EXT.[Art$]) +
                      +WHERE ACM.[Arz] = 0 OR ACM.[Arz] IS NULL) +
                      +PSQ

Adicional     [GdaAdi]=
##


'===============================================================================
#CMP:IDE - Campos disponiveis das tabelas - StcMst e StcAcm
'===============================================================================
'-------------------------------------------------------------------------------
'- Tabela StcMst ---------------------------------------------------------------
'-------------------------------------------------------------------------------
Artigo                               [T]=Codigo$
Nome                                 [T]=Nome1$
Nome Suplementar                     [T]=Nome2$
Cód.Barras                           [T]=CodBar$
Cód.Substituição                     [T]=CodSbt$
P.V.1                                [N]=Pv1
P.V.2                                [N]=Pv2
P.V.3                                [N]=Pv3
P.V.4                                [N]=Pv4
P.Origem                             [N]=PrcOrg
Desconto                             [T]=Desco$
Cód.IVA                              [N]=CodIva
Cód.CTA                              [N]=CtpTip
Tip.Art.                             [N]=TpArt
Unidade                              [T]=Unid$
Nr.Dec.                              [N]=NumDec
Med.Tipo                             [N]=MedTip
Medidas                              [T]=Medidas$
Peso                                 [N]=Peso
Ft.Conv.                             [N]=Fcnv
Tip.Linha                            [T]=TipRl$
Grupo                                [T]=Grupo$
Localização                          [T]=Loc$
Livre                                [T]=Txl$
País                                 [N]=Pais
Rapell                               [N]=RapTip
Pt.Encomenda                         [N]=Penc
St.Mínimo                            [N]=Smin
St.Máximo                            [N]=Smax
Fornecedor                           [T]=FrnCt$
Últ.Forn.                            [T]=FrnUlt$
Cód.Art.Forn.                        [T]=FrnArt$
Descrição do Artigo no Fornecedor    [T]=FrnDescr$
Desc.Fornecedor                      [T]=FrnDesco$
Ord.Aux.1                            [T]=Aux1$
Ord.Aux.2                            [T]=Aux2$

'-------------------------------------------------------------------------------
'- Tabela StcAcm ---------------------------------------------------------------
'-------------------------------------------------------------------------------
Ano                                  [N]=Ano
Armazém                              [N]=Arz
P.M.C.                               [N]=Pmc
U.P.C.                               [N]=Upc
Exist.-Quant                         [N]=QtExi
Exist.-Valor                         [N]=VlExi
Qt.Entradas                          [N]=QtEnt
Qt.Saidas                            [N]=QtSai
Qt.Enc.Cli.                          [N]=QtEncC
Qt.Enc.For.                          [N]=QtEncF
Qt.Reservada                         [N]=QtRes
Qt.Disponivel                        [N]=QtDisp
Compras-Qt.                          [N]=CprQtAct
Compras-Val.                         [N]=CprVlAct
Vendas-Qt.                           [N]=VndQtAct
Vendas-Val.                          [N]=VndVlAct
Vendas-PMC                           [N]=VndPmcAct
Entradas-Val.                        [N]=VlEnt
Saidas-Val.                          [N]=VlSai
Data Ult.Compra                      [T]=DtUltCompra$
Data Ult.Venda                       [T]=DtUltVenda$
Data Ult.Mov.                        [T]=DtUltMov$
Data Ult.Enc.F.                      [T]=DtUltEncFrn$

'-------------------------------------------------------------------------------
'- Tabela StcMstEX - Campos Extra/Adicionais (activar quando existirem os campos)
'-------------------------------------------------------------------------------
'Ext.T.Art.                          [T]=ExtTipArt$
'Ext.Ecovalor                        [N]=ExtEcoValor
'Ext.C.Adi.01                        [T]=ExtCad01$
'Ext.C.Adi.02                        [T]=ExtCad02$
'Ext.C.Adi.03                        [T]=ExtCad03$
'Ext.C.Adi.04                        [T]=ExtCad04$
'Ext.C.Adi.05                        [T]=ExtCad05$
'Ext.C.Adi.06                        [T]=ExtCad06$
'Ext.C.Adi.07                        [T]=ExtCad07$
'Ext.C.Adi.08                        [T]=ExtCad08$
'Ext.C.Adi.09                        [T]=ExtCad09$
'Ext.C.Adi.10                        [T]=ExtCad10$
##


'===============================================================================
#VER:IDE - Campos/Colunas a mostrar/limites
'===============================================================================
'Campo                             [VAR]=DIM ,LIM
Artigo                         [Codigo$]=1750,
Nome                            [Nome1$]=4500,
Existencia - Quantidade          [QtExi]=1100,
P.V.1                              [Pv1]=1100,
P.V.2                              [Pv2]=1100,
Código do IVA                   [CodIva]= 900,
Contrapartidas CTA              [CtpTip]= 900,
Código de Barras               [CodBar$]=1750,
##

