DROP VIEW if exists softsat_locacao_veiculo_licenciamento;
create view softsat_locacao_veiculo_licenciamento as
select `vei`.`id` AS `id`,`vei`.`created_on` AS `created_on`,`vei`.`updated_on` AS `updated_on`,`vei`.`created_by` AS `created_by`,`vei`.`updated_by` AS `updated_by`,`vei`.`placa` AS `placa`,`vei`.`marca_id` AS `marca_id`,`vei`.`modelo` AS `modelo`,`vei`.`ano` AS `ano`,`vei`.`ano_modelo` AS `ano_modelo`,`vei`.`combustivel_id` AS `combustivel_id`,`vei`.`chassi` AS `chassi`,`vei`.`grupo_id` AS `grupo_id`,`vei`.`imagem` AS `imagem`,`vei`.`tarifa_id` AS `tarifa_id`,`vei`.`km_atual` AS `km_atual`,`vei`.`km_oleo` AS `km_oleo`,`vei`.`data_oleo` AS `data_oleo`,`vei`.`km_pastilha` AS `km_pastilha`,`vei`.`data_pastilha` AS `data_pastilha`,`vei`.`km_pneu` AS `km_pneu`,`vei`.`data_pneu` AS `data_pneu`,`vei`.`ativo` AS `ativo`,`vei`.`situacao_frente` AS `situacao_frente`,`vei`.`situacao_traseira` AS `situacao_traseira`,`vei`.`situacao_direita` AS `situacao_direita`,`vei`.`situacao_esquerda` AS `situacao_esquerda`,`vei`.`situacao_superior` AS `situacao_superior`,`vei`.`situacao_inferior` AS `situacao_inferior`,`vei`.`ano_licenciamento` AS `ano_licenciamento`,`vei`.`grupo` AS `grupo`,`vei`.`marca` AS `marca`,`vei`.`combustivel` AS `combustivel`,`vei`.`tarifa` AS `tarifa`,`vei`.`diaria` AS `diaria`,`sal`.`value` AS `mes_licenciamento` from (`desenv_locacao`.`softsat_locacao_veiculo_detalhe` `vei` join `desenv_locacao`.`hwapx_setting` `sal` on((`sal`.`id` = concat('softsat.locacao.licenciamento.',substr(`vei`.`placa`,8,1))))) where ((`vei`.`ativo` = 1) and (`vei`.`ano_licenciamento` < year(curdate())))