Commit e8e7d04c3e21f973fcc8b42f94db7a9725d27c9a
Exists in
master
and in
1 other branch
Merge branch 'master' into 'develop'
Master See merge request !8
Showing
2 changed files
Show diff stats
src/js/controller.js
... | ... | @@ -8,31 +8,12 @@ angular.module('focaModalPrecioCondicion') |
8 | 8 | '$uibModalInstance', |
9 | 9 | 'focaModalService', |
10 | 10 | 'focaModalPrecioCondicionService', |
11 | + 'idListaPrecio', | |
11 | 12 | function( |
12 | 13 | $timeout, $filter, $scope, $uibModal, $uibModalInstance, |
13 | - focaModalService, focaModalPrecioCondicionService | |
14 | + focaModalService, focaModalPrecioCondicionService, idListaPrecio | |
14 | 15 | ) { |
15 | - | |
16 | - focaModalPrecioCondicionService.getPreciosCondicionesPlazosPagos().then( | |
17 | - function(res) { | |
18 | - for(var i = 0; i < res.data.length; i++) { | |
19 | - var plazosTemp = ''; | |
20 | - res.data[i].plazoPago.sort(function(a, b) { | |
21 | - return a.dias - b.dias; | |
22 | - }); | |
23 | - for(var j = 0; j < res.data[i].plazoPago.length; j++) { | |
24 | - if(j + 1 === res.data[i].plazoPago.length) { | |
25 | - plazosTemp += res.data[i].plazoPago[j].dias; | |
26 | - }else { | |
27 | - plazosTemp += res.data[i].plazoPago[j].dias + ', '; | |
28 | - } | |
29 | - } | |
30 | - res.data[i].plazos = plazosTemp.trim(); | |
31 | - } | |
32 | - $scope.precioCondicion = res.data; | |
33 | - $scope.search(); | |
34 | - } | |
35 | - ); | |
16 | + | |
36 | 17 | $scope.filters = ''; |
37 | 18 | $scope.ingreso = false; |
38 | 19 | $scope.plazosNuevos = []; |
... | ... | @@ -47,8 +28,31 @@ angular.module('focaModalPrecioCondicion') |
47 | 28 | $scope.currentPagePrecioCondicion = []; |
48 | 29 | $scope.selectedPrecioCondicion = -1; |
49 | 30 | |
50 | - //METODOS | |
31 | + var funcionGet = idListaPrecio ? 'getPreciosCondicionesByIdListaPrecio' : | |
32 | + 'getPreciosCondiciones'; | |
33 | + | |
34 | + focaModalPrecioCondicionService | |
35 | + [funcionGet](idListaPrecio) | |
36 | + .then(function(res) { | |
37 | + for (var i = 0; i < res.data.length; i++) { | |
38 | + var plazosTemp = ''; | |
39 | + res.data[i].plazoPago.sort(function(a, b) { | |
40 | + return a.dias - b.dias; | |
41 | + }); | |
42 | + for (var j = 0; j < res.data[i].plazoPago.length; j++) { | |
43 | + if (j + 1 === res.data[i].plazoPago.length) { | |
44 | + plazosTemp += res.data[i].plazoPago[j].dias; | |
45 | + } else { | |
46 | + plazosTemp += res.data[i].plazoPago[j].dias + ', '; | |
47 | + } | |
48 | + } | |
49 | + res.data[i].plazos = plazosTemp.trim(); | |
50 | + } | |
51 | + $scope.precioCondicion = res.data; | |
52 | + $scope.search(); | |
53 | + }); | |
51 | 54 | |
55 | + //METODOS | |
52 | 56 | $scope.agregarPlazo = function(key) { |
53 | 57 | if(key === 13) { |
54 | 58 | if(!$scope.plazoACargar.dias) { |
src/js/service.js
... | ... | @@ -4,14 +4,15 @@ angular.module('focaModalPrecioCondicion') |
4 | 4 | 'API_ENDPOINT', |
5 | 5 | function($http, API_ENDPOINT) { |
6 | 6 | return { |
7 | - getPreciosCondiciones: function() { | |
8 | - return $http.get(API_ENDPOINT.URL + '/precio-condicion'); | |
9 | - }, | |
10 | 7 | getPlazosByIdPrecioCondicion: function(id) { |
11 | 8 | return $http.get(API_ENDPOINT.URL + '/plazo-pago/precio-condicion/' + id); |
12 | 9 | }, |
13 | - getPreciosCondicionesPlazosPagos: function() { | |
10 | + getPreciosCondiciones: function() { | |
14 | 11 | return $http.get(API_ENDPOINT.URL + '/precio-condicion/plazo-pago'); |
12 | + }, | |
13 | + getPreciosCondicionesByIdListaPrecio: function(idListaPrecio) { | |
14 | + return $http.get(API_ENDPOINT.URL + '/precio-condicion/plazo-pago/' + | |
15 | + idListaPrecio); | |
15 | 16 | } |
16 | 17 | }; |
17 | 18 | } |