Commit ed56e1cb7c73722bc49ec0cd6e5f85220854a280
1 parent
555778cf
Exists in
master
Redmine #4483 Bloqueando exclusão de conta contábil durante o fechamento do mês de referência
Showing
4 changed files
with
74 additions
and
9 deletions
Show diff stats
cit-adm-materiais-web/src/main/java/br/com/centralit/controller/ContaContabilController.java
... | ... | @@ -5,6 +5,7 @@ import java.util.List; |
5 | 5 | |
6 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
7 | 7 | import org.springframework.stereotype.Controller; |
8 | +import org.springframework.web.bind.annotation.PathVariable; | |
8 | 9 | import org.springframework.web.bind.annotation.RequestBody; |
9 | 10 | import org.springframework.web.bind.annotation.RequestMapping; |
10 | 11 | import org.springframework.web.bind.annotation.RequestMethod; |
... | ... | @@ -370,4 +371,25 @@ public class ContaContabilController extends GenericController<ContaContabil> { |
370 | 371 | return responseBody; |
371 | 372 | } |
372 | 373 | } |
374 | + | |
375 | + @RequestMapping(method = RequestMethod.DELETE, value = "/{id}") | |
376 | + @ResponseBody | |
377 | + public ResponseBodyWrapper delete(@PathVariable("id") Long id) { | |
378 | + | |
379 | + Organizacao organizacao = this.organizacaoService.find(this.getUsuario().getOrganizacao().getId()); | |
380 | + | |
381 | + if (!organizacao.getEmFechamento()) { | |
382 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(contaContabilService.removeById(id), getEditView()); | |
383 | + | |
384 | + return responseBody; | |
385 | + } else { | |
386 | + MyRetornoStatus retorno = new MyRetornoStatus(); | |
387 | + retorno.data = id; | |
388 | + retorno.mensagens.add(new MyMensagemRetorno(MyMensagemRetorno.TipoMensagemRetorno.warning, "MSG.ORGANIZACAO_EM_FECHAMENTO_MES")); | |
389 | + | |
390 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(retorno, getEditView()); | |
391 | + | |
392 | + return responseBody; | |
393 | + } | |
394 | + } | |
373 | 395 | } |
374 | 396 | \ No newline at end of file | ... | ... |
cit-adm-materiais-web/src/main/webapp/assets/js/angular/custom/controller/ContaContabilController.js
... | ... | @@ -36,14 +36,21 @@ citApp.controller('ContaContabilController', ['$scope', 'ContaContabilRepository |
36 | 36 | $scope.$openModalConfirm({ |
37 | 37 | message: $translate.instant('ADMINISTRACAODEMATERIAIS.MSG.CONFIRMA_EXCLUIR_CONTA_CONTABIL'), |
38 | 38 | callback: function () { |
39 | - ContaContabilRepository.remove(contaContabil).then(function() { | |
40 | - $scope.contaContabil = {}; | |
41 | - | |
42 | - $scope.$modalConfirmInstance.dismiss('cancel'); | |
43 | - $scope.showAlert("success", $translate.instant('ADMINISTRACAODEMATERIAIS.MSG.SUCESSO_CONTA_CONTABIL_EXCLUIDO')); | |
44 | - angular.element('#searchContaContabil').scope().fetchResult(); | |
45 | - | |
46 | - $scope.resetForm(); | |
39 | + ContaContabilRepository.remove(contaContabil).then(function(result) { | |
40 | + if (result.originalElement && result.originalElement.status != undefined && !result.originalElement.status && result.originalElement.mensagens) { | |
41 | + $scope.setLoading(false); | |
42 | + angular.forEach(result.originalElement.mensagens, function (mensagem) { | |
43 | + $scope.showAlert(mensagem.tipoMensagem, $translate.instant(mensagem.mensagem)); | |
44 | + }); | |
45 | + } else { | |
46 | + $scope.contaContabil = {}; | |
47 | + | |
48 | + $scope.$modalConfirmInstance.dismiss('cancel'); | |
49 | + $scope.showAlert("success", $translate.instant('ADMINISTRACAODEMATERIAIS.MSG.SUCESSO_CONTA_CONTABIL_EXCLUIDO')); | |
50 | + angular.element('#searchContaContabil').scope().fetchResult(); | |
51 | + | |
52 | + $scope.resetForm(); | |
53 | + } | |
47 | 54 | }); |
48 | 55 | } |
49 | 56 | }); | ... | ... |
cit-adm-materiais-web/src/main/webapp/assets/js/angular/custom/controller/ContaContabilListController.js
... | ... | @@ -58,6 +58,42 @@ citApp.controller('ContaContabilListController', ['$scope', 'ContaContabilReposi |
58 | 58 | $scope.$showPageEditWorkspace($scope.workspace); |
59 | 59 | }; |
60 | 60 | |
61 | + // MODAL DE CONFIRMAÇÃO E REMOÇÃO DO REGISTRO | |
62 | + $scope.remover = function(){ | |
63 | + | |
64 | + var contaContabil = $scope.contaContabilChecked; | |
65 | + | |
66 | + if(contaContabil) { | |
67 | + | |
68 | + $scope.$openModalConfirm({ | |
69 | + message: $translate.instant("MSG.CONFIRMA_EXCLUSAO"), | |
70 | + callback: function () { | |
71 | + $scope.setLoadingRemove(true); | |
72 | + | |
73 | + ContaContabilRepository.remove(contaContabil).then(function(result) { | |
74 | + if (result.originalElement && result.originalElement.status != undefined && !result.originalElement.status && result.originalElement.mensagens) { | |
75 | + $scope.setLoading(false); | |
76 | + angular.forEach(result.originalElement.mensagens, function (mensagem) { | |
77 | + $scope.showAlert(mensagem.tipoMensagem, $translate.instant(mensagem.mensagem)); | |
78 | + }); | |
79 | + } else { | |
80 | + $scope.$modalConfirmInstance.dismiss('cancel'); | |
81 | + $scope.showAlert('success', $translate.instant('MSG.REGISTRO_EXCLUIDO')); | |
82 | + $scope.fetchResult(); | |
83 | + $scope.setLoading(false); | |
84 | + } | |
85 | + }); | |
86 | + | |
87 | + } | |
88 | + }); | |
89 | + | |
90 | + } else { | |
91 | + | |
92 | + $scope.showAlert('warning', $translate.instant('MSG.SELECIONE_UM_ITEM_PARA_SER_REMOVIDO')); | |
93 | + } | |
94 | + | |
95 | + }; | |
96 | + | |
61 | 97 | }]); |
62 | 98 | |
63 | 99 | ... | ... |
cit-adm-materiais-web/src/main/webapp/html/contaContabil/contaContabilList.html
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | <translate>LABEL.EDITAR</translate> |
18 | 18 | </button> |
19 | 19 | |
20 | - <button title="{{$translate.instant('LABEL.REMOVER')}}" alt="{{$translate.instant('LABEL.REMOVER')}}" class="btn btn-clear" ng-click="remove(contaContabil);"> | |
20 | + <button title="{{$translate.instant('LABEL.REMOVER')}}" alt="{{$translate.instant('LABEL.REMOVER')}}" class="btn btn-clear" ng-click="remover();"> | |
21 | 21 | <i class="fa fa-times red"></i> |
22 | 22 | <translate>LABEL.REMOVER</translate> |
23 | 23 | </button> | ... | ... |