Commit ed19ec8a77c930fb0bed2571828c29be47f2e6ef
1 parent
7fa728bc
Exists in
master
Redmine #4922 Correções na visualização da unidade de medida de uma entrada
Showing
2 changed files
with
55 additions
and
0 deletions
Show diff stats
cit-adm-materiais-api/src/main/resources/scripts-bd/postgres/v1.16.0/01-cit-adm-materiais-v1.16.0-postgres.sql
... | ... | @@ -51,5 +51,25 @@ DO $$ |
51 | 51 | END LOOP; |
52 | 52 | |
53 | 53 | END $$; |
54 | + | |
55 | +INSERT INTO alm_mc_unidmedidaentrada(id, materialconsumo_id, unidademedida_id, ispadrao) | |
56 | + SELECT NEXTVAL('hibernate_sequence') AS id, | |
57 | + mat.id AS materialconsumo_id, | |
58 | + mat.unidadearmazenamento_id AS unidademedida_id, | |
59 | + false AS ispadrao | |
60 | + FROM alm_materialconsumo mat | |
61 | + WHERE mat.unidadearmazenamento_id NOT IN ( | |
62 | + SELECT unidademedida_id FROM alm_mc_unidmedidaentrada WHERE materialconsumo_id = mat.id | |
63 | + ); | |
64 | + | |
65 | +UPDATE | |
66 | + alm_mc_unidmedidaentrada und | |
67 | +SET | |
68 | + ispadrao = true | |
69 | +FROM | |
70 | + (SELECT mat.id, mat.unidadearmazenamento_id FROM alm_materialconsumo mat WHERE | |
71 | + (SELECT count(*) FROM alm_mc_unidmedidaentrada WHERE materialconsumo_id = mat.id AND ispadrao = true) = 0) AS undidadesEnt | |
72 | +WHERE | |
73 | + und.materialconsumo_id = undidadesEnt.id AND und.unidademedida_id = undidadesEnt.unidadearmazenamento_id; | |
54 | 74 | |
55 | 75 | -- GEOVANE FIM 24/05/2016 |
56 | 76 | \ No newline at end of file | ... | ... |
cit-adm-materiais-web/src/main/webapp/assets/js/angular/custom/controller/MaterialController.js
... | ... | @@ -289,6 +289,41 @@ citApp.controller('MaterialController', ['$scope', 'MaterialRepository', 'Classi |
289 | 289 | $scope.$watch('material.dominioTipoMaterial.codigo', function() { |
290 | 290 | verificaMaterialConsumoSetGenerico(); |
291 | 291 | }); |
292 | + | |
293 | + $scope.$watch('material.unidadeArmazenamento', function() { | |
294 | + if ($scope.material.unidadeArmazenamento) { | |
295 | + if (!$scope.material.tiposUnidadeMedidaEntrada) { | |
296 | + $scope.material.tiposUnidadeMedidaEntrada = []; | |
297 | + } | |
298 | + | |
299 | + var jaAdd = false; | |
300 | + var isPossuiPadrao = false; | |
301 | + for (var i = 0; i < $scope.material.tiposUnidadeMedidaEntrada.length; i++) { | |
302 | + if ($scope.material.tiposUnidadeMedidaEntrada[i].unidadeMedida.id == $scope.material.unidadeArmazenamento.id) { | |
303 | + jaAdd = true; | |
304 | + } | |
305 | + if ($scope.material.tiposUnidadeMedidaEntrada[i].isPadrao) { | |
306 | + isPossuiPadrao = true; | |
307 | + } | |
308 | + } | |
309 | + | |
310 | + if (!jaAdd) { | |
311 | + if(isPossuiPadrao){ | |
312 | + var unidadeEntrada = { | |
313 | + unidadeMedida : $scope.material.unidadeArmazenamento, | |
314 | + isPadrao : false | |
315 | + }; | |
316 | + $scope.material.tiposUnidadeMedidaEntrada.push(unidadeEntrada); | |
317 | + } else { | |
318 | + var unidadeEntrada = { | |
319 | + unidadeMedida : $scope.material.unidadeArmazenamento, | |
320 | + isPadrao : true | |
321 | + }; | |
322 | + $scope.material.tiposUnidadeMedidaEntrada.push(unidadeEntrada); | |
323 | + } | |
324 | + } | |
325 | + } | |
326 | + }); | |
292 | 327 | |
293 | 328 | |
294 | 329 | DominioRepository.findAllDominio('tipoMaterial').then(function(result) { | ... | ... |