Commit 3acd4e2d3f25bc7e24417977cbb737b76a34be0c
Exists in
master
Merge branch 'master' of https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido
# Conflicts: # gulpfile.js # index.html # package.json # src/js/app.js # src/js/controller.js
Showing
7 changed files
Show diff stats
gulpfile.js
... | ... | @@ -46,7 +46,7 @@ gulp.task('uglify', ['templates'], function() { |
46 | 46 | replace('"ngRoute","ui.bootstrap","focaModalVendedores","focaBusquedaProductos",'+ |
47 | 47 | '"focaModalProveedor","focaBusquedaCliente","focaModalPrecioCondicion",'+ |
48 | 48 | '"focaModalFlete","focaDirectivas","focaModal","focaModalDomicilio",'+ |
49 | - '"angular-ladda"', ''), | |
49 | + '"angular-ladda","focaModalMoneda","focaModalCotizacion"', ''), | |
50 | 50 | gulp.dest(paths.dist) |
51 | 51 | ] |
52 | 52 | ); |
... | ... | @@ -72,7 +72,7 @@ gulp.task('pre-commit', function() { |
72 | 72 | |
73 | 73 | gulp.task('webserver', function() { |
74 | 74 | pump [ |
75 | - connect.server({port: 3000}) | |
75 | + connect.server({port: 3300, host: '0.0.0.0'}) | |
76 | 76 | ] |
77 | 77 | }); |
78 | 78 |
index.html
... | ... | @@ -27,6 +27,8 @@ |
27 | 27 | <script src="node_modules/foca-modal-flete/dist/foca-modal-flete.min.js"></script> |
28 | 28 | <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> |
29 | 29 | <script src="node_modules/foca-modal-domicilio/dist/foca-modal-domicilios.min.js"></script> |
30 | + <script src="node_modules/foca-modal-moneda/dist/foca-modal-moneda.min.js"></script> | |
31 | + <script src="node_modules/foca-modal-cotizacion/dist/foca-modal-cotizacion.min.js"></script> | |
30 | 32 | |
31 | 33 | <script src="src/js/app.js"></script> |
32 | 34 | <script src="src/js/controller.js"></script> |
package.json
... | ... | @@ -8,7 +8,7 @@ |
8 | 8 | "compile": "gulp uglify", |
9 | 9 | "gulp-pre-commit": "gulp pre-commit", |
10 | 10 | "postinstall": "npm run compile && gulp clean-post-install", |
11 | - "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 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 gulp-uglify jquery jshint pump git+https://debo.suite.repo/modulos-npm/foca-directivas.git git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git git+https://debo.suite.repo/modulos-npm/foca-modal-flete git+https://debo.suite.repo/modulos-npm/foca-modal.git git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git" | |
11 | + "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 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 gulp-uglify jquery jshint pump git+https://debo.suite.repo/modulos-npm/foca-directivas.git git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git git+https://debo.suite.repo/modulos-npm/foca-modal-flete git+https://debo.suite.repo/modulos-npm/foca-modal.git git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git" | |
12 | 12 | }, |
13 | 13 | "pre-commit": [ |
14 | 14 | "gulp-pre-commit" |
... | ... | @@ -35,8 +35,10 @@ |
35 | 35 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", |
36 | 36 | "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", |
37 | 37 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", |
38 | + "foca-modal-cotizacion": "git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git", | |
38 | 39 | "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", |
39 | 40 | "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete", |
41 | + "foca-modal-moneda": "git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git", | |
40 | 42 | "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", |
41 | 43 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", |
42 | 44 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", |
src/js/app.js
src/js/controller.js
... | ... | @@ -29,9 +29,27 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
29 | 29 | $scope.notaPedido = { |
30 | 30 | vendedor: {}, |
31 | 31 | cliente: {}, |
32 | + proveedor: {}, | |
32 | 33 | domicilio: {dom: ''}, |
33 | - moneda: {detalle: ''} | |
34 | + moneda: {}, | |
35 | + cotizacion: {} | |
34 | 36 | }; |
37 | + var monedaPorDefecto; | |
38 | + //Trabajo con la cotizaciรณn mรกs reciente, por eso uso siempre la primera '[0]' | |
39 | + crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | |
40 | + monedaPorDefecto = { | |
41 | + id: res.data[0].ID, | |
42 | + detalle: res.data[0].DETALLE, | |
43 | + simbolo: res.data[0].SIMBOLO, | |
44 | + cotizaciones: res.data[0].cotizaciones | |
45 | + }; | |
46 | + addCabecera('Moneda:', monedaPorDefecto.detalle); | |
47 | + addCabecera('Fecha cotizacion:', | |
48 | + new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | |
49 | + addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); | |
50 | + $scope.notaPedido.moneda = monedaPorDefecto; | |
51 | + $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; | |
52 | + }); | |
35 | 53 | |
36 | 54 | $scope.cabecera = []; |
37 | 55 | $scope.showCabecera = true; |
... | ... | @@ -41,25 +59,28 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
41 | 59 | $scope.comprobante = Math.round(Math.random() * 1000000); |
42 | 60 | |
43 | 61 | $scope.articulosTabla = []; |
44 | - var idLista; | |
45 | - var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | |
62 | + $scope.idLista = undefined; | |
63 | + //La pantalla solo se usa para cargar pedidos | |
64 | + //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | |
65 | + | |
46 | 66 | crearNotaPedidoService.getPrecioCondicion().then( |
47 | 67 | function(res) { |
48 | 68 | $scope.precioCondiciones = res.data; |
49 | 69 | } |
50 | 70 | ); |
51 | - if (notaPedidoTemp !== undefined) { | |
52 | - notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | |
53 | - $scope.notaPedido = notaPedidoTemp; | |
54 | - $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | |
55 | - $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | |
56 | - idLista = $scope.notaPedido.precioCondicion; | |
57 | - crearNotaPedidoService | |
58 | - .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | |
59 | - function(res) { | |
60 | - $scope.articulosTabla = res.data; | |
61 | - } | |
62 | - ); | |
71 | + //La pantalla solo se usa para cargar pedidos | |
72 | + // if (notaPedidoTemp !== undefined) { | |
73 | + // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | |
74 | + // $scope.notaPedido = notaPedidoTemp; | |
75 | + // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | |
76 | + // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | |
77 | + // $scope.idLista = $scope.notaPedido.precioCondicion; | |
78 | + // crearNotaPedidoService | |
79 | + // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | |
80 | + // function(res) { | |
81 | + // $scope.articulosTabla = res.data; | |
82 | + // } | |
83 | + // ); | |
63 | 84 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
64 | 85 | //(NO REQUERIDO EN ESTA VERSION) |
65 | 86 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
... | ... | @@ -67,12 +88,12 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
67 | 88 | // $scope.notaPedido.domicilio = res.data; |
68 | 89 | // } |
69 | 90 | // ); |
70 | - } else { | |
71 | - $scope.notaPedido.fechaCarga = new Date(); | |
72 | - $scope.notaPedido.bomba = '0'; | |
73 | - $scope.notaPedido.flete = '0'; | |
74 | - idLista = undefined; | |
75 | - } | |
91 | + // } else { | |
92 | + // $scope.notaPedido.fechaCarga = new Date(); | |
93 | + // $scope.notaPedido.bomba = '0'; | |
94 | + // $scope.notaPedido.flete = '0'; | |
95 | + // $scope.idLista = undefined; | |
96 | + // } | |
76 | 97 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
77 | 98 | // $scope.addNewDom = function() { |
78 | 99 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); |
... | ... | @@ -86,42 +107,59 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
86 | 107 | // ), 1); |
87 | 108 | // } |
88 | 109 | // }; |
110 | + | |
89 | 111 | $scope.crearNotaPedido = function() { |
90 | - if($scope.articulosTabla.length === 0) { | |
91 | - focaModalService.alert('Debe cargar almenos un articulo'); | |
112 | + if(!$scope.notaPedido.vendedor.codigo) { | |
113 | + focaModalService.alert('Ingrese Vendedor'); | |
114 | + return; | |
115 | + } else if(!$scope.notaPedido.cliente.id) { | |
116 | + focaModalService.alert('Ingrese Cliente'); | |
117 | + return; | |
118 | + } else if(!$scope.notaPedido.proveedor.codigo) { | |
119 | + focaModalService.alert('Ingrese Proveedor'); | |
120 | + return; | |
121 | + } else if(!$scope.notaPedido.moneda.id) { | |
122 | + focaModalService.alert('Ingrese Moneda'); | |
123 | + return; | |
124 | + } else if(!$scope.notaPedido.cotizacion.ID) { | |
125 | + focaModalService.alert('Ingrese Cotizaciรณn'); | |
126 | + return; | |
127 | + } else if(!$scope.plazosPagos) { | |
128 | + focaModalService.alert('Ingrese Precios y Condiciones'); | |
129 | + return; | |
130 | + } else if(!$scope.notaPedido.flete) { | |
131 | + focaModalService.alert('Ingrese Flete'); | |
132 | + return; | |
133 | + } else if(!$scope.notaPedido.domicilio.id) { | |
134 | + focaModalService.aler('Ingrese Domicilio'); | |
135 | + return; | |
136 | + } else if($scope.articulosTabla.length === 0) { | |
137 | + focaModalService.alert('Debe cargar al menos un articulo'); | |
92 | 138 | return; |
93 | - } | |
94 | - if($scope.notaPedido.domicilio.id === undefined) { | |
95 | - $scope.notaPedido.domicilio.id = 0; | |
96 | 139 | } |
97 | 140 | var date = new Date(); |
98 | 141 | var notaPedido = { |
99 | 142 | id: 0, |
100 | 143 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
101 | 144 | .toISOString().slice(0, 19).replace('T', ' '), |
102 | - vendedor: $scope.notaPedido.vendedor.nombre, | |
145 | + idVendedor: $scope.notaPedido.vendedor.codigo, | |
103 | 146 | idCliente: $scope.notaPedido.cliente.id, |
104 | - domicilio: $scope.notaPedido.domicilio, | |
105 | - bomba: $scope.notaPedido.bomba, | |
147 | + idProveedor: $scope.notaPedido.proveedor.codigo, | |
148 | + idDomicilio: $scope.notaPedido.domicilio.id, | |
149 | + idCotizacion: $scope.notaPedido.cotizacion.ID, | |
106 | 150 | flete: $scope.notaPedido.flete, |
151 | + fob: $scope.notaPedido.fob, | |
152 | + bomba: $scope.notaPedido.bomba, | |
153 | + kilometros: $scope.notaPedido.kilometros, | |
107 | 154 | total: $scope.getTotal() |
108 | 155 | }; |
109 | 156 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
110 | 157 | function(data) { |
111 | - if($scope.notaPedido.flete === 1) { | |
112 | - var flete = { | |
113 | - idNotaPedido: data.data.id, | |
114 | - idTransportista: $scope.notaPedido.fleteId, | |
115 | - idChofer: $scope.notaPedido.chofer.id, | |
116 | - idVehiculo: $scope.notaPedido.vehiculo.id, | |
117 | - kilometros: $scope.notaPedido.kilometros, | |
118 | - costoKilometro: $scope.notaPedido.costoUnitarioKmFlete | |
119 | - }; | |
120 | - crearNotaPedidoService.crearFlete(flete); | |
121 | - } | |
158 | + | |
122 | 159 | var articulosNotaPedido = $scope.articulosTabla; |
123 | 160 | for(var i = 0; i < articulosNotaPedido.length; i++) { |
124 | - delete articulosNotaPedido[i].edit; | |
161 | + delete articulosNotaPedido[i].editCantidad; | |
162 | + delete articulosNotaPedido[i].editPrecio; | |
125 | 163 | articulosNotaPedido[i].idNotaPedido = data.data.id; |
126 | 164 | crearNotaPedidoService |
127 | 165 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); |
... | ... | @@ -135,13 +173,28 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
135 | 173 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); |
136 | 174 | } |
137 | 175 | focaModalService.alert('Nota pedido creada'); |
138 | - $scope.limpiarPantalla(); | |
176 | + $scope.cabecera = []; | |
177 | + addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); | |
178 | + addCabecera( | |
179 | + 'Fecha cotizacion:', | |
180 | + $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') | |
181 | + ); | |
182 | + addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.cotizacion); | |
183 | + $scope.notaPedido.vendedor = {}; | |
184 | + $scope.notaPedido.cliente = {}; | |
185 | + $scope.notaPedido.proveedor = {}; | |
186 | + $scope.notaPedido.domicilio = {}; | |
187 | + $scope.notaPedido.flete = null; | |
188 | + $scope.notaPedido.fob = null; | |
189 | + $scope.notaPedido.bomba = null; | |
190 | + $scope.notaPedido.kilometros = null; | |
191 | + $scope.articulosTabla = []; | |
139 | 192 | } |
140 | 193 | ); |
141 | 194 | }; |
142 | 195 | |
143 | 196 | $scope.seleccionarArticulo = function() { |
144 | - if (idLista === undefined) { | |
197 | + if ($scope.idLista === undefined) { | |
145 | 198 | focaModalService.alert( |
146 | 199 | 'Primero seleccione una lista de precio y condicion'); |
147 | 200 | return; |
... | ... | @@ -151,7 +204,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
151 | 204 | ariaLabelledBy: 'Busqueda de Productos', |
152 | 205 | templateUrl: 'modal-busqueda-productos.html', |
153 | 206 | controller: 'modalBusquedaProductosCtrl', |
154 | - resolve: { idLista: function() { return idLista; } }, | |
207 | + resolve: { | |
208 | + idLista: function() { return $scope.idLista; }, | |
209 | + cotizacion: $scope.notaPedido.cotizacion.COTIZACION | |
210 | + }, | |
155 | 211 | size: 'lg' |
156 | 212 | } |
157 | 213 | ); |
... | ... | @@ -166,9 +222,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
166 | 222 | descripcion: producto.descripcion, |
167 | 223 | item: $scope.articulosTabla.length + 1, |
168 | 224 | nombre: producto.descripcion, |
169 | - precio: producto.precio.toFixed(2), | |
225 | + precio: parseFloat(producto.precio.toFixed(2)), | |
170 | 226 | costoUnitario: producto.costo, |
171 | - edit: false | |
227 | + editCantidad: false, | |
228 | + editPrecio: false | |
172 | 229 | }; |
173 | 230 | $scope.articuloACargar = newArt; |
174 | 231 | $scope.cargando = false; |
... | ... | @@ -190,7 +247,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
190 | 247 | modalInstance.result.then( |
191 | 248 | function(vendedor) { |
192 | 249 | addCabecera('Vendedor:', vendedor.NomVen); |
193 | - $scope.notaPedido.vendedor.nombre = vendedor.NomVen; | |
250 | + $scope.notaPedido.vendedor.codigo = vendedor.CodVen; | |
194 | 251 | }, function() { |
195 | 252 | |
196 | 253 | } |
... | ... | @@ -208,7 +265,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
208 | 265 | ); |
209 | 266 | modalInstance.result.then( |
210 | 267 | function(proveedor) { |
211 | - $scope.notaPedido.proveedor = proveedor.NOM; | |
268 | + $scope.notaPedido.proveedor.codigo = proveedor.COD; | |
212 | 269 | addCabecera('Proveedor:', proveedor.NOM); |
213 | 270 | }, function() { |
214 | 271 | |
... | ... | @@ -217,6 +274,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
217 | 274 | }; |
218 | 275 | |
219 | 276 | $scope.seleccionarCliente = function() { |
277 | + | |
220 | 278 | var modalInstance = $uibModal.open( |
221 | 279 | { |
222 | 280 | ariaLabelledBy: 'Busqueda de Cliente', |
... | ... | @@ -227,8 +285,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
227 | 285 | ); |
228 | 286 | modalInstance.result.then( |
229 | 287 | function(cliente) { |
230 | - $scope.notaPedido.cliente.nombre = cliente.nom; | |
231 | - $scope.notaPedido.cliente.id = cliente.cod; | |
232 | 288 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( |
233 | 289 | function(data) { |
234 | 290 | if(data.data.length === 0){ |
... | ... | @@ -237,37 +293,38 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
237 | 293 | .then( |
238 | 294 | function() { |
239 | 295 | $scope.seleccionarCliente(); |
240 | - $scope.notaPedido.cliente = {nombre: ''}; | |
241 | 296 | } |
242 | 297 | ); |
243 | 298 | return; |
244 | 299 | } |
245 | - var modalInstanceDomicilio = $uibModal.open( | |
246 | - { | |
247 | - ariaLabelledBy: 'Busqueda de Domicilios', | |
248 | - templateUrl: 'modal-domicilio.html', | |
249 | - controller: 'focaModalDomicilioController', | |
250 | - resolve: { idCliente: function() { return cliente.cod; }}, | |
251 | - size: 'lg', | |
252 | - backdrop: 'static', | |
253 | - } | |
254 | - ); | |
255 | - modalInstanceDomicilio.result.then( | |
256 | - function(domicilio) { | |
257 | - focaModalService.alert('Domicilio elegido' + domicilio.dom); | |
258 | - }, function() { | |
259 | - $scope.notaPedido.cliente.nombre = ''; | |
260 | - $scope.notaPedido.cliente.id = ''; | |
261 | - removeCabecera('Cliente:'); | |
262 | - $scope.seleccionarCliente(); | |
263 | - return; | |
264 | - } | |
265 | - ); | |
300 | + $scope.abrirModalDomicilios(cliente); | |
266 | 301 | } |
267 | 302 | ); |
268 | - addCabecera('Cliente:', cliente.nom); | |
269 | 303 | }, function() { |
304 | + | |
305 | + } | |
306 | + ); | |
307 | + }; | |
270 | 308 | |
309 | + $scope.abrirModalDomicilios = function(cliente) { | |
310 | + var modalInstanceDomicilio = $uibModal.open( | |
311 | + { | |
312 | + ariaLabelledBy: 'Busqueda de Domicilios', | |
313 | + templateUrl: 'modal-domicilio.html', | |
314 | + controller: 'focaModalDomicilioController', | |
315 | + resolve: { idCliente: function() { return cliente.cod; }}, | |
316 | + size: 'lg', | |
317 | + } | |
318 | + ); | |
319 | + modalInstanceDomicilio.result.then( | |
320 | + function(domicilio) { | |
321 | + $scope.notaPedido.domicilio.id = domicilio.id; | |
322 | + $scope.notaPedido.cliente.id = cliente.cod; | |
323 | + addCabecera('Cliente:', cliente.nom); | |
324 | + addCabecera('Domicilio:', domicilio.dom); | |
325 | + }, function() { | |
326 | + $scope.seleccionarCliente(); | |
327 | + return; | |
271 | 328 | } |
272 | 329 | ); |
273 | 330 | }; |
... | ... | @@ -289,7 +346,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
289 | 346 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
290 | 347 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
291 | 348 | } |
292 | - return total.toFixed(2); | |
349 | + return parseFloat(total.toFixed(2)); | |
293 | 350 | }; |
294 | 351 | |
295 | 352 | $scope.getSubTotal = function() { |
... | ... | @@ -313,13 +370,13 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
313 | 370 | var plazosConcat = ''; |
314 | 371 | if(!Array.isArray(precioCondicion)) { |
315 | 372 | $scope.plazosPagos = precioCondicion.plazoPago; |
316 | - idLista = precioCondicion.idListaPrecio; | |
373 | + $scope.idLista = precioCondicion.idListaPrecio; | |
317 | 374 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
318 | 375 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
319 | 376 | } |
320 | 377 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
321 | 378 | } else { //Cuando se ingresan los plazos manualmente |
322 | - idLista = -1; //-1, el modal productos busca todos los productos | |
379 | + $scope.idLista = -1; //-1, el modal productos busca todos los productos | |
323 | 380 | $scope.plazosPagos = precioCondicion; |
324 | 381 | for(var j = 0; j < precioCondicion.length; j++) { |
325 | 382 | plazosConcat += precioCondicion[j].dias + ' '; |
... | ... | @@ -345,8 +402,11 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
345 | 402 | parametrosFlete: |
346 | 403 | function() { |
347 | 404 | return { |
348 | - flete: $scope.notaPedido.flete, | |
349 | - bomba: $scope.notaPedido.bomba, | |
405 | + flete: $scope.notaPedido.flete ? '1' : | |
406 | + ($scope.notaPedido.fob ? 'FOB' : | |
407 | + ($scope.notaPedido.flete === undefined ? null : '0')), | |
408 | + bomba: $scope.notaPedido.bomba ? '1' : | |
409 | + ($scope.notaPedido.bomba === undefined ? null : '0'), | |
350 | 410 | kilometros: $scope.notaPedido.kilometros |
351 | 411 | }; |
352 | 412 | } |
... | ... | @@ -356,16 +416,21 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
356 | 416 | modalInstance.result.then( |
357 | 417 | function(datos) { |
358 | 418 | $scope.notaPedido.flete = datos.flete; |
419 | + $scope.notaPedido.fob = datos.FOB; | |
359 | 420 | $scope.notaPedido.bomba = datos.bomba; |
360 | 421 | $scope.notaPedido.kilometros = datos.kilometros; |
361 | 422 | |
362 | - addCabecera('Flete:', datos.flete); | |
363 | - if(datos.flete === 'si') { | |
364 | - addCabecera('Bomba:', datos.bomba); | |
365 | - addCabecera('Kilometros:', datos.kilometros); | |
423 | + addCabecera('Flete:', datos.flete ? 'Si' : | |
424 | + ($scope.notaPedido.fob ? 'FOB' : 'No')); | |
425 | + if(datos.flete) { | |
426 | + addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | |
427 | + addCabecera('Kilometros:', datos.kilometros ? 'Si' : 'No'); | |
366 | 428 | } else { |
367 | 429 | removeCabecera('Bomba:'); |
368 | 430 | removeCabecera('Kilometros:'); |
431 | + $scope.notaPedido.fob = false; | |
432 | + $scope.notaPedido.bomba = false; | |
433 | + $scope.notaPedido.kilometros = null; | |
369 | 434 | } |
370 | 435 | }, function() { |
371 | 436 | |
... | ... | @@ -384,37 +449,44 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
384 | 449 | ); |
385 | 450 | modalInstance.result.then( |
386 | 451 | function(moneda) { |
387 | - $scope.notaPedido.moneda = { | |
388 | - id: moneda.ID, | |
389 | - detalle: moneda.DETALLE, | |
390 | - simbolo: moneda.SIMBOLO | |
391 | - }; | |
392 | - | |
393 | - addCabecera('Moneda:', moneda.DETALLE); | |
394 | - $scope.abrirModalCotizacion(moneda.ID); | |
452 | + $scope.abrirModalCotizacion(moneda); | |
395 | 453 | }, function() { |
396 | 454 | |
397 | 455 | } |
398 | 456 | ); |
399 | 457 | }; |
400 | 458 | |
401 | - $scope.abrirModalCotizacion = function(idMoneda) { | |
459 | + $scope.abrirModalCotizacion = function(moneda) { | |
402 | 460 | var modalInstance = $uibModal.open( |
403 | 461 | { |
404 | 462 | ariaLabelledBy: 'Busqueda de Cotizaciรณn', |
405 | 463 | templateUrl: 'modal-cotizacion.html', |
406 | 464 | controller: 'focaModalCotizacionController', |
407 | 465 | size: 'lg', |
408 | - resolve: {idMoneda: function() {return idMoneda;}} | |
466 | + resolve: {idMoneda: function() {return moneda.ID;}} | |
409 | 467 | } |
410 | 468 | ); |
411 | 469 | modalInstance.result.then( |
412 | 470 | function(cotizacion) { |
471 | + var articulosTablaTemp = $scope.articulosTabla; | |
472 | + for(var i = 0; i < articulosTablaTemp.length; i++) { | |
473 | + articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | |
474 | + $scope.notaPedido.cotizacion.COTIZACION; | |
475 | + articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | |
476 | + cotizacion.COTIZACION; | |
477 | + } | |
478 | + $scope.articulosTabla = articulosTablaTemp; | |
479 | + $scope.notaPedido.moneda = { | |
480 | + id: moneda.ID, | |
481 | + detalle: moneda.DETALLE, | |
482 | + simbolo: moneda.SIMBOLO | |
483 | + }; | |
413 | 484 | $scope.notaPedido.cotizacion = { |
414 | - id: cotizacion.ID, | |
415 | - cotizacion: cotizacion.COTIZACION | |
485 | + ID: cotizacion.ID, | |
486 | + COTIZACION: cotizacion.COTIZACION, | |
487 | + FECHA: cotizacion.fecha | |
416 | 488 | }; |
417 | - | |
489 | + addCabecera('Moneda:', moneda.DETALLE); | |
418 | 490 | addCabecera( |
419 | 491 | 'Fecha cotizacion:', |
420 | 492 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
... | ... | @@ -451,12 +523,17 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
451 | 523 | focaModalService.alert('El valor debe ser al menos 1'); |
452 | 524 | return; |
453 | 525 | } |
454 | - articulo.edit = false; | |
526 | + articulo.editCantidad = false; | |
527 | + articulo.editPrecio = false; | |
455 | 528 | } |
456 | 529 | }; |
457 | 530 | |
458 | - $scope.cambioEdit = function(articulo) { | |
459 | - articulo.edit = true; | |
531 | + $scope.cambioEdit = function(articulo, propiedad) { | |
532 | + if(propiedad === 'cantidad') { | |
533 | + articulo.editCantidad = true; | |
534 | + } else if(propiedad === 'precio') { | |
535 | + articulo.editPrecio = true; | |
536 | + } | |
460 | 537 | }; |
461 | 538 | |
462 | 539 | $scope.limpiarFlete = function() { |
src/js/service.js
... | ... | @@ -45,6 +45,9 @@ angular.module('focaCrearNotaPedido') |
45 | 45 | }, |
46 | 46 | crearPlazosParaNotaPedido: function(plazos) { |
47 | 47 | return $http.post(route + '/plazo-pago/nota-pedido', plazos); |
48 | + }, | |
49 | + getCotizacionByIdMoneda: function(id) { | |
50 | + return $http.get(route + '/moneda/' + id); | |
48 | 51 | } |
49 | 52 | }; |
50 | 53 | }]); |
src/views/nota-pedido.html
... | ... | @@ -8,8 +8,10 @@ |
8 | 8 | <div class="col-12 col-sm-4 nota-pedido"> |
9 | 9 | <h5>NOTA DE PEDIDO</h5> |
10 | 10 | </div> |
11 | - <div class="col-6 col-sm-4 numero-pedido">Nยบ {{puntoVenta}}-{{comprobante}}</div> | |
12 | - <div class="col-6 col-sm-4 text-right crear-nota-pedido-fecha"> | |
11 | + <div class="col-5 col-sm-4 numero-pedido" | |
12 | + >Nยบ {{puntoVenta}}-{{comprobante}} | |
13 | + </div> | |
14 | + <div class="col-7 col-sm-4 text-right"> | |
13 | 15 | Fecha: |
14 | 16 | <span |
15 | 17 | ng-show="!datepickerAbierto" |
... | ... | @@ -81,8 +83,8 @@ |
81 | 83 | <div class="row"> |
82 | 84 | <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> |
83 | 85 | <!-- PC --> |
84 | - <div class="row grilla-articulo align-items-end"> | |
85 | - <table class="table tabla-articulo table-striped table-sm table-dark mb-0"> | |
86 | + <div class="row grilla-articulo align-items-end d-none d-sm-flex"> | |
87 | + <table class="table tabla-articulo table-striped table-sm table-dark"> | |
86 | 88 | <thead> |
87 | 89 | <tr class="d-flex"> |
88 | 90 | <th class="">#</th> |
... | ... | @@ -126,28 +128,43 @@ |
126 | 128 | class="col-4" |
127 | 129 | ng-bind="articulo.descripcion" |
128 | 130 | ></td> |
129 | - <td class="col text-right"> | |
131 | + <td class="col text-right"> | |
130 | 132 | <input |
131 | - ng-show="articulo.edit" | |
133 | + ng-show="articulo.editCantidad" | |
132 | 134 | ng-model="articulo.cantidad" |
133 | 135 | class="form-control" |
134 | 136 | type="number" |
135 | 137 | min="1" |
136 | - foca-focus="articulo.edit" | |
138 | + foca-focus="articulo.editCantidad" | |
137 | 139 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
138 | 140 | ng-focus="selectFocus($event)" |
139 | 141 | > |
140 | 142 | <i |
141 | 143 | class="selectable" |
142 | - ng-click="cambioEdit(articulo)" | |
143 | - ng-hide="articulo.edit" | |
144 | + ng-click="cambioEdit(articulo, 'cantidad')" | |
145 | + ng-hide="articulo.editCantidad" | |
144 | 146 | ng-bind="articulo.cantidad"> |
145 | 147 | </i> |
146 | 148 | </td> |
147 | - <td | |
148 | - class="col text-right" | |
149 | - ng-bind="articulo.precio | currency: '$'" | |
150 | - ></td> | |
149 | + <td class="col text-right"> | |
150 | + <input | |
151 | + ng-show="articulo.editPrecio" | |
152 | + ng-model="articulo.precio" | |
153 | + class="form-control" | |
154 | + type="number" | |
155 | + min="1" | |
156 | + step="0.01" | |
157 | + foca-focus="articulo.editPrecio" | |
158 | + ng-keypress="editarArticulo($event.keyCode, articulo)" | |
159 | + ng-focus="selectFocus($event)" | |
160 | + > | |
161 | + <i | |
162 | + class="selectable" | |
163 | + ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" | |
164 | + ng-hide="articulo.editPrecio" | |
165 | + ng-bind="articulo.precio | currency: '$'"> | |
166 | + </i> | |
167 | + </td> | |
151 | 168 | <td |
152 | 169 | class="col text-right" |
153 | 170 | ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'"> |
... | ... | @@ -197,8 +214,18 @@ |
197 | 214 | <input |
198 | 215 | class="form-control" |
199 | 216 | ng-value="articuloACargar.precio | currency: '$'" |
217 | + ng-show="idLista != -1" | |
200 | 218 | readonly |
201 | 219 | > |
220 | + <input | |
221 | + class="form-control" | |
222 | + type="number" | |
223 | + step="0.01" | |
224 | + ng-model="articuloACargar.precio" | |
225 | + esc-key="resetFilter()" | |
226 | + ng-keypress="agregarATabla($event.keyCode)" | |
227 | + ng-show="idLista == -1" | |
228 | + > | |
202 | 229 | </td> |
203 | 230 | <td class="col text-right"> |
204 | 231 | <input |
... | ... | @@ -226,15 +253,17 @@ |
226 | 253 | </td> |
227 | 254 | </tr> |
228 | 255 | <tr class="d-flex"> |
229 | - <td colspan="4"> | |
230 | - <strong>Cantidad Items:</strong> | |
256 | + <td colspan="4" class="no-border-top"> | |
257 | + <strong>Items:</strong> | |
231 | 258 | <a ng-bind="articulosTabla.length"></a> |
232 | 259 | </td> |
233 | - <td class="text-right ml-auto table-celda-total"><h3>Total:</h3></td> | |
234 | - <td class="table-celda-total text-right" colspan="1"> | |
260 | + <td class="text-right ml-auto table-celda-total no-border-top"> | |
261 | + <h3>Total:</h3> | |
262 | + </td> | |
263 | + <td class="table-celda-total text-right no-border-top" colspan="1"> | |
235 | 264 | <h3>{{getTotal() | currency: '$'}}</h3> |
236 | 265 | </td> |
237 | - <td class="text-right"> | |
266 | + <td class="text-right no-border-top"> | |
238 | 267 | <button |
239 | 268 | type="button" |
240 | 269 | class="btn btn-default btn-sm" |
... | ... | @@ -246,8 +275,176 @@ |
246 | 275 | </tfoot> |
247 | 276 | </table> |
248 | 277 | </div> |
278 | + | |
279 | + <!-- MOBILE --> | |
280 | + <div class="row d-sm-none"> | |
281 | + <table class="table table-sm table-striped table-dark margin-bottom-mobile"> | |
282 | + <thead> | |
283 | + <tr class="d-flex"> | |
284 | + <th class="">#</th> | |
285 | + <th class="col px-0"> | |
286 | + <div class="d-flex"> | |
287 | + <div class="col-4 px-1">Cรณdigo</div> | |
288 | + <div class="col-8 px-1">Descripciรณn</div> | |
289 | + </div> | |
290 | + <div class="d-flex"> | |
291 | + <div class="col-3 px-1">Cantidad</div> | |
292 | + <div class="col px-1 text-right">P. Uni.</div> | |
293 | + <div class="col px-1 text-right">Subtotal</div> | |
294 | + </div> | |
295 | + </th> | |
296 | + <th class="text-center tamaรฑo-boton"> | |
297 | + | |
298 | + </th> | |
299 | + </tr> | |
300 | + </thead> | |
301 | + <tbody> | |
302 | + <tr | |
303 | + ng-repeat="(key, articulo) in articulosTabla" | |
304 | + ng-show="show || key == articulosTabla.length - 1" | |
305 | + > | |
306 | + <td class="w-100 align-middle d-flex p-0"> | |
307 | + <div class="align-middle p-1"> | |
308 | + <span ng-bind="key+1" class="align-middle"></span> | |
309 | + </div> | |
310 | + <div class="col px-0"> | |
311 | + <div class="d-flex"> | |
312 | + <div class="col-4 px-1"> | |
313 | + <span | |
314 | + ng-bind="articulo.sector + '-' + articulo.codigo" | |
315 | + ></span> | |
316 | + </div> | |
317 | + <div class="col-8 px-1"> | |
318 | + <span ng-bind="articulo.descripcion"></span> | |
319 | + </div> | |
320 | + </div> | |
321 | + <div class="d-flex"> | |
322 | + <div class="col-3 px-1"> | |
323 | + <span ng-bind="'x' + articulo.cantidad"></span> | |
324 | + </div> | |
325 | + <div class="col-3 px-1 text-right"> | |
326 | + <span ng-bind="articulo.precio | currency: '$'"></span> | |
327 | + </div> | |
328 | + <div class="col px-1 text-right"> | |
329 | + <span | |
330 | + ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'" | |
331 | + > | |
332 | + </span> | |
333 | + </div> | |
334 | + </div> | |
335 | + </div> | |
336 | + <div class="align-middle p-1"> | |
337 | + <button | |
338 | + class="btn btn-outline-secondary" | |
339 | + ng-click="quitarArticulo(key)" | |
340 | + > | |
341 | + <i class="fa fa-trash"></i> | |
342 | + </button> | |
343 | + </div> | |
344 | + </td> | |
345 | + </tr> | |
346 | + </tbody> | |
347 | + <tfoot> | |
348 | + <!-- CARGANDO ITEM --> | |
349 | + <tr ng-show="!cargando" class="d-flex"> | |
350 | + <td | |
351 | + class="align-middle p-1" | |
352 | + ng-bind="articulosTabla.length + 1" | |
353 | + ></td> | |
354 | + <td class="col p-0"> | |
355 | + <div class="d-flex"> | |
356 | + <div class="col-4 px-1"> | |
357 | + <span | |
358 | + ng-bind="articuloACargar.sectorCodigo" | |
359 | + ></span> | |
360 | + </div> | |
361 | + <div class="col-8 px-1"> | |
362 | + <span ng-bind="articuloACargar.descripcion"></span> | |
363 | + </div> | |
364 | + </div> | |
365 | + <div class="d-flex"> | |
366 | + <div class="col-3 px-1 m-1"> | |
367 | + <input | |
368 | + class="form-control p-1" | |
369 | + type="number" | |
370 | + min="1" | |
371 | + ng-model="articuloACargar.cantidad" | |
372 | + foca-focus="!cargando" | |
373 | + ng-keypress="agregarATabla($event.keyCode)" | |
374 | + style="height: auto; line-height: 1.1em" | |
375 | + > | |
376 | + </div> | |
377 | + <div class="col-3 px-1 text-right"> | |
378 | + <span ng-bind="articuloACargar.precio | currency: '$'"></span> | |
379 | + </div> | |
380 | + <div class="col px-1 text-right"> | |
381 | + <span | |
382 | + ng-bind="getSubTotal() | currency: '$'" | |
383 | + > | |
384 | + </span> | |
385 | + </div> | |
386 | + </div> | |
387 | + </td> | |
388 | + <td class="text-center align-middle"> | |
389 | + <button | |
390 | + class="btn btn-outline-secondary" | |
391 | + ng-click="agregarATabla(13)" | |
392 | + > | |
393 | + <i class="fa fa-save"></i> | |
394 | + </button> | |
395 | + </td> | |
396 | + </tr> | |
397 | + <!-- SELECCIONAR PRODUCTO --> | |
398 | + <tr ng-show="cargando" class="d-flex"> | |
399 | + <td class="col-12"> | |
400 | + <input | |
401 | + placeholder="Seleccione Articulo" | |
402 | + class="form-control form-control-sm" | |
403 | + readonly | |
404 | + ng-click="seleccionarArticulo()" | |
405 | + /> | |
406 | + </td> | |
407 | + </tr> | |
408 | + <!-- TOOGLE EXPANDIR --> | |
409 | + <tr> | |
410 | + <td class="col"> | |
411 | + <button | |
412 | + class="btn btn-outline-secondary selectable w-100" | |
413 | + ng-click="show = !show; masMenos()" | |
414 | + ng-show="articulosTabla.length > 0" | |
415 | + > | |
416 | + <i | |
417 | + class="fa fa-chevron-down" | |
418 | + ng-hide="show" | |
419 | + aria-hidden="true" | |
420 | + > | |
421 | + </i> | |
422 | + <i | |
423 | + class="fa fa-chevron-up" | |
424 | + ng-show="show" | |
425 | + aria-hidden="true"> | |
426 | + </i> | |
427 | + </button> | |
428 | + </td> | |
429 | + </tr> | |
430 | + <!-- FOOTER --> | |
431 | + <tr class="d-flex"> | |
432 | + <td class="align-middle no-border-top" colspan="2"> | |
433 | + <strong>Cantidad Items:</strong> | |
434 | + <a ng-bind="articulosTabla.length"></a> | |
435 | + </td> | |
436 | + <td class="text-right ml-auto table-celda-total no-border-top"> | |
437 | + <h3>Total:</h3> | |
438 | + </td> | |
439 | + <td class="table-celda-total text-right no-border-top"> | |
440 | + <h3>{{getTotal() | currency: '$'}}</h3> | |
441 | + </td> | |
442 | + </tr> | |
443 | + </tfoot> | |
444 | + </table> | |
445 | + </div> | |
249 | 446 | </div> |
250 | - <div class="col-auto my-2 col-lg-2 botonera-lateral"> | |
447 | + <div class="col-auto my-2 col-lg-2 botonera-lateral d-none d-md-block"> | |
251 | 448 | <div class="row align-items-end"> |
252 | 449 | <div class="col-12"> |
253 | 450 | <button |
... | ... | @@ -268,4 +465,10 @@ |
268 | 465 | </div> |
269 | 466 | </div> |
270 | 467 | </div> |
468 | + <div class="row d-md-none fixed-bottom"> | |
469 | + <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> | |
470 | + <span class="ml-3 text-muted" ng-click="salir()">Salir</span> | |
471 | + <span class="mr-3 ml-auto" ng-click="crearNotaPedido()">Guardar</span> | |
472 | + </div> | |
473 | + </div> | |
271 | 474 | </div> |