1609 - DRE
This commit is contained in:
@@ -12,12 +12,14 @@ xsi:schemaLocation="http://www.davinti.com.br/vitruvio/form/panel https://bitbuc
|
||||
"nome" : "socios" ,
|
||||
"sequence" : "socio_seq" ,
|
||||
"idTabela" : "CODIGO",
|
||||
"campos" : ["CODIGO", "NOME" ],
|
||||
"camposTable" : ["CODIGO", "NOME" ]
|
||||
"campos" : ["CODIGO", "NOME", "PERCENTUAL_PARTICIPACAO" ],
|
||||
"camposTable" : ["CODIGO", "NOME", "PERCENTUAL_PARTICIPACAO" ],
|
||||
"condicao" : "CODIGO > 0"
|
||||
|
||||
},
|
||||
"relaciona" : [ ["CODIGO","idChave","Number"] ,
|
||||
["NOME","idDescricao","String"]
|
||||
["NOME","idDescricao","String"],
|
||||
["PERCENTUAL_PARTICIPACAO","idParticipacao","Number" ]
|
||||
] ,
|
||||
"validacaoExclusao" : [ ["SELECT 0 AS CONTAR FROM SOCIOS WHERE CODIGO = ", "Existem registros ligados a esta tabela"],
|
||||
["SELECT COUNT(CHAVE_RESPONSAVEL) AS CONTAR FROM CONTROLE_DESPESAS_PESSOAIS WHERE CHAVE_RESPONSAVEL = ", "Existem registros ligados a esta tabela."]
|
||||
@@ -152,6 +154,18 @@ xsi:schemaLocation="http://www.davinti.com.br/vitruvio/form/panel https://bitbuc
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
var validarPercentual = function(id) {
|
||||
var sql = "Select sum(percentual_participacao) ct from socios where codigo <> " + id;
|
||||
var db = libService.loadScript('db');
|
||||
var dbVitruvio = new db('vitruvio');
|
||||
var row = dbVitruvio.queryRow(sql);
|
||||
if ((parseFloat(row.ct) + parseFloat(engine.getField('idParticipacao').getValue())) > 100) {
|
||||
return false;
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function run() {
|
||||
@@ -168,6 +182,7 @@ xsi:schemaLocation="http://www.davinti.com.br/vitruvio/form/panel https://bitbuc
|
||||
engine.setGlobalVariable('deletarRegistro', deletarRegistro);
|
||||
engine.setGlobalVariable('validarDuplicidade', validarDuplicidade);
|
||||
engine.setGlobalVariable('painelLista',1);
|
||||
engine.setGlobalVariable('validarPercentual',validarPercentual);
|
||||
|
||||
habilitaCampos(false);
|
||||
|
||||
@@ -206,18 +221,21 @@ xsi:schemaLocation="http://www.davinti.com.br/vitruvio/form/panel https://bitbuc
|
||||
|
||||
var getSql = function() {
|
||||
|
||||
var config = { "tabela" :
|
||||
{
|
||||
"conexao" : "vitruvio",
|
||||
"nome" : "socios" ,
|
||||
"sequence" : "socio_seq" ,
|
||||
"idTabela" : "CODIGO",
|
||||
"campos" : ["CODIGO", "NOME" ],
|
||||
"camposTable" : ["CODIGO", "NOME" ]
|
||||
},
|
||||
"relaciona" : [ ["CODIGO","idChave","Number"] ,
|
||||
["NOME","idDescricao","String"]
|
||||
] ,
|
||||
var config = { "tabela" :
|
||||
{
|
||||
"conexao" : "vitruvio",
|
||||
"nome" : "socios" ,
|
||||
"sequence" : "socio_seq" ,
|
||||
"idTabela" : "CODIGO",
|
||||
"campos" : ["CODIGO", "NOME", "PERCENTUAL_PARTICIPACAO" ],
|
||||
"camposTable" : ["CODIGO", "NOME", "PERCENTUAL_PARTICIPACAO" ],
|
||||
"condicao" : "CODIGO > 0"
|
||||
|
||||
},
|
||||
"relaciona" : [ ["CODIGO","idChave","Number"] ,
|
||||
["NOME","idDescricao","String"],
|
||||
["PERCENTUAL_PARTICIPACAO","idParticipacao","Number"]
|
||||
] ,
|
||||
|
||||
"validacaoExclusao" :
|
||||
[ ["SELECT 0 AS CONTAR FROM SOCIOS WHERE CODIGO = ", "Existem registros ligados a esta tabela"],
|
||||
@@ -343,7 +361,7 @@ xsi:schemaLocation="http://www.davinti.com.br/vitruvio/form/panel https://bitbuc
|
||||
<datasource>
|
||||
<freeQuery connection-key="vitruvio">
|
||||
<![CDATA[
|
||||
SELECT * FROM socios
|
||||
SELECT * FROM socios WHERE CODIGO > 0
|
||||
]]>
|
||||
</freeQuery>
|
||||
</datasource>
|
||||
@@ -351,7 +369,7 @@ xsi:schemaLocation="http://www.davinti.com.br/vitruvio/form/panel https://bitbuc
|
||||
<![CDATA[
|
||||
SELECT *
|
||||
FROM socios
|
||||
nome = ? ORDER BY codigo
|
||||
nome = ? WHERE CODIGO > 0 ORDER BY codigo
|
||||
]]>
|
||||
</loadItemQuery>
|
||||
<key-field>CODIGO</key-field>
|
||||
@@ -379,8 +397,10 @@ xsi:schemaLocation="http://www.davinti.com.br/vitruvio/form/panel https://bitbuc
|
||||
</DBSearchField>
|
||||
<HorizontalLayout spacing="true" width="100%">
|
||||
<TextField id="idChave" type="number" caption="Código" width="100%" expandRatio="0.08" />
|
||||
<TextField id="idDescricao" type="string" text-transform="uppercase" caption="Nome" required="true" width="100%" expandRatio="1" />
|
||||
</HorizontalLayout>
|
||||
<TextField id="idDescricao" type="string" text-transform="uppercase" caption="Nome" required="true" width="100%" expandRatio="1" />
|
||||
<DecimalField type="decimal" id="idParticipacao" caption="% Participação" maximumValue="100" maxLength="6" width="100%" expandRatio="0.15" />
|
||||
</HorizontalLayout>
|
||||
<TextField id="idRateio" type="number" visible="false" />
|
||||
</VerticalLayout>
|
||||
</Tab>
|
||||
</TabLayout>
|
||||
@@ -399,15 +419,23 @@ xsi:schemaLocation="http://www.davinti.com.br/vitruvio/form/panel https://bitbuc
|
||||
if (engine.isValid()) {
|
||||
if ((engine.getGlobalVariable('validarDuplicidade')(engine.getField('idDescricao').getValue())) && (!engine.getField('idChave').getValue())) {
|
||||
MessageBox.show(MessageBox.BoxType.INFO, 'Atenção', 'Já existe um sócio cadastrado com este nome.');
|
||||
} else {
|
||||
var config = engine.getGlobalVariable('config');
|
||||
var id = engine.getField('idChave').getConvertedValue();
|
||||
var lib = libService.loadScript('lib_cadastro_padrao');
|
||||
var retorno = lib.fncGravarRegistro(config, id);
|
||||
|
||||
if (retorno) {
|
||||
engine.getGlobalVariable('fncLimpaCampos')();
|
||||
}
|
||||
} else {
|
||||
var socio = engine.getField('idChave').getValue();
|
||||
if (!socio) {
|
||||
socio = 0;
|
||||
}
|
||||
if (engine.getGlobalVariable('validarPercentual')(socio)) {
|
||||
var config = engine.getGlobalVariable('config');
|
||||
var id = engine.getField('idChave').getConvertedValue();
|
||||
var lib = libService.loadScript('lib_cadastro_padrao');
|
||||
var retorno = lib.fncGravarRegistro(config, id);
|
||||
|
||||
if (retorno) {
|
||||
engine.getGlobalVariable('fncLimpaCampos')();
|
||||
}
|
||||
} else {
|
||||
MessageBox.show(MessageBox.BoxType.INFO, 'Atenção', 'Percentual de participação dos sócios ultrapassa 100%.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user