Commit 46666e8cf10bc49659a342756ba1641e08d316cb
1 parent
7ab4bdc5
Exists in
master
[Redmine Atendimento #4206]Liberação pagamento mask
Showing
3 changed files
with
41 additions
and
9 deletions
Show diff stats
cit-contratos-api/src/main/java/br/com/centralit/api/service/impl/EventoLiberacaoPagamentoServiceImpl.java
... | ... | @@ -4,6 +4,7 @@ import java.math.BigDecimal; |
4 | 4 | import java.util.ArrayList; |
5 | 5 | import java.util.List; |
6 | 6 | |
7 | +import org.apache.commons.lang.StringUtils; | |
7 | 8 | import org.springframework.beans.factory.annotation.Autowired; |
8 | 9 | import org.springframework.beans.factory.annotation.Qualifier; |
9 | 10 | import org.springframework.security.core.context.SecurityContextHolder; |
... | ... | @@ -107,8 +108,11 @@ public class EventoLiberacaoPagamentoServiceImpl extends GenericServiceImpl<Even |
107 | 108 | } |
108 | 109 | |
109 | 110 | Dominio idioma = this.dominioService.findByChaveAndCodigo("tipoIdioma", Dominio.TIPO_IDIOMA_PT_BR_CODIGO); |
111 | + String ano = UtilDate.getAnoAtual(); | |
112 | + String[] numeroLiberacaoMask = liberacaoPagamento.getNumeroLiberacao().split(ano); | |
113 | + | |
110 | 114 | String descricaoEmpenho = this.internacionalizacaoService.getTranslate("LIBERACAO_PAGAMENTO.DESCRICAO_EVENTO", idioma); |
111 | - descricaoEmpenho = descricaoEmpenho.replace("{numeroLiberacaoPagamento}", liberacaoPagamento.getNumeroLiberacao()); | |
115 | + descricaoEmpenho = descricaoEmpenho.replace("{numeroLiberacaoPagamento}", numeroLiberacaoMask.length > 0 ? numeroLiberacaoMask[0] + "/" + ano : liberacaoPagamento.getNumeroLiberacao()); | |
112 | 116 | descricaoEmpenho = descricaoEmpenho.replace("{valor}", Util.convertBigDecimalToString(liberacaoPagamento.getTotalLiberadoPagamento())); |
113 | 117 | descricaoEmpenho = descricaoEmpenho.replace("{data}", UtilDate.formatarData(liberacaoPagamento.getDataLiberacao().getTime(), "dd/MM/yyyy")); |
114 | 118 | |
... | ... | @@ -186,18 +190,18 @@ public class EventoLiberacaoPagamentoServiceImpl extends GenericServiceImpl<Even |
186 | 190 | } |
187 | 191 | |
188 | 192 | private void configurarCodigo(EventoLiberacaoPagamento entitySaved) { |
189 | - | |
190 | - EventoLiberacaoPagamento ultimoRegistro = (EventoLiberacaoPagamento) this.dao.buscarUltimoRegistroComOrdenadoParametrizada(CAMPO_BUSCA_PARAMETRIZADA_ULTIMO_REGISTRO); | |
191 | - | |
193 | + String ano = UtilDate.getAnoAtual(); | |
194 | + Usuario usuarioLogado = (Usuario) usuarioService.find(( (Usuario) SecurityContextHolder.getContext().getAuthentication().getPrincipal() ).getId()); | |
195 | + EventoLiberacaoPagamento ultimoRegistro = (EventoLiberacaoPagamento) this.dao.buscarUltimoAnoRegistroComOrdenadoParametrizada(CAMPO_BUSCA_PARAMETRIZADA_ULTIMO_REGISTRO, ano, usuarioLogado.getOrganizacao().getId()); | |
192 | 196 | Long sequencial = null; |
193 | 197 | |
194 | 198 | if (UtilObjeto.isReferencia(ultimoRegistro)) { |
195 | - sequencial = ultimoRegistro.getNumeroLiberacao() == null ? null : Long.parseLong(ultimoRegistro.getNumeroLiberacao()); | |
199 | + sequencial = ultimoRegistro.getNumeroLiberacao().replace(ano, "") == null ? null : Long.parseLong(ultimoRegistro.getNumeroLiberacao().replace(ano, "") ); | |
200 | + }else{ | |
201 | + sequencial = 0l; | |
196 | 202 | } |
197 | 203 | |
198 | - String codigo = this.configuracaoParametroSistemaService.gerarNumeroIdentificacaoSeguencial(sequencial); | |
199 | - | |
200 | - entitySaved.setNumeroLiberacao(codigo); | |
204 | + entitySaved.setNumeroLiberacao(StringUtils.leftPad((Long.valueOf(sequencial + 1)).toString(), 5, "0") + ano); | |
201 | 205 | } |
202 | 206 | |
203 | 207 | @Override | ... | ... |
cit-contratos-api/src/main/resources/script-bd/v1.0.0-alpha10/01-cit-contratos-1.0.0-ALFA-10-postgres.sql
... | ... | @@ -144,5 +144,33 @@ BEGIN |
144 | 144 | END LOOP; |
145 | 145 | END$$; |
146 | 146 | |
147 | +DO $$ | |
148 | +DECLARE | |
149 | + r RECORD; | |
150 | +BEGIN | |
151 | + FOR r IN | |
152 | + SELECT | |
153 | + lpad(CAST(concat(CAST(CAST(numeroliberacao AS integer) AS VARCHAR), CAST(date_part('Year', (SELECT CURRENT_TIMESTAMP)) AS VARCHAR)) AS VARCHAR),9,'0') AS SEQUENCIALANO, ID as ID | |
154 | + FROM cnt_ev_liberacao_pagamento | |
155 | + LOOP | |
156 | + UPDATE cnt_ev_liberacao_pagamento SET numeroliberacao = r.SEQUENCIALANO WHERE ID = r.ID; | |
157 | + END LOOP; | |
158 | +END$$; | |
159 | + | |
160 | + | |
161 | +DO $$ | |
162 | +DECLARE | |
163 | + r RECORD; | |
164 | +BEGIN | |
165 | + FOR r IN | |
166 | + SELECT | |
167 | + concat(substring(descricao, 0, 30),concat(lpad(CAST(CAST(substring(descricao, 30, 6) AS INTEGER) AS VARCHAR),5,'0'),'/',CAST(date_part('Year', (SELECT CURRENT_TIMESTAMP)) AS VARCHAR)) | |
168 | + ,substring(descricao, 36, length(descricao))) AS DESCRICAO, | |
169 | + ID as ID FROM cnt_cn_evento WHERE descricao like 'Liberação%' | |
170 | + LOOP | |
171 | + UPDATE cnt_cn_evento SET descricao = r.DESCRICAO WHERE ID = r.ID; | |
172 | + END LOOP; | |
173 | +END$$; | |
174 | + | |
147 | 175 | -- ERICK FIM 31/03/2016 |
148 | 176 | ... | ... |
cit-contratos-web/src/main/webapp/html/eventos/cnt_ev_liberacao_pagamento.html
... | ... | @@ -49,7 +49,7 @@ |
49 | 49 | </div> |
50 | 50 | <div class="row"> |
51 | 51 | <div class="col-sm-4"> |
52 | - <label-input ng-type="text" ng-id="liberacaoPagamento.numeroLiberacao" ng-label="LIBERACAO_PAGAMENTO.NUMERO_LIBERACAO" | |
52 | + <label-input ng-type="text" ng-id="liberacaoPagamento.numeroLiberacao" ng-label="LIBERACAO_PAGAMENTO.NUMERO_LIBERACAO" ng-mask="99999/9999" | |
53 | 53 | ng-model="liberacaoPagamento.numeroLiberacao" ng-custom-maxlength="30" form="formDialogLiberacaoPagamento" ng-disabled="true" |
54 | 54 | ng-obrigatorio="false"/> |
55 | 55 | </div> | ... | ... |