2253 - Remover o campo "Forma de recebimento"

Outras atividades também vinculadas a este painel:
2257 - Calcular automaticamente o valor do imposto ao definir o cliente
2258 - Criar opção para separar lançamentos do tipo Caminhão ou Carreta
2259 - Adicionar filtro por Caminhão ou Carreta no grid
This commit is contained in:
Ana Elisa dos Santos
2019-02-22 12:29:21 +00:00
parent 37d3559e08
commit dec7fc2b91
+430 -225
View File
@@ -5,7 +5,7 @@
>
<form formKey="formCadastro" width="100%" height="100%">
<name>Lançar Valor</name>
<description>Regras Contábeis</description>
<description>Créditos</description>
<initScript language="JavaScript">
<![CDATA[
importClass(Packages.br.com.davinti.base.vaadin.components.icons.IconFactory);
@@ -21,9 +21,8 @@
engine.getField('valorLiquido')['setValue(java.lang.String)'](null);
engine.getField('tipoFrete')["setValue(java.lang.Object)"](null);
engine.getField('cte')['setValue(java.lang.String)'](null);
engine.getField('ufOrigem')["setValue(java.lang.Object)"](null);
/*engine.getField('ufOrigem')["setValue(java.lang.Object)"](null);*/
engine.getField('ufDestino')["setValue(java.lang.Object)"](null);
engine.getField('formaPagamento')["setValue(java.lang.Object)"](null);
engine.getField('placaCarreta')["setValue(java.lang.Object)"](null);
}
@@ -41,43 +40,82 @@
if (engine.getField('ftPlaca').getValue()) {
sql += " and ccf.chave_veiculo = " + engine.getField('ftPlaca').getValue();
}
if (engine.getField('ftCliente').getValue()) {
sql += " and ccf.chave_cliente = " + engine.getField('ftCliente').getValue();
if (engine.getField('ftPlacaCarreta').getCaptionValue()) {
sql += " and ccf.placa_carreta = '" + engine.getField('ftPlacaCarreta').getCaptionValue() + "'";
}
if (engine.getField('ftClientes').getValue() && engine.getField('ftClientes').getValue() != '[]') {
sql += " and ccf.chave_cliente in (" + engine.getField('ftClientes').getValue().toString().replace('[','').replace(']','') + ")";
}
/*if (engine.getField('ftCliente').getValue()) {
sql += " and ccf.chave_cliente = " + engine.getField('ftCliente').getValue();
}*/
if (engine.getField('ftFrotaTerceiro').getValue() == 'F') {
sql += " and ccf.frota_terceiro = 'F'";
}
if (engine.getField('ftFrotaTerceiro').getValue() == 'T') {
sql += " and ccf.frota_terceiro = 'T'";
}
if (engine.getField('ftCaminhaoCarreta').getValue() == 'C') {
sql += " and ccf.caminhao_carreta = 'C'";
}
if (engine.getField('ftCaminhaoCarreta').getValue() == 'T') {
sql += " and ccf.caminhao_carreta = 'T'";
}
if (engine.getField('ftUfOrigem').getValue()) {
sql += " and ccf.uf_origem = '" + engine.getField('ftUfOrigem').getValue() + "'";
}
if (engine.getField('ftUfDestino').getValue()) {
sql += " and ccf.uf_destino = '" + engine.getField('ftUfDestino').getValue() + "'";
}
vitruvio.query(sql).each(function (r) {
if (r.total_frete) {
engine.getLabel('sub').setValue('<b><font color="blue">Subtotal Frete <br>R$ ' + r.total_frete + '</font></b>');
engine.getLabel('sub').setValue('<b><font color="blue">Subtotal Frete R$ ' + r.total_frete + '</font></b>');
} else {
engine.getLabel('sub').setValue('<b><font color="blue">Subtotal Frete <br>R$ 0,00</font></b>');
engine.getLabel('sub').setValue('<b><font color="blue">Subtotal Frete R$ 0,00</font></b>');
}
if (r.total_imposto) {
engine.getLabel('subImposto').setValue('<b><font color="red">Subtotal Impostos <br>R$ ' + r.total_imposto + '</font></b>');
engine.getLabel('subImposto').setValue('<b><font color="red">Subtotal Impostos R$ ' + r.total_imposto + '</font></b>');
} else {
engine.getLabel('subImposto').setValue('<b><font color="red">Subtotal Impostos <br>R$ 0,00</font></b>');
engine.getLabel('subImposto').setValue('<b><font color="red">Subtotal Impostos R$ 0,00</font></b>');
}
if (r.total_liquido) {
engine.getLabel('subLiquido').setValue('<b><font color="green">Subtotal (Frete - Impostos) <br>R$ ' + r.total_liquido + '</font></b>');
engine.getLabel('subLiquido').setValue('<b><font color="green">Subtotal (Frete - Impostos) R$ ' + r.total_liquido + '</font></b>');
} else {
engine.getLabel('subLiquido').setValue('<b><font color="green">Subtotal (Frete - Impostos) <br>R$ 0,00</font></b>');
engine.getLabel('subLiquido').setValue('<b><font color="green">Subtotal (Frete - Impostos) R$ 0,00</font></b>');
}
});
}
function fncLancFrete(){
var funcionario = engine.getField('funcionario').getValue();
var sql = "Select coalesce(nao_carregar_frete,false) as nao_carregar_frete from funcionario where codigo = :ParFuncionario";
var db = libService.loadScript('db');
var dbVitruvio = new db('vitruvio');
var row = dbVitruvio.queryRow(sql, {ParFuncionario: funcionario});
if (row) {
//Enable/disable componente frete
if (row.nao_carregar_frete == false) {
engine.getField('valorFrete').setEnabled(false);
engine.getField('origemFrete').setRequired(true);
engine.getField('origemFrete').setVisible(true);
} else {
engine.getField('valorFrete').setEnabled(true);
engine.getField('origemFrete').setRequired(false);
engine.getField('origemFrete').setVisible(false);
}
}
}
function run() {
engine.getField('valorImposto').setEnabled(false);
engine.getField('valorLiquido').setEnabled(false);
engine.setGlobalVariable('abertura',1);
engine.getField('frotaTerceiro').setValue('F');
engine.getField('ftFrotaTerceiro').setValue('A');
engine.getField('caminhaoCarreta').setValue('C');
engine.getField('ftCaminhaoCarreta').setValue('A');
var d = new java.util.Date();
engine.setGlobalVariable('fncLimpaCampos', fncLimpaCampos);
@@ -86,6 +124,7 @@
engine.getField('dataFinal').setValue(d);
engine.getField('tbLancamentos').refresh();
engine.getGlobalVariable('fncSubTotal')();
engine.setGlobalVariable('fncLancFrete', fncLancFrete);
// Registrando icones
engine.getWidgetController('btnGravar').getButton().setIcon(IconFactory.instance().getIconAsResource(IconLibraryAPISmall.SALVAR));
@@ -96,13 +135,13 @@
</initScript>
<components>
<VerticalLayout margin="true" width="100%" >
<VerticalLayout margin="true" width="100%" height="100%" >
<TabLayout align="BOTTOM_LEFT" id="credito" compact="true" width="100%" height="100%" >
<Tab caption="Fretes">
<VerticalLayout spacing="true" width="100%" height="100%">
<Panel caption=" " width="100%" expandRatio="0.1" align="TOP_LEFT" height="100%">
<VerticalLayout width="100%" margin="true" spacing="true">
<HorizontalLayout width="100%" spacing="true" height="100%">
<Panel caption=" " width="100%" expandRatio="0.5" align="TOP_LEFT" height="100%">
<VerticalLayout width="100%" spacing="true">
<HorizontalLayout width="100%" spacing="true" height="100%" margin="true">
<ImageWidget id="img1" height="46" width="68" align="TOP_LEFT">
<image>
<base64 extension="jpg">
@@ -112,13 +151,43 @@
</base64>
</image>
</ImageWidget>
<DateField type="date" id="dataLancamento" align="TOP_LEFT" caption="Data" width="100%" expandRatio="0.15" required="true" resolution="DAY" description="Informe a data do lançamento" format="dd/MM/yyyy" >
<DateField type="date" id="dataLancamento" align="TOP_LEFT" caption="Data" width="100%" expandRatio="0.8" required="true" resolution="DAY" description="Informe a data do lançamento" format="dd/MM/yyyy" >
</DateField>
<DBComboBox type="string" id="placa" width="100%" required="true" expandRatio="0.2" align="TOP_LEFT" caption="Placa">
<OptionGroup type="string" id="frotaTerceiro" disposition="vertical" required="true" width="100%" expandRatio="0.5" >
<entry value="Frota" key="F"/>
<entry value="Terceiro" key="T"/>
</OptionGroup>
<OptionGroup type="string" id="caminhaoCarreta" disposition="vertical" required="true" width="75%" expandRatio="0.5">
<entry value="Caminhão" key="C"/>
<entry value="Carreta" key="T"/>
<events>
<valueChange>
<script language="JavaScript">
<![CDATA[
function run() {
var keyValue = engine.getField('caminhaoCarreta').getValue();
if (keyValue=="T") {
engine.getField('placaCarreta').setVisible(true);
engine.getField('placaCarreta').setRequired(true);
} else {
engine.getField('placaCarreta').setVisible(false);
engine.getField('placaCarreta').setRequired(false);
engine.getField('placaCarreta').setValue(null);
}
}
]]>
</script>
</valueChange>
</events>
</OptionGroup>
<DBComboBox type="string" id="placa" width="100%" required="true" expandRatio="1" align="TOP_LEFT" caption="Placa">
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
Select * from veiculo
Select * from veiculo where inativo is false order by PLACA
]]>
</freeQuery>
</datasource>
@@ -142,41 +211,91 @@
</valueChange>
</events>
</DBComboBox>
<DBComboBox type="string" id="placaCarreta" width="100%" required="true" expandRatio="0.2" align="TOP_LEFT" caption="Placa carreta">
<DBComboBox type="string" id="placaCarreta" width="100%" expandRatio="1" align="TOP_LEFT" caption="Placa carreta" required="true">
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
Select * from veiculo where placa_carreta is not null
Select * from veiculo where placa_carreta is not null order by placa_carreta
]]>
</freeQuery>
</datasource>
<key-field>PLACA_CARRETA</key-field>
<caption-field>PLACA_CARRETA</caption-field>
</DBComboBox>
<DBComboBox type="string" id="funcionario" required="true" width="100%" expandRatio="0.2" align="TOP_LEFT" caption="Funcionário">
<DBComboBox type="string" id="funcionario" required="true" width="100%" expandRatio="1" align="TOP_LEFT" caption="Funcionário">
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
Select * from funcionario
Select * from funcionario where inativo is false order by nome
]]>
</freeQuery>
</datasource>
<key-field>CODIGO</key-field>
<caption-field>NOME</caption-field>
<events>
<valueChange>
<script language="JavaScript">
<![CDATA[
function run() {
var fncLancFrete = engine.getGlobalVariable('fncLancFrete');
if(fncLancFrete){
engine.getGlobalVariable('fncLancFrete')();
}
}
]]>
</script>
</valueChange>
</events>
</DBComboBox>
<DBComboBox type="string" id="cliente" required="true" width="100%" expandRatio="1" align="TOP_LEFT" caption="Cliente">
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
Select * from clientes where inativo is false order by nome
]]>
</freeQuery>
</datasource>
<key-field>CODIGO</key-field>
<caption-field>NOME</caption-field>
<events>
<valueChange>
<script language="JavaScript">
<![CDATA[
function run(){
var cliente = engine.getField('cliente').getValue();
var sql = "Select count(*) as contador from clientes_frete where chave_cliente = :ParCliente";
var db = libService.loadScript('db');
var dbVitruvio = new db('vitruvio');
var row = dbVitruvio.queryRow(sql, {ParCliente: cliente});
if (row) {
if (row.contador == 0) {
engine.getField('valorFrete').setEnabled(true);
engine.getField('origemFrete').setRequired(false);
engine.getField('origemFrete').setVisible(false);
}else{
var fncLancFrete = engine.getGlobalVariable('fncLancFrete');
if(fncLancFrete){
engine.getGlobalVariable('fncLancFrete')();
}
}
}
}
]]>
</script>
</valueChange>
</events>
</DBComboBox>
</HorizontalLayout>
<HorizontalLayout width="100%" spacing="true" margin="true">
<NumericField type="number" id="cte" caption="CTE" />
<DBComboBox type="string" id="cliente" required="true" width="100%" expandRatio="0.2" align="TOP_LEFT" caption="Cliente">
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
Select * from clientes
]]>
</freeQuery>
</datasource>
<key-field>CODIGO</key-field>
<caption-field>NOME</caption-field>
</DBComboBox>
<DBComboBox type="string" id="tipoFrete" required="true" width="100%" expandRatio="0.2" align="TOP_LEFT" caption="Tipo de frete">
<DBComboBox type="string" id="tipoFrete" required="true" width="100%" expandRatio="0.5" align="TOP_LEFT" caption="Tipo de frete">
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
@@ -187,20 +306,115 @@
<key-field>CODIGO</key-field>
<caption-field>DESCRICAO</caption-field>
</DBComboBox>
</HorizontalLayout>
<HorizontalLayout width="100%" spacing="true">
<OptionGroup type="string" id="frotaTerceiro" disposition="vertical" required="true" width="60" >
<entry value="Frota" key="F"/>
<entry value="Terceiro" key="T"/>
</OptionGroup>
<DecimalField type="decimal" id="valorFrete" required="true" immediate="true" caption="Valor frete (R$)" format="#,##0.00" description="Valor frete" width="100%" expandRatio="0.2" >
<DBComboBox type="number" id="origemFrete" width="100%" expandRatio="0.5" align="TOP_LEFT" caption="Lanc. Frete" required="false">
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
select chave_frete, descricao||' - R$ '||valor_frete as descricao
from clientes_frete
where chave_cliente = ${ParCodigo}
order by descricao
]]>
</freeQuery>
</datasource>
<key-field>CHAVE_FRETE</key-field>
<caption-field>DESCRICAO</caption-field>
<bind>
<parameter value-type="number" defaultValue="-1" parameterName="ParCodigo" field-ref="cliente"/>
</bind>
<events>
<valueChange>
<script language="JavaScript">
<![CDATA[
function run() {
var db = libService.loadScript('db');
var dbVitruvio = new db('vitruvio');
var sql = "Select valor_frete from clientes_frete ";
sql += "where chave_frete = " + engine.getField('origemFrete').getValue();
var row = dbVitruvio.queryRow(sql);
if (row) {
//Atribui o valor do frete no componente
if (row.valor_frete > 0) {
engine.getField('valorFrete').setValue(row.valor_frete);
} else {
engine.getField('valorFrete').setValue(0);
}
}
}
]]>
</script>
</valueChange>
</events>
</DBComboBox>
<DBComboBox type="string" id="ufDestino" caption="UF Origem-Destino" width="100%" expandRatio=".6" >
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
Select cp.chave_praca, ori.nome ||' - '|| dest.nome as percurso
from clientes_praca cp, estados ori, estados dest
where cp.chave_estado_origem = ori.chave_estado
and cp.chave_estado = dest.chave_estado
and cp.chave_cliente = ${ParCodigo}
order by 2
]]>
</freeQuery>
</datasource>
<key-field>CHAVE_PRACA</key-field>
<caption-field>PERCURSO</caption-field>
<bind>
<parameter value-type="number" defaultValue="-1" parameterName="ParCodigo" field-ref="cliente"/>
</bind>
<events>
<valueChange>
<script language="JavaScript">
<![CDATA[
function run() {
var db = libService.loadScript('db');
var dbVitruvio = new db('vitruvio');
var pImpostos;
var sql = "Select percentual_impostos, chave_estado, chave_estado_origem from clientes_praca ";
sql += "where chave_praca = " + engine.getField('ufDestino').getValue();
var row = dbVitruvio.queryRow(sql);
if (row) {
engine.setGlobalVariable('praca',row.chave_estado);
engine.setGlobalVariable('pracaOrigem',row.chave_estado_origem);
//Atribui o % do imposto
if (row.percentual_impostos > 0) {
pImpostos = row.percentual_impostos/100;
} else {
pImpostos = 0;
}
}
var impostos = engine.getField('valorFrete').getConvertedValue() * pImpostos;
var liquido = engine.getField('valorFrete').getConvertedValue() - impostos;
engine.getField('valorImposto').setValue(impostos);
engine.getField('valorLiquido').setValue(liquido);
}
]]>
</script>
</valueChange>
</events>
</DBComboBox>
<DecimalField type="decimal" id="valorFrete" required="true" immediate="true" caption="Valor frete (R$)" format="#,##0.00" description="Valor frete" width="100%" expandRatio=".6" >
<events>
<valueChange>
<script language="JavaScript">
<![CDATA[
function run() {
var pImpostos;
var sql = "Select percentual_impostos from clientes_praca where chave_estado = " + engine.getField('ufDestino').getValue() + " and chave_cliente = " + engine.getField('cliente').getValue();
var sql = "Select percentual_impostos from clientes_praca where chave_praca = " + engine.getField('ufDestino').getValue();
var db = libService.loadScript('db');
var dbVitruvio = new db('vitruvio');
var row = dbVitruvio.queryRow(sql);
@@ -219,72 +433,10 @@
</valueChange>
</events>
</DecimalField>
<DBComboBox type="number" id="ufOrigem" caption="UF Origem" width="100%" expandRatio="0.1">
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
Select * from estados
]]>
</freeQuery>
</datasource>
<key-field>CHAVE_ESTADO</key-field>
<caption-field>SIGLA</caption-field>
</DBComboBox>
<DBComboBox type="string" id="ufDestino" caption="UF Destino" width="100%" expandRatio="0.1" >
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
Select cp.chave_estado, e.sigla from clientes_praca cp inner join estados e on e.chave_estado = cp.chave_estado where cp.chave_cliente = ${codigo}
]]>
</freeQuery>
</datasource>
<key-field>CHAVE_ESTADO</key-field>
<caption-field>SIGLA</caption-field>
<bind>
<parameter value-type="number" defaultValue="-1" parameterName="codigo" field-ref="cliente"/>
</bind>
<events>
<valueChange>
<script language="JavaScript">
<![CDATA[
function run() {
var pImpostos;
var sql = "Select percentual_impostos, chave_estado from clientes_praca where chave_estado = " + engine.getField('ufDestino').getValue() + " and chave_cliente = " + engine.getField('cliente').getValue();
var db = libService.loadScript('db');
var dbVitruvio = new db('vitruvio');
var row = dbVitruvio.queryRow(sql);
if (row) {
engine.setGlobalVariable('praca',row.chave_estado);
}
if (row && row.percentual_impostos) {
pImpostos = row.percentual_impostos/100;
} else {
pImpostos = 0;
}
var impostos = engine.getField('valorFrete').getConvertedValue() * pImpostos;
var liquido = engine.getField('valorFrete').getConvertedValue() - impostos;
engine.getField('valorImposto').setValue(impostos);
engine.getField('valorLiquido').setValue(liquido);
}
]]>
</script>
</valueChange>
</events>
</DBComboBox>
<DBComboBox type="string" id="formaPagamento" required="true" width="100%" expandRatio="0.2" align="TOP_LEFT" caption="Forma de pagamento">
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
Select * from forma_pagamento
]]>
</freeQuery>
</datasource>
<key-field>CODIGO</key-field>
<caption-field>NOME</caption-field>
</DBComboBox>
<DecimalField type="decimal" id="valorImposto" caption="Valor impostos (R$)" format="#,##0.00" description="Valor impostos" width="100%" expandRatio="0.2" />
<DecimalField type="decimal" id="valorLiquido" caption="Valor Líquido (Frete - Impostos) (R$)" format="#,##0.00" description="Valor frete menos o valor dos impostos" width="100%" expandRatio="0.2" />
<ButtonWidget id="btnGravar" caption="Gravar" align="BOTTOM_RIGHT" description="Grava o lançamento" width="100" >
<DecimalField type="decimal" id="valorImposto" caption="Valor impostos (R$)" format="#,##0.00" description="Valor impostos" width="100%" expandRatio=".6" />
<DecimalField type="decimal" id="valorLiquido" caption="Valor Líquido (Frete - Impostos) (R$)" format="#,##0.00" description="Valor frete menos o valor dos impostos" width="100%" expandRatio=".6" align="BOTTOM_LEFT"/>
<ButtonWidget id="btnGravar" caption="Gravar" description="Grava o lançamento" width="100" expandRatio=".3" >
<onClickScript language="JavaScript">
<![CDATA[
importClass(Packages.com.vaadin.ui.Notification);
@@ -294,8 +446,8 @@
var dbVitruvio = new db('vitruvio');
var sql;
dbVitruvio.transaction(function() {
sql = "insert into controle_receitas_fretes (chave_receita_frete,data,chave_cliente,chave_veiculo,chave_funcionario,valor_frete,valor_imposto,valor_liquido,chave_tipo_frete,cte,frota_terceiro,uf_origem,uf_destino,chave_forma_pagamento,placa_carreta) " +
" values (" + dbVitruvio.getSequenceNextValSql('controle_rec_fr_seq') + ",:data,:chave_cliente,:chave_veiculo,:chave_funcionario,:valor_frete,:valor_imposto,:valor_liquido,:tipo_frete,:cte,:frota_terceiro,:uf_origem,:uf_destino,:forma_pagamento,:placa_carreta)";
sql = "insert into controle_receitas_fretes (chave_receita_frete,data,chave_cliente,chave_veiculo,chave_funcionario,valor_frete,valor_imposto,valor_liquido,chave_tipo_frete,cte,frota_terceiro,caminhao_carreta,uf_origem,uf_destino,chave_forma_pagamento,placa_carreta,usuario) " +
" values (" + dbVitruvio.getSequenceNextValSql('controle_rec_fr_seq') + ",:data,:chave_cliente,:chave_veiculo,:chave_funcionario,:valor_frete,:valor_imposto,:valor_liquido,:tipo_frete,:cte,:frota_terceiro,:caminhao_carreta,:uf_origem,:uf_destino,0,:placa_carreta,:usuario)";
this.update(sql, {
data: engine.getField('dataLancamento').getValue(),
chave_cliente: Number(engine.getField('cliente').getValue()),
@@ -307,10 +459,11 @@
tipo_frete: engine.getField('tipoFrete').getValue(),
cte: Number(engine.getField('cte').getValue()),
frota_terceiro: String(engine.getField('frotaTerceiro').getValue()),
uf_origem: Number(engine.getField('ufOrigem').getValue()),
caminhao_carreta: String(engine.getField('caminhaoCarreta').getValue()),
uf_origem: Number(engine.getGlobalVariable('pracaOrigem')),
uf_destino: Number(engine.getGlobalVariable('praca')),
forma_pagamento: engine.getField('formaPagamento').getValue(),
placa_carreta: engine.getField('placaCarreta').getValue()
placa_carreta: engine.getField('placaCarreta').getValue(),
usuario: engine.getLoggedUser().getLogin()
});
});
engine.getField('tbLancamentos').refresh();
@@ -326,61 +479,99 @@
</VerticalLayout>
</Panel>
<Panel width="100%" margin="true" >
<VerticalLayout width="100%" spacing="true" align="TOP_LEFT" >
<HorizontalLayout width="100%" spacing="true" align="TOP_LEFT">
<DateField type="date" id="dataInicio" caption="Data inicial" align="TOP_LEFT" width="100%" expandRatio="0.2" description="Data iniacial da exibição" format="dd/MM/yyyy" />
<DateField type="date" id="dataFinal" caption="Data final" align="TOP_LEFT" width="100%" expandRatio="0.2" description="Data final da exibição" format="dd/MM/yyyy" />
<DBComboBox type="string" id="ftFuncionario" width="100%" expandRatio="0.2" align="TOP_LEFT" caption="Funcionário" allowNullSelection="true">
<Panel width="100%" margin="true" height="100%" expandRatio="1" >
<VerticalLayout width="100%" spacing="true" align="TOP_LEFT" height="100%" >
<HorizontalLayout width="100%" spacing="true" height="100%" expandRatio="0.6">
<DBTwinColSelect type="string" id="ftClientes" allowNullSelection="true" multivalue="true" caption="Clientes" rows="5" width="100%" expandRatio="0.5" align="TOP_LEFT">
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
Select * from funcionario
Select codigo, substr(nome,1,15)::varchar as nome from clientes order by nome
]]>
</freeQuery>
</datasource>
<key-field>CODIGO</key-field>
<caption-field>NOME</caption-field>
</DBComboBox>
<DBComboBox type="string" id="ftPlaca" width="100%" expandRatio="0.2" align="TOP_LEFT" caption="Placa" allowNullSelection="true">
</DBTwinColSelect>
<VerticalLayout width="100%" spacing="true" expandRatio="1" align="TOP_LEFT">
<HorizontalLayout width="100%" spacing="true" align="TOP_LEFT">
<DateField type="date" id="dataInicio" caption="Data inicial" align="TOP_LEFT" width="100%" expandRatio="1" description="Data iniacial da exibição" format="dd/MM/yyyy" />
<DateField type="date" id="dataFinal" caption="Data final" align="TOP_LEFT" width="100%" expandRatio="1" description="Data final da exibição" format="dd/MM/yyyy" />
<DBComboBox type="string" id="ftPlaca" width="100%" expandRatio="1" align="TOP_LEFT" caption="Placa" allowNullSelection="true">
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
Select * from veiculo
Select * from veiculo order by placa
]]>
</freeQuery>
</datasource>
<key-field>CODIGO</key-field>
<caption-field>PLACA</caption-field>
</DBComboBox>
<DBComboBox type="string" id="ftCliente" width="100%" expandRatio="0.2" align="TOP_LEFT" caption="Cliente" allowNullSelection="true" >
<DBComboBox type="string" id="ftPlacaCarreta" width="100%" expandRatio="1" align="TOP_LEFT" caption="Placa Carreta" allowNullSelection="true">
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
Select * from clientes
select distinct placa_carreta from veiculo where placa_carreta is not null order by placa_carreta
]]>
</freeQuery>
</datasource>
<key-field>PLACA_CARRETA</key-field>
<caption-field>PLACA_CARRETA</caption-field>
</DBComboBox>
</HorizontalLayout>
<HorizontalLayout width="100%" margin="false" spacing="true">
<DBComboBox type="string" id="ftFuncionario" width="100%" expandRatio="0.2" align="TOP_LEFT" caption="Funcionário" allowNullSelection="true">
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
Select * from funcionario order by nome
]]>
</freeQuery>
</datasource>
<key-field>CODIGO</key-field>
<caption-field>NOME</caption-field>
</DBComboBox>
<OptionGroup type="string" id="ftFrotaTerceiro" disposition="vertical" width="60" >
<entry value="Ambos" key="A"/>
<entry value="Frota" key="F"/>
<entry value="Terceiro" key="T"/>
</OptionGroup>
<DBComboBox type="number" id="ftUfDestino" caption="UF destino" width="100%" expandRatio="0.1" allowNullSelection="true" align="TOP_LEFT" >
<DBComboBox type="number" id="ftUfOrigem" caption="UF origem" width="100%" expandRatio="0.1" allowNullSelection="true" align="TOP_LEFT" >
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
Select * from estados
Select * from estados order by sigla
]]>
</freeQuery>
</datasource>
<key-field>CHAVE_ESTADO</key-field>
<caption-field>SIGLA</caption-field>
</DBComboBox>
<ButtonWidget id="btnFiltrar" caption="Filtrar" align="MIDDLE_LEFT" description="Aplica filtro" width="100" >
<DBComboBox type="number" id="ftUfDestino" caption="UF destino" width="100%" expandRatio="0.1" allowNullSelection="true" align="TOP_LEFT" >
<datasource>
<freeQuery connection-key="vitruvio">
<![CDATA[
Select * from estados order by sigla
]]>
</freeQuery>
</datasource>
<key-field>CHAVE_ESTADO</key-field>
<caption-field>SIGLA</caption-field>
</DBComboBox>
<OptionGroup type="string" id="ftFrotaTerceiro" disposition="horizontal" width="100%" expandRatio="0.3" align="MIDDLE_CENTER" caption="Frota">
<entry value="Ambos" key="A"/>
<entry value="Frota" key="F"/>
<entry value="Terceiro" key="T"/>
</OptionGroup>
<OptionGroup type="string" id="ftCaminhaoCarreta" disposition="horizontal" width="100%" expandRatio="0.3" align="MIDDLE_LEFT" caption="Caminhão/Carreta">
<entry value="Ambos" key="A"/>
<entry value="Caminhão" key="C"/>
<entry value="Carreta" key="T"/>
</OptionGroup>
<ButtonWidget id="btnFiltrar" caption="Filtrar" align="BOTTOM_RIGHT" description="Aplica filtro" width="100" >
<onClickScript language="JavaScript">
<![CDATA[
function run() {
@@ -390,7 +581,8 @@
]]>
</onClickScript>
</ButtonWidget>
<ButtonWidget id="btnLimparFiltro" caption="Limpar" align="MIDDLE_LEFT" description="Limpar filtro" width="100" >
<ButtonWidget id="btnLimparFiltro" caption="Limpar" align="BOTTOM_RIGHT" description="Limpar filtro" width="100" >
<onClickScript language="JavaScript">
<![CDATA[
function run() {
@@ -399,8 +591,11 @@
engine.getField('dataFinal').setValue(d);
engine.getField('ftFuncionario')["setValue(java.lang.Object)"](null);
engine.getField('ftPlaca')["setValue(java.lang.Object)"](null);
engine.getField('ftCliente')["setValue(java.lang.Object)"](null);
engine.getField('ftPlacaCarreta')["setValue(java.lang.Object)"](null);
engine.getField('ftClientes')["setValue(java.lang.Object)"](null);
engine.getField('ftFrotaTerceiro').setValue('A');
engine.getField('ftCaminhaoCarreta').setValue('2');
engine.getField('ftUfOrigem')["setValue(java.lang.Object)"](null);
engine.getField('ftUfDestino')["setValue(java.lang.Object)"](null);
engine.getField('tbLancamentos').refresh();
engine.getGlobalVariable('fncSubTotal')();
@@ -409,7 +604,9 @@
</onClickScript>
</ButtonWidget>
</HorizontalLayout>
<HorizontalLayout width="70%" spacing="true" align="TOP_LEFT">
</VerticalLayout>
</HorizontalLayout>
<HorizontalLayout width="70%" spacing="true" align="TOP_LEFT" height="100%" expandRatio="0.1">
<Label id="sub" align="BOTTOM_RIGHT" width="100%" expandRatio="1" contentMode="HTML">
<value>
@@ -426,7 +623,7 @@
</value>
</Label>
</HorizontalLayout>
<DBTable id="tbLancamentos" type="number" showRowCount="true" width="100%" rows="6" selectable="false" exportXLS="true" editable="true" >
<DBTable id="tbLancamentos" type="number" showRowCount="true" width="100%" rows="6" selectable="false" exportXLS="true" editable="true" height="100%" expandRatio="1">
<datasource>
<sqlBuilderDataSource connection-key="vitruvio" language="JavaScript">
<![CDATA[
@@ -438,9 +635,9 @@
" ccf.cte," +
" (select descricao from tipo_frete where codigo = ccf.chave_tipo_frete) tipo_frete," +
" ccf.frota_terceiro," +
" ccf.caminhao_carreta," +
" (select e.sigla from estados e where e.chave_estado = ccf.uf_origem) uf_origem," +
" (Select e.sigla from estados e where e.chave_estado = ccf.uf_destino) uf_destino," +
" (select nome from forma_pagamento where codigo = ccf.chave_forma_pagamento) forma_pagamento," +
" replace(replace(replace(to_char(ccf.valor_frete, '9999999999D99'),',','-' ),'.',','),'-','.') valor_frete, " +
" replace(replace(replace(to_char(ccf.valor_imposto, '9999999999D99'),',','-' ),'.',','),'-','.') valor_imposto, " +
" replace(replace(replace(to_char(ccf.valor_liquido, '9999999999D99'),',','-' ),'.',','),'-','.') valor_liquido, " +
@@ -457,16 +654,16 @@
" ccf.cte," +
" (select descricao from tipo_frete where codigo = ccf.chave_tipo_frete) tipo_frete," +
" ccf.frota_terceiro," +
" ccf.caminhao_carreta," +
" (select e.sigla from estados e where e.chave_estado = ccf.uf_origem) uf_origem," +
" (Select e.sigla from estados e where e.chave_estado = ccf.uf_destino) uf_destino," +
" (select nome from forma_pagamento where codigo = ccf.chave_forma_pagamento) forma_pagamento," +
" ccf.valor_frete valor_frete, " +
" ccf.valor_imposto valor_imposto, " +
" ccf.valor_liquido valor_liquido, " +
" ccf.placa_carreta placa_carreta " +
" from controle_receitas_fretes ccf";
" from controle_receitas_fretes ccf where 1 = 1 ";
if (datainicio && datafinal) {
sql += " where ccf.data between '" + engine.getField('dataInicio') + "' and '" + engine.getField('dataFinal') + "'";
sql += " and ccf.data between '" + engine.getField('dataInicio') + "' and '" + engine.getField('dataFinal') + "'";
}
if (engine.getField('ftFuncionario').getValue()) {
sql += " and ccf.chave_funcionario = " + engine.getField('ftFuncionario').getValue();
@@ -474,8 +671,11 @@
if (engine.getField('ftPlaca').getValue()) {
sql += " and ccf.chave_veiculo = " + engine.getField('ftPlaca').getValue();
}
if (engine.getField('ftCliente').getValue()) {
sql += " and ccf.chave_cliente = " + engine.getField('ftCliente').getValue();
if (engine.getField('ftPlacaCarreta').getCaptionValue()) {
sql += " and ccf.placa_carreta = '" + engine.getField('ftPlacaCarreta').getCaptionValue() +"'";
}
if (engine.getField('ftClientes').getValue() && engine.getField('ftClientes').getValue() != '[]') {
sql += " and ccf.chave_cliente in (" + engine.getField('ftClientes').getValue().toString().replace('[','').replace(']','') + ")";
}
if (engine.getField('ftFrotaTerceiro').getValue() && engine.getField('ftFrotaTerceiro').getValue() == 'F') {
sql += " and ccf.frota_terceiro = 'F'";
@@ -483,6 +683,15 @@
if (engine.getField('ftFrotaTerceiro').getValue() && engine.getField('ftFrotaTerceiro').getValue() == 'T') {
sql += " and ccf.frota_terceiro = 'T'";
}
if (engine.getField('ftCaminhaoCarreta').getValue() && engine.getField('ftCaminhaoCarreta').getValue() == 'C') {
sql += " and ccf.caminhao_carreta = 'C'";
}
if (engine.getField('ftCaminhaoCarreta').getValue() && engine.getField('ftCaminhaoCarreta').getValue() == 'T') {
sql += " and ccf.caminhao_carreta = 'T'";
}
if (engine.getField('ftUfOrigem').getValue()) {
sql += " and ccf.uf_origem = '" + engine.getField('ftUfOrigem').getValue() + "'";
}
if (engine.getField('ftUfDestino').getValue()) {
sql += " and ccf.uf_destino = '" + engine.getField('ftUfDestino').getValue() + "'";
}
@@ -509,6 +718,14 @@
var btn = comp.buttonIcon('excluir', function () {
var deletar = function(idRegistro) {
var sqlAtualiza = "UPDATE controle_receitas_fretes SET usuario = ?, blindar = ? "+
" WHERE CHAVE_RECEITA_FRETE = ? ";
var params = new java.util.ArrayList();
params.add(engine.getLoggedUser().getLogin());
params.add(1);
params.add(idRegistro);
vQueryService.executePSUpdateQuery('vitruvio', sqlAtualiza, params.toArray());
var sql = 'delete from controle_receitas_fretes where chave_receita_frete = :id';
vQueryService.doInTransaction('vitruvio', new DatabaseSnippet() {
execute: function(db, transaction) {
@@ -543,8 +760,8 @@
]]>
</scriptColumnGenerator>
</generated>
<column name="DATA" caption="Data" format="dd/MM/yyyy" commitOnValueChange="true" editable="true" />
<generated name="VEICULO" caption="Veículo" cache="false" expand-ratio="0.05" >
<column name="DATA" caption="Data" format="dd/MM/yyyy" commitOnValueChange="true" editable="true" expand-ratio="0.15" />
<generated name="VEICULO" caption="Veículo" cache="false" expand-ratio="0.15" >
<scriptColumnGenerator language="JavaScript">
<![CDATA[
importClass(Packages.com.vaadin.ui.ComboBox);
@@ -609,7 +826,7 @@
]]>
</scriptColumnGenerator>
</generated>
<generated name="PLACA_CARRETA" caption="Placa carreta" cache="false" >
<generated name="PLACA_CARRETA" caption="Placa carreta" cache="false" expand-ratio="0.15">
<scriptColumnGenerator language="JavaScript">
<![CDATA[
importClass(Packages.com.vaadin.ui.ComboBox);
@@ -674,7 +891,7 @@
]]>
</scriptColumnGenerator>
</generated>
<generated name="FUNCIONARIO" caption="Funcionário" cache="false" >
<generated name="FUNCIONARIO" caption="Funcionário" cache="false" expand-ratio="0.2">
<scriptColumnGenerator language="JavaScript">
<![CDATA[
importClass(Packages.com.vaadin.ui.ComboBox);
@@ -739,8 +956,8 @@
]]>
</scriptColumnGenerator>
</generated>
<column name="CTE" caption="CTE" editable="true" commitOnValueChange="true"/>
<generated name="CLIENTE" caption="Cliente" cache="false" >
<column name="CTE" caption="CTE" editable="true" commitOnValueChange="true" expand-ratio="0.1"/>
<generated name="CLIENTE" caption="Cliente" cache="false" expand-ratio="0.2">
<scriptColumnGenerator language="JavaScript">
<![CDATA[
importClass(Packages.com.vaadin.ui.ComboBox);
@@ -805,7 +1022,7 @@
]]>
</scriptColumnGenerator>
</generated>
<generated name="TIPO_FRETE" caption="Tipo frete" cache="false" >
<generated name="TIPO_FRETE" caption="Tipo frete" cache="false" expand-ratio="0.15" >
<scriptColumnGenerator language="JavaScript">
<![CDATA[
importClass(Packages.com.vaadin.ui.ComboBox);
@@ -871,7 +1088,7 @@
]]>
</scriptColumnGenerator>
</generated>
<generated name="FROTA_TERCEIRO" caption="Frota" cache="false" >
<generated name="FROTA_TERCEIRO" caption="Frota" cache="false" expand-ratio="0.15" >
<scriptColumnGenerator language="JavaScript">
<![CDATA[
importClass(Packages.com.vaadin.ui.ComboBox);
@@ -899,7 +1116,6 @@
map.put('F', 'Frota');
map.put('T', 'Terceiro');
var combo = new ComboBox();
combo.setWidth("100%");
ContainerUtils.createAndConfigureContainerFromCaptionMap(map, combo);
@@ -925,8 +1141,62 @@
]]>
</scriptColumnGenerator>
</generated>
<column name="VALOR_FRETE" caption="Valor frete" align="RIGHT" format="#.##0,00" commitOnValueChange="true" editable="true" decimalSeparator="," />
<generated name="UF_ORIGEM" caption="Uf Origem" cache="false" >
<generated name="CAMINHAO_CARRETA" caption="Caminhão/Carreta" cache="false" expand-ratio="0.15" >
<scriptColumnGenerator language="JavaScript">
<![CDATA[
importClass(Packages.com.vaadin.ui.ComboBox);
importClass(Packages.br.com.davinti.base.vaadin.components.data.container.ContainerUtils);
importClass(Packages.com.vaadin.data.Property);
importClass(Packages.br.com.davinti.base.vaadin.components.layout.MessageBox);
var setUsuario = function(chave, cliente) {
if (cliente) {
var sqlAtualiza = "UPDATE controle_receitas_fretes SET caminhao_carreta = ? "+
" WHERE CHAVE_RECEITA_FRETE = ? ";
var params = new java.util.ArrayList();
params.add(String(cliente));
params.add(chave);
vQueryService.executePSUpdateQuery('vitruvio', sqlAtualiza, params.toArray());
} else {
MessageBox.show(MessageBox.BoxType.INFO, 'Atenção', 'Caminhão / Carreta não pode ser vazio.');
}
};
function generate(itemId, columnId, item, container) {
var map = new java.util.LinkedHashMap();
map.put('C', 'Caminhão');
map.put('T', 'Carreta');
var combo = new ComboBox();
combo.setWidth("100%");
ContainerUtils.createAndConfigureContainerFromCaptionMap(map, combo);
var linha = item;
if(linha.getItemProperty('CAMINHAO_CARRETA').getValue()) {
combo.setValue(linha.getItemProperty('CAMINHAO_CARRETA').getValue());
}
combo.addValueChangeListener(new Property.ValueChangeListener() {
valueChange: function(event) {
setUsuario(linha.getItemProperty('CHAVE_RECEITA_FRETE').getValue().longValue(),
event.getProperty().getValue());
},
hashCode: function() {
return combo.hashCode();
}
});
return combo;
}
]]>
</scriptColumnGenerator>
</generated>
<column name="VALOR_FRETE" caption="Valor frete" align="RIGHT" format="#.##0,00" commitOnValueChange="true" editable="true" decimalSeparator="," expand-ratio="0.1" />
<generated name="UF_ORIGEM" caption="Uf Origem" cache="false" expand-ratio="0.1" >
<scriptColumnGenerator language="JavaScript">
<![CDATA[
importClass(Packages.com.vaadin.ui.ComboBox);
@@ -987,7 +1257,7 @@
]]>
</scriptColumnGenerator>
</generated>
<generated name="UF_DESTINO" caption="Uf Destino" cache="false" >
<generated name="UF_DESTINO" caption="Uf Destino" cache="false" expand-ratio="0.1" >
<scriptColumnGenerator language="JavaScript">
<![CDATA[
importClass(Packages.com.vaadin.ui.ComboBox);
@@ -1063,74 +1333,8 @@
]]>
</scriptColumnGenerator>
</generated>
<generated name="FORMA_PAGAMENTO" caption="Forma pagamento" cache="false" >
<scriptColumnGenerator language="JavaScript">
<![CDATA[
importClass(Packages.com.vaadin.ui.ComboBox);
importClass(Packages.br.com.davinti.base.vaadin.components.data.container.ContainerUtils);
importClass(Packages.com.vaadin.data.Property);
importClass(Packages.br.com.davinti.base.vaadin.components.layout.MessageBox);
var setUsuario = function(chave, cliente) {
if (cliente) {
var sqlAtualiza = "UPDATE controle_receitas_fretes SET chave_forma_pagamento = ? "+
" WHERE CHAVE_RECEITA_FRETE = ? ";
var sql = "Select codigo from forma_pagamento where nome = '" + cliente + "'";
var db = libService.loadScript('db');
var dbVitruvio = new db('vitruvio');
var row = dbVitruvio.queryRow(sql);
var params = new java.util.ArrayList();
params.add(row.codigo);
params.add(chave);
vQueryService.executePSUpdateQuery('vitruvio', sqlAtualiza, params.toArray());
} else {
MessageBox.show(MessageBox.BoxType.INFO, 'Atenção', 'Forma de pagamento não pode ser vazio.');
}
};
function generate(itemId, columnId, item, container) {
var sql = "Select codigo, nome from forma_pagamento";
var ds = vQueryService.executeQuery('vitruvio', sql);
if(ds == null){
return null;
}
var map = new java.util.LinkedHashMap();
while(ds.next()) {
map.put(ds.getString('nome'), ds.getString('nome'));
}
var combo = new ComboBox();
combo.setWidth("100%");
ContainerUtils.createAndConfigureContainerFromCaptionMap(map, combo);
var linha = item;
if(linha.getItemProperty('FORMA_PAGAMENTO').getValue()) {
combo.setValue(linha.getItemProperty('FORMA_PAGAMENTO').getValue());
}
combo.addValueChangeListener(new Property.ValueChangeListener() {
valueChange: function(event) {
setUsuario(linha.getItemProperty('CHAVE_RECEITA_FRETE').getValue().longValue(),
event.getProperty().getValue());
},
hashCode: function() {
return combo.hashCode();
}
});
return combo;
}
]]>
</scriptColumnGenerator>
</generated>
<column name="VALOR_IMPOSTO" caption="Valor impostos" format="###0.00" decimalSeparator="," />
<column name="VALOR_LIQUIDO" caption="Lucro (Frete - Impostos)" format="###0.00" decimalSeparator="," />
<column name="VALOR_IMPOSTO" caption="Valor impostos" format="###0.00" decimalSeparator="," expand-ratio="0.1" />
<column name="VALOR_LIQUIDO" caption="Lucro (Frete - Impostos)" format="###0.00" decimalSeparator="," expand-ratio="0.1" />
</columns>
<events>
<itemChange>
@@ -1144,7 +1348,7 @@
var impostos = row.impostos;
var liquido = row.liquido;
dbVitruvio.transaction(function() {
var sqlAtualiza = "UPDATE controle_receitas_fretes SET data = :data, cte = :cte, valor_frete = :valor_frete, valor_imposto = :valor_imposto, valor_liquido = :valor_liquido" +
var sqlAtualiza = "UPDATE controle_receitas_fretes SET data = :data, cte = :cte, valor_frete = :valor_frete, valor_imposto = :valor_imposto, valor_liquido = :valor_liquido, usuario = :usuario " +
" WHERE CHAVE_RECEITA_FRETE = :chave";
this.update(sqlAtualiza, {
chave: Number(event.getItemId()),
@@ -1152,7 +1356,8 @@
cte: event.getField('CTE').getConvertedValue(),
valor_frete: event.getField('VALOR_FRETE').getConvertedValue(),
valor_imposto: impostos,
valor_liquido: liquido
valor_liquido: liquido,
usuario: engine.getLoggedUser().getLogin()
});
});
engine.getField('tbLancamentos').refresh();