Commit 1a0d47688c7959154aa365c64b5671cd407ae99f
1 parent
77bd417f
Exists in
master
Redmine $4483 Bloqueando exclusão de transferência interna durante o fechamento …
…do mês de referência.
Showing
3 changed files
with
48 additions
and
13 deletions
Show diff stats
citgrp-patrimonio-web/src/main/java/br/com/centralit/controller/TransferenciaController.java
... | ... | @@ -402,6 +402,27 @@ public class TransferenciaController extends GenericController<Transferencia>{ |
402 | 402 | return responseBody; |
403 | 403 | } |
404 | 404 | } |
405 | + | |
406 | + @RequestMapping(method = RequestMethod.DELETE, value = "/{id}") | |
407 | + @ResponseBody | |
408 | + public ResponseBodyWrapper delete(@PathVariable("id") Long id) { | |
409 | + | |
410 | + Organizacao organizacao = this.organizacaoService.find(this.getUsuario().getOrganizacao().getId()); | |
411 | + | |
412 | + if (!organizacao.getEmFechamento()) { | |
413 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(transferenciaService.removeById(id), getEditView()); | |
414 | + | |
415 | + return responseBody; | |
416 | + } else { | |
417 | + MyRetornoStatus retorno = new MyRetornoStatus(); | |
418 | + retorno.data = id; | |
419 | + retorno.mensagens.add(new MyMensagemRetorno(MyMensagemRetorno.TipoMensagemRetorno.warning, "MSG.ORGANIZACAO_EM_FECHAMENTO_MES")); | |
420 | + | |
421 | + ResponseBodyWrapper responseBody = new ResponseBodyWrapper(retorno, getEditView()); | |
422 | + | |
423 | + return responseBody; | |
424 | + } | |
425 | + } | |
405 | 426 | |
406 | 427 | @RequestMapping(value = "/validarTransferenciaMesmoDia", method = RequestMethod.POST) |
407 | 428 | @ResponseBody | ... | ... |
citgrp-patrimonio-web/src/main/webapp/assets/js/angular/custom/controller/TransferenciaController.js
... | ... | @@ -441,13 +441,20 @@ citApp.controller('TransferenciaController', ['$scope', '$filter', '$timeout', ' |
441 | 441 | message: $translate.instant("MSG.CONFIRMA_EXCLUSAO"), |
442 | 442 | callback: function () { |
443 | 443 | $scope.setLoadingRemove(true); |
444 | - TransferenciaRepository.remove($scope.transferencia).then(function() { | |
445 | - $scope.showAlert('success', $translate.instant('MSG.EXCLUSAO_SUCESSO'), " ", false); | |
446 | - angular.element('#searchTransferencia').scope().fetchResult(); | |
447 | - $scope.$showPageSearchWorkspace($scope.workspace); | |
448 | - angular.element('#searchTransferencia').scope().listaSelecionados = []; | |
449 | - $scope.$modalConfirmInstance.dismiss('cancel'); | |
450 | - $scope.setLoading(false); | |
444 | + TransferenciaRepository.remove($scope.transferencia).then(function(result) { | |
445 | + if (result.originalElement && result.originalElement.status != undefined && !result.originalElement.status && result.originalElement.mensagens) { | |
446 | + $scope.setLoading(false); | |
447 | + angular.forEach(result.originalElement.mensagens, function (mensagem) { | |
448 | + $scope.showAlert(mensagem.tipoMensagem, $translate.instant(mensagem.mensagem)); | |
449 | + }); | |
450 | + } else { | |
451 | + $scope.showAlert('success', $translate.instant('MSG.EXCLUSAO_SUCESSO'), " ", false); | |
452 | + angular.element('#searchTransferencia').scope().fetchResult(); | |
453 | + $scope.$showPageSearchWorkspace($scope.workspace); | |
454 | + angular.element('#searchTransferencia').scope().listaSelecionados = []; | |
455 | + $scope.$modalConfirmInstance.dismiss('cancel'); | |
456 | + $scope.setLoading(false); | |
457 | + } | |
451 | 458 | }); |
452 | 459 | |
453 | 460 | } | ... | ... |
citgrp-patrimonio-web/src/main/webapp/assets/js/angular/custom/controller/TransferenciaListController.js
... | ... | @@ -97,12 +97,19 @@ citApp.controller('TransferenciaListController', ['$scope', '$filter', '$transla |
97 | 97 | callback: function () { |
98 | 98 | $scope.setLoadingRemove(true); |
99 | 99 | |
100 | - TransferenciaRepository.remove(transferencia).then(function() { | |
101 | - $scope.showAlert('success', $translate.instant('MSG.EXCLUSAO_SUCESSO'), " ", false); | |
102 | - $scope.listaSelecionados = []; | |
103 | - $scope.fetchResult(); | |
104 | - $scope.$modalConfirmInstance.dismiss('cancel'); | |
105 | - $scope.setLoading(false); | |
100 | + TransferenciaRepository.remove(transferencia).then(function(result) { | |
101 | + if (result.originalElement && result.originalElement.status != undefined && !result.originalElement.status && result.originalElement.mensagens) { | |
102 | + $scope.setLoading(false); | |
103 | + angular.forEach(result.originalElement.mensagens, function (mensagem) { | |
104 | + $scope.showAlert(mensagem.tipoMensagem, $translate.instant(mensagem.mensagem)); | |
105 | + }); | |
106 | + } else { | |
107 | + $scope.showAlert('success', $translate.instant('MSG.EXCLUSAO_SUCESSO'), " ", false); | |
108 | + $scope.listaSelecionados = []; | |
109 | + $scope.fetchResult(); | |
110 | + $scope.$modalConfirmInstance.dismiss('cancel'); | |
111 | + $scope.setLoading(false); | |
112 | + } | |
106 | 113 | }); |
107 | 114 | |
108 | 115 | } | ... | ... |