Commit 4ce4edd31a9613a37ea6766b277b94a68d235bae
Exists in
master
and in
1 other branch
Merge branch 'master' of https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido
Showing
3 changed files
Show diff stats
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" |
| 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-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", | 38 | "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-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", | 39 | "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete", |
| 40 | "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", | 41 | "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", | 42 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", |
| 43 | "font-awesome": "^4.7.0", | 43 | "font-awesome": "^4.7.0", |
| 44 | "gulp": "^3.9.1", | 44 | "gulp": "^3.9.1", |
| 45 | "gulp-angular-templatecache": "^2.2.2", | 45 | "gulp-angular-templatecache": "^2.2.2", |
| 46 | "gulp-clean": "^0.4.0", | 46 | "gulp-clean": "^0.4.0", |
| 47 | "gulp-concat": "^2.6.1", | 47 | "gulp-concat": "^2.6.1", |
| 48 | "gulp-connect": "^5.6.1", | 48 | "gulp-connect": "^5.6.1", |
| 49 | "gulp-htmlmin": "^5.0.1", | 49 | "gulp-htmlmin": "^5.0.1", |
| 50 | "gulp-jshint": "^2.1.0", | 50 | "gulp-jshint": "^2.1.0", |
| 51 | "gulp-rename": "^1.4.0", | 51 | "gulp-rename": "^1.4.0", |
| 52 | "gulp-replace": "^1.0.0", | 52 | "gulp-replace": "^1.0.0", |
| 53 | "gulp-sequence": "^1.0.0", | 53 | "gulp-sequence": "^1.0.0", |
| 54 | "gulp-uglify": "^3.0.1", | 54 | "gulp-uglify": "^3.0.1", |
| 55 | "gulp-uglify-es": "^1.0.4", | 55 | "gulp-uglify-es": "^1.0.4", |
| 56 | "jasmine-core": "^3.3.0", | 56 | "jasmine-core": "^3.3.0", |
| 57 | "jquery": "^3.3.1", | 57 | "jquery": "^3.3.1", |
| 58 | "jshint": "^2.9.6", | 58 | "jshint": "^2.9.6", |
| 59 | "ladda": "1.0.6", | 59 | "ladda": "1.0.6", |
| 60 | "pre-commit": "^1.2.2", | 60 | "pre-commit": "^1.2.2", |
| 61 | "pump": "^3.0.0", | 61 | "pump": "^3.0.0", |
| 62 | "ui-bootstrap4": "^3.0.5" | 62 | "ui-bootstrap4": "^3.0.5" |
| 63 | } | 63 | } |
| 64 | } | 64 | } |
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 | 21 | ||
| 21 | $scope.show = false; | 22 | $scope.show = false; |
| 22 | $scope.cargando = true; | 23 | $scope.cargando = true; |
| 23 | $scope.dateOptions = { | 24 | $scope.dateOptions = { |
| 24 | maxDate: new Date(), | 25 | maxDate: new Date(), |
| 25 | minDate: new Date(2010, 0, 1) | 26 | minDate: new Date(2010, 0, 1) |
| 26 | }; | 27 | }; |
| 27 | 28 | ||
| 28 | $scope.notaPedido = { | 29 | $scope.notaPedido = { |
| 29 | vendedor: {}, | 30 | vendedor: {}, |
| 30 | cliente: {}, | 31 | cliente: {}, |
| 31 | domicilio: {dom: ''}, | 32 | domicilio: {dom: ''}, |
| 32 | moneda: {detalle: ''} | 33 | moneda: {detalle: ''} |
| 33 | }; | 34 | }; |
| 34 | 35 | ||
| 35 | $scope.cabecera = []; | 36 | $scope.cabecera = []; |
| 36 | $scope.showCabecera = true; | 37 | $scope.showCabecera = true; |
| 37 | 38 | ||
| 38 | $scope.now = new Date(); | 39 | $scope.now = new Date(); |
| 39 | $scope.puntoVenta = Math.round(Math.random() * 10000); | 40 | $scope.puntoVenta = Math.round(Math.random() * 10000); |
| 40 | $scope.comprobante = Math.round(Math.random() * 1000000); | 41 | $scope.comprobante = Math.round(Math.random() * 1000000); |
| 41 | 42 | ||
| 42 | $scope.articulosTabla = []; | 43 | $scope.articulosTabla = []; |
| 43 | var idLista; | 44 | var idLista; |
| 44 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | 45 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
| 45 | crearNotaPedidoService.getPrecioCondicion().then( | 46 | crearNotaPedidoService.getPrecioCondicion().then( |
| 46 | function(res) { | 47 | function(res) { |
| 47 | $scope.precioCondiciones = res.data; | 48 | $scope.precioCondiciones = res.data; |
| 48 | } | 49 | } |
| 49 | ); | 50 | ); |
| 50 | if (notaPedidoTemp !== undefined) { | 51 | if (notaPedidoTemp !== undefined) { |
| 51 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | 52 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
| 52 | $scope.notaPedido = notaPedidoTemp; | 53 | $scope.notaPedido = notaPedidoTemp; |
| 53 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | 54 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
| 54 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | 55 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
| 55 | idLista = $scope.notaPedido.precioCondicion; | 56 | idLista = $scope.notaPedido.precioCondicion; |
| 56 | crearNotaPedidoService | 57 | crearNotaPedidoService |
| 57 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | 58 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
| 58 | function(res) { | 59 | function(res) { |
| 59 | $scope.articulosTabla = res.data; | 60 | $scope.articulosTabla = res.data; |
| 60 | } | 61 | } |
| 61 | ); | 62 | ); |
| 62 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | 63 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
| 63 | //(NO REQUERIDO EN ESTA VERSION) | 64 | //(NO REQUERIDO EN ESTA VERSION) |
| 64 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 65 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
| 65 | // function(res) { | 66 | // function(res) { |
| 66 | // $scope.notaPedido.domicilio = res.data; | 67 | // $scope.notaPedido.domicilio = res.data; |
| 67 | // } | 68 | // } |
| 68 | // ); | 69 | // ); |
| 69 | } else { | 70 | } else { |
| 70 | $scope.notaPedido.fechaCarga = new Date(); | 71 | $scope.notaPedido.fechaCarga = new Date(); |
| 71 | $scope.notaPedido.bomba = '0'; | 72 | $scope.notaPedido.bomba = '0'; |
| 72 | $scope.notaPedido.flete = '0'; | 73 | $scope.notaPedido.flete = '0'; |
| 73 | idLista = undefined; | 74 | idLista = undefined; |
| 74 | } | 75 | } |
| 75 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 76 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
| 76 | // $scope.addNewDom = function() { | 77 | // $scope.addNewDom = function() { |
| 77 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); | 78 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); |
| 78 | // }; | 79 | // }; |
| 79 | // $scope.removeNewChoice = function(choice) { | 80 | // $scope.removeNewChoice = function(choice) { |
| 80 | // if ($scope.notaPedido.domicilio.length > 1) { | 81 | // if ($scope.notaPedido.domicilio.length > 1) { |
| 81 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | 82 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
| 82 | // function(c) { | 83 | // function(c) { |
| 83 | // return c.$$hashKey === choice.$$hashKey; | 84 | // return c.$$hashKey === choice.$$hashKey; |
| 84 | // } | 85 | // } |
| 85 | // ), 1); | 86 | // ), 1); |
| 86 | // } | 87 | // } |
| 87 | // }; | 88 | // }; |
| 88 | $scope.crearNotaPedido = function() { | 89 | $scope.crearNotaPedido = function() { |
| 89 | if($scope.articulosTabla.length === 0) { | 90 | if($scope.articulosTabla.length === 0) { |
| 90 | focaModalService.alert('Debe cargar almenos un articulo'); | 91 | focaModalService.alert('Debe cargar almenos un articulo'); |
| 91 | return; | 92 | return; |
| 92 | } | 93 | } |
| 93 | if($scope.notaPedido.domicilio.id === undefined) { | 94 | if($scope.notaPedido.domicilio.id === undefined) { |
| 94 | $scope.notaPedido.domicilio.id = 0; | 95 | $scope.notaPedido.domicilio.id = 0; |
| 95 | } | 96 | } |
| 96 | var date = new Date(); | 97 | var date = new Date(); |
| 97 | var notaPedido = { | 98 | var notaPedido = { |
| 98 | id: 0, | 99 | id: 0, |
| 99 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 100 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
| 100 | .toISOString().slice(0, 19).replace('T', ' '), | 101 | .toISOString().slice(0, 19).replace('T', ' '), |
| 101 | vendedor: $scope.notaPedido.vendedor.nombre, | 102 | vendedor: $scope.notaPedido.vendedor.nombre, |
| 102 | idCliente: $scope.notaPedido.cliente.id, | 103 | idCliente: $scope.notaPedido.cliente.id, |
| 103 | domicilio: $scope.notaPedido.domicilio, | 104 | domicilio: $scope.notaPedido.domicilio, |
| 104 | bomba: $scope.notaPedido.bomba, | ||
| 105 | flete: $scope.notaPedido.flete, | 105 | bomba: $scope.notaPedido.bomba, |
| 106 | total: $scope.getTotal() | 106 | flete: $scope.notaPedido.flete, |
| 107 | }; | 107 | total: $scope.getTotal() |
| 108 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 108 | }; |
| 109 | function(data) { | 109 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
| 110 | if($scope.notaPedido.flete === 1) { | 110 | function(data) { |
| 111 | var flete = { | 111 | if($scope.notaPedido.flete === 1) { |
| 112 | idNotaPedido: data.data.id, | 112 | var flete = { |
| 113 | idTransportista: $scope.notaPedido.fleteId, | 113 | idNotaPedido: data.data.id, |
| 114 | idChofer: $scope.notaPedido.chofer.id, | 114 | idTransportista: $scope.notaPedido.fleteId, |
| 115 | idVehiculo: $scope.notaPedido.vehiculo.id, | 115 | idChofer: $scope.notaPedido.chofer.id, |
| 116 | kilometros: $scope.notaPedido.kilometros, | 116 | idVehiculo: $scope.notaPedido.vehiculo.id, |
| 117 | costoKilometro: $scope.notaPedido.costoUnitarioKmFlete | 117 | kilometros: $scope.notaPedido.kilometros, |
| 118 | }; | 118 | costoKilometro: $scope.notaPedido.costoUnitarioKmFlete |
| 119 | crearNotaPedidoService.crearFlete(flete); | 119 | }; |
| 120 | } | 120 | crearNotaPedidoService.crearFlete(flete); |
| 121 | var articulosNotaPedido = $scope.articulosTabla; | 121 | } |
| 122 | for(var i = 0; i < articulosNotaPedido.length; i++) { | 122 | var articulosNotaPedido = $scope.articulosTabla; |
| 123 | delete articulosNotaPedido[i].edit; | 123 | for(var i = 0; i < articulosNotaPedido.length; i++) { |
| 124 | articulosNotaPedido[i].idNotaPedido = data.data.id; | 124 | delete articulosNotaPedido[i].edit; |
| 125 | crearNotaPedidoService | 125 | articulosNotaPedido[i].idNotaPedido = data.data.id; |
| 126 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); | 126 | crearNotaPedidoService |
| 127 | } | 127 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); |
| 128 | var plazos = $scope.plazosPagos; | 128 | } |
| 129 | for(var j = 0; j < plazos.length; j++) { | 129 | var plazos = $scope.plazosPagos; |
| 130 | var json = { | 130 | for(var j = 0; j < plazos.length; j++) { |
| 131 | idPedido: data.data.id, | 131 | var json = { |
| 132 | dias: plazos[j].dias | 132 | idPedido: data.data.id, |
| 133 | }; | 133 | dias: plazos[j].dias |
| 134 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); | 134 | }; |
| 135 | } | 135 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); |
| 136 | focaModalService.alert('Nota pedido creada'); | 136 | } |
| 137 | $scope.limpiarPantalla(); | 137 | focaModalService.alert('Nota pedido creada'); |
| 138 | } | 138 | $scope.limpiarPantalla(); |
| 139 | ); | 139 | } |
| 140 | }; | 140 | ); |
| 141 | 141 | }; | |
| 142 | $scope.seleccionarArticulo = function() { | 142 | |
| 143 | if (idLista === undefined) { | 143 | $scope.seleccionarArticulo = function() { |
| 144 | focaModalService.alert( | 144 | if (idLista === undefined) { |
| 145 | 'Primero seleccione una lista de precio y condicion'); | 145 | focaModalService.alert( |
| 146 | return; | 146 | 'Primero seleccione una lista de precio y condicion'); |
| 147 | } | 147 | return; |
| 148 | var modalInstance = $uibModal.open( | 148 | } |
| 149 | { | 149 | var modalInstance = $uibModal.open( |
| 150 | ariaLabelledBy: 'Busqueda de Productos', | 150 | { |
| 151 | templateUrl: 'modal-busqueda-productos.html', | 151 | ariaLabelledBy: 'Busqueda de Productos', |
| 152 | controller: 'modalBusquedaProductosCtrl', | 152 | templateUrl: 'modal-busqueda-productos.html', |
| 153 | resolve: { idLista: function() { return idLista; } }, | 153 | controller: 'modalBusquedaProductosCtrl', |
| 154 | size: 'lg' | 154 | resolve: { idLista: function() { return idLista; } }, |
| 155 | } | 155 | size: 'lg' |
| 156 | ); | 156 | } |
| 157 | modalInstance.result.then( | 157 | ); |
| 158 | function(producto) { | 158 | modalInstance.result.then( |
| 159 | var newArt = | 159 | function(producto) { |
| 160 | { | 160 | var newArt = |
| 161 | id: 0, | 161 | { |
| 162 | codigo: producto.codigo, | 162 | id: 0, |
| 163 | sector: producto.sector, | 163 | codigo: producto.codigo, |
| 164 | sectorCodigo: producto.sector + '-' + producto.codigo, | 164 | sector: producto.sector, |
| 165 | descripcion: producto.descripcion, | 165 | sectorCodigo: producto.sector + '-' + producto.codigo, |
| 166 | item: $scope.articulosTabla.length + 1, | 166 | descripcion: producto.descripcion, |
| 167 | nombre: producto.descripcion, | 167 | item: $scope.articulosTabla.length + 1, |
| 168 | precio: producto.precio.toFixed(2), | 168 | nombre: producto.descripcion, |
| 169 | costoUnitario: producto.costo, | 169 | precio: producto.precio.toFixed(2), |
| 170 | edit: false | 170 | costoUnitario: producto.costo, |
| 171 | }; | 171 | edit: false |
| 172 | $scope.articuloACargar = newArt; | 172 | }; |
| 173 | $scope.cargando = false; | 173 | $scope.articuloACargar = newArt; |
| 174 | }, function() { | 174 | $scope.cargando = false; |
| 175 | // funcion ejecutada cuando se cancela el modal | 175 | }, function() { |
| 176 | } | 176 | // funcion ejecutada cuando se cancela el modal |
| 177 | ); | 177 | } |
| 178 | }; | 178 | ); |
| 179 | 179 | }; | |
| 180 | $scope.seleccionarVendedor = function() { | 180 | |
| 181 | var modalInstance = $uibModal.open( | 181 | $scope.seleccionarVendedor = function() { |
| 182 | { | 182 | var modalInstance = $uibModal.open( |
| 183 | ariaLabelledBy: 'Busqueda de Vendedores', | 183 | { |
| 184 | templateUrl: 'modal-vendedores.html', | 184 | ariaLabelledBy: 'Busqueda de Vendedores', |
| 185 | controller: 'modalVendedoresCtrl', | 185 | templateUrl: 'modal-vendedores.html', |
| 186 | size: 'lg' | 186 | controller: 'modalVendedoresCtrl', |
| 187 | } | 187 | size: 'lg' |
| 188 | ); | 188 | } |
| 189 | modalInstance.result.then( | 189 | ); |
| 190 | function(vendedor) { | 190 | modalInstance.result.then( |
| 191 | addCabecera('Vendedor:', vendedor.NomVen); | 191 | function(vendedor) { |
| 192 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; | 192 | addCabecera('Vendedor:', vendedor.NomVen); |
| 193 | }, function() { | 193 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; |
| 194 | 194 | }, function() { | |
| 195 | } | 195 | |
| 196 | ); | 196 | } |
| 197 | }; | 197 | ); |
| 198 | 198 | }; | |
| 199 | $scope.seleccionarProveedor = function() { | 199 | |
| 200 | var modalInstance = $uibModal.open( | 200 | $scope.seleccionarProveedor = function() { |
| 201 | { | 201 | var modalInstance = $uibModal.open( |
| 202 | ariaLabelledBy: 'Busqueda de Proveedor', | 202 | { |
| 203 | templateUrl: 'modal-proveedor.html', | 203 | ariaLabelledBy: 'Busqueda de Proveedor', |
| 204 | controller: 'focaModalProveedorCtrl', | 204 | templateUrl: 'modal-proveedor.html', |
| 205 | size: 'lg' | 205 | controller: 'focaModalProveedorCtrl', |
| 206 | } | 206 | size: 'lg' |
| 207 | ); | 207 | } |
| 208 | modalInstance.result.then( | 208 | ); |
| 209 | function(proveedor) { | 209 | modalInstance.result.then( |
| 210 | $scope.notaPedido.proveedor = proveedor.NOM; | 210 | function(proveedor) { |
| 211 | addCabecera('Proveedor:', proveedor.NOM); | 211 | $scope.notaPedido.proveedor = proveedor.NOM; |
| 212 | }, function() { | 212 | addCabecera('Proveedor:', proveedor.NOM); |
| 213 | 213 | }, function() { | |
| 214 | } | 214 | |
| 215 | ); | 215 | } |
| 216 | }; | 216 | ); |
| 217 | 217 | }; | |
| 218 | $scope.seleccionarCliente = function() { | 218 | |
| 219 | var modalInstance = $uibModal.open( | 219 | $scope.seleccionarCliente = function() { |
| 220 | { | 220 | var modalInstance = $uibModal.open( |
| 221 | ariaLabelledBy: 'Busqueda de Cliente', | 221 | { |
| 222 | templateUrl: 'foca-busqueda-cliente-modal.html', | 222 | ariaLabelledBy: 'Busqueda de Cliente', |
| 223 | controller: 'focaBusquedaClienteModalController', | 223 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 224 | size: 'lg' | 224 | controller: 'focaBusquedaClienteModalController', |
| 225 | } | 225 | size: 'lg' |
| 226 | ); | 226 | } |
| 227 | modalInstance.result.then( | 227 | ); |
| 228 | function(cliente) { | 228 | modalInstance.result.then( |
| 229 | $scope.notaPedido.cliente.nombre = cliente.nom; | 229 | function(cliente) { |
| 230 | $scope.notaPedido.cliente.id = cliente.cod; | 230 | $scope.notaPedido.cliente.nombre = cliente.nom; |
| 231 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( | 231 | $scope.notaPedido.cliente.id = cliente.cod; |
| 232 | function(data) { | 232 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( |
| 233 | if(data.data.length === 0){ | 233 | function(data) { |
| 234 | focaModalService | 234 | if(data.data.length === 0){ |
| 235 | .alert('El cliente no tienen domicilios de entrega') | 235 | focaModalService |
| 236 | .then( | 236 | .alert('El cliente no tienen domicilios de entrega') |
| 237 | function() { | 237 | .then( |
| 238 | $scope.seleccionarCliente(); | 238 | function() { |
| 239 | $scope.notaPedido.cliente = {nombre: ''}; | 239 | $scope.seleccionarCliente(); |
| 240 | } | 240 | $scope.notaPedido.cliente = {nombre: ''}; |
| 241 | ); | 241 | } |
| 242 | return; | 242 | ); |
| 243 | } | 243 | return; |
| 244 | var modalInstanceDomicilio = $uibModal.open( | 244 | } |
| 245 | { | 245 | var modalInstanceDomicilio = $uibModal.open( |
| 246 | ariaLabelledBy: 'Busqueda de Domicilios', | 246 | { |
| 247 | templateUrl: 'modal-domicilio.html', | 247 | ariaLabelledBy: 'Busqueda de Domicilios', |
| 248 | controller: 'focaModalDomicilioController', | 248 | templateUrl: 'modal-domicilio.html', |
| 249 | resolve: { idCliente: function() { return cliente.cod; }}, | 249 | controller: 'focaModalDomicilioController', |
| 250 | size: 'lg', | 250 | resolve: { idCliente: function() { return cliente.cod; }}, |
| 251 | backdrop: 'static', | 251 | size: 'lg', |
| 252 | } | 252 | backdrop: 'static', |
| 253 | ); | 253 | } |
| 254 | modalInstanceDomicilio.result.then( | 254 | ); |
| 255 | function(domicilio) { | 255 | modalInstanceDomicilio.result.then( |
| 256 | focaModalService.alert('Domicilio elegido' + domicilio.dom); | 256 | function(domicilio) { |
| 257 | }, function() { | 257 | focaModalService.alert('Domicilio elegido' + domicilio.dom); |
| 258 | $scope.notaPedido.cliente.nombre = ''; | 258 | }, function() { |
| 259 | $scope.notaPedido.cliente.id = ''; | 259 | $scope.notaPedido.cliente.nombre = ''; |
| 260 | removeCabecera('Cliente:'); | 260 | $scope.notaPedido.cliente.id = ''; |
| 261 | $scope.seleccionarCliente(); | 261 | removeCabecera('Cliente:'); |
| 262 | return; | 262 | $scope.seleccionarCliente(); |
| 263 | } | 263 | return; |
| 264 | ); | 264 | } |
| 265 | } | 265 | ); |
| 266 | ); | 266 | } |
| 267 | addCabecera('Cliente:', cliente.nom); | 267 | ); |
| 268 | }, function() { | 268 | addCabecera('Cliente:', cliente.nom); |
| 269 | 269 | }, function() { | |
| 270 | } | 270 | |
| 271 | ); | 271 | } |
| 272 | }; | 272 | ); |
| 273 | 273 | }; | |
| 274 | $scope.mostrarFichaCliente = function() { | 274 | |
| 275 | $uibModal.open( | 275 | $scope.mostrarFichaCliente = function() { |
| 276 | { | 276 | $uibModal.open( |
| 277 | ariaLabelledBy: 'Datos del Cliente', | 277 | { |
| 278 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 278 | ariaLabelledBy: 'Datos del Cliente', |
| 279 | controller: 'focaCrearNotaPedidoFichaClienteController', | 279 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
| 280 | size: 'lg' | 280 | controller: 'focaCrearNotaPedidoFichaClienteController', |
| 281 | } | 281 | size: 'lg' |
| 282 | ); | 282 | } |
| 283 | }; | 283 | ); |
| 284 | 284 | }; | |
| 285 | $scope.getTotal = function() { | 285 | |
| 286 | var total = 0; | 286 | $scope.getTotal = function() { |
| 287 | var arrayTempArticulos = $scope.articulosTabla; | 287 | var total = 0; |
| 288 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 288 | var arrayTempArticulos = $scope.articulosTabla; |
| 289 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 289 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
| 290 | } | 290 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 291 | return total.toFixed(2); | 291 | } |
| 292 | }; | 292 | return total.toFixed(2); |
| 293 | 293 | }; | |
| 294 | $scope.getSubTotal = function() { | 294 | |
| 295 | if($scope.articuloACargar) { | 295 | $scope.getSubTotal = function() { |
| 296 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 296 | if($scope.articuloACargar) { |
| 297 | } | 297 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 298 | }; | 298 | } |
| 299 | 299 | }; | |
| 300 | $scope.abrirModalListaPrecio = function() { | 300 | |
| 301 | var modalInstance = $uibModal.open( | 301 | $scope.abrirModalListaPrecio = function() { |
| 302 | { | 302 | var modalInstance = $uibModal.open( |
| 303 | ariaLabelledBy: 'Busqueda de Precio Condición', | 303 | { |
| 304 | templateUrl: 'modal-precio-condicion.html', | 304 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 305 | controller: 'focaModalPrecioCondicionController', | 305 | templateUrl: 'modal-precio-condicion.html', |
| 306 | controller: 'focaModalPrecioCondicionController', | ||
| 307 | size: 'lg' | ||
| 308 | } | ||
| 309 | ); | ||
| 310 | modalInstance.result.then( | ||
| 311 | function(precioCondicion) { | ||
| 312 | var cabecera = ''; | ||
| 313 | var plazosConcat = ''; | ||
| 314 | if(!Array.isArray(precioCondicion)) { | ||
| 315 | $scope.plazosPagos = precioCondicion.plazoPago; | ||
| 316 | idLista = precioCondicion.idListaPrecio; | ||
| 317 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | ||
| 318 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | ||
| 319 | } | ||
| 320 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | ||
| 306 | size: 'lg' | 321 | } else { //Cuando se ingresan los plazos manualmente |
| 307 | } | 322 | idLista = -1; //-1, el modal productos busca todos los productos |
| 308 | ); | ||
| 309 | modalInstance.result.then( | 323 | $scope.plazosPagos = precioCondicion; |
| 310 | function(precioCondicion) { | 324 | for(var j = 0; j < precioCondicion.length; j++) { |
| 311 | var cabecera = ''; | 325 | plazosConcat += precioCondicion[j].dias + ' '; |
| 312 | var plazosConcat = ''; | 326 | } |
| 313 | if(!Array.isArray(precioCondicion)) { | 327 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
| 314 | $scope.plazosPagos = precioCondicion.plazoPago; | 328 | } |
| 315 | idLista = precioCondicion.idListaPrecio; | 329 | $scope.articulosTabla = []; |
| 316 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 330 | addCabecera('Precios y condiciones:', cabecera); |
| 317 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 331 | }, function() { |
| 318 | } | 332 | |
| 319 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 333 | } |
| 320 | } else { //Cuando se ingresan los plazos manualmente | 334 | ); |
| 321 | idLista = -1; //-1, el modal productos busca todos los productos | 335 | }; |
| 322 | $scope.plazosPagos = precioCondicion; | 336 | |
| 323 | for(var j = 0; j < precioCondicion.length; j++) { | 337 | $scope.abrirModalFlete = function() { |
| 324 | plazosConcat += precioCondicion[j].dias + ' '; | 338 | var modalInstance = $uibModal.open( |
| 325 | } | 339 | { |
| 326 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 340 | ariaLabelledBy: 'Busqueda de Flete', |
| 327 | } | 341 | templateUrl: 'modal-flete.html', |
| 328 | $scope.articulosTabla = []; | 342 | controller: 'focaModalFleteController', |
| 329 | addCabecera('Precios y condiciones:', cabecera); | 343 | size: 'lg', |
| 330 | }, function() { | 344 | resolve: { |
| 331 | 345 | parametrosFlete: | |
| 332 | } | 346 | function() { |
| 333 | ); | 347 | return { |
| 334 | }; | 348 | flete: $scope.notaPedido.flete, |
| 335 | 349 | bomba: $scope.notaPedido.bomba, | |
| 336 | $scope.abrirModalFlete = function() { | 350 | kilometros: $scope.notaPedido.kilometros |
| 337 | var modalInstance = $uibModal.open( | 351 | }; |
| 338 | { | 352 | } |
| 339 | ariaLabelledBy: 'Busqueda de Flete', | 353 | } |
| 340 | templateUrl: 'modal-flete.html', | 354 | } |
| 341 | controller: 'focaModalFleteController', | 355 | ); |
| 342 | size: 'lg', | 356 | modalInstance.result.then( |
| 343 | resolve: { | 357 | function(datos) { |
| 344 | parametrosFlete: | 358 | $scope.notaPedido.flete = datos.flete; |
| 345 | function() { | 359 | $scope.notaPedido.bomba = datos.bomba; |
| 346 | return { | 360 | $scope.notaPedido.kilometros = datos.kilometros; |
| 347 | flete: $scope.notaPedido.flete, | 361 | |
| 348 | bomba: $scope.notaPedido.bomba, | 362 | addCabecera('Flete:', datos.flete); |
| 349 | kilometros: $scope.notaPedido.kilometros | 363 | if(datos.flete === 'si') { |
| 350 | }; | 364 | addCabecera('Bomba:', datos.bomba); |
| 351 | } | 365 | addCabecera('Kilometros:', datos.kilometros); |
| 352 | } | 366 | } else { |
| 353 | } | 367 | removeCabecera('Bomba:'); |
| 354 | ); | 368 | removeCabecera('Kilometros:'); |
| 355 | modalInstance.result.then( | 369 | } |
| 356 | function(datos) { | 370 | }, function() { |
| 357 | $scope.notaPedido.flete = datos.flete; | 371 | |
| 358 | $scope.notaPedido.bomba = datos.bomba; | 372 | } |
| 359 | $scope.notaPedido.kilometros = datos.kilometros; | 373 | ); |
| 360 | 374 | }; | |
| 361 | addCabecera('Flete:', datos.flete); | 375 | |
| 362 | if(datos.flete === 'si') { | 376 | $scope.abrirModalMoneda = function() { |
| 363 | addCabecera('Bomba:', datos.bomba); | 377 | var modalInstance = $uibModal.open( |
| 364 | addCabecera('Kilometros:', datos.kilometros); | 378 | { |
| 365 | } else { | 379 | ariaLabelledBy: 'Busqueda de Moneda', |
| 366 | removeCabecera('Bomba:'); | 380 | templateUrl: 'modal-moneda.html', |
| 367 | removeCabecera('Kilometros:'); | 381 | controller: 'focaModalMonedaController', |
| 368 | } | 382 | size: 'lg' |
| 369 | }, function() { | 383 | } |
| 370 | 384 | ); | |
| 371 | } | 385 | modalInstance.result.then( |
| 372 | ); | 386 | function(moneda) { |
| 373 | }; | 387 | $scope.notaPedido.moneda = { |
| 374 | 388 | id: moneda.ID, | |
| 375 | $scope.abrirModalMoneda = function() { | 389 | detalle: moneda.DETALLE, |
| 376 | var modalInstance = $uibModal.open( | 390 | simbolo: moneda.SIMBOLO |
| 377 | { | 391 | }; |
| 378 | ariaLabelledBy: 'Busqueda de Moneda', | 392 | |
| 379 | templateUrl: 'modal-moneda.html', | 393 | addCabecera('Moneda:', moneda.DETALLE); |
| 380 | controller: 'focaModalMonedaController', | 394 | }, function() { |
| 381 | size: 'lg' | 395 | |
| 382 | } | 396 | } |
| 383 | ); | 397 | ); |
| 384 | modalInstance.result.then( | 398 | }; |
| 385 | function(moneda) { | 399 | |
| 386 | $scope.notaPedido.moneda = { | 400 | $scope.agregarATabla = function(key) { |
| 387 | id: moneda.ID, | 401 | if(key === 13) { |
| 388 | detalle: moneda.DETALLE, | 402 | if($scope.articuloACargar.cantidad === undefined || |
| 389 | simbolo: moneda.SIMBOLO | 403 | $scope.articuloACargar.cantidad === 0 || |
| 390 | }; | 404 | $scope.articuloACargar.cantidad === null ){ |
| 391 | 405 | focaModalService.alert('El valor debe ser al menos 1'); | |
| 392 | addCabecera('Moneda:', moneda.DETALLE); | 406 | return; |
| 393 | }, function() { | 407 | } |
| 394 | 408 | delete $scope.articuloACargar.sectorCodigo; | |
| 395 | } | 409 | $scope.articulosTabla.push($scope.articuloACargar); |
| 396 | ); | 410 | $scope.cargando = true; |
| 397 | }; | 411 | } |
| 398 | 412 | }; | |
| 399 | $scope.agregarATabla = function(key) { | 413 | |
| 400 | if(key === 13) { | 414 | $scope.quitarArticulo = function(key) { |
| 401 | if($scope.articuloACargar.cantidad === undefined || | 415 | $scope.articulosTabla.splice(key, 1); |
| 402 | $scope.articuloACargar.cantidad === 0 || | 416 | }; |
| 403 | $scope.articuloACargar.cantidad === null ){ | 417 | |
| 404 | focaModalService.alert('El valor debe ser al menos 1'); | 418 | $scope.editarArticulo = function(key, articulo) { |
| 405 | return; | 419 | if(key === 13) { |
| 406 | } | 420 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
| 407 | delete $scope.articuloACargar.sectorCodigo; | 421 | articulo.cantidad === undefined){ |
| 408 | $scope.articulosTabla.push($scope.articuloACargar); | 422 | focaModalService.alert('El valor debe ser al menos 1'); |
| 409 | $scope.cargando = true; | 423 | return; |
| 410 | } | 424 | } |
| 411 | }; | 425 | articulo.edit = false; |
| 412 | 426 | } | |
| 413 | $scope.quitarArticulo = function(key) { | 427 | }; |
| 414 | $scope.articulosTabla.splice(key, 1); | 428 | |
| 415 | }; | 429 | $scope.cambioEdit = function(articulo) { |
| 416 | 430 | articulo.edit = true; | |
| 417 | $scope.editarArticulo = function(key, articulo) { | 431 | }; |
| 418 | if(key === 13) { | 432 | |
| 419 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 433 | $scope.limpiarFlete = function() { |
| 420 | articulo.cantidad === undefined){ | 434 | $scope.notaPedido.fleteNombre = ''; |
| 421 | focaModalService.alert('El valor debe ser al menos 1'); | 435 | $scope.notaPedido.chofer = ''; |
| 422 | return; | 436 | $scope.notaPedido.vehiculo = ''; |
| 423 | } | 437 | $scope.notaPedido.kilometros = ''; |
| 424 | articulo.edit = false; | 438 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
| 425 | } | 439 | $scope.choferes = ''; |
| 426 | }; | 440 | $scope.vehiculos = ''; |
| 427 | 441 | }; | |
| 428 | $scope.cambioEdit = function(articulo) { | 442 | |
| 429 | articulo.edit = true; | 443 | $scope.limpiarPantalla = function() { |
| 430 | }; | 444 | $scope.limpiarFlete(); |
| 431 | 445 | $scope.notaPedido.flete = '0'; | |
| 432 | $scope.limpiarFlete = function() { | 446 | $scope.notaPedido.bomba = '0'; |
| 433 | $scope.notaPedido.fleteNombre = ''; | 447 | $scope.notaPedido.precioCondicion = ''; |
| 434 | $scope.notaPedido.chofer = ''; | 448 | $scope.articulosTabla = []; |
| 435 | $scope.notaPedido.vehiculo = ''; | 449 | $scope.notaPedido.vendedor.nombre = ''; |
| 436 | $scope.notaPedido.kilometros = ''; | 450 | $scope.notaPedido.cliente = {nombre: ''}; |
| 437 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 451 | $scope.notaPedido.domicilio = {dom: ''}; |
| 438 | $scope.choferes = ''; | 452 | $scope.domiciliosCliente = []; |
| 439 | $scope.vehiculos = ''; | 453 | }; |
| 440 | }; | 454 | |
| 441 | 455 | $scope.resetFilter = function() { | |
| 442 | $scope.limpiarPantalla = function() { | 456 | $scope.articuloACargar = {}; |
| 443 | $scope.limpiarFlete(); | 457 | $scope.cargando = true; |
| 444 | $scope.notaPedido.flete = '0'; | 458 | }; |
| 445 | $scope.notaPedido.bomba = '0'; | 459 | |
| 446 | $scope.notaPedido.precioCondicion = ''; | 460 | $scope.selectFocus = function($event) { |
| 447 | $scope.articulosTabla = []; | 461 | $event.target.select(); |
| 448 | $scope.notaPedido.vendedor.nombre = ''; | 462 | }; |
| 449 | $scope.notaPedido.cliente = {nombre: ''}; | 463 | |
| 450 | $scope.notaPedido.domicilio = {dom: ''}; | 464 | $scope.salir = function() { |
| 451 | $scope.domiciliosCliente = []; | 465 | $location.path('/'); |
| 452 | }; | 466 | }; |
| 453 | 467 | ||
| 454 | $scope.resetFilter = function() { | 468 | function addCabecera(label, valor) { |
| 455 | $scope.articuloACargar = {}; | 469 | var propiedad = $filter('filter')($scope.cabecera, {label: label}); |
| 456 | $scope.cargando = true; | 470 | if(propiedad.length === 1) { |
| 457 | }; | 471 | propiedad[0].valor = valor; |
| 458 | 472 | } else { | |
| 459 | $scope.selectFocus = function($event) { | 473 | $scope.cabecera.push({label: label, valor: valor}); |
| 460 | $event.target.select(); | 474 | } |
| 461 | }; | 475 | } |
| 462 | 476 | ||
| 463 | $scope.salir = function() { | 477 | function removeCabecera(label) { |
| 464 | $location.path('/'); | 478 | var propiedad = $filter('filter')($scope.cabecera, {label: label}); |
| 465 | }; | 479 | if(propiedad.length === 1){ |
| 466 | 480 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | |
| 467 | function addCabecera(label, valor) { | 481 | } |
| 468 | var propiedad = $filter('filter')($scope.cabecera, {label: label}); | 482 | } |
| 469 | if(propiedad.length === 1) { | 483 | } |
| 470 | propiedad[0].valor = valor; | 484 | ] |
| 471 | } else { | 485 | ) |
| 472 | $scope.cabecera.push({label: label, valor: valor}); | 486 | .controller('notaPedidoListaCtrl', [ |
| 473 | } | 487 | '$scope', |
| 474 | } | 488 | 'crearNotaPedidoService', |
| 475 | 489 | '$location', | |
| 476 | function removeCabecera(label) { | 490 | function($scope, crearNotaPedidoService, $location) { |
| 477 | var propiedad = $filter('filter')($scope.cabecera, {label: label}); | 491 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
| 478 | if(propiedad.length === 1){ | 492 | $scope.notaPedidos = datos.data; |
| 479 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 493 | }); |
| 480 | } | 494 | $scope.editar = function(notaPedido) { |
| 481 | } | 495 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 482 | } | 496 | $location.path('/venta-nota-pedido/abm/'); |
| 483 | ] | 497 | }; |
| 484 | ) | 498 | $scope.crearPedido = function() { |
| 485 | .controller('notaPedidoListaCtrl', [ | 499 | crearNotaPedidoService.clearNotaPedido(); |
| 486 | '$scope', | 500 | $location.path('/venta-nota-pedido/abm/'); |
| 487 | 'crearNotaPedidoService', | 501 | }; |
| 488 | '$location', | 502 | } |
| 489 | function($scope, crearNotaPedidoService, $location) { | 503 | ]) |
| 490 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 504 | .controller('focaCrearNotaPedidoFichaClienteController', [ |
| 491 | $scope.notaPedidos = datos.data; | 505 | '$scope', |
| 492 | }); | 506 | 'crearNotaPedidoService', |
| 493 | $scope.editar = function(notaPedido) { | 507 | '$location', |
| 494 | crearNotaPedidoService.setNotaPedido(notaPedido); | 508 | function($scope, crearNotaPedidoService, $location) { |
| 495 | $location.path('/venta-nota-pedido/abm/'); | 509 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
| 496 | }; | 510 | $scope.notaPedidos = datos.data; |
| 497 | $scope.crearPedido = function() { | 511 | }); |
| 498 | crearNotaPedidoService.clearNotaPedido(); | 512 | $scope.editar = function(notaPedido) { |
| 499 | $location.path('/venta-nota-pedido/abm/'); | 513 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 500 | }; | 514 | $location.path('/venta-nota-pedido/abm/'); |
| 501 | } | 515 | }; |
| 502 | ]) | 516 | $scope.crearPedido = function() { |
| 503 | .controller('focaCrearNotaPedidoFichaClienteController', [ | 517 | crearNotaPedidoService.clearNotaPedido(); |
| 504 | '$scope', | 518 | $location.path('/venta-nota-pedido/abm/'); |
| 505 | 'crearNotaPedidoService', | 519 | }; |
| 506 | '$location', | 520 | } |
src/views/nota-pedido.html
| 1 | <div class="crear-nota-pedido"> | 1 | <div class="crear-nota-pedido"> |
| 2 | <form name="formCrearNota" ng-submit="crearNotaPedido()"> | 2 | <form name="formCrearNota" ng-submit="crearNotaPedido()" class="mb-0"> |
| 3 | <div class="row"> | 3 | <div class="row"> |
| 4 | <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2"> | 4 | <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2"> |
| 5 | <div class="row p-1 panel-informativo"> | 5 | <div class="row p-1 panel-informativo"> |
| 6 | <div class="col-12"> | 6 | <div class="col-12"> |
| 7 | <div class="row"> | 7 | <div class="row"> |
| 8 | <div class="col-12 col-sm-4 nota-pedido"> | 8 | <div class="col-12 col-sm-4 nota-pedido"> |
| 9 | <h5>NOTA DE PEDIDO</h5> | 9 | <h5>NOTA DE PEDIDO</h5> |
| 10 | </div> | 10 | </div> |
| 11 | <div class="col-6 col-sm-4 numero-pedido">Nº {{puntoVenta}}-{{comprobante}}</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"> | 12 | <div class="col-6 col-sm-4 text-right crear-nota-pedido-fecha"> |
| 13 | Fecha: {{ now | date:'dd/MM/yyyy HH:mm'}} | 13 | Fecha: |
| 14 | <span | ||
| 15 | ng-show="!datepickerAbierto" | ||
| 16 | ng-bind="now | date:'dd/MM/yyyy HH:mm'" | ||
| 17 | ng-click="datepickerAbierto = true" | ||
| 18 | > | ||
| 19 | </span> | ||
| 20 | <input | ||
| 21 | ng-show="datepickerAbierto" | ||
| 22 | type="date" | ||
| 23 | ng-model="now" | ||
| 24 | ng-change="datepickerAbierto = false" | ||
| 25 | ng-blur="datepickerAbierto = false" | ||
| 26 | class="form-control form-control-sm col-8 float-right" | ||
| 27 | foca-focus="datepickerAbierto" | ||
| 28 | /> | ||
| 14 | </div> | 29 | </div> |
| 15 | </div> | 30 | </div> |
| 16 | <div class="row"> | 31 | <div class="row"> |
| 17 | <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> | 32 | <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> |
| 18 | <span class="label" ng-bind="cab.label"></span> | 33 | <span class="label" ng-bind="cab.label"></span> |
| 19 | <span class="valor" ng-bind="cab.valor"></span> | 34 | <span class="valor" ng-bind="cab.valor"></span> |
| 20 | </div> | 35 | </div> |
| 21 | <a | 36 | <a |
| 22 | class="btn col-12 btn-secondary d-sm-none" | 37 | class="btn col-12 btn-secondary d-sm-none" |
| 23 | ng-show="cabecera.length > 0" | 38 | ng-show="cabecera.length > 0" |
| 24 | ng-click="showCabecera = !showCabecera" | 39 | ng-click="showCabecera = !showCabecera" |
| 25 | > | 40 | > |
| 26 | <i | 41 | <i |
| 27 | class="fa fa-chevron-down" | 42 | class="fa fa-chevron-down" |
| 28 | ng-hide="showCabecera" | 43 | ng-hide="showCabecera" |
| 29 | aria-hidden="true" | 44 | aria-hidden="true" |
| 30 | > | 45 | > |
| 31 | </i> | 46 | </i> |
| 32 | <i | 47 | <i |
| 33 | class="fa fa-chevron-up" | 48 | class="fa fa-chevron-up" |
| 34 | ng-show="showCabecera" | 49 | ng-show="showCabecera" |
| 35 | aria-hidden="true"> | 50 | aria-hidden="true"> |
| 36 | </i> | 51 | </i> |
| 37 | </a> | 52 | </a> |
| 38 | </div> | 53 | </div> |
| 39 | </div> | 54 | </div> |
| 40 | </div> | 55 | </div> |
| 41 | <div class="row p-1 botonera-secundaria"> | 56 | <div class="row p-1 botonera-secundaria"> |
| 42 | <div class="col-12"> | 57 | <div class="col-12"> |
| 43 | <div class="row"> | 58 | <div class="row"> |
| 44 | <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera"> | 59 | <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera"> |
| 45 | <button | 60 | <button |
| 46 | type="button" | 61 | type="button" |
| 47 | class="btn btn-default btn-block btn-xs text-left py-2" | 62 | class="btn btn-default btn-block btn-xs text-left py-2" |
| 48 | ng-click="boton.accion()" | 63 | ng-click="boton.accion()" |
| 49 | ng-class="{'d-none d-sm-block': boton.texto == ''}" | 64 | ng-class="{'d-none d-sm-block': boton.texto == ''}" |
| 50 | > | 65 | > |
| 51 | <i | 66 | <i |
| 52 | class="fa fa-arrow-circle-right" | 67 | class="fa fa-arrow-circle-right" |
| 53 | ng-show="boton.texto != ''" | 68 | ng-show="boton.texto != ''" |
| 54 | ></i> | 69 | ></i> |
| 55 | | 70 | |
| 56 | {{boton.texto}} | 71 | {{boton.texto}} |
| 57 | </button> | 72 | </button> |
| 58 | </div> | 73 | </div> |
| 59 | </div> | 74 | </div> |
| 60 | </div> | 75 | </div> |
| 61 | </div> | 76 | </div> |
| 62 | </div> | 77 | </div> |
| 63 | </div> | 78 | </div> |
| 64 | </form> | 79 | </form> |
| 65 | <div class="row"> | 80 | <div class="row"> |
| 66 | <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> | 81 | <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> |
| 67 | <!-- PC --> | 82 | <!-- PC --> |
| 68 | <div class="row grilla-articulo align-items-end"> | 83 | <div class="row grilla-articulo align-items-end"> |
| 69 | <table class="table tabla-articulo table-striped table-sm table-dark"> | 84 | <table class="table tabla-articulo table-striped table-sm table-dark mb-0"> |
| 70 | <thead> | 85 | <thead> |
| 71 | <tr class="d-flex"> | 86 | <tr class="d-flex"> |
| 72 | <th class="">#</th> | 87 | <th class="">#</th> |
| 73 | <th class="col">Código</th> | 88 | <th class="col">Código</th> |
| 74 | <th class="col-4">Descripción</th> | 89 | <th class="col-4">Descripción</th> |
| 75 | <th class="col text-right">Cantidad</th> | 90 | <th class="col text-right">Cantidad</th> |
| 76 | <th class="col text-right">Precio Unitario</th> | 91 | <th class="col text-right">Precio Unitario</th> |
| 77 | <th class="col text-right">SubTotal</th> | 92 | <th class="col text-right">SubTotal</th> |
| 78 | <th class="text-right"> | 93 | <th class="text-right"> |
| 79 | <button | 94 | <button |
| 80 | class="btn btn-outline-secondary selectable" | 95 | class="btn btn-outline-secondary selectable" |
| 81 | ng-click="show = !show; masMenos()" | 96 | ng-click="show = !show; masMenos()" |
| 82 | > | 97 | > |
| 83 | <i | 98 | <i |
| 84 | class="fa fa-chevron-down" | 99 | class="fa fa-chevron-down" |
| 85 | ng-show="show" | 100 | ng-show="show" |
| 86 | aria-hidden="true" | 101 | aria-hidden="true" |
| 87 | > | 102 | > |
| 88 | </i> | 103 | </i> |
| 89 | <i | 104 | <i |
| 90 | class="fa fa-chevron-up" | 105 | class="fa fa-chevron-up" |
| 91 | ng-hide="show" | 106 | ng-hide="show" |
| 92 | aria-hidden="true"> | 107 | aria-hidden="true"> |
| 93 | </i> | 108 | </i> |
| 94 | </button> | 109 | </button> |
| 95 | </th> | 110 | </th> |
| 96 | </tr> | 111 | </tr> |
| 97 | </thead> | 112 | </thead> |
| 98 | <tbody class="tabla-articulo-body"> | 113 | <tbody class="tabla-articulo-body"> |
| 99 | <tr | 114 | <tr |
| 100 | ng-repeat="(key, articulo) in articulosTabla" | 115 | ng-repeat="(key, articulo) in articulosTabla" |
| 101 | ng-show="show || key == (articulosTabla.length - 1)" | 116 | ng-show="show || key == (articulosTabla.length - 1)" |
| 102 | class="d-flex" | 117 | class="d-flex" |
| 103 | > | 118 | > |
| 104 | <td ng-bind="key + 1"></td> | 119 | <td ng-bind="key + 1"></td> |
| 105 | <td | 120 | <td |
| 106 | class="col" | 121 | class="col" |
| 107 | ng-bind="articulo.sector + '-' + articulo.codigo" | 122 | ng-bind="articulo.sector + '-' + articulo.codigo" |
| 108 | ></td> | 123 | ></td> |
| 109 | <td | 124 | <td |
| 110 | class="col-4" | 125 | class="col-4" |
| 111 | ng-bind="articulo.descripcion" | 126 | ng-bind="articulo.descripcion" |
| 112 | ></td> | 127 | ></td> |
| 113 | <td class="col text-right"> | 128 | <td class="col text-right"> |
| 114 | <input | 129 | <input |
| 115 | ng-show="articulo.edit" | 130 | ng-show="articulo.edit" |
| 116 | ng-model="articulo.cantidad" | 131 | ng-model="articulo.cantidad" |
| 117 | class="form-control" | 132 | class="form-control" |
| 118 | type="number" | 133 | type="number" |
| 119 | min="1" | 134 | min="1" |
| 120 | foca-focus="articulo.edit" | 135 | foca-focus="articulo.edit" |
| 121 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 136 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
| 122 | ng-focus="selectFocus($event)" | 137 | ng-focus="selectFocus($event)" |
| 123 | > | 138 | > |
| 124 | <i | 139 | <i |
| 125 | class="selectable" | 140 | class="selectable" |
| 126 | ng-click="cambioEdit(articulo)" | 141 | ng-click="cambioEdit(articulo)" |
| 127 | ng-hide="articulo.edit" | 142 | ng-hide="articulo.edit" |
| 128 | ng-bind="articulo.cantidad"> | 143 | ng-bind="articulo.cantidad"> |
| 129 | </i> | 144 | </i> |
| 130 | </td> | 145 | </td> |
| 131 | <td | 146 | <td |
| 132 | class="col text-right" | 147 | class="col text-right" |
| 133 | ng-bind="articulo.precio | currency: '$'" | 148 | ng-bind="articulo.precio | currency: '$'" |
| 134 | ></td> | 149 | ></td> |
| 135 | <td | 150 | <td |
| 136 | class="col text-right" | 151 | class="col text-right" |
| 137 | ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'"> | 152 | ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'"> |
| 138 | </td> | 153 | </td> |
| 139 | <td class="text-center"> | 154 | <td class="text-center"> |
| 140 | <button | 155 | <button |
| 141 | class="btn btn-outline-secondary" | 156 | class="btn btn-outline-secondary" |
| 142 | ng-click="quitarArticulo(key)" | 157 | ng-click="quitarArticulo(key)" |
| 143 | > | 158 | > |
| 144 | <i class="fa fa-trash"></i> | 159 | <i class="fa fa-trash"></i> |
| 145 | </button> | 160 | </button> |
| 146 | </td> | 161 | </td> |
| 147 | </tr> | 162 | </tr> |
| 148 | </tbody> | 163 | </tbody> |
| 149 | <tfoot> | 164 | <tfoot> |
| 150 | <tr ng-show="!cargando" class="d-flex"> | 165 | <tr ng-show="!cargando" class="d-flex"> |
| 151 | <td | 166 | <td |
| 152 | class="align-middle" | 167 | class="align-middle" |
| 153 | ng-bind="articulosTabla.length + 1" | 168 | ng-bind="articulosTabla.length + 1" |
| 154 | ></td> | 169 | ></td> |
| 155 | <td class="col"> | 170 | <td class="col"> |
| 156 | <input | 171 | <input |
| 157 | class="form-control" | 172 | class="form-control" |
| 158 | ng-model="articuloACargar.sectorCodigo" | 173 | ng-model="articuloACargar.sectorCodigo" |
| 159 | readonly | 174 | readonly |
| 160 | > | 175 | > |
| 161 | </td> | 176 | </td> |
| 162 | <td class="col-4 tabla-articulo-descripcion"> | 177 | <td class="col-4 tabla-articulo-descripcion"> |
| 163 | <input | 178 | <input |
| 164 | class="form-control" | 179 | class="form-control" |
| 165 | ng-model="articuloACargar.descripcion" | 180 | ng-model="articuloACargar.descripcion" |
| 166 | readonly | 181 | readonly |
| 167 | > | 182 | > |
| 168 | </td> | 183 | </td> |
| 169 | <td class="col text-right"> | 184 | <td class="col text-right"> |
| 170 | <input | 185 | <input |
| 171 | class="form-control" | 186 | class="form-control" |
| 172 | type="number" | 187 | type="number" |
| 173 | min="1" | 188 | min="1" |
| 174 | ng-model="articuloACargar.cantidad" | 189 | ng-model="articuloACargar.cantidad" |
| 175 | foca-focus="!cargando" | 190 | foca-focus="!cargando" |
| 176 | esc-key="resetFilter()" | 191 | esc-key="resetFilter()" |
| 177 | ng-keypress="agregarATabla($event.keyCode)" | 192 | ng-keypress="agregarATabla($event.keyCode)" |
| 178 | > | 193 | > |
| 179 | </td> | 194 | </td> |
| 180 | <td class="col text-right"> | 195 | <td class="col text-right"> |
| 181 | <input | 196 | <input |
| 182 | class="form-control" | 197 | class="form-control" |
| 183 | ng-value="articuloACargar.precio | currency: '$'" | 198 | ng-value="articuloACargar.precio | currency: '$'" |
| 184 | readonly | 199 | readonly |
| 185 | > | 200 | > |
| 186 | </td> | 201 | </td> |
| 187 | <td class="col text-right"> | 202 | <td class="col text-right"> |
| 188 | <input | 203 | <input |
| 189 | class="form-control" | 204 | class="form-control" |
| 190 | ng-value="getSubTotal() | currency: '$'" | 205 | ng-value="getSubTotal() | currency: '$'" |
| 191 | readonly | 206 | readonly |
| 192 | ></td> | 207 | ></td> |
| 193 | <td class="text-center align-middle"> | 208 | <td class="text-center align-middle"> |
| 194 | <button | 209 | <button |
| 195 | class="btn btn-outline-secondary" | 210 | class="btn btn-outline-secondary" |
| 196 | ng-click="agregarATabla(13)" | 211 | ng-click="agregarATabla(13)" |
| 197 | > | 212 | > |
| 198 | <i class="fa fa-save"></i> | 213 | <i class="fa fa-save"></i> |
| 199 | </button> | 214 | </button> |
| 200 | </td> | 215 | </td> |
| 201 | </tr> | 216 | </tr> |
| 202 | <tr ng-show="cargando" class="d-flex"> | 217 | <tr ng-show="cargando" class="d-flex"> |
| 203 | <td colspan="7" class="col-12"> | 218 | <td colspan="7" class="col-12"> |
| 204 | <input | 219 | <input |
| 205 | placeholder="Seleccione Articulo" | 220 | placeholder="Seleccione Articulo" |
| 206 | class="form-control form-control-sm" | 221 | class="form-control form-control-sm" |
| 207 | readonly | 222 | readonly |
| 208 | ng-click="seleccionarArticulo()" | 223 | ng-click="seleccionarArticulo()" |
| 209 | /> | 224 | /> |
| 210 | </td> | 225 | </td> |
| 211 | </tr> | 226 | </tr> |
| 212 | <tr class="d-flex"> | 227 | <tr class="d-flex"> |
| 213 | <td colspan="4"> | 228 | <td colspan="4"> |
| 214 | <strong>Cantidad Items:</strong> | 229 | <strong>Cantidad Items:</strong> |
| 215 | <a ng-bind="articulosTabla.length"></a> | 230 | <a ng-bind="articulosTabla.length"></a> |
| 216 | </td> | 231 | </td> |
| 217 | <td class="text-right ml-auto table-celda-total"><h3>Total:</h3></td> | 232 | <td class="text-right ml-auto table-celda-total"><h3>Total:</h3></td> |
| 218 | <td class="table-celda-total text-right" colspan="1"> | 233 | <td class="table-celda-total text-right" colspan="1"> |
| 219 | <h3>{{getTotal() | currency: '$'}}</h3> | 234 | <h3>{{getTotal() | currency: '$'}}</h3> |
| 220 | </td> | 235 | </td> |
| 221 | <td class="text-right"> | 236 | <td class="text-right"> |
| 222 | <button | 237 | <button |
| 223 | type="button" | 238 | type="button" |
| 224 | class="btn btn-default btn-sm" | 239 | class="btn btn-default btn-sm" |
| 225 | > | 240 | > |
| 226 | Totales | 241 | Totales |
| 227 | </button> | 242 | </button> |
| 228 | </td> | 243 | </td> |
| 229 | </tr> | 244 | </tr> |
| 230 | </tfoot> | 245 | </tfoot> |
| 231 | </table> | 246 | </table> |
| 232 | </div> | 247 | </div> |
| 233 | </div> | 248 | </div> |
| 234 | <div class="col-auto my-2 col-lg-2 botonera-lateral"> | 249 | <div class="col-auto my-2 col-lg-2 botonera-lateral"> |
| 235 | <div class="row align-items-end"> | 250 | <div class="row align-items-end"> |
| 236 | <div class="col-12"> | 251 | <div class="col-12"> |
| 237 | <button | 252 | <button |
| 238 | ng-click="crearNotaPedido()" | 253 | ng-click="crearNotaPedido()" |
| 239 | type="submit" | 254 | type="submit" |
| 240 | title="Crear nota pedido" | 255 | title="Crear nota pedido" |
| 241 | class="btn btn-default btn-block mb-2"> | 256 | class="btn btn-default btn-block mb-2"> |
| 242 | Guardar | 257 | Guardar |
| 243 | </button> | 258 | </button> |
| 244 | <button | 259 | <button |
| 245 | ng-click="salir()" | 260 | ng-click="salir()" |
| 246 | type="button" | 261 | type="button" |
| 247 | title="Salir" | 262 | title="Salir" |
| 248 | class="btn btn-default btn-block"> | 263 | class="btn btn-default btn-block"> |
| 249 | Salir | 264 | Salir |
| 250 | </button> | 265 | </button> |
| 251 | </div> | 266 | </div> |
| 252 | </div> | 267 | </div> |
| 253 | </div> | 268 | </div> |
| 254 | </div> | 269 | </div> |
| 255 | </div> | 270 | </div> |
| 256 | 271 |