Commit 6d049380aa69899b5acc0b6ad2840f2e93eb3604
1 parent
9e918791b9
Exists in
master
and in
1 other branch
Validaciones de ingreso de datos
guarda nota de pedido
Showing
5 changed files
with
140 additions
and
85 deletions
Show diff stats
index.html
| 1 | <html ng-app="focaCrearNotaPedido"> | 1 | <html ng-app="focaCrearNotaPedido"> |
| 2 | <head> | 2 | <head> |
| 3 | <meta charset="UTF-8"/> | 3 | <meta charset="UTF-8"/> |
| 4 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | 4 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
| 5 | 5 | ||
| 6 | <!--CSS--> | 6 | <!--CSS--> |
| 7 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> | 7 | <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> |
| 8 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/> | 8 | <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/> |
| 9 | <link href="node_modules/ladda/dist/ladda-themeless.min.css" rel="stylesheet"> | 9 | <link href="node_modules/ladda/dist/ladda-themeless.min.css" rel="stylesheet"> |
| 10 | 10 | ||
| 11 | <!--VENDOR JS--> | 11 | <!--VENDOR JS--> |
| 12 | <script src="node_modules/jquery/dist/jquery.min.js"></script> | 12 | <script src="node_modules/jquery/dist/jquery.min.js"></script> |
| 13 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> | 13 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> |
| 14 | <script src="node_modules/angular/angular.min.js"></script> | 14 | <script src="node_modules/angular/angular.min.js"></script> |
| 15 | <script src="node_modules/angular-route/angular-route.min.js"></script> | 15 | <script src="node_modules/angular-route/angular-route.min.js"></script> |
| 16 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> | 16 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> |
| 17 | <script src="node_modules/ladda/dist/spin.min.js"></script> | 17 | <script src="node_modules/ladda/dist/spin.min.js"></script> |
| 18 | <script src="node_modules/ladda/dist/ladda.min.js"></script> | 18 | <script src="node_modules/ladda/dist/ladda.min.js"></script> |
| 19 | <script src="node_modules/angular-ladda/dist/angular-ladda.min.js"></script> | 19 | <script src="node_modules/angular-ladda/dist/angular-ladda.min.js"></script> |
| 20 | 20 | ||
| 21 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> | 21 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> |
| 22 | <script src="node_modules/foca-modal-vendedores/dist/foca-modal-vendedores.min.js"></script> | 22 | <script src="node_modules/foca-modal-vendedores/dist/foca-modal-vendedores.min.js"></script> |
| 23 | <script src="node_modules/foca-modal-busqueda-productos/dist/foca-busqueda-productos.min.js"></script> | 23 | <script src="node_modules/foca-modal-busqueda-productos/dist/foca-busqueda-productos.min.js"></script> |
| 24 | <script src="node_modules/foca-modal-proveedor/dist/foca-modal-proveedor.min.js"></script> | 24 | <script src="node_modules/foca-modal-proveedor/dist/foca-modal-proveedor.min.js"></script> |
| 25 | <script src="node_modules/foca-busqueda-cliente/dist/foca-busqueda-cliente.min.js"></script> | 25 | <script src="node_modules/foca-busqueda-cliente/dist/foca-busqueda-cliente.min.js"></script> |
| 26 | <script src="node_modules/foca-modal-precio-condiciones/dist/foca-modal-precio-condiciones.min.js"></script> | 26 | <script src="node_modules/foca-modal-precio-condiciones/dist/foca-modal-precio-condiciones.min.js"></script> |
| 27 | <script src="node_modules/foca-modal-flete/dist/foca-modal-flete.min.js"></script> | 27 | <script src="node_modules/foca-modal-flete/dist/foca-modal-flete.min.js"></script> |
| 28 | <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> | 28 | <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> |
| 29 | <script src="node_modules/foca-modal-domicilio/dist/foca-modal-domicilios.min.js"></script> | 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 | <script src="src/js/app.js"></script> | 33 | <script src="src/js/app.js"></script> |
| 32 | <script src="src/js/controller.js"></script> | 34 | <script src="src/js/controller.js"></script> |
| 33 | <script src="src/js/service.js"></script> | 35 | <script src="src/js/service.js"></script> |
| 34 | <script src="src/js/route.js"></script> | 36 | <script src="src/js/route.js"></script> |
| 35 | 37 | ||
| 36 | <script src="src/etc/develop.js"></script> | 38 | <script src="src/etc/develop.js"></script> |
| 37 | </head> | 39 | </head> |
| 38 | <body> | 40 | <body> |
| 39 | <div ng-view class="container-fluid"></div> | 41 | <div ng-view class="container-fluid"></div> |
| 40 | </body> | 42 | </body> |
| 41 | </html> | 43 | </html> |
| 42 | 44 |
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 | "gulp-pre-commit": "gulp pre-commit", | 9 | "gulp-pre-commit": "gulp pre-commit", |
| 10 | "postinstall": "npm run compile && gulp clean-post-install", | 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" |
| 12 | }, | 12 | }, |
| 13 | "pre-commit": [ | 13 | "pre-commit": [ |
| 14 | "gulp-pre-commit" | 14 | "gulp-pre-commit" |
| 15 | ], | 15 | ], |
| 16 | "repository": { | 16 | "repository": { |
| 17 | "type": "git", | 17 | "type": "git", |
| 18 | "url": "https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido.git" | 18 | "url": "https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido.git" |
| 19 | }, | 19 | }, |
| 20 | "author": "Foca Software", | 20 | "author": "Foca Software", |
| 21 | "license": "ISC", | 21 | "license": "ISC", |
| 22 | "peerDependencies": { | 22 | "peerDependencies": { |
| 23 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", | 23 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", |
| 24 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", | 24 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", |
| 25 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", | 25 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", |
| 26 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", | 26 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", |
| 27 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git" | 27 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git" |
| 28 | }, | 28 | }, |
| 29 | "devDependencies": { | 29 | "devDependencies": { |
| 30 | "angular": "^1.7.5", | 30 | "angular": "^1.7.5", |
| 31 | "angular-ladda": "^0.4.3", | 31 | "angular-ladda": "^0.4.3", |
| 32 | "angular-route": "^1.7.5", | 32 | "angular-route": "^1.7.5", |
| 33 | "bootstrap": "^4.1.3", | 33 | "bootstrap": "^4.1.3", |
| 34 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", | 34 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", |
| 35 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", | 35 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", |
| 36 | "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", | 36 | "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", |
| 37 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", | 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 | "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", | 39 | "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", |
| 39 | "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete", | 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 | "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", | 42 | "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", |
| 41 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", | 43 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", |
| 42 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", | 44 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", |
| 43 | "font-awesome": "^4.7.0", | 45 | "font-awesome": "^4.7.0", |
| 44 | "gulp": "^3.9.1", | 46 | "gulp": "^3.9.1", |
| 45 | "gulp-angular-templatecache": "^2.2.2", | 47 | "gulp-angular-templatecache": "^2.2.2", |
| 46 | "gulp-clean": "^0.4.0", | 48 | "gulp-clean": "^0.4.0", |
| 47 | "gulp-concat": "^2.6.1", | 49 | "gulp-concat": "^2.6.1", |
| 48 | "gulp-connect": "^5.6.1", | 50 | "gulp-connect": "^5.6.1", |
| 49 | "gulp-htmlmin": "^5.0.1", | 51 | "gulp-htmlmin": "^5.0.1", |
| 50 | "gulp-jshint": "^2.1.0", | 52 | "gulp-jshint": "^2.1.0", |
| 51 | "gulp-rename": "^1.4.0", | 53 | "gulp-rename": "^1.4.0", |
| 52 | "gulp-replace": "^1.0.0", | 54 | "gulp-replace": "^1.0.0", |
| 53 | "gulp-sequence": "^1.0.0", | 55 | "gulp-sequence": "^1.0.0", |
| 54 | "gulp-uglify": "^3.0.1", | 56 | "gulp-uglify": "^3.0.1", |
| 55 | "gulp-uglify-es": "^1.0.4", | 57 | "gulp-uglify-es": "^1.0.4", |
| 56 | "jasmine-core": "^3.3.0", | 58 | "jasmine-core": "^3.3.0", |
| 57 | "jquery": "^3.3.1", | 59 | "jquery": "^3.3.1", |
| 58 | "jshint": "^2.9.6", | 60 | "jshint": "^2.9.6", |
| 59 | "ladda": "1.0.6", | 61 | "ladda": "1.0.6", |
| 60 | "pre-commit": "^1.2.2", | 62 | "pre-commit": "^1.2.2", |
| 61 | "pump": "^3.0.0", | 63 | "pump": "^3.0.0", |
| 62 | "ui-bootstrap4": "^3.0.5" | 64 | "ui-bootstrap4": "^3.0.5" |
| 63 | } | 65 | } |
| 64 | } | 66 | } |
| 65 | 67 |
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 | 'focaModalProveedor', | 6 | 'focaModalProveedor', |
| 7 | 'focaBusquedaCliente', | 7 | 'focaBusquedaCliente', |
| 8 | 'focaModalPrecioCondicion', | 8 | 'focaModalPrecioCondicion', |
| 9 | 'focaModalFlete', | 9 | 'focaModalFlete', |
| 10 | 'focaDirectivas', | 10 | 'focaDirectivas', |
| 11 | 'focaModal', | 11 | 'focaModal', |
| 12 | 'focaModalDomicilio', | 12 | 'focaModalDomicilio', |
| 13 | 'angular-ladda' | 13 | 'angular-ladda', |
| 14 | 'focaModalMoneda', | ||
| 15 | 'focaModalCotizacion' | ||
| 14 | ]); | 16 | ]); |
| 15 | 17 |
src/js/controller.js
| 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 2 | [ | 2 | [ |
| 3 | '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', |
| 4 | 'focaModalService', | 4 | 'focaModalService', |
| 5 | function( | 5 | function( |
| 6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService | 6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService |
| 7 | ) { | 7 | ) { |
| 8 | $scope.botonera = [ | 8 | $scope.botonera = [ |
| 9 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, | 9 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, |
| 10 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | 10 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
| 11 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, | 11 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, |
| 12 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | 12 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, |
| 13 | { | 13 | { |
| 14 | texto: 'Precios y condiciones', | 14 | texto: 'Precios y condiciones', |
| 15 | accion: function() {$scope.abrirModalListaPrecio();}}, | 15 | accion: function() {$scope.abrirModalListaPrecio();}}, |
| 16 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | 16 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, |
| 17 | {texto: '', accion: function() {}}, | 17 | {texto: '', accion: function() {}}, |
| 18 | {texto: '', accion: function() {}} | 18 | {texto: '', accion: function() {}} |
| 19 | ]; | 19 | ]; |
| 20 | $scope.datepickerAbierto = false; | 20 | $scope.datepickerAbierto = false; |
| 21 | 21 | ||
| 22 | $scope.show = false; | 22 | $scope.show = false; |
| 23 | $scope.cargando = true; | 23 | $scope.cargando = true; |
| 24 | $scope.dateOptions = { | 24 | $scope.dateOptions = { |
| 25 | maxDate: new Date(), | 25 | maxDate: new Date(), |
| 26 | minDate: new Date(2010, 0, 1) | 26 | minDate: new Date(2010, 0, 1) |
| 27 | }; | 27 | }; |
| 28 | $scope.crearObjetoNotaPedido = function() { | ||
| 29 | $scope.notaPedido = { | ||
| 30 | vendedor: {}, | ||
| 31 | cliente: {}, | ||
| 32 | proveedor: {}, | ||
| 33 | domicilio: {dom: ''}, | ||
| 34 | moneda: {}, | ||
| 35 | cotizacion: {} | ||
| 36 | }; | ||
| 37 | }; | ||
| 28 | 38 | ||
| 29 | $scope.notaPedido = { | 39 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
| 30 | vendedor: {}, | 40 | $scope.obtenerMonedaPorDefecto = function() { |
| 31 | cliente: {}, | 41 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { |
| 32 | domicilio: {dom: ''}, | 42 | monedaPorDefecto = { |
| 33 | moneda: {detalle: ''} | 43 | id: res.data[0].ID, |
| 44 | detalle: res.data[0].DETALLE, | ||
| 45 | simbolo: res.data[0].SIMBOLO, | ||
| 46 | cotizaciones: res.data[0].cotizaciones | ||
| 47 | }; | ||
| 48 | addCabecera('Moneda:', monedaPorDefecto.detalle); | ||
| 49 | addCabecera('Fecha cotizacion:', | ||
| 50 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | ||
| 51 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); | ||
| 52 | $scope.notaPedido.moneda = monedaPorDefecto; | ||
| 53 | $scope.notaPedido.cotizacion.id = monedaPorDefecto.cotizaciones[0].ID; | ||
| 54 | }); | ||
| 34 | }; | 55 | }; |
| 35 | 56 | ||
| 57 | var monedaPorDefecto; | ||
| 58 | $scope.crearObjetoNotaPedido(); | ||
| 59 | $scope.obtenerMonedaPorDefecto(); | ||
| 36 | $scope.cabecera = []; | 60 | $scope.cabecera = []; |
| 37 | $scope.showCabecera = true; | 61 | $scope.showCabecera = true; |
| 38 | 62 | ||
| 39 | $scope.now = new Date(); | 63 | $scope.now = new Date(); |
| 40 | $scope.puntoVenta = Math.round(Math.random() * 10000); | 64 | $scope.puntoVenta = Math.round(Math.random() * 10000); |
| 41 | $scope.comprobante = Math.round(Math.random() * 1000000); | 65 | $scope.comprobante = Math.round(Math.random() * 1000000); |
| 42 | 66 | ||
| 43 | $scope.articulosTabla = []; | 67 | $scope.articulosTabla = []; |
| 44 | $scope.idLista = undefined; | 68 | $scope.idLista = undefined; |
| 45 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | 69 | //La pantalla solo se usa para cargar pedidos |
| 70 | //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | ||
| 71 | |||
| 46 | crearNotaPedidoService.getPrecioCondicion().then( | 72 | crearNotaPedidoService.getPrecioCondicion().then( |
| 47 | function(res) { | 73 | function(res) { |
| 48 | $scope.precioCondiciones = res.data; | 74 | $scope.precioCondiciones = res.data; |
| 49 | } | 75 | } |
| 50 | ); | 76 | ); |
| 51 | if (notaPedidoTemp !== undefined) { | 77 | //La pantalla solo se usa para cargar pedidos |
| 52 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | 78 | // if (notaPedidoTemp !== undefined) { |
| 53 | $scope.notaPedido = notaPedidoTemp; | 79 | // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
| 54 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | 80 | // $scope.notaPedido = notaPedidoTemp; |
| 55 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | 81 | // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
| 56 | $scope.idLista = $scope.notaPedido.precioCondicion; | 82 | // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
| 57 | crearNotaPedidoService | 83 | // $scope.idLista = $scope.notaPedido.precioCondicion; |
| 58 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | 84 | // crearNotaPedidoService |
| 59 | function(res) { | 85 | // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
| 60 | $scope.articulosTabla = res.data; | 86 | // function(res) { |
| 61 | } | 87 | // $scope.articulosTabla = res.data; |
| 62 | ); | 88 | // } |
| 89 | // ); | ||
| 63 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | 90 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
| 64 | //(NO REQUERIDO EN ESTA VERSION) | 91 | //(NO REQUERIDO EN ESTA VERSION) |
| 65 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 92 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
| 66 | // function(res) { | 93 | // function(res) { |
| 67 | // $scope.notaPedido.domicilio = res.data; | 94 | // $scope.notaPedido.domicilio = res.data; |
| 68 | // } | 95 | // } |
| 69 | // ); | 96 | // ); |
| 70 | } else { | 97 | // } else { |
| 71 | $scope.notaPedido.fechaCarga = new Date(); | 98 | // $scope.notaPedido.fechaCarga = new Date(); |
| 72 | $scope.notaPedido.bomba = '0'; | 99 | // $scope.notaPedido.bomba = '0'; |
| 73 | $scope.notaPedido.flete = '0'; | 100 | // $scope.notaPedido.flete = '0'; |
| 74 | $scope.idLista = undefined; | 101 | // $scope.idLista = undefined; |
| 75 | } | 102 | // } |
| 76 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 103 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
| 77 | // $scope.addNewDom = function() { | 104 | // $scope.addNewDom = function() { |
| 78 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); | 105 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); |
| 79 | // }; | 106 | // }; |
| 80 | // $scope.removeNewChoice = function(choice) { | 107 | // $scope.removeNewChoice = function(choice) { |
| 81 | // if ($scope.notaPedido.domicilio.length > 1) { | 108 | // if ($scope.notaPedido.domicilio.length > 1) { |
| 82 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | 109 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
| 83 | // function(c) { | 110 | // function(c) { |
| 84 | // return c.$$hashKey === choice.$$hashKey; | 111 | // return c.$$hashKey === choice.$$hashKey; |
| 85 | // } | 112 | // } |
| 86 | // ), 1); | 113 | // ), 1); |
| 87 | // } | 114 | // } |
| 88 | // }; | 115 | // }; |
| 116 | |||
| 89 | $scope.crearNotaPedido = function() { | 117 | $scope.crearNotaPedido = function() { |
| 90 | if($scope.articulosTabla.length === 0) { | 118 | if(!$scope.notaPedido.vendedor.codigo) { |
| 119 | focaModalService.alert('Ingrese Vendedor'); | ||
| 120 | return; | ||
| 121 | } else if(!$scope.notaPedido.cliente.id) { | ||
| 122 | focaModalService.alert('Ingrese Cliente'); | ||
| 123 | return; | ||
| 124 | } else if(!$scope.notaPedido.proveedor.codigo) { | ||
| 125 | focaModalService.alert('Ingrese Proveedor'); | ||
| 126 | return; | ||
| 127 | } else if(!$scope.notaPedido.moneda.id) { | ||
| 128 | focaModalService.alert('Ingrese Moneda'); | ||
| 129 | return; | ||
| 130 | } else if(!$scope.notaPedido.cotizacion.id) { | ||
| 131 | focaModalService.alert('Ingrese Cotización'); | ||
| 132 | return; | ||
| 133 | } else if(!$scope.plazosPagos) { | ||
| 134 | focaModalService.alert('Ingrese Precios y Condiciones'); | ||
| 135 | return; | ||
| 136 | } else if(!$scope.notaPedido.flete) { | ||
| 137 | focaModalService.alert('Ingrese Flete'); | ||
| 138 | return; | ||
| 139 | } else if(!$scope.notaPedido.domicilio.id) { | ||
| 140 | focaModalService.aler('Ingrese Domicilio'); | ||
| 141 | return; | ||
| 142 | } else if($scope.articulosTabla.length === 0) { | ||
| 91 | focaModalService.alert('Debe cargar almenos un articulo'); | 143 | focaModalService.alert('Debe cargar almenos un articulo'); |
| 92 | return; | 144 | return; |
| 93 | } | 145 | } |
| 94 | if($scope.notaPedido.domicilio.id === undefined) { | ||
| 95 | $scope.notaPedido.domicilio.id = 0; | ||
| 96 | } | ||
| 97 | var date = new Date(); | 146 | var date = new Date(); |
| 98 | var notaPedido = { | 147 | var notaPedido = { |
| 99 | id: 0, | 148 | id: 0, |
| 100 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 149 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
| 101 | .toISOString().slice(0, 19).replace('T', ' '), | 150 | .toISOString().slice(0, 19).replace('T', ' '), |
| 102 | vendedor: $scope.notaPedido.vendedor.nombre, | 151 | idVendedor: $scope.notaPedido.vendedor.codigo, |
| 103 | idCliente: $scope.notaPedido.cliente.id, | 152 | idCliente: $scope.notaPedido.cliente.id, |
| 104 | domicilio: $scope.notaPedido.domicilio, | 153 | idProveedor: $scope.notaPedido.proveedor.codigo, |
| 105 | bomba: $scope.notaPedido.bomba, | 154 | idDomicilio: $scope.notaPedido.domicilio.id, |
| 106 | flete: $scope.notaPedido.flete, | 155 | idCotizacion: $scope.notaPedido.cotizacion.id, |
| 156 | flete: parseInt($scope.notaPedido.flete), | ||
| 157 | fob: parseInt($scope.notaPedido.fob), | ||
| 158 | bomba: parseInt($scope.notaPedido.bomba), | ||
| 159 | kilometros: $scope.notaPedido.kilometros, | ||
| 107 | total: $scope.getTotal() | 160 | total: $scope.getTotal() |
| 108 | }; | 161 | }; |
| 109 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 162 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
| 110 | function(data) { | 163 | function(data) { |
| 111 | if($scope.notaPedido.flete === 1) { | 164 | |
| 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 | } | ||
| 122 | var articulosNotaPedido = $scope.articulosTabla; | 165 | var articulosNotaPedido = $scope.articulosTabla; |
| 123 | for(var i = 0; i < articulosNotaPedido.length; i++) { | 166 | for(var i = 0; i < articulosNotaPedido.length; i++) { |
| 124 | delete articulosNotaPedido[i].editCantidad; | 167 | delete articulosNotaPedido[i].editCantidad; |
| 125 | delete articulosNotaPedido[i].editPrecio; | 168 | delete articulosNotaPedido[i].editPrecio; |
| 126 | articulosNotaPedido[i].idNotaPedido = data.data.id; | 169 | articulosNotaPedido[i].idNotaPedido = data.data.id; |
| 127 | crearNotaPedidoService | 170 | crearNotaPedidoService |
| 128 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); | 171 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); |
| 129 | } | 172 | } |
| 130 | var plazos = $scope.plazosPagos; | 173 | var plazos = $scope.plazosPagos; |
| 131 | for(var j = 0; j < plazos.length; j++) { | 174 | for(var j = 0; j < plazos.length; j++) { |
| 132 | var json = { | 175 | var json = { |
| 133 | idPedido: data.data.id, | 176 | idPedido: data.data.id, |
| 134 | dias: plazos[j].dias | 177 | dias: plazos[j].dias |
| 135 | }; | 178 | }; |
| 136 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); | 179 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); |
| 137 | } | 180 | } |
| 138 | focaModalService.alert('Nota pedido creada'); | 181 | focaModalService.alert('Nota pedido creada'); |
| 139 | $scope.limpiarPantalla(); | 182 | $scope.obtenerMonedaPorDefecto(); |
| 183 | $scope.crearObjetoNotaPedido(); | ||
| 184 | $scope.cabecera = []; | ||
| 185 | $scope.articulosTabla = []; | ||
| 140 | } | 186 | } |
| 141 | ); | 187 | ); |
| 142 | }; | 188 | }; |
| 143 | 189 | ||
| 144 | $scope.seleccionarArticulo = function() { | 190 | $scope.seleccionarArticulo = function() { |
| 145 | if ($scope.idLista === undefined) { | 191 | if ($scope.idLista === undefined) { |
| 146 | focaModalService.alert( | 192 | focaModalService.alert( |
| 147 | 'Primero seleccione una lista de precio y condicion'); | 193 | 'Primero seleccione una lista de precio y condicion'); |
| 148 | return; | 194 | return; |
| 149 | } | 195 | } |
| 150 | var modalInstance = $uibModal.open( | 196 | var modalInstance = $uibModal.open( |
| 151 | { | 197 | { |
| 152 | ariaLabelledBy: 'Busqueda de Productos', | 198 | ariaLabelledBy: 'Busqueda de Productos', |
| 153 | templateUrl: 'modal-busqueda-productos.html', | 199 | templateUrl: 'modal-busqueda-productos.html', |
| 154 | controller: 'modalBusquedaProductosCtrl', | 200 | controller: 'modalBusquedaProductosCtrl', |
| 155 | resolve: { idLista: function() { return $scope.idLista; } }, | 201 | resolve: { idLista: function() { return $scope.idLista; } }, |
| 156 | size: 'lg' | 202 | size: 'lg' |
| 157 | } | 203 | } |
| 158 | ); | 204 | ); |
| 159 | modalInstance.result.then( | 205 | modalInstance.result.then( |
| 160 | function(producto) { | 206 | function(producto) { |
| 161 | var newArt = | 207 | var newArt = |
| 162 | { | 208 | { |
| 163 | id: 0, | 209 | id: 0, |
| 164 | codigo: producto.codigo, | 210 | codigo: producto.codigo, |
| 165 | sector: producto.sector, | 211 | sector: producto.sector, |
| 166 | sectorCodigo: producto.sector + '-' + producto.codigo, | 212 | sectorCodigo: producto.sector + '-' + producto.codigo, |
| 167 | descripcion: producto.descripcion, | 213 | descripcion: producto.descripcion, |
| 168 | item: $scope.articulosTabla.length + 1, | 214 | item: $scope.articulosTabla.length + 1, |
| 169 | nombre: producto.descripcion, | 215 | nombre: producto.descripcion, |
| 170 | precio: parseFloat(producto.precio.toFixed(2)), | 216 | precio: parseFloat(producto.precio.toFixed(2)), |
| 171 | costoUnitario: producto.costo, | 217 | costoUnitario: producto.costo, |
| 172 | editCantidad: false, | 218 | editCantidad: false, |
| 173 | editPrecio: false | 219 | editPrecio: false |
| 174 | }; | 220 | }; |
| 175 | $scope.articuloACargar = newArt; | 221 | $scope.articuloACargar = newArt; |
| 176 | $scope.cargando = false; | 222 | $scope.cargando = false; |
| 177 | }, function() { | 223 | }, function() { |
| 178 | // funcion ejecutada cuando se cancela el modal | 224 | // funcion ejecutada cuando se cancela el modal |
| 179 | } | 225 | } |
| 180 | ); | 226 | ); |
| 181 | }; | 227 | }; |
| 182 | 228 | ||
| 183 | $scope.seleccionarVendedor = function() { | 229 | $scope.seleccionarVendedor = function() { |
| 184 | var modalInstance = $uibModal.open( | 230 | var modalInstance = $uibModal.open( |
| 185 | { | 231 | { |
| 186 | ariaLabelledBy: 'Busqueda de Vendedores', | 232 | ariaLabelledBy: 'Busqueda de Vendedores', |
| 187 | templateUrl: 'modal-vendedores.html', | 233 | templateUrl: 'modal-vendedores.html', |
| 188 | controller: 'modalVendedoresCtrl', | 234 | controller: 'modalVendedoresCtrl', |
| 189 | size: 'lg' | 235 | size: 'lg' |
| 190 | } | 236 | } |
| 191 | ); | 237 | ); |
| 192 | modalInstance.result.then( | 238 | modalInstance.result.then( |
| 193 | function(vendedor) { | 239 | function(vendedor) { |
| 194 | addCabecera('Vendedor:', vendedor.NomVen); | 240 | addCabecera('Vendedor:', vendedor.NomVen); |
| 195 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; | 241 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; |
| 196 | }, function() { | 242 | }, function() { |
| 197 | 243 | ||
| 198 | } | 244 | } |
| 199 | ); | 245 | ); |
| 200 | }; | 246 | }; |
| 201 | 247 | ||
| 202 | $scope.seleccionarProveedor = function() { | 248 | $scope.seleccionarProveedor = function() { |
| 203 | var modalInstance = $uibModal.open( | 249 | var modalInstance = $uibModal.open( |
| 204 | { | 250 | { |
| 205 | ariaLabelledBy: 'Busqueda de Proveedor', | 251 | ariaLabelledBy: 'Busqueda de Proveedor', |
| 206 | templateUrl: 'modal-proveedor.html', | 252 | templateUrl: 'modal-proveedor.html', |
| 207 | controller: 'focaModalProveedorCtrl', | 253 | controller: 'focaModalProveedorCtrl', |
| 208 | size: 'lg' | 254 | size: 'lg' |
| 209 | } | 255 | } |
| 210 | ); | 256 | ); |
| 211 | modalInstance.result.then( | 257 | modalInstance.result.then( |
| 212 | function(proveedor) { | 258 | function(proveedor) { |
| 213 | $scope.notaPedido.proveedor = proveedor.NOM; | 259 | $scope.notaPedido.proveedor.codigo = proveedor.COD; |
| 214 | addCabecera('Proveedor:', proveedor.NOM); | 260 | addCabecera('Proveedor:', proveedor.NOM); |
| 215 | }, function() { | 261 | }, function() { |
| 216 | 262 | ||
| 217 | } | 263 | } |
| 218 | ); | 264 | ); |
| 219 | }; | 265 | }; |
| 220 | 266 | ||
| 221 | $scope.seleccionarCliente = function() { | 267 | $scope.seleccionarCliente = function() { |
| 268 | |||
| 222 | var modalInstance = $uibModal.open( | 269 | var modalInstance = $uibModal.open( |
| 223 | { | 270 | { |
| 224 | ariaLabelledBy: 'Busqueda de Cliente', | 271 | ariaLabelledBy: 'Busqueda de Cliente', |
| 225 | templateUrl: 'foca-busqueda-cliente-modal.html', | 272 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 226 | controller: 'focaBusquedaClienteModalController', | 273 | controller: 'focaBusquedaClienteModalController', |
| 227 | size: 'lg' | 274 | size: 'lg' |
| 228 | } | 275 | } |
| 229 | ); | 276 | ); |
| 230 | modalInstance.result.then( | 277 | modalInstance.result.then( |
| 231 | function(cliente) { | 278 | function(cliente) { |
| 232 | $scope.notaPedido.cliente.nombre = cliente.nom; | ||
| 233 | $scope.notaPedido.cliente.id = cliente.cod; | ||
| 234 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( | 279 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( |
| 235 | function(data) { | 280 | function(data) { |
| 236 | if(data.data.length === 0){ | 281 | if(data.data.length === 0){ |
| 237 | focaModalService | 282 | focaModalService |
| 238 | .alert('El cliente no tienen domicilios de entrega') | 283 | .alert('El cliente no tienen domicilios de entrega') |
| 239 | .then( | 284 | .then( |
| 240 | function() { | 285 | function() { |
| 241 | $scope.seleccionarCliente(); | 286 | $scope.seleccionarCliente(); |
| 242 | $scope.notaPedido.cliente = {nombre: ''}; | ||
| 243 | } | 287 | } |
| 244 | ); | 288 | ); |
| 245 | return; | 289 | return; |
| 246 | } | 290 | } |
| 247 | var modalInstanceDomicilio = $uibModal.open( | 291 | $scope.abrirModalDomicilios(cliente); |
| 248 | { | ||
| 249 | ariaLabelledBy: 'Busqueda de Domicilios', | ||
| 250 | templateUrl: 'modal-domicilio.html', | ||
| 251 | controller: 'focaModalDomicilioController', | ||
| 252 | resolve: { idCliente: function() { return cliente.cod; }}, | ||
| 253 | size: 'lg', | ||
| 254 | backdrop: 'static', | ||
| 255 | } | ||
| 256 | ); | ||
| 257 | modalInstanceDomicilio.result.then( | ||
| 258 | function(domicilio) { | ||
| 259 | focaModalService.alert('Domicilio elegido' + domicilio.dom); | ||
| 260 | }, function() { | ||
| 261 | $scope.notaPedido.cliente.nombre = ''; | ||
| 262 | $scope.notaPedido.cliente.id = ''; | ||
| 263 | removeCabecera('Cliente:'); | ||
| 264 | $scope.seleccionarCliente(); | ||
| 265 | return; | ||
| 266 | } | ||
| 267 | ); | ||
| 268 | } | 292 | } |
| 269 | ); | 293 | ); |
| 270 | addCabecera('Cliente:', cliente.nom); | ||
| 271 | }, function() { | 294 | }, function() { |
| 295 | |||
| 296 | } | ||
| 297 | ); | ||
| 298 | }; | ||
| 272 | 299 | ||
| 300 | $scope.abrirModalDomicilios = function(cliente) { | ||
| 301 | var modalInstanceDomicilio = $uibModal.open( | ||
| 302 | { | ||
| 303 | ariaLabelledBy: 'Busqueda de Domicilios', | ||
| 304 | templateUrl: 'modal-domicilio.html', | ||
| 305 | controller: 'focaModalDomicilioController', | ||
| 306 | resolve: { idCliente: function() { return cliente.cod; }}, | ||
| 307 | size: 'lg', | ||
| 308 | } | ||
| 309 | ); | ||
| 310 | modalInstanceDomicilio.result.then( | ||
| 311 | function(domicilio) { | ||
| 312 | $scope.notaPedido.domicilio.id = domicilio.id; | ||
| 313 | $scope.notaPedido.cliente.id = cliente.cod; | ||
| 314 | addCabecera('Cliente:', cliente.nom); | ||
| 315 | addCabecera('Domicilio:', domicilio.dom); | ||
| 316 | }, function() { | ||
| 317 | $scope.seleccionarCliente(); | ||
| 318 | return; | ||
| 273 | } | 319 | } |
| 274 | ); | 320 | ); |
| 275 | }; | 321 | }; |
| 276 | 322 | ||
| 277 | $scope.mostrarFichaCliente = function() { | 323 | $scope.mostrarFichaCliente = function() { |
| 278 | $uibModal.open( | 324 | $uibModal.open( |
| 279 | { | 325 | { |
| 280 | ariaLabelledBy: 'Datos del Cliente', | 326 | ariaLabelledBy: 'Datos del Cliente', |
| 281 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 327 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
| 282 | controller: 'focaCrearNotaPedidoFichaClienteController', | 328 | controller: 'focaCrearNotaPedidoFichaClienteController', |
| 283 | size: 'lg' | 329 | size: 'lg' |
| 284 | } | 330 | } |
| 285 | ); | 331 | ); |
| 286 | }; | 332 | }; |
| 287 | 333 | ||
| 288 | $scope.getTotal = function() { | 334 | $scope.getTotal = function() { |
| 289 | var total = 0; | 335 | var total = 0; |
| 290 | var arrayTempArticulos = $scope.articulosTabla; | 336 | var arrayTempArticulos = $scope.articulosTabla; |
| 291 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 337 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
| 292 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 338 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 293 | } | 339 | } |
| 294 | return total.toFixed(2); | 340 | return parseFloat(total.toFixed(2)); |
| 295 | }; | 341 | }; |
| 296 | 342 | ||
| 297 | $scope.getSubTotal = function() { | 343 | $scope.getSubTotal = function() { |
| 298 | if($scope.articuloACargar) { | 344 | if($scope.articuloACargar) { |
| 299 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 345 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 300 | } | 346 | } |
| 301 | }; | 347 | }; |
| 302 | 348 | ||
| 303 | $scope.abrirModalListaPrecio = function() { | 349 | $scope.abrirModalListaPrecio = function() { |
| 304 | var modalInstance = $uibModal.open( | 350 | var modalInstance = $uibModal.open( |
| 305 | { | 351 | { |
| 306 | ariaLabelledBy: 'Busqueda de Precio Condición', | 352 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 307 | templateUrl: 'modal-precio-condicion.html', | 353 | templateUrl: 'modal-precio-condicion.html', |
| 308 | controller: 'focaModalPrecioCondicionController', | 354 | controller: 'focaModalPrecioCondicionController', |
| 309 | size: 'lg' | 355 | size: 'lg' |
| 310 | } | 356 | } |
| 311 | ); | 357 | ); |
| 312 | modalInstance.result.then( | 358 | modalInstance.result.then( |
| 313 | function(precioCondicion) { | 359 | function(precioCondicion) { |
| 314 | var cabecera = ''; | 360 | var cabecera = ''; |
| 315 | var plazosConcat = ''; | 361 | var plazosConcat = ''; |
| 316 | if(!Array.isArray(precioCondicion)) { | 362 | if(!Array.isArray(precioCondicion)) { |
| 317 | $scope.plazosPagos = precioCondicion.plazoPago; | 363 | $scope.plazosPagos = precioCondicion.plazoPago; |
| 318 | $scope.idLista = precioCondicion.idListaPrecio; | 364 | $scope.idLista = precioCondicion.idListaPrecio; |
| 319 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 365 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
| 320 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 366 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
| 321 | } | 367 | } |
| 322 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 368 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
| 323 | } else { //Cuando se ingresan los plazos manualmente | 369 | } else { //Cuando se ingresan los plazos manualmente |
| 324 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 370 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
| 325 | $scope.plazosPagos = precioCondicion; | 371 | $scope.plazosPagos = precioCondicion; |
| 326 | for(var j = 0; j < precioCondicion.length; j++) { | 372 | for(var j = 0; j < precioCondicion.length; j++) { |
| 327 | plazosConcat += precioCondicion[j].dias + ' '; | 373 | plazosConcat += precioCondicion[j].dias + ' '; |
| 328 | } | 374 | } |
| 329 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 375 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
| 330 | } | 376 | } |
| 331 | $scope.articulosTabla = []; | 377 | $scope.articulosTabla = []; |
| 332 | addCabecera('Precios y condiciones:', cabecera); | 378 | addCabecera('Precios y condiciones:', cabecera); |
| 333 | }, function() { | 379 | }, function() { |
| 334 | 380 | ||
| 335 | } | 381 | } |
| 336 | ); | 382 | ); |
| 337 | }; | 383 | }; |
| 338 | 384 | ||
| 339 | $scope.abrirModalFlete = function() { | 385 | $scope.abrirModalFlete = function() { |
| 340 | var modalInstance = $uibModal.open( | 386 | var modalInstance = $uibModal.open( |
| 341 | { | 387 | { |
| 342 | ariaLabelledBy: 'Busqueda de Flete', | 388 | ariaLabelledBy: 'Busqueda de Flete', |
| 343 | templateUrl: 'modal-flete.html', | 389 | templateUrl: 'modal-flete.html', |
| 344 | controller: 'focaModalFleteController', | 390 | controller: 'focaModalFleteController', |
| 345 | size: 'lg', | 391 | size: 'lg', |
| 346 | resolve: { | 392 | resolve: { |
| 347 | parametrosFlete: | 393 | parametrosFlete: |
| 348 | function() { | 394 | function() { |
| 349 | return { | 395 | return { |
| 350 | flete: $scope.notaPedido.flete, | 396 | flete: $scope.notaPedido.flete, |
| 351 | bomba: $scope.notaPedido.bomba, | 397 | bomba: $scope.notaPedido.bomba, |
| 352 | kilometros: $scope.notaPedido.kilometros | 398 | kilometros: $scope.notaPedido.kilometros |
| 353 | }; | 399 | }; |
| 354 | } | 400 | } |
| 355 | } | 401 | } |
| 356 | } | 402 | } |
| 357 | ); | 403 | ); |
| 358 | modalInstance.result.then( | 404 | modalInstance.result.then( |
| 359 | function(datos) { | 405 | function(datos) { |
| 360 | $scope.notaPedido.flete = datos.flete; | 406 | $scope.notaPedido.flete = datos.flete; |
| 407 | $scope.notaPedido.fob = datos.FOB; | ||
| 361 | $scope.notaPedido.bomba = datos.bomba; | 408 | $scope.notaPedido.bomba = datos.bomba; |
| 362 | $scope.notaPedido.kilometros = datos.kilometros; | 409 | $scope.notaPedido.kilometros = datos.kilometros; |
| 363 | 410 | ||
| 364 | addCabecera('Flete:', datos.flete); | 411 | addCabecera('Flete:', datos.flete); |
| 365 | if(datos.flete === 'si') { | 412 | if(datos.flete === '1') { |
| 366 | addCabecera('Bomba:', datos.bomba); | 413 | addCabecera('Bomba:', datos.bomba); |
| 367 | addCabecera('Kilometros:', datos.kilometros); | 414 | addCabecera('Kilometros:', datos.kilometros); |
| 368 | } else { | 415 | } else { |
| 369 | removeCabecera('Bomba:'); | 416 | removeCabecera('Bomba:'); |
| 370 | removeCabecera('Kilometros:'); | 417 | removeCabecera('Kilometros:'); |
| 371 | } | 418 | } |
| 372 | }, function() { | 419 | }, function() { |
| 373 | 420 | ||
| 374 | } | 421 | } |
| 375 | ); | 422 | ); |
| 376 | }; | 423 | }; |
| 377 | 424 | ||
| 378 | $scope.abrirModalMoneda = function() { | 425 | $scope.abrirModalMoneda = function() { |
| 379 | var modalInstance = $uibModal.open( | 426 | var modalInstance = $uibModal.open( |
| 380 | { | 427 | { |
| 381 | ariaLabelledBy: 'Busqueda de Moneda', | 428 | ariaLabelledBy: 'Busqueda de Moneda', |
| 382 | templateUrl: 'modal-moneda.html', | 429 | templateUrl: 'modal-moneda.html', |
| 383 | controller: 'focaModalMonedaController', | 430 | controller: 'focaModalMonedaController', |
| 384 | size: 'lg' | 431 | size: 'lg' |
| 385 | } | 432 | } |
| 386 | ); | 433 | ); |
| 387 | modalInstance.result.then( | 434 | modalInstance.result.then( |
| 388 | function(moneda) { | 435 | function(moneda) { |
| 389 | $scope.notaPedido.moneda = { | ||
| 390 | id: moneda.ID, | ||
| 391 | detalle: moneda.DETALLE, | ||
| 392 | simbolo: moneda.SIMBOLO | ||
| 393 | }; | ||
| 394 | 436 | ||
| 395 | addCabecera('Moneda:', moneda.DETALLE); | 437 | $scope.abrirModalCotizacion(moneda); |
| 396 | $scope.abrirModalCotizacion(moneda.ID); | ||
| 397 | }, function() { | 438 | }, function() { |
| 398 | 439 | ||
| 399 | } | 440 | } |
| 400 | ); | 441 | ); |
| 401 | }; | 442 | }; |
| 402 | 443 | ||
| 403 | $scope.abrirModalCotizacion = function(idMoneda) { | 444 | $scope.abrirModalCotizacion = function(moneda) { |
| 404 | var modalInstance = $uibModal.open( | 445 | var modalInstance = $uibModal.open( |
| 405 | { | 446 | { |
| 406 | ariaLabelledBy: 'Busqueda de Cotización', | 447 | ariaLabelledBy: 'Busqueda de Cotización', |
| 407 | templateUrl: 'modal-cotizacion.html', | 448 | templateUrl: 'modal-cotizacion.html', |
| 408 | controller: 'focaModalCotizacionController', | 449 | controller: 'focaModalCotizacionController', |
| 409 | size: 'lg', | 450 | size: 'lg', |
| 410 | resolve: {idMoneda: function() {return idMoneda;}} | 451 | resolve: {idMoneda: function() {return moneda.ID;}} |
| 411 | } | 452 | } |
| 412 | ); | 453 | ); |
| 413 | modalInstance.result.then( | 454 | modalInstance.result.then( |
| 414 | function(cotizacion) { | 455 | function(cotizacion) { |
| 456 | $scope.notaPedido.moneda = { | ||
| 457 | id: moneda.ID, | ||
| 458 | detalle: moneda.DETALLE, | ||
| 459 | simbolo: moneda.SIMBOLO | ||
| 460 | }; | ||
| 415 | $scope.notaPedido.cotizacion = { | 461 | $scope.notaPedido.cotizacion = { |
| 416 | id: cotizacion.ID, | 462 | id: cotizacion.ID, |
| 417 | cotizacion: cotizacion.COTIZACION | 463 | cotizacion: cotizacion.COTIZACION |
| 418 | }; | 464 | }; |
| 419 | 465 | addCabecera('Moneda:', moneda.DETALLE); | |
| 420 | addCabecera( | 466 | addCabecera( |
| 421 | 'Fecha cotizacion:', | 467 | 'Fecha cotizacion:', |
| 422 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 468 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
| 423 | ); | 469 | ); |
| 424 | addCabecera('Cotizacion:', cotizacion.COTIZACION); | 470 | addCabecera('Cotizacion:', cotizacion.COTIZACION); |
| 425 | }, function() { | 471 | }, function() { |
| 426 | 472 | ||
| 427 | } | 473 | } |
| 428 | ); | 474 | ); |
| 429 | }; | 475 | }; |
| 430 | 476 | ||
| 431 | $scope.agregarATabla = function(key) { | 477 | $scope.agregarATabla = function(key) { |
| 432 | if(key === 13) { | 478 | if(key === 13) { |
| 433 | if($scope.articuloACargar.cantidad === undefined || | 479 | if($scope.articuloACargar.cantidad === undefined || |
| 434 | $scope.articuloACargar.cantidad === 0 || | 480 | $scope.articuloACargar.cantidad === 0 || |
| 435 | $scope.articuloACargar.cantidad === null ){ | 481 | $scope.articuloACargar.cantidad === null ){ |
| 436 | focaModalService.alert('El valor debe ser al menos 1'); | 482 | focaModalService.alert('El valor debe ser al menos 1'); |
| 437 | return; | 483 | return; |
| 438 | } | 484 | } |
| 439 | delete $scope.articuloACargar.sectorCodigo; | 485 | delete $scope.articuloACargar.sectorCodigo; |
| 440 | $scope.articulosTabla.push($scope.articuloACargar); | 486 | $scope.articulosTabla.push($scope.articuloACargar); |
| 441 | $scope.cargando = true; | 487 | $scope.cargando = true; |
| 442 | } | 488 | } |
| 443 | }; | 489 | }; |
| 444 | 490 | ||
| 445 | $scope.quitarArticulo = function(key) { | 491 | $scope.quitarArticulo = function(key) { |
| 446 | $scope.articulosTabla.splice(key, 1); | 492 | $scope.articulosTabla.splice(key, 1); |
| 447 | }; | 493 | }; |
| 448 | 494 | ||
| 449 | $scope.editarArticulo = function(key, articulo) { | 495 | $scope.editarArticulo = function(key, articulo) { |
| 450 | if(key === 13) { | 496 | if(key === 13) { |
| 451 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 497 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
| 452 | articulo.cantidad === undefined){ | 498 | articulo.cantidad === undefined){ |
| 453 | focaModalService.alert('El valor debe ser al menos 1'); | 499 | focaModalService.alert('El valor debe ser al menos 1'); |
| 454 | return; | 500 | return; |
| 455 | } | 501 | } |
| 456 | articulo.editCantidad = false; | 502 | articulo.editCantidad = false; |
| 457 | articulo.editPrecio = false; | 503 | articulo.editPrecio = false; |
| 458 | } | 504 | } |
| 459 | }; | 505 | }; |
| 460 | 506 | ||
| 461 | $scope.cambioEdit = function(articulo, propiedad) { | 507 | $scope.cambioEdit = function(articulo, propiedad) { |
| 462 | if(propiedad === 'cantidad') { | 508 | if(propiedad === 'cantidad') { |
| 463 | articulo.editCantidad = true; | 509 | articulo.editCantidad = true; |
| 464 | } else if(propiedad === 'precio') { | 510 | } else if(propiedad === 'precio') { |
| 465 | articulo.editPrecio = true; | 511 | articulo.editPrecio = true; |
| 466 | } | 512 | } |
| 467 | }; | 513 | }; |
| 468 | 514 | ||
| 469 | $scope.limpiarFlete = function() { | 515 | $scope.limpiarFlete = function() { |
| 470 | $scope.notaPedido.fleteNombre = ''; | 516 | $scope.notaPedido.fleteNombre = ''; |
| 471 | $scope.notaPedido.chofer = ''; | 517 | $scope.notaPedido.chofer = ''; |
| 472 | $scope.notaPedido.vehiculo = ''; | 518 | $scope.notaPedido.vehiculo = ''; |
| 473 | $scope.notaPedido.kilometros = ''; | 519 | $scope.notaPedido.kilometros = ''; |
| 474 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 520 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
| 475 | $scope.choferes = ''; | 521 | $scope.choferes = ''; |
| 476 | $scope.vehiculos = ''; | 522 | $scope.vehiculos = ''; |
| 477 | }; | 523 | }; |
| 478 | 524 | ||
| 479 | $scope.limpiarPantalla = function() { | 525 | $scope.limpiarPantalla = function() { |
| 480 | $scope.limpiarFlete(); | 526 | $scope.limpiarFlete(); |
| 481 | $scope.notaPedido.flete = '0'; | 527 | $scope.notaPedido.flete = '0'; |
| 482 | $scope.notaPedido.bomba = '0'; | 528 | $scope.notaPedido.bomba = '0'; |
| 483 | $scope.notaPedido.precioCondicion = ''; | 529 | $scope.notaPedido.precioCondicion = ''; |
| 484 | $scope.articulosTabla = []; | 530 | $scope.articulosTabla = []; |
| 485 | $scope.notaPedido.vendedor.nombre = ''; | 531 | $scope.notaPedido.vendedor.nombre = ''; |
| 486 | $scope.notaPedido.cliente = {nombre: ''}; | 532 | $scope.notaPedido.cliente = {nombre: ''}; |
| 487 | $scope.notaPedido.domicilio = {dom: ''}; | 533 | $scope.notaPedido.domicilio = {dom: ''}; |
| 488 | $scope.domiciliosCliente = []; | 534 | $scope.domiciliosCliente = []; |
| 489 | }; | 535 | }; |
| 490 | 536 | ||
| 491 | $scope.resetFilter = function() { | 537 | $scope.resetFilter = function() { |
| 492 | $scope.articuloACargar = {}; | 538 | $scope.articuloACargar = {}; |
| 493 | $scope.cargando = true; | 539 | $scope.cargando = true; |
| 494 | }; | 540 | }; |
| 495 | 541 | ||
| 496 | $scope.selectFocus = function($event) { | 542 | $scope.selectFocus = function($event) { |
| 497 | $event.target.select(); | 543 | $event.target.select(); |
| 498 | }; | 544 | }; |
| 499 | 545 | ||
| 500 | $scope.salir = function() { | 546 | $scope.salir = function() { |
| 501 | $location.path('/'); | 547 | $location.path('/'); |
| 502 | }; | 548 | }; |
| 503 | 549 | ||
| 504 | function addCabecera(label, valor) { | 550 | function addCabecera(label, valor) { |
| 505 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 551 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
| 506 | if(propiedad.length === 1) { | 552 | if(propiedad.length === 1) { |
| 507 | propiedad[0].valor = valor; | 553 | propiedad[0].valor = valor; |
| 508 | } else { | 554 | } else { |
| 509 | $scope.cabecera.push({label: label, valor: valor}); | 555 | $scope.cabecera.push({label: label, valor: valor}); |
| 510 | } | 556 | } |
| 511 | } | 557 | } |
| 512 | 558 | ||
| 513 | function removeCabecera(label) { | 559 | function removeCabecera(label) { |
| 514 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 560 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
| 515 | if(propiedad.length === 1){ | 561 | if(propiedad.length === 1){ |
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 | return { | 4 | return { |
| 5 | crearNotaPedido: function(notaPedido) { | 5 | crearNotaPedido: function(notaPedido) { |
| 6 | return $http.post(route + '/nota-pedido', {notaPedido: notaPedido}); | 6 | return $http.post(route + '/nota-pedido', {notaPedido: notaPedido}); |
| 7 | }, | 7 | }, |
| 8 | obtenerNotaPedido: function() { | 8 | obtenerNotaPedido: function() { |
| 9 | return $http.get(route +'/nota-pedido'); | 9 | return $http.get(route +'/nota-pedido'); |
| 10 | }, | 10 | }, |
| 11 | setNotaPedido: function(notaPedido) { | 11 | setNotaPedido: function(notaPedido) { |
| 12 | this.notaPedido = notaPedido; | 12 | this.notaPedido = notaPedido; |
| 13 | }, | 13 | }, |
| 14 | clearNotaPedido: function() { | 14 | clearNotaPedido: function() { |
| 15 | this.notaPedido = undefined; | 15 | this.notaPedido = undefined; |
| 16 | }, | 16 | }, |
| 17 | getNotaPedido: function() { | 17 | getNotaPedido: function() { |
| 18 | return this.notaPedido; | 18 | return this.notaPedido; |
| 19 | }, | 19 | }, |
| 20 | getArticulosByIdNotaPedido: function(id) { | 20 | getArticulosByIdNotaPedido: function(id) { |
| 21 | return $http.get(route+'/articulos/nota-pedido/'+id); | 21 | return $http.get(route+'/articulos/nota-pedido/'+id); |
| 22 | }, | 22 | }, |
| 23 | crearArticulosParaNotaPedido: function(articuloNotaPedido) { | 23 | crearArticulosParaNotaPedido: function(articuloNotaPedido) { |
| 24 | return $http.post(route + '/articulos/nota-pedido', | 24 | return $http.post(route + '/articulos/nota-pedido', |
| 25 | {articuloNotaPedido: articuloNotaPedido}); | 25 | {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 | getDomiciliosByIdCliente: function(id) { | 30 | getDomiciliosByIdCliente: function(id) { |
| 31 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) | 31 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) |
| 32 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); | 32 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); |
| 33 | }, | 33 | }, |
| 34 | getPrecioCondicion: function() { | 34 | getPrecioCondicion: function() { |
| 35 | return $http.get(route + '/precio-condicion'); | 35 | return $http.get(route + '/precio-condicion'); |
| 36 | }, | 36 | }, |
| 37 | getPrecioCondicionById: function(id) { | 37 | getPrecioCondicionById: function(id) { |
| 38 | return $http.get(route + '/precio-condicion/' + id); | 38 | return $http.get(route + '/precio-condicion/' + id); |
| 39 | }, | 39 | }, |
| 40 | getPlazoPagoByPrecioCondicion: function(id) { | 40 | getPlazoPagoByPrecioCondicion: function(id) { |
| 41 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); | 41 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); |
| 42 | }, | 42 | }, |
| 43 | crearFlete: function(flete) { | 43 | crearFlete: function(flete) { |
| 44 | return $http.post(route + '/flete', {flete : flete}); | 44 | return $http.post(route + '/flete', {flete : flete}); |
| 45 | }, | 45 | }, |
| 46 | crearPlazosParaNotaPedido: function(plazos) { | 46 | crearPlazosParaNotaPedido: function(plazos) { |
| 47 | return $http.post(route + '/plazo-pago/nota-pedido', plazos); | 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 | }]); |
| 51 | 54 |