Commit 2e1c1db0c9f667fb5e2ae3c91291c043cc2d7b17
1 parent
dcfb219ac3
Exists in
master
- Correcciones para que funcione el módulo.
Showing
5 changed files
with
47 additions
and
33 deletions
Show diff stats
gulpfile.js
1 | const templateCache = require('gulp-angular-templatecache'); | 1 | const templateCache = require('gulp-angular-templatecache'); |
2 | const clean = require('gulp-clean'); | ||
2 | const concat = require('gulp-concat'); | 3 | const concat = require('gulp-concat'); |
3 | const htmlmin = require('gulp-htmlmin'); | 4 | const htmlmin = require('gulp-htmlmin'); |
4 | const rename = require('gulp-rename'); | 5 | const rename = require('gulp-rename'); |
5 | const uglify = require('gulp-uglify'); | 6 | const uglify = require('gulp-uglify'); |
6 | const gulp = require('gulp'); | 7 | const gulp = require('gulp'); |
7 | const pump = require('pump'); | 8 | const pump = require('pump'); |
8 | const jshint = require('gulp-jshint'); | 9 | const jshint = require('gulp-jshint'); |
9 | const replace = require('gulp-replace'); | 10 | const replace = require('gulp-replace'); |
10 | const connect = require('gulp-connect'); | 11 | const connect = require('gulp-connect'); |
11 | 12 | ||
12 | var paths = { | 13 | var paths = { |
13 | srcJS: 'src/js/*.js', | 14 | srcJS: 'src/js/*.js', |
14 | srcViews: 'src/views/*.html', | 15 | srcViews: 'src/views/*.html', |
15 | tmp: 'tmp', | 16 | tmp: 'tmp', |
16 | dist: 'dist/' | 17 | dist: 'dist/' |
17 | }; | 18 | }; |
18 | 19 | ||
19 | gulp.task('templates', function() { | 20 | gulp.task('templates', ['clean'], function() { |
20 | return pump( | 21 | return pump( |
21 | [ | 22 | [ |
22 | gulp.src(paths.srcViews), | 23 | gulp.src(paths.srcViews), |
23 | replace('views/', ''), | ||
24 | htmlmin(), | 24 | htmlmin(), |
25 | templateCache('views.js', { | 25 | templateCache('views.js', { |
26 | module: 'focaCrearNotaPedido', | 26 | module: 'focaCrearNotaPedido', |
27 | root: '' | 27 | root: '' |
28 | }), | 28 | }), |
29 | gulp.dest(paths.tmp) | 29 | gulp.dest(paths.tmp) |
30 | ] | 30 | ] |
31 | ); | 31 | ); |
32 | }); | 32 | }); |
33 | 33 | ||
34 | gulp.task('uglify', ['templates'], function() { | 34 | gulp.task('uglify', ['templates'], function() { |
35 | return pump( | 35 | return pump( |
36 | [ | 36 | [ |
37 | gulp.src([ | 37 | gulp.src([ |
38 | paths.srcJS, | 38 | paths.srcJS, |
39 | 'tmp/views.js' | 39 | 'tmp/views.js' |
40 | ]), | 40 | ]), |
41 | concat('foca-crear-nota-pedido.js'), | 41 | concat('foca-crear-nota-pedido.js'), |
42 | replace('src/views/', ''), | ||
42 | gulp.dest(paths.tmp), | 43 | gulp.dest(paths.tmp), |
43 | rename('foca-crear-nota-pedido.min.js'), | 44 | rename('foca-crear-nota-pedido.min.js'), |
44 | uglify(), | 45 | uglify(), |
45 | gulp.dest(paths.dist) | 46 | gulp.dest(paths.dist) |
46 | ] | 47 | ] |
47 | ); | 48 | ); |
48 | }); | 49 | }); |
49 | 50 | ||
51 | gulp.task('clean', function(){ | ||
52 | return gulp.src(['tmp', 'dist'], {read: false}) | ||
53 | .pipe(clean()); | ||
54 | }); | ||
55 | |||
50 | gulp.task('pre-commit', function() { | 56 | gulp.task('pre-commit', function() { |
51 | return pump( | 57 | return pump( |
52 | [ | 58 | [ |
53 | gulp.src(paths.srcJS), | 59 | gulp.src(paths.srcJS), |
54 | jshint('.jshintrc'), | 60 | jshint('.jshintrc'), |
55 | jshint.reporter('default'), | 61 | jshint.reporter('default'), |
56 | jshint.reporter('fail') | 62 | jshint.reporter('fail') |
57 | ] | 63 | ] |
58 | ); | 64 | ); |
59 | 65 | ||
60 | gulp.start('uglify'); | 66 | gulp.start('uglify'); |
61 | }); | 67 | }); |
62 | 68 | ||
63 | gulp.task('webserver', function() { | 69 | gulp.task('webserver', function() { |
64 | pump [ | 70 | pump [ |
65 | connect.server({port: 3000}) | 71 | connect.server({port: 3000}) |
66 | ] | 72 | ] |
67 | }); | 73 | }); |
68 | 74 | ||
69 | gulp.task('default', ['webserver']); |
package.json
1 | { | 1 | { |
2 | "name": "foca-crear-nota-pedido", | 2 | "name": "foca-crear-nota-pedido", |
3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
4 | "description": "Listado y ABM nota de pedidos", | 4 | "description": "Listado y ABM nota de pedidos", |
5 | "main": "index.js", | 5 | "main": "index.js", |
6 | "scripts": { | 6 | "scripts": { |
7 | "test": "echo \"Error: no test specified\" && exit 1", | 7 | "test": "echo \"Error: no test specified\" && exit 1", |
8 | "compile": "gulp uglify", | 8 | "compile": "gulp uglify", |
9 | "postinstall": "npm run compile && rm -R src && rm index.html && rm .jshintrc && rm gulpfile.js" | 9 | "postinstall": "npm run compile && rm -R src && rm index.html && rm .jshintrc && rm gulpfile.js", |
10 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es jquery jshint pump" | ||
10 | }, | 11 | }, |
11 | "repository": { | 12 | "repository": { |
12 | "type": "git", | 13 | "type": "git", |
13 | "url": "https://192.168.0.11/modulos-npm/foca-crear-nota-pedido.git" | 14 | "url": "https://192.168.0.11/modulos-npm/foca-crear-nota-pedido.git" |
14 | }, | 15 | }, |
15 | "author": "Foca Software", | 16 | "author": "Foca Software", |
16 | "license": "ISC", | 17 | "license": "ISC", |
17 | "dependencies": { | 18 | "dependencies": { |
18 | "angular": "^1.7.x", | ||
19 | "angular-route": "^1.7.4", | ||
20 | "bootstrap": "^4.1.x", | ||
21 | "foca-directivas": "git+https://192.168.0.11/modulos-npm/foca-directivas.git", | 19 | "foca-directivas": "git+https://192.168.0.11/modulos-npm/foca-directivas.git", |
22 | "foca-modal-busqueda-productos": "git+https://192.168.0.11/nguarnieri/foca-modal-busqueda-productos", | 20 | "foca-modal-busqueda-productos": "git+https://192.168.0.11/nguarnieri/foca-modal-busqueda-productos", |
23 | "foca-modal-petroleras": "git+https://192.168.0.11/modulos-npm/foca-modal-petroleras.git", | 21 | "foca-modal-petroleras": "git+https://192.168.0.11/modulos-npm/foca-modal-petroleras.git", |
24 | "foca-modal-vendedores": "git+https://192.168.0.11/modulos-npm/foca-modal-vendedores.git", | 22 | "foca-modal-vendedores": "git+https://192.168.0.11/modulos-npm/foca-modal-vendedores.git", |
25 | "font-awesome": "^4.7.x", | 23 | "jquery": "^3.3.x" |
26 | "gulp": "^3.9.x", | ||
27 | "gulp-angular-templatecache": "^2.2.1", | ||
28 | "gulp-clean": "^0.4.0", | ||
29 | "gulp-concat": "2.6.x", | ||
30 | "gulp-jshint": "^2.1.x", | ||
31 | "gulp-rename": "^1.4.x", | ||
32 | "gulp-replace": "^1.0.x", | ||
33 | "gulp-uglify-es": "^1.0.x", | ||
34 | "jquery": "^3.3.x", | ||
35 | "jshint": "^2.9.x", | ||
36 | "pump": "^3.0.x", | ||
37 | "ui-bootstrap4": "^3.0.5" | ||
38 | }, | 24 | }, |
39 | "devDependencies": { | 25 | "devDependencies": { |
26 | "angular": "^1.7.5", | ||
27 | "angular-route": "^1.7.5", | ||
28 | "bootstrap": "^4.1.3", | ||
40 | "foca-busqueda-cliente": "git+https://192.168.0.11/modulos-npm/foca-busqueda-cliente", | 29 | "foca-busqueda-cliente": "git+https://192.168.0.11/modulos-npm/foca-busqueda-cliente", |
30 | "font-awesome": "^4.7.0", | ||
31 | "gulp": "^3.9.1", | ||
32 | "gulp-angular-templatecache": "^2.2.2", | ||
33 | "gulp-clean": "^0.4.0", | ||
34 | "gulp-concat": "^2.6.1", |
src/js/app.js
1 | angular.module('focaCrearNotaPedido', [ | 1 | angular.module('focaCrearNotaPedido', [ |
2 | 'ngRoute', | 2 | 'ngRoute', |
3 | 'ui.bootstrap', | 3 | 'ui.bootstrap', |
4 | 'focaModalVendedores', | 4 | 'focaModalVendedores', |
5 | 'focaBusquedaProductos', | 5 | 'focaBusquedaProductos', |
6 | 'focaModalPetroleras', | 6 | 'focaModalPetroleras', |
7 | 'focaBusquedaCliente' | 7 | 'focaBusquedaCliente' |
8 | ]); | 8 | ]); |
9 |
src/js/controller.js
1 | angular.module('focaCrearNotaPedido') | 1 | angular.module('focaCrearNotaPedido') |
2 | .controller('notaPedidoCtrl', | 2 | .controller('notaPedidoCtrl', |
3 | ['$scope', '$uibModal', '$location', 'crearNotaPedidoService', | 3 | ['$scope', '$uibModal', '$location', 'crearNotaPedidoService', |
4 | function($scope, $uibModal, $location, crearNotaPedidoService) { | 4 | function($scope, $uibModal, $location, crearNotaPedidoService) { |
5 | $scope.show = false; | 5 | $scope.show = false; |
6 | 6 | ||
7 | $scope.dateOptions = { | 7 | $scope.dateOptions = { |
8 | maxDate: new Date(), | 8 | maxDate: new Date(), |
9 | minDate: new Date(2010,0,1) | 9 | minDate: new Date(2010,0,1) |
10 | }; | 10 | }; |
11 | 11 | ||
12 | $scope.notaPedido = {}; | 12 | $scope.notaPedido = {}; |
13 | $scope.articulosTabla = []; | 13 | $scope.articulosTabla = []; |
14 | var idLista; | 14 | var idLista; |
15 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | 15 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
16 | $scope.domiciliosCliente = crearNotaPedidoService.getDomicilios(1); | 16 | $scope.domiciliosCliente = crearNotaPedidoService.getDomicilios(1); |
17 | crearNotaPedidoService.getPrecioCondicion().then( | 17 | crearNotaPedidoService.getPrecioCondicion().then( |
18 | function(res) { | 18 | function(res) { |
19 | $scope.precioCondiciones = res.data; | 19 | $scope.precioCondiciones = res.data; |
20 | } | 20 | } |
21 | ); | 21 | ); |
22 | if (notaPedidoTemp != undefined) { | 22 | if (notaPedidoTemp != undefined) { |
23 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | 23 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
24 | $scope.notaPedido = notaPedidoTemp; | 24 | $scope.notaPedido = notaPedidoTemp; |
25 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | 25 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
26 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | 26 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
27 | idLista = $scope.notaPedido.precioCondicion; | 27 | idLista = $scope.notaPedido.precioCondicion; |
28 | crearNotaPedidoService | 28 | crearNotaPedidoService |
29 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | 29 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
30 | function(res) { | 30 | function(res) { |
31 | $scope.articulosTabla = res.data; | 31 | $scope.articulosTabla = res.data; |
32 | } | 32 | } |
33 | ); | 33 | ); |
34 | crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 34 | crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
35 | function(res) { | 35 | function(res) { |
36 | $scope.notaPedido.domicilio = res.data; | 36 | $scope.notaPedido.domicilio = res.data; |
37 | } | 37 | } |
38 | ) | 38 | ) |
39 | } else { | 39 | } else { |
40 | $scope.notaPedido.fechaCarga = new Date(); | 40 | $scope.notaPedido.fechaCarga = new Date(); |
41 | $scope.notaPedido.domicilio = [{ id: 0 }] | 41 | $scope.notaPedido.domicilio = [{ id: 0 }] |
42 | $scope.notaPedido.bomba = '1'; | 42 | $scope.notaPedido.bomba = '1'; |
43 | $scope.notaPedido.flete = '1'; | 43 | $scope.notaPedido.flete = '1'; |
44 | idLista = undefined; | 44 | idLista = undefined; |
45 | } | 45 | } |
46 | $scope.addNewDom = function() { | 46 | $scope.addNewDom = function() { |
47 | $scope.notaPedido.domicilio.push({ 'id': 0 }); | 47 | $scope.notaPedido.domicilio.push({ 'id': 0 }); |
48 | } | 48 | } |
49 | $scope.removeNewChoice = function(choice) { | 49 | $scope.removeNewChoice = function(choice) { |
50 | if ($scope.notaPedido.domicilio.length > 1) { | 50 | if ($scope.notaPedido.domicilio.length > 1) { |
51 | $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex(c => c.$$hashKey == choice.$$hashKey), 1) | 51 | $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
52 | function(c) { | ||
53 | return c.$$hashKey == choice.$$hashKey; | ||
54 | } | ||
55 | ), 1) | ||
52 | } | 56 | } |
53 | } | 57 | } |
54 | $scope.crearNotaPedido = function() { | 58 | $scope.crearNotaPedido = function() { |
55 | var notaPedido = { | 59 | var notaPedido = { |
56 | id: 0, | 60 | id: 0, |
57 | precioCondicion: $scope.notaPedido.precioCondicion, | 61 | precioCondicion: $scope.notaPedido.precioCondicion, |
58 | fechaCarga: $scope.notaPedido.fechaCarga, | 62 | fechaCarga: $scope.notaPedido.fechaCarga, |
59 | vendedor: $scope.notaPedido.vendedor, | 63 | vendedor: $scope.notaPedido.vendedor, |
60 | cliente: $scope.notaPedido.cliente, | 64 | cliente: $scope.notaPedido.cliente, |
61 | producto: $scope.notaPedido.producto, | 65 | producto: $scope.notaPedido.producto, |
62 | bomba: $scope.notaPedido.bomba, | 66 | bomba: $scope.notaPedido.bomba, |
63 | petrolera: $scope.notaPedido.petrolera, | 67 | petrolera: $scope.notaPedido.petrolera, |
64 | domicilio: $scope.notaPedido.domicilio, | 68 | domicilio: $scope.notaPedido.domicilio, |
65 | kilometros: $scope.notaPedido.kilometros, | 69 | kilometros: $scope.notaPedido.kilometros, |
66 | jurisdiccionIIBB: $scope.notaPedido.jurisdiccionIIBB, | 70 | jurisdiccionIIBB: $scope.notaPedido.jurisdiccionIIBB, |
67 | costoFinanciacion: $scope.notaPedido.costoFinanciacion, | 71 | costoFinanciacion: $scope.notaPedido.costoFinanciacion, |
68 | flete: $scope.notaPedido.flete, | 72 | flete: $scope.notaPedido.flete, |
69 | costoUnitarioKmFlete: $scope.notaPedido.costoUnitarioKmFlete, | 73 | costoUnitarioKmFlete: $scope.notaPedido.costoUnitarioKmFlete, |
70 | total : $scope.articulosTabla[0].subTotal | 74 | total : $scope.articulosTabla[0].subTotal |
71 | } | 75 | } |
72 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 76 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
73 | function(res) { | 77 | function(res) { |
74 | alert('Nota pedido creada'); | 78 | alert('Nota pedido creada'); |
75 | $location.path('/venta-nota-pedido'); | 79 | $location.path('/venta-nota-pedido'); |
76 | } | 80 | } |
77 | ) | 81 | ) |
78 | var articulosNotaPedido = $scope.articulosTabla; | 82 | var articulosNotaPedido = $scope.articulosTabla; |
79 | for(var i = 0; i< articulosNotaPedido.length;i++) { | 83 | for(var i = 0; i< articulosNotaPedido.length;i++) { |
80 | crearNotaPedidoService.crearArticulosParaNotaPedido(articulosNotaPedido[i]).then( | 84 | crearNotaPedidoService.crearArticulosParaNotaPedido(articulosNotaPedido[i]).then( |
81 | function(res) { | 85 | function(res) { |
82 | return; | 86 | return; |
83 | } | 87 | } |
84 | ) | 88 | ) |
85 | } | 89 | } |
86 | 90 | ||
87 | } | 91 | } |
88 | $scope.siguienteTab = function() { | 92 | $scope.siguienteTab = function() { |
89 | $scope.active = 1; | 93 | $scope.active = 1; |
90 | } | 94 | } |
91 | $scope.seleccionarArticulo = function() { | 95 | $scope.seleccionarArticulo = function() { |
92 | if (idLista == undefined) { | 96 | if (idLista == undefined) { |
93 | alert('primero seleccione una lista de precio y condicion'); | 97 | alert('primero seleccione una lista de precio y condicion'); |
94 | return; | 98 | return; |
95 | } | 99 | } |
96 | var modalInstance = $uibModal.open( | 100 | var modalInstance = $uibModal.open( |
97 | { | 101 | { |
98 | ariaLabelledBy: 'Busqueda de Productos', | 102 | ariaLabelledBy: 'Busqueda de Productos', |
99 | templateUrl: 'modal-busqueda-productos.html', | 103 | templateUrl: 'modal-busqueda-productos.html', |
100 | controller: 'modalBusquedaProductosCtrl', | 104 | controller: 'modalBusquedaProductosCtrl', |
101 | resolve: { idLista: function() { return idLista } }, | 105 | resolve: { idLista: function() { return idLista } }, |
102 | size: 'lg' | 106 | size: 'lg' |
103 | } | 107 | } |
104 | ) | 108 | ) |
105 | modalInstance.result.then( | 109 | modalInstance.result.then( |
106 | function(producto) { | 110 | function(producto) { |
107 | var newArt = | 111 | var newArt = |
108 | { | 112 | { |
109 | id: 0, | 113 | id: 0, |
110 | codigo: producto.FiltroSectorCodigo, | 114 | codigo: producto.FiltroSectorCodigo, |
111 | item: $scope.articulosTabla.length + 1, | 115 | item: $scope.articulosTabla.length + 1, |
112 | nombre: producto.descripcion, | 116 | nombre: producto.descripcion, |
113 | precio: producto.precio, | 117 | precio: producto.precio, |
114 | costoUnitario: producto.costo, | 118 | costoUnitario: producto.costo, |
115 | cantidad: 1 | 119 | cantidad: 1 |
116 | } | 120 | } |
117 | $scope.articulosTabla.unshift(newArt); | 121 | $scope.articulosTabla.unshift(newArt); |
118 | }, function() { | 122 | }, function() { |
119 | // funcion ejecutada cuando se cancela el modal | 123 | // funcion ejecutada cuando se cancela el modal |
120 | } | 124 | } |
121 | ); | 125 | ); |
122 | } | 126 | } |
123 | $scope.seleccionarVendedor = function() { | 127 | $scope.seleccionarVendedor = function() { |
124 | var modalInstance = $uibModal.open( | 128 | var modalInstance = $uibModal.open( |
125 | { | 129 | { |
126 | ariaLabelledBy: 'Busqueda de Vendedores', | 130 | ariaLabelledBy: 'Busqueda de Vendedores', |
127 | templateUrl: 'modal-vendedores.html', | 131 | templateUrl: 'modal-vendedores.html', |
128 | controller: 'modalVendedoresCtrl', | 132 | controller: 'modalVendedoresCtrl', |
129 | size: 'lg' | 133 | size: 'lg' |
130 | } | 134 | } |
131 | ) | 135 | ) |
132 | modalInstance.result.then( | 136 | modalInstance.result.then( |
133 | function(vendedor) { | 137 | function(vendedor) { |
134 | $scope.notaPedido.vendedor = vendedor.NomVen; | 138 | $scope.notaPedido.vendedor = vendedor.NomVen; |
135 | }, function() { | 139 | }, function() { |
136 | 140 | ||
137 | } | 141 | } |
138 | ); | 142 | ); |
139 | } | 143 | } |
140 | $scope.seleccionarPetrolera = function() { | 144 | $scope.seleccionarPetrolera = function() { |
141 | var modalInstance = $uibModal.open( | 145 | var modalInstance = $uibModal.open( |
142 | { | 146 | { |
143 | ariaLabelledBy: 'Busqueda de Petrolera', | 147 | ariaLabelledBy: 'Busqueda de Petrolera', |
144 | templateUrl: 'modal-petroleras.html', | 148 | templateUrl: 'modal-petroleras.html', |
145 | controller: 'modalPetrolerasCtrl', | 149 | controller: 'modalPetrolerasCtrl', |
146 | size: 'lg' | 150 | size: 'lg' |
147 | } | 151 | } |
148 | ) | 152 | ) |
149 | modalInstance.result.then( | 153 | modalInstance.result.then( |
150 | function(petrolera) { | 154 | function(petrolera) { |
151 | $scope.notaPedido.petrolera = petrolera.NOM; | 155 | $scope.notaPedido.petrolera = petrolera.NOM; |
152 | }, function() { | 156 | }, function() { |
153 | 157 | ||
154 | } | 158 | } |
155 | ); | 159 | ); |
156 | } | 160 | } |
157 | $scope.seleccionarCliente = function() { | 161 | $scope.seleccionarCliente = function() { |
158 | var modalInstance = $uibModal.open( | 162 | var modalInstance = $uibModal.open( |
159 | { | 163 | { |
160 | ariaLabelledBy: 'Busqueda de Cliente', | 164 | ariaLabelledBy: 'Busqueda de Cliente', |
161 | templateUrl: 'foca-busqueda-cliente-modal.html', | 165 | templateUrl: 'foca-busqueda-cliente-modal.html', |
162 | controller: 'focaBusquedaClienteModalController', | 166 | controller: 'focaBusquedaClienteModalController', |
163 | size: 'lg' | 167 | size: 'lg' |
164 | } | 168 | } |
165 | ) | 169 | ) |
166 | modalInstance.result.then( | 170 | modalInstance.result.then( |
167 | function(cliente) { | 171 | function(cliente) { |
168 | $scope.notaPedido.cliente = cliente.nom; | 172 | $scope.notaPedido.cliente = cliente.nom; |
169 | }, function() { | 173 | }, function() { |
170 | 174 | ||
171 | } | 175 | } |
172 | ); | 176 | ); |
173 | } | 177 | } |
174 | $scope.obtenerDomicilios = function(id) { | 178 | $scope.obtenerDomicilios = function(id) { |
175 | crearNotaPedidoService.getDomicilios(id).then( | 179 | crearNotaPedidoService.getDomicilios(id).then( |
176 | function(res) { | 180 | function(res) { |
177 | $scope.notaPedido.domicilio = res.data; | 181 | $scope.notaPedido.domicilio = res.data; |
178 | } | 182 | } |
179 | ) | 183 | ) |
180 | } | 184 | } |
181 | $scope.getSubTotal = function(item) { | 185 | $scope.getSubTotal = function(item) { |
182 | var subTotal = 0; | 186 | var subTotal = 0; |
183 | var array = $scope.articulosTabla.filter(a => a.item <= item); | 187 | var array = $scope.articulosTabla.filter( |
188 | function(a) { | ||
189 | return a.item <= item; | ||
190 | } | ||
191 | ); | ||
184 | for (var i = 0; i < array.length; i++) { | 192 | for (var i = 0; i < array.length; i++) { |
185 | subTotal += array[i].precio * array[i].cantidad | 193 | subTotal += array[i].precio * array[i].cantidad |
186 | } | 194 | } |
187 | return subTotal.toFixed(2); | 195 | return subTotal.toFixed(2); |
188 | } | 196 | } |
189 | $scope.cargarArticulos = function() { | 197 | $scope.cargarArticulos = function() { |
190 | idLista = $scope.notaPedido.precioCondicion; | 198 | idLista = $scope.notaPedido.precioCondicion; |
191 | $scope.articulosTabla = []; | 199 | $scope.articulosTabla = []; |
192 | } | 200 | } |
193 | } | 201 | } |
194 | ] | 202 | ] |
195 | ) | 203 | ) |
196 | .controller('notaPedidoListaCtrl', [ | 204 | .controller('notaPedidoListaCtrl', [ |
197 | '$scope', | 205 | '$scope', |
198 | 'crearNotaPedidoService', | 206 | 'crearNotaPedidoService', |
199 | '$location', | 207 | '$location', |
200 | function($scope, crearNotaPedidoService, $location) { | 208 | function($scope, crearNotaPedidoService, $location) { |
201 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 209 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
202 | $scope.notaPedidos = datos.data; | 210 | $scope.notaPedidos = datos.data; |
203 | }); | 211 | }); |
204 | $scope.editar = function(notaPedido) { | 212 | $scope.editar = function(notaPedido) { |
205 | crearNotaPedidoService.setNotaPedido(notaPedido); | 213 | crearNotaPedidoService.setNotaPedido(notaPedido); |
206 | $location.path('/venta-nota-pedido/abm/'); | 214 | $location.path('/venta-nota-pedido/abm/'); |
207 | } | 215 | } |
208 | $scope.crearPedido = function() { | 216 | $scope.crearPedido = function() { |
209 | crearNotaPedidoService.clearNotaPedido(); | 217 | crearNotaPedidoService.clearNotaPedido(); |
210 | $location.path('/venta-nota-pedido/abm/'); | 218 | $location.path('/venta-nota-pedido/abm/'); |
211 | } | 219 | } |
212 | } | 220 | } |
213 | ]) | 221 | ]) |
214 | 222 |
src/js/service.js
1 | angular.module('focaCrearNotaPedido') | 1 | angular.module('focaCrearNotaPedido') |
2 | .service('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | 2 | .service('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { |
3 | var route = API_ENDPOINT.URL; | 3 | var route = API_ENDPOINT.URL; |
4 | var notaPedido; | 4 | var notaPedido; |
5 | return { | 5 | return { |
6 | crearNotaPedido: function(notaPedido) { | 6 | crearNotaPedido: function(notaPedido) { |
7 | return $http.post(route + '/nota-pedido', {notaPedido: notaPedido}); | 7 | return $http.post(route + '/nota-pedido', {notaPedido: notaPedido}); |
8 | }, | 8 | }, |
9 | obtenerNotaPedido: function() { | 9 | obtenerNotaPedido: function() { |
10 | return $http.get(route +'/nota-pedido'); | 10 | return $http.get(route +'/nota-pedido'); |
11 | }, | 11 | }, |
12 | setNotaPedido: function(notaPedido) { | 12 | setNotaPedido: function(notaPedido) { |
13 | this.notaPedido = notaPedido; | 13 | this.notaPedido = notaPedido; |
14 | }, | 14 | }, |
15 | clearNotaPedido: function() { | 15 | clearNotaPedido: function() { |
16 | this.notaPedido = undefined; | 16 | this.notaPedido = undefined; |
17 | }, | 17 | }, |
18 | getNotaPedido: function() { | 18 | getNotaPedido: function() { |
19 | return this.notaPedido; | 19 | return this.notaPedido; |
20 | }, | 20 | }, |
21 | getArticulosByIdNotaPedido: function(id) { | 21 | getArticulosByIdNotaPedido: function(id) { |
22 | return $http.get(route+'/articulos/nota-pedido/'+id); | 22 | return $http.get(route+'/articulos/nota-pedido/'+id); |
23 | }, | 23 | }, |
24 | crearArticulosParaNotaPedido: function(articuloNotaPedido) { | 24 | crearArticulosParaNotaPedido: function(articuloNotaPedido) { |
25 | return $http.post(route + '/articulos/nota-pedido', {articuloNotaPedido}); | 25 | return $http.post(route + '/articulos/nota-pedido', {articuloNotaPedido: articuloNotaPedido}); |
26 | }, | 26 | }, |
27 | getDomiciliosByIdNotaPedido: function(id) { | 27 | getDomiciliosByIdNotaPedido: function(id) { |
28 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); | 28 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); |
29 | }, | 29 | }, |
30 | //EN DESARROLLO | 30 | //EN DESARROLLO |
31 | getDomicilios: function(id) { | 31 | getDomicilios: function(id) { |
32 | // return $http.get(route + '/'+id) | 32 | // return $http.get(route + '/'+id) |
33 | var domicilio = [ | 33 | var domicilio = [ |
34 | { | 34 | { |
35 | id: 1, | 35 | id: 1, |
36 | dom: 'RISSO PATRON 781' | 36 | dom: 'RISSO PATRON 781' |
37 | }, | 37 | }, |
38 | { | 38 | { |
39 | id: 2, | 39 | id: 2, |
40 | dom: 'MARIANO MORENO 533' | 40 | dom: 'MARIANO MORENO 533' |
41 | }, | 41 | }, |
42 | { | 42 | { |
43 | id: 3, | 43 | id: 3, |
44 | dom: 'SALTA 796' | 44 | dom: 'SALTA 796' |
45 | } | 45 | } |
46 | ] | 46 | ] |
47 | return domicilio; | 47 | return domicilio; |
48 | }, | 48 | }, |
49 | getPrecioCondicion: function() { | 49 | getPrecioCondicion: function() { |
50 | return $http.get(route + '/precio-condicion') | 50 | return $http.get(route + '/precio-condicion') |
51 | }, | 51 | }, |
52 | getPrecioCondicionById: function(id) { | 52 | getPrecioCondicionById: function(id) { |
53 | return $http.get(route + '/precio-condicion/' + id) | 53 | return $http.get(route + '/precio-condicion/' + id) |
54 | }, | 54 | }, |
55 | getPlazoPagoByPrecioCondicion: function(id) { | 55 | getPlazoPagoByPrecioCondicion: function(id) { |
56 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id) | 56 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id) |
57 | } | 57 | } |
58 | } | 58 | } |
59 | }]) | 59 | }]) |
60 | 60 |