Commit 780a9f584b05c2fc609c7197453e22a11bed145c

Authored by Pablo Marco del Pont
1 parent 386044763b
Exists in master

- Cambié el servicio focaAbmPlazoPagoService por el focaAbmPreciosCondicionesService.

- Agregué método para editar plazo de pago.
- Eliminé el servicio focaAbmPlazoPagoService de los servicios.
- Agregué títulos.
- Cambié tipos de datos a numérico.
src/js/controller.js
1 angular.module('focaAbmPreciosCondiciones') 1 angular.module('focaAbmPreciosCondiciones')
2 .controller('focaAbmPreciosCondicionesController', [ 2 .controller('focaAbmPreciosCondicionesController', [
3 '$scope', 'focaAbmPreciosCondicionesService', '$location', '$uibModal', 3 '$scope', 'focaAbmPreciosCondicionesService', '$location', '$uibModal',
4 function($scope, focaAbmPreciosCondicionesService, $location, $uibModal) { 4 function($scope, focaAbmPreciosCondicionesService, $location, $uibModal) {
5 focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) { 5 focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) {
6 $scope.preciosCondiciones = datos.data; 6 $scope.preciosCondiciones = datos.data;
7 }); 7 });
8 $scope.editar = function(id) { 8 $scope.editar = function(id) {
9 $location.path('/precio-condicion/' + id); 9 $location.path('/precio-condicion/' + id);
10 }; 10 };
11 $scope.solicitarConfirmacion = function(precioCondicion) { 11 $scope.solicitarConfirmacion = function(precioCondicion) {
12 $uibModal.open({ 12 $uibModal.open({
13 templateUrl: 'foca-abm-precios-condiciones-modal-confirmar.html', 13 templateUrl: 'foca-abm-precios-condiciones-modal-confirmar.html',
14 controller: 'focaAbmPreciosCondicionesModalConfirmarController', 14 controller: 'focaAbmPreciosCondicionesModalConfirmarController',
15 animation: false, 15 animation: false,
16 backdrop: false, 16 backdrop: false,
17 resolve: {precioCondicion: function(){return precioCondicion;}} 17 resolve: {precioCondicion: function(){return precioCondicion;}}
18 }) 18 })
19 .result.then(function(precioCondicion){ 19 .result.then(function(precioCondicion){
20 focaAbmPreciosCondicionesService.borrarPrecioCondicion(precioCondicion.id); 20 focaAbmPreciosCondicionesService.borrarPrecioCondicion(precioCondicion.id);
21 $scope.preciosCondiciones.splice( 21 $scope.preciosCondiciones.splice(
22 $scope.preciosCondiciones.indexOf(precioCondicion), 1 22 $scope.preciosCondiciones.indexOf(precioCondicion), 1
23 ); 23 );
24 }); 24 });
25 }; 25 };
26 } 26 }
27 ]) 27 ])
28 .controller('focaAbmPrecioCondicionController', [ 28 .controller('focaAbmPrecioCondicionController', [
29 '$scope', 'focaAbmPreciosCondicionesService', 'focaAbmPlazoPagoService', 29 '$scope', 'focaAbmPreciosCondicionesService',
30 '$routeParams', '$location', 30 '$routeParams', '$location',
31 function( 31 function(
32 $scope, focaAbmPreciosCondicionesService, focaAbmPlazoPagoService, 32 $scope, focaAbmPreciosCondicionesService,
33 $routeParams, $location 33 $routeParams, $location
34 ) { 34 ) {
35 focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id) 35 focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id)
36 .then(function(datos) { 36 .then(function(datos) {
37 $scope.precioCondicion = { 37 $scope.precioCondicion = {
38 id: 0, 38 id: 0,
39 codigo: '', 39 codigo: '',
40 nombre: '', 40 nombre: '',
41 descripcion: '', 41 descripcion: '',
42 idListaPrecio: 0, 42 idListaPrecio: 0,
43 vigencia: new Date() 43 vigencia: new Date()
44 }; 44 };
45 if(datos.data.id) { 45 if(datos.data.id) {
46 $scope.precioCondicion = datos.data; 46 $scope.precioCondicion = datos.data;
47 focaAbmPlazoPagoService.obtenerPlazoPago(datos.data.id) 47 focaAbmPreciosCondicionesService.obtenerPlazoPago(datos.data.id)
48 .then(function(datos){ 48 .then(function(datos){
49 $scope.precioCondicion.plazos = datos.data; 49 $scope.precioCondicion.plazos = datos.data;
50 }); 50 });
51 } 51 }
52 }); 52 });
53 $scope.cancelar = function() { 53 $scope.cancelar = function() {
54 $location.path('/precio-condicion'); 54 $location.path('/precio-condicion');
55 }; 55 };
56 $scope.guardar = function(precioCondicion) { 56 $scope.guardar = function(precioCondicion) {
57 focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion) 57 focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion)
58 .then(function() { 58 .then(function() {
59 $location.path('/precio-condicion'); 59 $location.path('/precio-condicion');
60 }); 60 });
61 }; 61 };
62 $scope.editarPlazoPago = function(id) {
63 $location.path(
64 '/precio-condicion/' + $scope.precioCondicion.id +
65 '/plazo-pago/' + id
66 );
67 };
62 } 68 }
63 ]) 69 ])
64 .controller('focaAbmPreciosCondicionesModalConfirmarController', [ 70 .controller('focaAbmPreciosCondicionesModalConfirmarController', [
65 '$uibModalInstance', '$scope', 'precioCondicion', 71 '$uibModalInstance', '$scope', 'precioCondicion',
66 function($uibModalInstance, $scope, precioCondicion) { 72 function($uibModalInstance, $scope, precioCondicion) {
67 $scope.precioCondicion = precioCondicion; 73 $scope.precioCondicion = precioCondicion;
68 $scope.cancelar = function() { 74 $scope.cancelar = function() {
69 $uibModalInstance.dismiss(); 75 $uibModalInstance.dismiss();
70 }; 76 };
71 $scope.borrar = function() { 77 $scope.borrar = function() {
72 $uibModalInstance.close(precioCondicion); 78 $uibModalInstance.close(precioCondicion);
73 }; 79 };
74 } 80 }
75 ]); 81 ]);
76 82
1 angular.module('focaAbmPreciosCondiciones') 1 angular.module('focaAbmPreciosCondiciones')
2 .service('focaAbmPreciosCondicionesService', [ 2 .service('focaAbmPreciosCondicionesService', [
3 '$http', 'API_ENDPOINT', 3 '$http', 'API_ENDPOINT',
4 function($http, API_ENDPOINT) { 4 function($http, API_ENDPOINT) {
5 return { 5 return {
6 obtenerPreciosCondiciones: function() { 6 obtenerPreciosCondiciones: function() {
7 return $http.get(API_ENDPOINT.URL + '/precio-condicion'); 7 return $http.get(API_ENDPOINT.URL + '/precio-condicion');
8 }, 8 },
9 obtenerPrecioCondicion: function(id) { 9 obtenerPrecioCondicion: function(id) {
10 return $http.get(API_ENDPOINT.URL + '/precio-condicion/' + id); 10 return $http.get(API_ENDPOINT.URL + '/precio-condicion/' + id);
11 }, 11 },
12 guardarPrecioCondicion: function(precioCondicion) { 12 guardarPrecioCondicion: function(precioCondicion) {
13 return $http.post( 13 return $http.post(
14 API_ENDPOINT.URL + '/precio-condicion', 14 API_ENDPOINT.URL + '/precio-condicion',
15 {precioCondicion: precioCondicion} 15 {precioCondicion: precioCondicion}
16 ); 16 );
17 }, 17 },
18 borrarPrecioCondicion: function(id) { 18 borrarPrecioCondicion: function(id) {
19 return $http.delete(API_ENDPOINT.URL + '/precio-condicion/' + id); 19 return $http.delete(API_ENDPOINT.URL + '/precio-condicion/' + id);
20 } 20 },
21 };
22 }
23 ])
24 .service('focaAbmPlazoPagoService', [
25 '$http', 'API_ENDPOINT',
26 function($http, API_ENDPOINT) {
27 return {
28 obtenerPlazoPago: function(idPrecioCondicion) { 21 obtenerPlazoPago: function(idPrecioCondicion) {
29 return $http.get( 22 return $http.get(
30 API_ENDPOINT.URL + '/plazo-pago/precio-condicion/' + idPrecioCondicion 23 API_ENDPOINT.URL + '/plazo-pago/precio-condicion/' + idPrecioCondicion
31 ); 24 );
32 } 25 }
33 }; 26 };
34 } 27 }
35 ]); 28 ]);
36 29
src/views/foca-abm-precios-condiciones-item.html
1 <h4>Precios y Condiciones</h4>
1 <form> 2 <form>
2 <input type="hidden" name="id" ng-model="precioCondicion.id" /> 3 <input type="hidden" name="id" ng-model="precioCondicion.id" />
3 <div class="form-group row"> 4 <div class="form-group row">
4 <label class="offset-sm-1 col-sm-2 col-form-label">Código</label> 5 <label class="offset-sm-1 col-sm-2 col-form-label">Código</label>
5 <div class="col-sm-4"> 6 <div class="col-sm-4">
6 <input 7 <input
7 class="form-control" 8 class="form-control"
8 type="text" 9 type="text"
9 name="codigo" 10 name="codigo"
10 ng-model="precioCondicion.codigo" 11 ng-model="precioCondicion.codigo"
11 /> 12 />
12 </div> 13 </div>
13 </div> 14 </div>
14 <div class="form-group row"> 15 <div class="form-group row">
15 <label class="offset-sm-1 col-sm-2 col-form-label">Nombre</label> 16 <label class="offset-sm-1 col-sm-2 col-form-label">Nombre</label>
16 <div class="col-sm-4"> 17 <div class="col-sm-4">
17 <input 18 <input
18 class="form-control" 19 class="form-control"
19 type="text" 20 type="text"
20 name="nombre" 21 name="nombre"
21 ng-model="precioCondicion.nombre" 22 ng-model="precioCondicion.nombre"
22 /> 23 />
23 </div> 24 </div>
24 </div> 25 </div>
25 <div class="form-group row"> 26 <div class="form-group row">
26 <label class="offset-sm-1 col-sm-2 col-form-label">Descripción</label> 27 <label class="offset-sm-1 col-sm-2 col-form-label">Descripción</label>
27 <div class="col-sm-4"> 28 <div class="col-sm-4">
28 <input 29 <input
29 class="form-control" 30 class="form-control"
30 type="text" 31 type="text"
31 name="nombre" 32 name="nombre"
32 ng-model="precioCondicion.descripcion" 33 ng-model="precioCondicion.descripcion"
33 /> 34 />
34 </div> 35 </div>
35 </div> 36 </div>
36 <div class="form-group row"> 37 <div class="form-group row">
37 <label class="offset-sm-1 col-sm-2 col-form-label">Lista de precios</label> 38 <label class="offset-sm-1 col-sm-2 col-form-label">Lista de precios</label>
38 <div class="col-sm-4"> 39 <div class="col-sm-4">
39 <input 40 <input
40 class="form-control" 41 class="form-control"
41 type="text" 42 type="number"
42 name="nombre" 43 name="nombre"
43 ng-model="precioCondicion.idListaPrecio" 44 ng-model="precioCondicion.idListaPrecio"
44 /> 45 />
45 </div> 46 </div>
46 </div> 47 </div>
47 <div class="form-group row"> 48 <div class="form-group row">
48 <label class="offset-sm-1 col-sm-2 col-form-label">Plazos</label> 49 <label class="offset-sm-1 col-sm-2 col-form-label">Plazos</label>
49 <div class="col-sm-4"> 50 <div class="col-sm-4">
50 <table class="table table-sm table-hover"> 51 <table class="table table-sm table-hover">
51 <tr> 52 <tr>
52 <th>Item</th> 53 <th>Item</th>
53 <th>Dias</th> 54 <th>Dias</th>
54 <th colspan="2" class="text-center"> 55 <th colspan="2" class="text-center">
55 <button class="btn btn-default" ng-click="editar(0)"> 56 <button class="btn btn-default" ng-click="editarPlazoPago(0)">
56 <i class="fa fa-plus"></i> 57 <i class="fa fa-plus"></i>
57 </button> 58 </button>
58 </th> 59 </th>
59 </tr> 60 </tr>
60 <tr ng-repeat="plazo in precioCondicion.plazos"> 61 <tr ng-repeat="plazo in precioCondicion.plazos">
61 <td ng-bind="plazo.item"></td> 62 <td ng-bind="plazo.item"></td>
62 <td ng-bind="plazo.dias"></td> 63 <td ng-bind="plazo.dias"></td>
63 <td class="text-center"> 64 <td class="text-center">
64 <button class="btn btn-default" ng-click="editarPlazo(plazo.id)"> 65 <button class="btn btn-default" ng-click="editarPlazoPago(plazo.id)">
65 <i class="fa fa-pencil"></i> 66 <i class="fa fa-pencil"></i>
66 </button> 67 </button>
67 <button 68 <button
68 class="btn btn-default" 69 class="btn btn-default"
69 ng-click="solicitarConfirmacionPlazo(plazo)" 70 ng-click="solicitarConfirmacionPlazoPago(plazo)"
70 > 71 >
71 <i class="fa fa-trash"></i> 72 <i class="fa fa-trash"></i>
72 </button> 73 </button>
73 </td> 74 </td>
74 </tr> 75 </tr>
75 </table> 76 </table>
76 </div> 77 </div>
77 </div> 78 </div>
78 <div class="form-group row"> 79 <div class="form-group row">
79 <div class="col-sm-7 text-right"> 80 <div class="col-sm-7 text-right">
80 <button class="btn btn-primary" ng-click="guardar(precioCondicion)">Guardar</button> 81 <button class="btn btn-primary" ng-click="guardar(precioCondicion)">Guardar</button>
81 <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> 82 <button class="btn btn-default" ng-click="cancelar()">Cancelar</button>
82 </div> 83 </div>
83 </div> 84 </div>
84 </form> 85 </form>
85 86
src/views/foca-abm-precios-condiciones-listado.html
1 <h4>Precios y Condiciones</h4>
1 <table class="table table-sm table-hover table-nonfluid"> 2 <table class="table table-sm table-hover table-nonfluid">
2 <tr> 3 <tr>
3 <th>Código</th> 4 <th>Código</th>
4 <th>Nombre</th> 5 <th>Nombre</th>
5 <th colspan="2" class="text-center"> 6 <th colspan="2" class="text-center">
6 <button class="btn btn-default" ng-click="editar(0)"> 7 <button class="btn btn-default" ng-click="editar(0)">
7 <i class="fa fa-plus"></i> 8 <i class="fa fa-plus"></i>
8 </button> 9 </button>
9 </th> 10 </th>
10 </tr> 11 </tr>
11 <tr ng-repeat="precioCondicion in preciosCondiciones"> 12 <tr ng-repeat="precioCondicion in preciosCondiciones">
12 <td ng-bind="precioCondicion.codigo"></td> 13 <td ng-bind="precioCondicion.codigo"></td>
13 <td ng-bind="precioCondicion.nombre"></td> 14 <td ng-bind="precioCondicion.nombre"></td>
14 <td> 15 <td>
15 <button class="btn btn-default" ng-click="editar(precioCondicion.id)"> 16 <button class="btn btn-default" ng-click="editar(precioCondicion.id)">
16 <i class="fa fa-pencil"></i> 17 <i class="fa fa-pencil"></i>
17 </button> 18 </button>
18 <button class="btn btn-default" ng-click="solicitarConfirmacion(precioCondicion)"> 19 <button class="btn btn-default" ng-click="solicitarConfirmacion(precioCondicion)">
19 <i class="fa fa-trash"></i> 20 <i class="fa fa-trash"></i>
20 </button> 21 </button>
21 </td> 22 </td>
22 </tr> 23 </tr>
23 </table> 24 </table>
24 25