Commit 6ee7bd2ecb1ff4826b6d658b4f152cd2ec838591
Exists in
master
and in
1 other branch
Merge branch 'develop' into 'master'
Develop See merge request !98
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 | "refresh": "gulp uglify && cp tmp/foca-crear-nota-pedido.js ../wrapper-demo/node_modules/foca-crear-nota-pedido/dist/foca-crear-nota-pedido.min.js", | ||
| 7 | "test": "test.html", | 8 | "test": "test.html", |
| 8 | "compile": "gulp uglify", | 9 | "compile": "gulp uglify", |
| 9 | "gulp-pre-commit": "gulp pre-commit", | 10 | "gulp-pre-commit": "gulp pre-commit", |
| 10 | "postinstall": "npm run compile && gulp clean-post-install", | 11 | "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+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-vendedores.git git+http://git.focasoftware.com/npm/foca-modal-proveedor.git git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git git+http://git.focasoftware.com/npm/foca-modal-flete.git git+http://git.focasoftware.com/npm/foca-modal.git git+http://git.focasoftware.com/npm/foca-modal-domicilio.git git+http://git.focasoftware.com/npm/foca-seguimiento.git git+http://git.focasoftware.com/npm/foca-modal-moneda.git git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git" | 12 | "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+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-vendedores.git git+http://git.focasoftware.com/npm/foca-modal-proveedor.git git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git git+http://git.focasoftware.com/npm/foca-modal-flete.git git+http://git.focasoftware.com/npm/foca-modal.git git+http://git.focasoftware.com/npm/foca-modal-domicilio.git git+http://git.focasoftware.com/npm/foca-seguimiento.git git+http://git.focasoftware.com/npm/foca-modal-moneda.git git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git" |
| 12 | }, | 13 | }, |
| 13 | "pre-commit": [ | 14 | "pre-commit": [ |
| 14 | "gulp-pre-commit" | 15 | "gulp-pre-commit" |
| 15 | ], | 16 | ], |
| 16 | "repository": { | 17 | "repository": { |
| 17 | "type": "git", | 18 | "type": "git", |
| 18 | "url": "https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido.git" | 19 | "url": "https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido.git" |
| 19 | }, | 20 | }, |
| 20 | "author": "Foca Software", | 21 | "author": "Foca Software", |
| 21 | "license": "ISC", | 22 | "license": "ISC", |
| 22 | "peerDependencies": { | 23 | "peerDependencies": { |
| 23 | "foca-botonera-facturador": "git+http://git.focasoftware.com/npm/foca-botonera-facturador.git", | 24 | "foca-botonera-facturador": "git+http://git.focasoftware.com/npm/foca-botonera-facturador.git", |
| 24 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", | 25 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", |
| 25 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | 26 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
| 26 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", | 27 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", |
| 27 | "foca-modal-busqueda-productos": "git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git", | 28 | "foca-modal-busqueda-productos": "git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git", |
| 28 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", | 29 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", |
| 29 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", | 30 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", |
| 30 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", | 31 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", |
| 31 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", | 32 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", |
| 32 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git" | 33 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git" |
| 33 | }, | 34 | }, |
| 34 | "devDependencies": { | 35 | "devDependencies": { |
| 35 | "angular": "^1.7.5", | 36 | "angular": "^1.7.5", |
| 36 | "angular-ladda": "^0.4.3", | 37 | "angular-ladda": "^0.4.3", |
| 37 | "angular-mocks": "^1.7.7", | 38 | "angular-mocks": "^1.7.7", |
| 38 | "angular-route": "^1.7.5", | 39 | "angular-route": "^1.7.5", |
| 39 | "bootstrap": "^4.1.3", | 40 | "bootstrap": "^4.1.3", |
| 40 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", | 41 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", |
| 41 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | 42 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
| 42 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", | 43 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", |
| 43 | "foca-modal-busqueda-productos": "git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git", | 44 | "foca-modal-busqueda-productos": "git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git", |
| 44 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", | 45 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", |
| 45 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", | 46 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", |
| 46 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", | 47 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", |
| 47 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", | 48 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", |
| 48 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git", | 49 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git", |
| 49 | "font-awesome": "^4.7.0", | 50 | "font-awesome": "^4.7.0", |
| 50 | "gulp": "^3.9.1", | 51 | "gulp": "^3.9.1", |
| 51 | "gulp-angular-templatecache": "^2.2.5", | 52 | "gulp-angular-templatecache": "^2.2.5", |
| 52 | "gulp-clean": "^0.4.0", | 53 | "gulp-clean": "^0.4.0", |
| 53 | "gulp-concat": "^2.6.1", | 54 | "gulp-concat": "^2.6.1", |
| 54 | "gulp-connect": "^5.6.1", | 55 | "gulp-connect": "^5.6.1", |
| 55 | "gulp-htmlmin": "^5.0.1", | 56 | "gulp-htmlmin": "^5.0.1", |
| 56 | "gulp-jshint": "^2.1.0", | 57 | "gulp-jshint": "^2.1.0", |
| 57 | "gulp-rename": "^1.4.0", | 58 | "gulp-rename": "^1.4.0", |
| 58 | "gulp-replace": "^1.0.0", | 59 | "gulp-replace": "^1.0.0", |
| 59 | "gulp-sequence": "^1.0.0", | 60 | "gulp-sequence": "^1.0.0", |
| 60 | "gulp-uglify": "^3.0.1", | 61 | "gulp-uglify": "^3.0.1", |
| 61 | "gulp-uglify-es": "^1.0.4", | 62 | "gulp-uglify-es": "^1.0.4", |
| 62 | "jasmine-core": "^3.3.0", | 63 | "jasmine-core": "^3.3.0", |
| 63 | "jquery": "^3.3.1", | 64 | "jquery": "^3.3.1", |
| 64 | "jshint": "^2.9.6", | 65 | "jshint": "^2.9.6", |
| 65 | "ladda": "1.0.6", | 66 | "ladda": "1.0.6", |
| 66 | "ngstorage": "^0.3.11", | 67 | "ngstorage": "^0.3.11", |
| 67 | "pre-commit": "^1.2.2", | 68 | "pre-commit": "^1.2.2", |
| 68 | "pump": "^3.0.0", | 69 | "pump": "^3.0.0", |
| 69 | "ui-bootstrap4": "^3.0.5" | 70 | "ui-bootstrap4": "^3.0.5" |
| 70 | } | 71 | } |
| 71 | } | 72 | } |
| 72 | 73 |
src/js/controller.js
| 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 1 | angular.module('focaCrearNotaPedido').controller('notaPedidoCtrl', |
| 2 | [ | 2 | [ |
| 3 | '$scope', | 3 | '$scope', |
| 4 | '$uibModal', | 4 | '$uibModal', |
| 5 | '$location', | 5 | '$location', |
| 6 | '$filter', | 6 | '$filter', |
| 7 | '$timeout', | 7 | '$timeout', |
| 8 | 'crearNotaPedidoService', | 8 | 'crearNotaPedidoService', |
| 9 | 'focaBotoneraLateralService', | 9 | 'focaBotoneraLateralService', |
| 10 | 'focaModalService', | 10 | 'focaModalService', |
| 11 | 'notaPedidoBusinessService', | 11 | 'notaPedidoBusinessService', |
| 12 | '$rootScope', | 12 | '$rootScope', |
| 13 | 'focaSeguimientoService', | 13 | 'focaSeguimientoService', |
| 14 | 'APP', | 14 | 'APP', |
| 15 | 'focaLoginService', | 15 | 'focaLoginService', |
| 16 | '$localStorage', | 16 | '$localStorage', |
| 17 | function( | 17 | function ( |
| 18 | $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService, | 18 | $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService, |
| 19 | focaBotoneraLateralService, focaModalService, notaPedidoBusinessService, | 19 | focaBotoneraLateralService, focaModalService, notaPedidoBusinessService, |
| 20 | $rootScope, focaSeguimientoService, APP, focaLoginService, $localStorage) | 20 | $rootScope, focaSeguimientoService, APP, focaLoginService, $localStorage) { |
| 21 | { | ||
| 22 | config(); | 21 | config(); |
| 23 | var cotizacionPArgentino = {}; | 22 | var cotizacionPArgentino = {}; |
| 24 | 23 | ||
| 25 | function config() { | 24 | function config() { |
| 26 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA | 25 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA |
| 27 | $scope.tmpCantidad = Number; | 26 | $scope.tmpCantidad = Number; |
| 28 | $scope.tmpPrecio = Number; | 27 | $scope.tmpPrecio = Number; |
| 29 | $scope.notaPedido = {}; | 28 | $scope.notaPedido = {}; |
| 30 | $scope.isNumber = angular.isNumber; | 29 | $scope.isNumber = angular.isNumber; |
| 31 | $scope.datepickerAbierto = false; | 30 | $scope.datepickerAbierto = false; |
| 32 | $scope.show = false; | 31 | $scope.show = false; |
| 33 | $scope.cargando = true; | 32 | $scope.cargando = true; |
| 34 | $scope.botonera = crearNotaPedidoService.getBotonera(); | 33 | $scope.botonera = crearNotaPedidoService.getBotonera(); |
| 35 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); | 34 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
| 36 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); | 35 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
| 37 | $scope.dateOptions = { | 36 | $scope.dateOptions = { |
| 38 | maxDate: new Date(), | 37 | maxDate: new Date(), |
| 39 | minDate: new Date(2010, 0, 1) | 38 | minDate: new Date(2010, 0, 1) |
| 40 | }; | 39 | }; |
| 41 | 40 | ||
| 42 | //SETEO BOTONERA LATERAL | 41 | //SETEO BOTONERA LATERAL |
| 43 | $timeout(function() { | 42 | $timeout(function () { |
| 44 | focaBotoneraLateralService.showSalir(false); | 43 | focaBotoneraLateralService.showSalir(false); |
| 45 | focaBotoneraLateralService.showPausar(true); | 44 | focaBotoneraLateralService.showPausar(true); |
| 46 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); | 45 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); |
| 47 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 46 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
| 48 | }); | 47 | }); |
| 49 | 48 | ||
| 50 | // SETEA BOTONERA DE FACTURADOR TENIENDO EN CUENTA SI ESTA SETEADO EL VENDEDOR | 49 | // SETEA BOTONERA DE FACTURADOR TENIENDO EN CUENTA SI ESTA SETEADO EL VENDEDOR |
| 51 | if (APP === 'distribuidor') { | 50 | if (APP === 'distribuidor') { |
| 52 | $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; | 51 | $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; |
| 53 | } | 52 | } |
| 54 | 53 | ||
| 55 | crearNotaPedidoService.getParametros().then(function(res) { | 54 | crearNotaPedidoService.getParametros().then(function (res) { |
| 56 | var parametros = JSON.parse(res.data[0].jsonText); | 55 | var parametros = JSON.parse(res.data[0].jsonText); |
| 57 | if ($localStorage.notaPedido) { | 56 | if ($localStorage.notaPedido) { |
| 58 | $timeout(function() { getLSNotaPedido();} ); | 57 | $timeout(function () { getLSNotaPedido(); }); |
| 59 | } else { | 58 | } else { |
| 60 | for (var property in parametros) { | 59 | for (var property in parametros) { |
| 61 | $scope.notaPedido[property] = parametros[property]; | 60 | $scope.notaPedido[property] = parametros[property]; |
| 62 | $scope.inicial[property] = parametros[property]; | 61 | $scope.inicial[property] = parametros[property]; |
| 63 | } | 62 | } |
| 64 | setearNotaPedido($scope.notaPedido); | 63 | setearNotaPedido($scope.notaPedido); |
| 65 | } | 64 | } |
| 66 | }); | 65 | }); |
| 67 | 66 | ||
| 68 | init(); | 67 | init(); |
| 69 | 68 | ||
| 70 | } | 69 | } |
| 71 | 70 | ||
| 72 | function init() { | 71 | function init() { |
| 73 | $scope.$broadcast('cleanCabecera'); | 72 | $scope.$broadcast('cleanCabecera'); |
| 74 | 73 | ||
| 75 | $scope.notaPedido = { | 74 | $scope.notaPedido = { |
| 76 | id: 0, | 75 | id: 0, |
| 77 | cliente: {}, | 76 | cliente: {}, |
| 78 | proveedor: {}, | 77 | proveedor: {}, |
| 79 | domicilio: {dom: ''}, | 78 | domicilio: { dom: '' }, |
| 80 | vendedor: {}, | 79 | vendedor: {}, |
| 81 | fechaCarga: new Date(), | 80 | fechaCarga: new Date(), |
| 82 | cotizacion: {}, | 81 | cotizacion: {}, |
| 83 | articulosNotaPedido: [], | 82 | articulosNotaPedido: [], |
| 84 | notaPedidoPlazo: [], | 83 | notaPedidoPlazo: [], |
| 85 | notaPedidoPuntoDescarga: [] | 84 | notaPedidoPuntoDescarga: [] |
| 86 | }; | 85 | }; |
| 87 | $scope.idLista = undefined; | 86 | $scope.idLista = undefined; |
| 88 | 87 | ||
| 89 | crearNotaPedidoService.getNumeroNotaPedido().then( | 88 | crearNotaPedidoService.getNumeroNotaPedido().then( |
| 90 | function(res) { | 89 | function (res) { |
| 91 | $scope.puntoVenta = $filter('rellenarDigitos')( | 90 | $scope.puntoVenta = $filter('rellenarDigitos')( |
| 92 | res.data.sucursal, 4 | 91 | res.data.sucursal, 4 |
| 93 | ); | 92 | ); |
| 94 | 93 | ||
| 95 | $scope.comprobante = $filter('rellenarDigitos')( | 94 | $scope.comprobante = $filter('rellenarDigitos')( |
| 96 | res.data.numeroNotaPedido, 8 | 95 | res.data.numeroNotaPedido, 8 |
| 97 | ); | 96 | ); |
| 98 | }, | 97 | }, |
| 99 | function(err) { | 98 | function (err) { |
| 100 | focaModalService.alert('La terminal no esta configurada correctamente'); | 99 | focaModalService.alert('La terminal no esta configurada correctamente'); |
| 101 | console.info(err); | 100 | console.info(err); |
| 102 | } | 101 | } |
| 103 | ); | 102 | ); |
| 104 | 103 | ||
| 105 | if (APP === 'distribuidor') { | 104 | if (APP === 'distribuidor') { |
| 106 | crearNotaPedidoService.getVendedorById($scope.idVendedor).then( | 105 | crearNotaPedidoService.getVendedorById($scope.idVendedor).then( |
| 107 | function(res) { | 106 | function (res) { |
| 108 | var vendedor = res.data; | 107 | var vendedor = res.data; |
| 109 | $scope.$broadcast('addCabecera', { | 108 | $scope.$broadcast('addCabecera', { |
| 110 | label: 'Vendedor:', | 109 | label: 'Vendedor:', |
| 111 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 110 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
| 112 | vendedor.NOM | 111 | vendedor.NOM |
| 113 | }); | 112 | }); |
| 114 | 113 | ||
| 115 | $scope.notaPedido.vendedor = vendedor; | 114 | $scope.notaPedido.vendedor = vendedor; |
| 116 | $scope.inicial.vendedor = $scope.notaPedido.vendedor; | 115 | $scope.inicial.vendedor = $scope.notaPedido.vendedor; |
| 117 | } | 116 | } |
| 118 | ); | 117 | ); |
| 119 | } | 118 | } |
| 120 | 119 | ||
| 121 | $scope.inicial = angular.copy($scope.notaPedido); | 120 | $scope.inicial = angular.copy($scope.notaPedido); |
| 122 | } | 121 | } |
| 123 | 122 | ||
| 124 | $scope.$watch('notaPedido', function(newValue) { | 123 | $scope.$watch('notaPedido', function (newValue) { |
| 125 | focaBotoneraLateralService.setPausarData({ | 124 | focaBotoneraLateralService.setPausarData({ |
| 126 | label: 'notaPedido', | 125 | label: 'notaPedido', |
| 127 | val: newValue | 126 | val: newValue |
| 128 | }); | 127 | }); |
| 129 | }, true); | 128 | }, true); |
| 130 | 129 | ||
| 131 | $scope.crearNotaPedido = function() { | 130 | $scope.crearNotaPedido = function () { |
| 132 | if (!$scope.notaPedido.cliente.COD) { | 131 | if (!$scope.notaPedido.cliente.COD) { |
| 133 | focaModalService.alert('Ingrese Cliente'); | 132 | focaModalService.alert('Ingrese Cliente'); |
| 134 | return; | 133 | return; |
| 135 | } else if ($scope.notaPedido.idRemito === -1) { | 134 | } else if ($scope.notaPedido.idRemito === -1) { |
| 136 | focaBotoneraLateralService.alert('No se puede modificar esta nota de pedido'); | 135 | focaBotoneraLateralService.alert('No se puede modificar esta nota de pedido'); |
| 137 | return; | 136 | return; |
| 138 | } else if (!$scope.notaPedido.proveedor.COD) { | 137 | } else if (!$scope.notaPedido.proveedor.COD) { |
| 139 | focaModalService.alert('Ingrese Proveedor'); | 138 | focaModalService.alert('Ingrese Proveedor'); |
| 140 | return; | 139 | return; |
| 141 | } else if (!$scope.notaPedido.cotizacion.ID) { | 140 | } else if (!$scope.notaPedido.cotizacion.ID) { |
| 142 | focaModalService.alert('Ingrese Cotización'); | 141 | focaModalService.alert('Ingrese Cotización'); |
| 143 | return; | 142 | return; |
| 144 | } else if (!$scope.notaPedido.cotizacion.moneda.ID) { | 143 | } else if (!$scope.notaPedido.cotizacion.moneda.ID) { |
| 145 | focaModalService.alert('Ingrese Moneda'); | 144 | focaModalService.alert('Ingrese Moneda'); |
| 146 | return; | 145 | return; |
| 147 | } else if (!$scope.notaPedido.notaPedidoPlazo) { | 146 | } else if (!$scope.notaPedido.notaPedidoPlazo) { |
| 148 | focaModalService.alert('Ingrese Precios y Condiciones'); | 147 | focaModalService.alert('Ingrese Precios y Condiciones'); |
| 149 | return; | 148 | return; |
| 150 | } else if ( | 149 | } else if ( |
| 151 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) | 150 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) { |
| 152 | { | ||
| 153 | focaModalService.alert('Ingrese Flete'); | 151 | focaModalService.alert('Ingrese Flete'); |
| 154 | return; | 152 | return; |
| 155 | } else if (!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto | 153 | } else if (!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto |
| 156 | focaModalService.alert('Ingrese Domicilio'); | 154 | focaModalService.alert('Ingrese Domicilio'); |
| 157 | return; | 155 | return; |
| 158 | } else if ($scope.notaPedido.articulosNotaPedido.length === 0) { | 156 | } else if ($scope.notaPedido.articulosNotaPedido.length === 0) { |
| 159 | focaModalService.alert('Debe cargar al menos un articulo'); | 157 | focaModalService.alert('Debe cargar al menos un articulo'); |
| 160 | return; | 158 | return; |
| 161 | } | 159 | } |
| 162 | 160 | ||
| 163 | focaBotoneraLateralService.startGuardar(); | 161 | focaBotoneraLateralService.startGuardar(); |
| 164 | $scope.saveLoading = true; | 162 | $scope.saveLoading = true; |
| 165 | var notaPedido = { | 163 | var notaPedido = { |
| 166 | id: $scope.notaPedido.id, | 164 | id: $scope.notaPedido.id, |
| 167 | fechaCarga: new Date($scope.notaPedido.fechaCarga) | 165 | fechaCarga: new Date($scope.notaPedido.fechaCarga) |
| 168 | .toISOString().slice(0, 19).replace('T', ' '), | 166 | .toISOString().slice(0, 19).replace('T', ' '), |
| 169 | idVendedor: $scope.notaPedido.vendedor.id, | 167 | idVendedor: $scope.notaPedido.vendedor.id, |
| 170 | idCliente: $scope.notaPedido.cliente.COD, | 168 | idCliente: $scope.notaPedido.cliente.COD, |
| 171 | nombreCliente: $scope.notaPedido.cliente.NOM, | 169 | nombreCliente: $scope.notaPedido.cliente.NOM, |
| 172 | cuitCliente: $scope.notaPedido.cliente.CUIT, | 170 | cuitCliente: $scope.notaPedido.cliente.CUIT, |
| 173 | idProveedor: $scope.notaPedido.proveedor.COD, | 171 | idProveedor: $scope.notaPedido.proveedor.COD, |
| 174 | idDomicilio: $scope.notaPedido.domicilio.id, | 172 | idDomicilio: $scope.notaPedido.domicilio.id, |
| 175 | idCotizacion: $scope.notaPedido.cotizacion.ID, | 173 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
| 176 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, | 174 | idListaPrecio: $scope.notaPedido.idPrecioCondicion, |
| 177 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 175 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
| 178 | flete: $scope.notaPedido.flete, | 176 | flete: $scope.notaPedido.flete, |
| 179 | fob: $scope.notaPedido.fob, | 177 | fob: $scope.notaPedido.fob, |
| 180 | bomba: $scope.notaPedido.bomba, | 178 | bomba: $scope.notaPedido.bomba, |
| 181 | kilometros: $scope.notaPedido.kilometros, | 179 | kilometros: $scope.notaPedido.kilometros, |
| 182 | domicilioStamp: $scope.notaPedido.domicilioStamp, | 180 | domicilioStamp: $scope.notaPedido.domicilioStamp, |
| 183 | observaciones: $scope.notaPedido.observaciones, | 181 | observaciones: $scope.notaPedido.observaciones, |
| 184 | estado: 0, | 182 | estado: 0, |
| 185 | total: $scope.getTotal() | 183 | total: $scope.getTotal() |
| 186 | }; | 184 | }; |
| 187 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 185 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
| 188 | function(data) { | 186 | function (data) { |
| 189 | // Al guardar los datos de la nota de pedido logueamos la | 187 | // Al guardar los datos de la nota de pedido logueamos la |
| 190 | // actividad para su seguimiento. | 188 | // actividad para su seguimiento. |
| 191 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? | 189 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? |
| 192 | focaSeguimientoService.guardarPosicion( | 190 | focaSeguimientoService.guardarPosicion( |
| 193 | 'Nota de pedido', | 191 | 'Nota de pedido', |
| 194 | data.data.id, | 192 | data.data.id, |
| 195 | '' | 193 | '' |
| 196 | ); | 194 | ); |
| 197 | notaPedidoBusinessService.addArticulos( | 195 | notaPedidoBusinessService.addArticulos( |
| 198 | $scope.notaPedido.articulosNotaPedido, | 196 | $scope.notaPedido.articulosNotaPedido, |
| 199 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); | 197 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); |
| 200 | 198 | ||
| 201 | if ($scope.notaPedido.notaPedidoPuntoDescarga) { | 199 | if ($scope.notaPedido.notaPedidoPuntoDescarga.length > 0) { |
| 202 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, | 200 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, |
| 203 | $scope.notaPedido.notaPedidoPuntoDescarga); | 201 | $scope.notaPedido.notaPedidoPuntoDescarga); |
| 204 | } | 202 | } |
| 205 | 203 | ||
| 206 | var plazos = $scope.notaPedido.notaPedidoPlazo; | 204 | var plazos = $scope.notaPedido.notaPedidoPlazo; |
| 207 | var plazosACrear = []; | 205 | var plazosACrear = []; |
| 208 | plazos.forEach(function(plazo) { | 206 | plazos.forEach(function (plazo) { |
| 209 | plazosACrear.push({ | 207 | plazosACrear.push({ |
| 210 | idNotaPedido: data.data.id, | 208 | idNotaPedido: data.data.id, |
| 211 | dias: plazo.dias | 209 | dias: plazo.dias |
| 212 | }); | 210 | }); |
| 213 | }); | 211 | }); |
| 214 | 212 | ||
| 215 | if (plazosACrear.length) { | 213 | if (plazosACrear.length) { |
| 216 | crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); | 214 | crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); |
| 217 | } | 215 | } |
| 218 | 216 | ||
| 219 | notaPedidoBusinessService.addEstado(data.data.id, | 217 | notaPedidoBusinessService.addEstado(data.data.id, |
| 220 | $scope.notaPedido.vendedor.id); | 218 | $scope.notaPedido.vendedor.id); |
| 221 | 219 | ||
| 222 | focaBotoneraLateralService.endGuardar(true); | 220 | focaBotoneraLateralService.endGuardar(true); |
| 223 | $scope.saveLoading = false; | 221 | $scope.saveLoading = false; |
| 224 | 222 | ||
| 225 | config(); | 223 | config(); |
| 226 | }, function(error) { | 224 | }, function (error) { |
| 227 | focaModalService.alert('Hubo un error al crear la nota de pedido'); | 225 | focaModalService.alert('Hubo un error al crear la nota de pedido'); |
| 228 | focaBotoneraLateralService.endGuardar(); | 226 | focaBotoneraLateralService.endGuardar(); |
| 229 | $scope.saveLoading = false; | 227 | $scope.saveLoading = false; |
| 230 | console.info(error); | 228 | console.info(error); |
| 231 | }); | 229 | }); |
| 232 | }; | 230 | }; |
| 233 | 231 | ||
| 234 | $scope.seleccionarNotaPedido = function() { | 232 | $scope.seleccionarNotaPedido = function () { |
| 235 | var modalInstance = $uibModal.open( | 233 | var modalInstance = $uibModal.open( |
| 236 | { | 234 | { |
| 237 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 235 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
| 238 | templateUrl: 'foca-modal-nota-pedido.html', | 236 | templateUrl: 'foca-modal-nota-pedido.html', |
| 239 | controller: 'focaModalNotaPedidoController', | 237 | controller: 'focaModalNotaPedidoController', |
| 240 | size: 'lg', | 238 | size: 'lg', |
| 241 | resolve: { | 239 | resolve: { |
| 242 | usadoPor: function() {return 'notaPedido';}, | 240 | usadoPor: function () { return 'notaPedido'; }, |
| 243 | idVendedor: function() { | 241 | idVendedor: function () { |
| 244 | if (APP === 'distribuidor') | 242 | if (APP === 'distribuidor') |
| 245 | return $scope.notaPedido.vendedor.id; | 243 | return $scope.notaPedido.vendedor.id; |
| 246 | else | 244 | else |
| 247 | return null; | 245 | return null; |
| 248 | } | 246 | } |
| 249 | } | 247 | } |
| 250 | } | 248 | } |
| 251 | ); | 249 | ); |
| 252 | modalInstance.result.then(setearNotaPedido); | 250 | modalInstance.result.then(setearNotaPedido); |
| 253 | }; | 251 | }; |
| 254 | 252 | ||
| 255 | $scope.seleccionarProductos = function() { | 253 | $scope.seleccionarProductos = function () { |
| 254 | |||
| 256 | if ($scope.idLista === undefined) { | 255 | if ($scope.idLista === undefined) { |
| 257 | focaModalService.alert( | 256 | focaModalService.alert('Primero seleccione una lista de precio y condición'); |
| 258 | 'Primero seleccione una lista de precio y condicion'); | 257 | return; |
| 258 | } else if (!validarNotaRemitada()) { | ||
| 259 | return; | 259 | return; |
| 260 | } | 260 | } |
| 261 | |||
| 261 | var modalInstance = $uibModal.open( | 262 | var modalInstance = $uibModal.open( |
| 262 | { | 263 | { |
| 263 | ariaLabelledBy: 'Busqueda de Productos', | 264 | ariaLabelledBy: 'Busqueda de Productos', |
| 264 | templateUrl: 'modal-busqueda-productos.html', | 265 | templateUrl: 'modal-busqueda-productos.html', |
| 265 | controller: 'modalBusquedaProductosCtrl', | 266 | controller: 'modalBusquedaProductosCtrl', |
| 266 | resolve: { | 267 | resolve: { |
| 267 | parametroProducto: { | 268 | parametroProducto: { |
| 268 | idLista: $scope.idLista, | 269 | idLista: $scope.idLista, |
| 269 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 270 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
| 270 | simbolo: $scope.notaPedido.cotizacion.moneda.SIMBOLO | 271 | simbolo: $scope.notaPedido.cotizacion.moneda.SIMBOLO |
| 271 | } | 272 | } |
| 272 | }, | 273 | }, |
| 273 | size: 'lg' | 274 | size: 'lg' |
| 274 | } | 275 | } |
| 275 | ); | 276 | ); |
| 276 | modalInstance.result.then( | 277 | modalInstance.result.then( |
| 277 | function(producto) { | 278 | function (producto) { |
| 278 | var newArt = | 279 | var newArt = |
| 279 | { | 280 | { |
| 280 | id: 0, | 281 | id: 0, |
| 281 | codigo: producto.codigo, | 282 | codigo: producto.codigo, |
| 282 | sector: producto.sector, | 283 | sector: producto.sector, |
| 283 | sectorCodigo: producto.sector + '-' + producto.codigo, | 284 | sectorCodigo: producto.sector + '-' + producto.codigo, |
| 284 | descripcion: producto.descripcion, | 285 | descripcion: producto.descripcion, |
| 285 | item: $scope.notaPedido.articulosNotaPedido.length + 1, | 286 | item: $scope.notaPedido.articulosNotaPedido.length + 1, |
| 286 | nombre: producto.descripcion, | 287 | nombre: producto.descripcion, |
| 287 | precio: parseFloat(producto.precio.toFixed(4)), | 288 | precio: parseFloat(producto.precio.toFixed(4)), |
| 288 | costoUnitario: producto.costo, | 289 | costoUnitario: producto.costo, |
| 289 | editCantidad: false, | 290 | editCantidad: false, |
| 290 | editPrecio: false, | 291 | editPrecio: false, |
| 291 | rubro: producto.CodRub, | 292 | rubro: producto.CodRub, |
| 292 | ivaUnitario: producto.IMPIVA, | 293 | ivaUnitario: producto.IMPIVA, |
| 293 | impuestoInternoUnitario: producto.ImpInt, | 294 | impuestoInternoUnitario: producto.ImpInt, |
| 294 | impuestoInterno1Unitario: producto.ImpInt2, | 295 | impuestoInterno1Unitario: producto.ImpInt2, |
| 295 | impuestoInterno2Unitario: producto.ImpInt3, | 296 | impuestoInterno2Unitario: producto.ImpInt3, |
| 296 | precioLista: producto.precio, | 297 | precioLista: producto.precio, |
| 297 | combustible: 1, | 298 | combustible: 1, |
| 298 | facturado: 0, | 299 | facturado: 0, |
| 299 | idArticulo: producto.id, | 300 | idArticulo: producto.id, |
| 300 | tasaIva: producto.tasaIVA | 301 | tasaIva: producto.tasaIVA |
| 301 | }; | 302 | }; |
| 302 | 303 | ||
| 303 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : producto.neto; | 304 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : producto.neto; |
| 304 | newArt.netoUnitario = newArt.ivaUnitario ? producto.neto : 0; | 305 | newArt.netoUnitario = newArt.ivaUnitario ? producto.neto : 0; |
| 305 | 306 | ||
| 306 | $scope.articuloACargar = newArt; | 307 | $scope.articuloACargar = newArt; |
| 307 | $scope.cargando = false; | 308 | $scope.cargando = false; |
| 308 | }, function() { | 309 | }, function () { |
| 309 | // funcion ejecutada cuando se cancela el modal | 310 | // funcion ejecutada cuando se cancela el modal |
| 310 | } | 311 | } |
| 311 | ); | 312 | ); |
| 312 | }; | 313 | }; |
| 313 | 314 | ||
| 314 | $scope.seleccionarPuntosDeDescarga = function() { | 315 | $scope.seleccionarPuntosDeDescarga = function () { |
| 315 | if (!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { | 316 | if (!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { |
| 316 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 317 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
| 317 | return; | 318 | return; |
| 318 | } else { | 319 | } else { |
| 319 | var modalInstance = $uibModal.open( | 320 | var modalInstance = $uibModal.open( |
| 320 | { | 321 | { |
| 321 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', | 322 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
| 322 | templateUrl: 'modal-punto-descarga.html', | 323 | templateUrl: 'modal-punto-descarga.html', |
| 323 | controller: 'focaModalPuntoDescargaController', | 324 | controller: 'focaModalPuntoDescargaController', |
| 324 | size: 'lg', | 325 | size: 'lg', |
| 325 | resolve: { | 326 | resolve: { |
| 326 | filters: { | 327 | filters: { |
| 327 | idDomicilio: $scope.notaPedido.domicilio.id, | 328 | idDomicilio: $scope.notaPedido.domicilio.id, |
| 328 | idCliente: $scope.notaPedido.cliente.COD, | 329 | idCliente: $scope.notaPedido.cliente.COD, |
| 329 | articulos: $scope.notaPedido.articulosNotaPedido, | 330 | articulos: $scope.notaPedido.articulosNotaPedido, |
| 330 | puntoDescarga: $scope.notaPedido.notaPedidoPuntoDescarga, | 331 | puntoDescarga: $scope.notaPedido.notaPedidoPuntoDescarga, |
| 331 | domicilio: $scope.notaPedido.domicilio | 332 | domicilio: $scope.notaPedido.domicilio |
| 332 | } | 333 | } |
| 333 | } | 334 | } |
| 334 | } | 335 | } |
| 335 | ); | 336 | ); |
| 336 | modalInstance.result.then( | 337 | modalInstance.result.then( |
| 337 | function(puntoDescarga) { | 338 | function (puntoDescarga) { |
| 338 | 339 | ||
| 339 | puntoDescarga.forEach(function(punto) { | 340 | puntoDescarga.forEach(function (punto) { |
| 340 | $scope.notaPedido.notaPedidoPuntoDescarga.push( | 341 | $scope.notaPedido.notaPedidoPuntoDescarga.push( |
| 341 | { | 342 | { |
| 342 | puntoDescarga: punto | 343 | puntoDescarga: punto |
| 343 | } | 344 | } |
| 344 | ) | 345 | ); |
| 345 | }); | 346 | }); |
| 346 | 347 | ||
| 347 | $scope.$broadcast('addCabecera', { | 348 | $scope.$broadcast('addCabecera', { |
| 348 | label: 'Puntos de descarga:', | 349 | label: 'Puntos de descarga:', |
| 349 | valor: getCabeceraPuntoDescarga(puntoDescarga) | 350 | valor: getCabeceraPuntoDescarga(puntoDescarga) |
| 350 | }); | 351 | }); |
| 351 | }, function() { | 352 | }, function () { |
| 352 | $scope.abrirModalDomicilios($scope.cliente); | 353 | $scope.abrirModalDomicilios($scope.cliente); |
| 353 | } | 354 | } |
| 354 | ); | 355 | ); |
| 355 | } | 356 | } |
| 356 | }; | 357 | }; |
| 357 | 358 | ||
| 358 | $scope.seleccionarProveedor = function() { | 359 | $scope.seleccionarProveedor = function () { |
| 359 | $scope.abrirModalProveedores(function() { | 360 | $scope.abrirModalProveedores(function () { |
| 360 | if (validarNotaRemitada()) { | 361 | if (validarNotaRemitada()) { |
| 361 | var modalInstance = $uibModal.open( | 362 | var modalInstance = $uibModal.open( |
| 362 | { | 363 | { |
| 363 | ariaLabelledBy: 'Busqueda de Flete', | 364 | ariaLabelledBy: 'Busqueda de Flete', |
| 364 | templateUrl: 'modal-flete.html', | 365 | templateUrl: 'modal-flete.html', |
| 365 | controller: 'focaModalFleteController', | 366 | controller: 'focaModalFleteController', |
| 366 | size: 'lg', | 367 | size: 'lg', |
| 367 | resolve: { | 368 | resolve: { |
| 368 | parametrosFlete: | 369 | parametrosFlete: |
| 369 | function() { | 370 | function () { |
| 370 | return { | 371 | return { |
| 371 | flete: $scope.notaPedido.fob ? 'FOB' : | 372 | flete: $scope.notaPedido.fob ? 'FOB' : |
| 372 | ( $scope.notaPedido.flete ? '1' : | 373 | ($scope.notaPedido.flete ? '1' : |
| 373 | ($scope.notaPedido.flete === undefined ? | 374 | ($scope.notaPedido.flete === undefined ? |
| 374 | null : '0')), | 375 | null : '0')), |
| 375 | bomba: $scope.notaPedido.bomba ? '1' : | 376 | bomba: $scope.notaPedido.bomba ? '1' : |
| 376 | ($scope.notaPedido.bomba === undefined ? | 377 | ($scope.notaPedido.bomba === undefined ? |
| 377 | null : '0'), | 378 | null : '0'), |
| 378 | kilometros: $scope.notaPedido.kilometros | 379 | kilometros: $scope.notaPedido.kilometros |
| 379 | }; | 380 | }; |
| 380 | } | 381 | } |
| 381 | } | 382 | } |
| 382 | } | 383 | } |
| 383 | ); | 384 | ); |
| 384 | modalInstance.result.then( | 385 | modalInstance.result.then( |
| 385 | function(datos) { | 386 | function (datos) { |
| 386 | $scope.notaPedido.flete = datos.flete; | 387 | $scope.notaPedido.flete = datos.flete; |
| 387 | $scope.notaPedido.fob = datos.FOB; | 388 | $scope.notaPedido.fob = datos.FOB; |
| 388 | $scope.notaPedido.bomba = datos.bomba; | 389 | $scope.notaPedido.bomba = datos.bomba; |
| 389 | $scope.notaPedido.kilometros = datos.kilometros; | 390 | $scope.notaPedido.kilometros = datos.kilometros; |
| 390 | $scope.$broadcast('addCabecera', { | 391 | $scope.$broadcast('addCabecera', { |
| 391 | label: 'Flete:', | 392 | label: 'Flete:', |
| 392 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') | 393 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') |
| 393 | }); | 394 | }); |
| 394 | if (datos.flete) { | 395 | if (datos.flete) { |
| 395 | $scope.$broadcast('addCabecera', { | 396 | $scope.$broadcast('addCabecera', { |
| 396 | label: 'Bomba:', | 397 | label: 'Bomba:', |
| 397 | valor: datos.bomba ? 'Si' : 'No' | 398 | valor: datos.bomba ? 'Si' : 'No' |
| 398 | }); | 399 | }); |
| 399 | $scope.$broadcast('addCabecera', { | 400 | $scope.$broadcast('addCabecera', { |
| 400 | label: 'Kilometros:', | 401 | label: 'Kilometros:', |
| 401 | valor: datos.kilometros | 402 | valor: datos.kilometros |
| 402 | }); | 403 | }); |
| 403 | } else { | 404 | } else { |
| 404 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 405 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
| 405 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 406 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
| 406 | $scope.notaPedido.bomba = false; | 407 | $scope.notaPedido.bomba = false; |
| 407 | $scope.notaPedido.kilometros = null; | 408 | $scope.notaPedido.kilometros = null; |
| 408 | } | 409 | } |
| 409 | 410 | ||
| 410 | $filter('filter')($scope.botonera, | 411 | $filter('filter')($scope.botonera, |
| 411 | { label: 'Proveedor'})[0].checked = true; | 412 | { label: 'Proveedor' })[0].checked = true; |
| 412 | }, function() { | 413 | }, function () { |
| 413 | $scope.seleccionarTransportista(); | 414 | $scope.seleccionarTransportista(); |
| 414 | } | 415 | } |
| 415 | ); | 416 | ); |
| 416 | } | 417 | } |
| 417 | }); | 418 | }); |
| 418 | }; | 419 | }; |
| 419 | 420 | ||
| 420 | $scope.seleccionarVendedor = function(callback, ocultarVendedor) { | 421 | $scope.seleccionarVendedor = function (callback, ocultarVendedor) { |
| 421 | if (APP === 'distribuidor' || ocultarVendedor) { | 422 | if (APP === 'distribuidor' || ocultarVendedor) { |
| 422 | callback(); | 423 | callback(); |
| 423 | return; | 424 | return; |
| 424 | } | 425 | } |
| 425 | 426 | ||
| 426 | if (validarNotaRemitada()) { | 427 | if (validarNotaRemitada()) { |
| 427 | var parametrosModal = { | 428 | var parametrosModal = { |
| 428 | titulo: 'Búsqueda vendedores', | 429 | titulo: 'Búsqueda vendedores', |
| 429 | query: '/vendedor', | 430 | query: '/vendedor', |
| 430 | columnas: [ | 431 | columnas: [ |
| 431 | { | 432 | { |
| 432 | propiedad: 'NUM', | 433 | propiedad: 'NUM', |
| 433 | nombre: 'Código', | 434 | nombre: 'Código', |
| 434 | filtro: { | 435 | filtro: { |
| 435 | nombre: 'rellenarDigitos', | 436 | nombre: 'rellenarDigitos', |
| 436 | parametro: 3 | 437 | parametro: 3 |
| 437 | } | 438 | } |
| 438 | }, | 439 | }, |
| 439 | { | 440 | { |
| 440 | propiedad: 'NOM', | 441 | propiedad: 'NOM', |
| 441 | nombre: 'Nombre' | 442 | nombre: 'Nombre' |
| 442 | } | 443 | } |
| 443 | ], | 444 | ], |
| 444 | size: 'md' | 445 | size: 'md' |
| 445 | }; | 446 | }; |
| 446 | focaModalService.modal(parametrosModal).then( | 447 | focaModalService.modal(parametrosModal).then( |
| 447 | function(vendedor) { | 448 | function (vendedor) { |
| 448 | $scope.$broadcast('addCabecera', { | 449 | $scope.$broadcast('addCabecera', { |
| 449 | label: 'Vendedor:', | 450 | label: 'Vendedor:', |
| 450 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 451 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
| 451 | vendedor.NOM | 452 | vendedor.NOM |
| 452 | }); | 453 | }); |
| 453 | $scope.notaPedido.vendedor = vendedor; | 454 | $scope.notaPedido.vendedor = vendedor; |
| 454 | deleteCliente(); | 455 | deleteCliente(); |
| 455 | callback(); | 456 | callback(); |
| 456 | }, function() {} | 457 | }, function () { } |
| 457 | ); | 458 | ); |
| 458 | } | 459 | } |
| 459 | }; | 460 | }; |
| 460 | 461 | ||
| 461 | $scope.seleccionarCliente = function(ocultarVendedor) { | 462 | $scope.seleccionarCliente = function () { |
| 462 | $scope.seleccionarVendedor(function() { | 463 | if (validarNotaRemitada()) { |
| 463 | if (validarNotaRemitada()) { | 464 | var modalInstance = $uibModal.open( |
| 464 | var modalInstance = $uibModal.open( | 465 | { |
| 465 | { | 466 | ariaLabelledBy: 'Busqueda de Cliente', |
| 466 | ariaLabelledBy: 'Busqueda de Cliente', | 467 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 467 | templateUrl: 'foca-busqueda-cliente-modal.html', | 468 | controller: 'focaBusquedaClienteModalController', |
| 468 | controller: 'focaBusquedaClienteModalController', | 469 | resolve: { |
| 469 | resolve: { | 470 | vendedor: function () { return null; }, |
| 470 | vendedor: function() { return $scope.notaPedido.vendedor; }, | 471 | cobrador: function () { return null; } |
| 471 | cobrador: function() { return null; } | 472 | }, |
| 472 | }, | 473 | size: 'lg' |
| 473 | size: 'lg' | 474 | } |
| 474 | } | 475 | ); |
| 475 | ); | 476 | modalInstance.result.then( |
| 476 | modalInstance.result.then( | 477 | function (cliente) { |
| 477 | function(cliente) { | 478 | cliente.mod = cliente.mod; |
| 478 | $scope.abrirModalDomicilios(cliente); | 479 | $scope.abrirModalDomicilios(cliente); |
| 479 | $scope.cliente = cliente; | 480 | $scope.cliente = cliente; |
| 480 | }, function() { | 481 | }, function () { } |
| 481 | if (APP !== 'distribuidor') $scope.seleccionarCliente(); | 482 | ); |
| 482 | } | 483 | } |
| 483 | ); | ||
| 484 | } | ||
| 485 | }, ocultarVendedor); | ||
| 486 | }; | 484 | }; |
| 487 | 485 | ||
| 488 | $scope.abrirModalProveedores = function(callback) { | 486 | $scope.abrirModalProveedores = function (callback) { |
| 489 | if (validarNotaRemitada()) { | 487 | if (validarNotaRemitada()) { |
| 490 | var parametrosModal = { | 488 | var parametrosModal = { |
| 491 | titulo: 'Búsqueda de Proveedor', | 489 | titulo: 'Búsqueda de Proveedor', |
| 492 | query: '/proveedor', | 490 | query: '/proveedor', |
| 493 | columnas: [ | 491 | columnas: [ |
| 494 | { | 492 | { |
| 495 | nombre: 'Código', | 493 | nombre: 'Código', |
| 496 | propiedad: 'COD', | 494 | propiedad: 'COD', |
| 497 | filtro: { | 495 | filtro: { |
| 498 | nombre: 'rellenarDigitos', | 496 | nombre: 'rellenarDigitos', |
| 499 | parametro: 5 | 497 | parametro: 5 |
| 500 | } | 498 | } |
| 501 | }, | 499 | }, |
| 502 | { | 500 | { |
| 503 | nombre: 'Nombre', | 501 | nombre: 'Nombre', |
| 504 | propiedad: 'NOM' | 502 | propiedad: 'NOM' |
| 505 | }, | 503 | }, |
| 506 | { | 504 | { |
| 507 | nombre: 'CUIT', | 505 | nombre: 'CUIT', |
| 508 | propiedad: 'CUIT' | 506 | propiedad: 'CUIT' |
| 509 | } | 507 | } |
| 510 | ], | 508 | ], |
| 511 | tipo: 'POST', | 509 | tipo: 'POST', |
| 512 | json: {razonCuitCod: ''} | 510 | json: { razonCuitCod: '' } |
| 513 | }; | 511 | }; |
| 514 | focaModalService.modal(parametrosModal).then( | 512 | focaModalService.modal(parametrosModal).then( |
| 515 | function(proveedor) { | 513 | function (proveedor) { |
| 516 | $scope.notaPedido.proveedor = proveedor; | 514 | $scope.notaPedido.proveedor = proveedor; |
| 517 | $scope.$broadcast('addCabecera', { | 515 | $scope.$broadcast('addCabecera', { |
| 518 | label: 'Proveedor:', | 516 | label: 'Proveedor:', |
| 519 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 517 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
| 520 | proveedor.NOM | 518 | proveedor.NOM |
| 521 | }); | 519 | }); |
| 522 | callback(); | 520 | callback(); |
| 523 | }, function() { | 521 | }, function () { |
| 524 | 522 | ||
| 525 | } | 523 | } |
| 526 | ); | 524 | ); |
| 527 | } | 525 | } |
| 528 | }; | 526 | }; |
| 529 | 527 | ||
| 530 | $scope.abrirModalDomicilios = function(cliente) { | 528 | $scope.abrirModalDomicilios = function (cliente) { |
| 531 | var modalInstanceDomicilio = $uibModal.open( | 529 | var modalInstanceDomicilio = $uibModal.open( |
| 532 | { | 530 | { |
| 533 | ariaLabelledBy: 'Busqueda de Domicilios', | 531 | ariaLabelledBy: 'Busqueda de Domicilios', |
| 534 | templateUrl: 'modal-domicilio.html', | 532 | templateUrl: 'modal-domicilio.html', |
| 535 | controller: 'focaModalDomicilioController', | 533 | controller: 'focaModalDomicilioController', |
| 536 | resolve: { | 534 | resolve: { |
| 537 | idCliente: function() { return cliente.cod; }, | 535 | idCliente: function () { return cliente.cod; }, |
| 538 | esNuevo: function() { return cliente.esNuevo; } | 536 | esNuevo: function () { return cliente.esNuevo; } |
| 539 | }, | 537 | }, |
| 540 | size: 'lg', | 538 | size: 'lg', |
| 541 | } | 539 | } |
| 542 | ); | 540 | ); |
| 543 | modalInstanceDomicilio.result.then( | 541 | modalInstanceDomicilio.result.then( |
| 544 | function(domicilio) { | 542 | function (domicilio) { |
| 545 | $scope.notaPedido.domicilio = domicilio; | 543 | $scope.notaPedido.domicilio = domicilio; |
| 546 | $scope.notaPedido.cliente = { | 544 | $scope.notaPedido.cliente = { |
| 547 | COD: cliente.cod, | 545 | COD: cliente.cod, |
| 548 | CUIT: cliente.cuit, | 546 | CUIT: cliente.cuit, |
| 549 | NOM: cliente.nom, | 547 | NOM: cliente.nom, |
| 550 | MOD: cliente.mod | 548 | MOD: cliente.mod, |
| 549 | VEN: cliente.ven | ||
| 551 | }; | 550 | }; |
| 552 | var domicilioStamp = | 551 | crearNotaPedidoService.getVendedorById($scope.notaPedido.cliente.VEN) |
| 553 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 552 | .then(function (res) { |
| 554 | domicilio.Localidad + ', ' + domicilio.Provincia; | 553 | if (res.data !== '') { |
| 555 | $scope.notaPedido.domicilioStamp = domicilioStamp; | 554 | $scope.notaPedido.vendedor = res.data; |
| 556 | 555 | $scope.$broadcast('addCabecera', { | |
| 557 | $scope.$broadcast('addCabecera', { | 556 | label: 'Vendedor:', |
| 558 | label: 'Cliente:', | 557 | valor: $filter('rellenarDigitos') |
| 559 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom | 558 | ($scope.notaPedido.vendedor.NUM, 3) + |
| 560 | }); | 559 | ' - ' + $scope.notaPedido.vendedor.NOM |
| 560 | }); | ||
| 561 | } | ||
| 562 | var domicilioStamp = | ||
| 563 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | ||
| 564 | domicilio.Localidad + ', ' + domicilio.Provincia; | ||
| 565 | $scope.notaPedido.domicilioStamp = domicilioStamp; | ||
| 561 | 566 | ||
| 562 | $scope.$broadcast('addCabecera', { | 567 | $scope.$broadcast('addCabecera', { |
| 563 | label: 'Domicilio:', | 568 | label: 'Cliente:', |
| 564 | valor: domicilioStamp | 569 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + |
| 565 | }); | 570 | ' - ' + cliente.nom |
| 571 | }); | ||
| 566 | 572 | ||
| 567 | if (domicilio.verPuntos) { | 573 | $scope.$broadcast('addCabecera', { |
| 568 | delete $scope.notaPedido.domicilio.verPuntos; | 574 | label: 'Domicilio:', |
| 569 | $scope.seleccionarPuntosDeDescarga(); | 575 | valor: domicilioStamp |
| 570 | } | 576 | }); |
| 571 | 577 | ||
| 572 | // Seteo checked en botonera | 578 | if (domicilio.verPuntos) { |
| 573 | $filter('filter')($scope.botonera, { label: 'Cliente'})[0].checked = true; | 579 | delete $scope.notaPedido.domicilio.verPuntos; |
| 580 | $scope.seleccionarPuntosDeDescarga(); | ||
| 581 | } | ||
| 574 | 582 | ||
| 575 | }, function() { | 583 | // Seteo checked en botonera |
| 584 | $filter('filter')($scope.botonera, | ||
| 585 | { label: 'Cliente' })[0].checked = true; | ||
| 586 | }) | ||
| 587 | .catch(function (e) { console.log(e); }); | ||
| 588 | }, function () { | ||
| 576 | $scope.seleccionarCliente(true); | 589 | $scope.seleccionarCliente(true); |
| 577 | return; | 590 | return; |
| 578 | } | 591 | } |
| 579 | ); | 592 | ); |
| 580 | }; | 593 | }; |
| 581 | 594 | ||
| 582 | $scope.getTotal = function() { | 595 | $scope.getTotal = function () { |
| 583 | var total = 0; | 596 | var total = 0; |
| 584 | if ($scope.notaPedido.articulosNotaPedido) { | 597 | if ($scope.notaPedido.articulosNotaPedido) { |
| 585 | var arrayTempArticulos = $scope.notaPedido.articulosNotaPedido; | 598 | var arrayTempArticulos = $scope.notaPedido.articulosNotaPedido; |
| 586 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 599 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
| 587 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 600 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 588 | } | 601 | } |
| 589 | } | 602 | } |
| 590 | return parseFloat(total.toFixed(2)); | 603 | return parseFloat(total.toFixed(2)); |
| 591 | }; | 604 | }; |
| 592 | 605 | ||
| 593 | $scope.getSubTotal = function() { | 606 | $scope.getSubTotal = function () { |
| 594 | if ($scope.articuloACargar) { | 607 | if ($scope.articuloACargar) { |
| 595 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 608 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 596 | } | 609 | } |
| 597 | }; | 610 | }; |
| 598 | 611 | ||
| 599 | $scope.seleccionarPreciosYCondiciones = function() { | 612 | $scope.seleccionarPreciosYCondiciones = function () { |
| 613 | |||
| 614 | if (!validarNotaRemitada()) { | ||
| 615 | return; | ||
| 616 | } | ||
| 617 | |||
| 600 | if (!$scope.notaPedido.cliente.COD) { | 618 | if (!$scope.notaPedido.cliente.COD) { |
| 601 | focaModalService.alert('Primero seleccione un cliente'); | 619 | focaModalService.alert('Primero seleccione un cliente'); |
| 602 | return; | 620 | return; |
| 603 | } | 621 | } |
| 604 | if ($scope.notaPedido.articulosNotaPedido.length !== 0) { | 622 | if ($scope.notaPedido.articulosNotaPedido.length !== 0) { |
| 605 | focaModalService.confirm('Se perderan los productos ingresados') | 623 | focaModalService.confirm('Se perderan los productos ingresados') |
| 606 | .then(function(data) { | 624 | .then(function (data) { |
| 607 | if (data) { | 625 | if (data) { |
| 608 | abrirModal(); | 626 | abrirModal(); |
| 609 | } | 627 | } |
| 610 | }); | 628 | }); |
| 611 | } else if (validarNotaRemitada()) { | 629 | } else if (validarNotaRemitada()) { |
| 612 | abrirModal(); | 630 | abrirModal(); |
| 613 | } | 631 | } |
| 614 | function abrirModal() { | 632 | function abrirModal() { |
| 615 | var modalInstance = $uibModal.open( | 633 | var modalInstance = $uibModal.open( |
| 616 | { | 634 | { |
| 617 | ariaLabelledBy: 'Busqueda de Precio Condición', | 635 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 618 | templateUrl: 'modal-precio-condicion.html', | 636 | templateUrl: 'modal-precio-condicion.html', |
| 619 | controller: 'focaModalPrecioCondicionController', | 637 | controller: 'focaModalPrecioCondicionController', |
| 620 | size: 'lg', | 638 | size: 'lg', |
| 621 | resolve: { | 639 | resolve: { |
| 622 | idListaPrecio: function() { | 640 | idListaPrecio: function () { return $scope.notaPedido.cliente.MOD || null; }, |
| 623 | return $scope.notaPedido.cliente.MOD || null; | 641 | idCliente: function () { return $scope.notaPedido.cliente.COD } |
| 624 | } | ||
| 625 | } | 642 | } |
| 626 | } | 643 | } |
| 627 | ); | 644 | ); |
| 628 | 645 | ||
| 629 | modalInstance.result.then( | 646 | modalInstance.result |
| 630 | function(precioCondicion) { | 647 | .then(function (precioCondicion) { |
| 631 | var cabecera = ''; | 648 | var cabecera = ''; |
| 632 | var plazosConcat = ''; | 649 | var plazosConcat = ''; |
| 633 | if (!Array.isArray(precioCondicion)) { | 650 | if (!Array.isArray(precioCondicion)) { |
| 634 | $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; | 651 | $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; |
| 635 | $scope.notaPedido.precioCondicion = precioCondicion; | 652 | $scope.notaPedido.precioCondicion = precioCondicion; |
| 636 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; | 653 | $scope.notaPedido.idPrecioCondicion = precioCondicion.listaPrecio.ID; |
| 637 | $scope.idLista = precioCondicion.idListaPrecio; | 654 | $scope.idLista = precioCondicion.listaPrecio.ID; |
| 638 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | 655 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { |
| 639 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 656 | plazosConcat += precioCondicion.plazoPago[i].dias + ', '; |
| 640 | } | 657 | } |
| 641 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + | 658 | plazosConcat = plazosConcat.substring(0, plazosConcat.length - 2); |
| 642 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); | 659 | cabecera = $filter('rellenarDigitos')(parseInt(precioCondicion.listaPrecio.ID), 4) + |
| 660 | ' - ' + precioCondicion.listaPrecio.DES + ' ' + plazosConcat.trim(); | ||
| 643 | } else { //Cuando se ingresan los plazos manualmente | 661 | } else { //Cuando se ingresan los plazos manualmente |
| 644 | $scope.notaPedido.idPrecioCondicion = 0; | 662 | $scope.notaPedido.idPrecioCondicion = 0; |
| 645 | //-1, el modal productos busca todos los productos | 663 | //-1, el modal productos busca todos los productos |
| 646 | $scope.idLista = -1; | 664 | $scope.idLista = -1; |
| 647 | $scope.notaPedido.notaPedidoPlazo = precioCondicion; | 665 | $scope.notaPedido.notaPedidoPlazo = precioCondicion; |
| 648 | for (var j = 0; j < precioCondicion.length; j++) { | 666 | for (var j = 0; j < precioCondicion.length; j++) { |
| 649 | plazosConcat += precioCondicion[j].dias + ' '; | 667 | plazosConcat += precioCondicion[j].dias + ' '; |
| 650 | } | 668 | } |
| 651 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 669 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
| 652 | } | 670 | } |
| 653 | $scope.notaPedido.articulosNotaPedido = []; | 671 | $scope.notaPedido.articulosNotaPedido = []; |
| 654 | $scope.$broadcast('addCabecera', { | 672 | $scope.$broadcast('addCabecera', { |
| 655 | label: 'Precios y condiciones:', | 673 | label: 'Precios y condiciones:', |
| 656 | valor: cabecera | 674 | valor: cabecera |
| 657 | }); | 675 | }); |
| 658 | 676 | ||
| 659 | $filter('filter')($scope.botonera, | 677 | $filter('filter')($scope.botonera, |
| 660 | { label: 'Precios y Condiciones'})[0].checked = true; | 678 | { label: 'Precios y Condiciones' })[0].checked = true; |
| 661 | }, function() { | 679 | }) |
| 680 | .catch(function (e) { | ||
| 681 | console.log(e); | ||
| 682 | }) | ||
| 662 | 683 | ||
| 663 | } | ||
| 664 | ); | ||
| 665 | } | 684 | } |
| 666 | }; | 685 | }; |
| 667 | 686 | ||
| 668 | $scope.seleccionarMoneda = function() { | 687 | $scope.seleccionarMoneda = function () { |
| 669 | if (validarNotaRemitada()) { | 688 | if (validarNotaRemitada()) { |
| 670 | var parametrosModal = { | 689 | var parametrosModal = { |
| 671 | titulo: 'Búsqueda de monedas', | 690 | titulo: 'Búsqueda de monedas', |
| 672 | query: '/moneda', | 691 | query: '/moneda', |
| 673 | columnas: [ | 692 | columnas: [ |
| 674 | { | 693 | { |
| 675 | propiedad: 'DETALLE', | 694 | propiedad: 'DETALLE', |
| 676 | nombre: 'Nombre' | 695 | nombre: 'Nombre' |
| 677 | }, | 696 | }, |
| 678 | { | 697 | { |
| 679 | propiedad: 'SIMBOLO', | 698 | propiedad: 'SIMBOLO', |
| 680 | nombre: 'Símbolo' | 699 | nombre: 'Símbolo' |
| 681 | } | 700 | } |
| 682 | ], | 701 | ], |
| 683 | size: 'md' | 702 | size: 'md' |
| 684 | }; | 703 | }; |
| 685 | focaModalService.modal(parametrosModal).then( | 704 | focaModalService.modal(parametrosModal).then( |
| 686 | function(moneda) { | 705 | function (moneda) { |
| 687 | 706 | ||
| 688 | if (moneda.ID !== 1) { | 707 | if (moneda.ID !== 1) { |
| 689 | $scope.abrirModalCotizacion(moneda); | 708 | $scope.abrirModalCotizacion(moneda); |
| 690 | return; | 709 | return; |
| 691 | } | 710 | } |
| 692 | 711 | ||
| 693 | crearNotaPedidoService.getCotizacionByIdMoneda(1) | 712 | crearNotaPedidoService.getCotizacionByIdMoneda(1) |
| 694 | .then(function (res) { | 713 | .then(function (res) { |
| 695 | 714 | ||
| 696 | cotizacionPArgentino = res.data[0].cotizaciones[0]; | 715 | cotizacionPArgentino = res.data[0].cotizaciones[0]; |
| 697 | cotizacionPArgentino.moneda = moneda; | 716 | cotizacionPArgentino.moneda = moneda; |
| 698 | 717 | ||
| 699 | actualizarCabeceraMoneda(cotizacionPArgentino); | 718 | actualizarCabeceraMoneda(cotizacionPArgentino); |
| 700 | $scope.notaPedido.cotizacion = cotizacionPArgentino; | 719 | $scope.notaPedido.cotizacion = cotizacionPArgentino; |
| 701 | }); | 720 | }); |
| 702 | } | 721 | } |
| 703 | ); | 722 | ); |
| 704 | } | 723 | } |
| 705 | }; | 724 | }; |
| 706 | 725 | ||
| 707 | $scope.seleccionarObservaciones = function() { | 726 | $scope.seleccionarObservaciones = function () { |
| 708 | var observacion = { | 727 | var observacion = { |
| 709 | titulo: 'Ingrese Observaciones', | 728 | titulo: 'Ingrese Observaciones', |
| 710 | value: $scope.notaPedido.observaciones, | 729 | value: $scope.notaPedido.observaciones, |
| 711 | maxlength: 155, | 730 | maxlength: 155, |
| 712 | textarea: true | 731 | textarea: true |
| 713 | }; | 732 | }; |
| 714 | 733 | ||
| 715 | focaModalService | 734 | focaModalService |
| 716 | .prompt(observacion) | 735 | .prompt(observacion) |
| 717 | .then(function(observaciones) { | 736 | .then(function (observaciones) { |
| 718 | $scope.notaPedido.observaciones = observaciones; | 737 | $scope.notaPedido.observaciones = observaciones; |
| 719 | }); | 738 | }); |
| 720 | }; | 739 | }; |
| 721 | 740 | ||
| 722 | $scope.abrirModalCotizacion = function(moneda) { | 741 | $scope.abrirModalCotizacion = function (moneda) { |
| 723 | var modalInstance = $uibModal.open( | 742 | var modalInstance = $uibModal.open( |
| 724 | { | 743 | { |
| 725 | ariaLabelledBy: 'Busqueda de Cotización', | 744 | ariaLabelledBy: 'Busqueda de Cotización', |
| 726 | templateUrl: 'modal-cotizacion.html', | 745 | templateUrl: 'modal-cotizacion.html', |
| 727 | controller: 'focaModalCotizacionController', | 746 | controller: 'focaModalCotizacionController', |
| 728 | size: 'lg', | 747 | size: 'lg', |
| 729 | resolve: { | 748 | resolve: { |
| 730 | idMoneda: function() { | 749 | idMoneda: function () { |
| 731 | return moneda.ID; | 750 | return moneda.ID; |
| 732 | } | 751 | } |
| 733 | } | 752 | } |
| 734 | } | 753 | } |
| 735 | ); | 754 | ); |
| 736 | modalInstance.result.then( | 755 | modalInstance.result.then( |
| 737 | function(cotizacion) { | 756 | function (cotizacion) { |
| 738 | 757 | ||
| 739 | cotizacion.moneda = moneda; | 758 | cotizacion.moneda = moneda; |
| 740 | actualizarCabeceraMoneda(cotizacion); | 759 | actualizarCabeceraMoneda(cotizacion); |
| 741 | 760 | ||
| 742 | $scope.notaPedido.cotizacion = cotizacion; | 761 | $scope.notaPedido.cotizacion = cotizacion; |
| 743 | $filter('filter')($scope.botonera, { label: 'Moneda'})[0].checked = true; | 762 | $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; |
| 744 | }, function() { | 763 | }, function () { |
| 745 | 764 | ||
| 746 | } | 765 | } |
| 747 | ); | 766 | ); |
| 748 | }; | 767 | }; |
| 749 | 768 | ||
| 750 | function actualizarCabeceraMoneda (cotizacion) { | 769 | function actualizarCabeceraMoneda(cotizacion) { |
| 751 | 770 | ||
| 752 | $scope.notaPedido.articulosNotaPedido.forEach(function(art) { | 771 | $scope.notaPedido.articulosNotaPedido.forEach(function (art) { |
| 753 | art.precio = (art.precio * $scope.notaPedido.cotizacion.VENDEDOR).toFixed(4); | 772 | art.precio = (art.precio * $scope.notaPedido.cotizacion.VENDEDOR).toFixed(4); |
| 754 | art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4); | 773 | art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4); |
| 755 | }); | 774 | }); |
| 756 | 775 | ||
| 757 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { | 776 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { |
| 758 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 777 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
| 759 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 778 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
| 760 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 779 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
| 761 | } else { | 780 | } else { |
| 762 | $scope.$broadcast('addCabecera', { | 781 | $scope.$broadcast('addCabecera', { |
| 763 | label: 'Moneda:', | 782 | label: 'Moneda:', |
| 764 | valor: cotizacion.moneda.DETALLE | 783 | valor: cotizacion.moneda.DETALLE |
| 765 | }); | 784 | }); |
| 766 | $scope.$broadcast('addCabecera', { | 785 | $scope.$broadcast('addCabecera', { |
| 767 | label: 'Fecha cotizacion:', | 786 | label: 'Fecha cotizacion:', |
| 768 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 787 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
| 769 | }); | 788 | }); |
| 770 | $scope.$broadcast('addCabecera', { | 789 | $scope.$broadcast('addCabecera', { |
| 771 | label: 'Cotizacion:', | 790 | label: 'Cotizacion:', |
| 772 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 791 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
| 773 | }); | 792 | }); |
| 774 | } | 793 | } |
| 775 | } | 794 | } |
| 776 | 795 | ||
| 777 | $scope.agregarATabla = function(key) { | 796 | $scope.agregarATabla = function (key) { |
| 778 | if (key === 13) { | 797 | if (key === 13) { |
| 779 | if ($scope.articuloACargar.cantidad === undefined || | 798 | if (!$scope.articuloACargar.cantidad || !$scope.articuloACargar.precio) { |
| 780 | $scope.articuloACargar.cantidad === 0 || | 799 | focaModalService.alert('El valor debe ser al menos 1'); |
| 781 | $scope.articuloACargar.cantidad === null ) { | 800 | return; |
| 782 | focaModalService.alert('El valor debe ser al menos 1'); | ||
| 783 | return; | ||
| 784 | } | 801 | } |
| 785 | delete $scope.articuloACargar.sectorCodigo; | 802 | delete $scope.articuloACargar.sectorCodigo; |
| 786 | $scope.notaPedido.articulosNotaPedido.push($scope.articuloACargar); | 803 | $scope.notaPedido.articulosNotaPedido.push($scope.articuloACargar); |
| 787 | $scope.cargando = true; | 804 | $scope.cargando = true; |
| 788 | } | 805 | } |
| 789 | }; | 806 | }; |
| 790 | 807 | ||
| 791 | $scope.quitarArticulo = function(key) { | 808 | $scope.quitarArticulo = function (key) { |
| 792 | $scope.notaPedido.articulosNotaPedido.splice(key, 1); | 809 | if (validarNotaRemitada()) { |
| 810 | $scope.notaPedido.articulosNotaPedido.splice(key, 1); | ||
| 811 | } | ||
| 793 | }; | 812 | }; |
| 794 | 813 | ||
| 795 | $scope.editarArticulo = function(key, articulo, tmpCantidad, tmpPrecio) { | 814 | $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) { |
| 796 | if (key === 13) { | 815 | if (key === 13) { |
| 797 | if (!articulo.cantidad || !articulo.precio) { | 816 | if (!articulo.cantidad || !articulo.precio || !tmpCantidad || !tmpPrecio) { |
| 798 | focaModalService.alert('Los valores deben ser al menos 1'); | 817 | focaModalService.alert('Los valores deben ser al menos 1'); |
| 799 | return; | 818 | return; |
| 800 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { | 819 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { |
| 801 | focaModalService.alert('Los valores no pueden ser negativos'); | 820 | focaModalService.alert('Los valores no pueden ser negativos'); |
| 802 | return; | 821 | return; |
| 803 | } | 822 | } |
| 804 | articulo.cantidad = tmpCantidad; | 823 | articulo.cantidad = tmpCantidad; |
| 805 | articulo.precio = tmpPrecio; | 824 | articulo.precio = tmpPrecio; |
| 806 | $scope.getTotal(); | 825 | $scope.getTotal(); |
| 807 | articulo.editCantidad = articulo.editPrecio = false; | 826 | articulo.editCantidad = articulo.editPrecio = false; |
| 808 | } | 827 | } |
| 809 | }; | 828 | }; |
| 810 | 829 | ||
| 811 | $scope.cancelarEditar = function(articulo) { | 830 | $scope.cancelarEditar = function (articulo) { |
| 812 | $scope.tmpCantidad = articulo.cantidad; | 831 | $scope.tmpCantidad = articulo.cantidad; |
| 813 | $scope.tmpPrecio = articulo.precio; | 832 | $scope.tmpPrecio = articulo.precio; |
| 814 | articulo.editCantidad = articulo.editPrecio = false; | 833 | articulo.editCantidad = articulo.editPrecio = false; |
| 815 | }; | 834 | }; |
| 816 | 835 | ||
| 817 | $scope.cambioEdit = function(articulo, propiedad) { | 836 | $scope.cambioEdit = function (articulo, propiedad) { |
| 818 | if (propiedad === 'cantidad') { | 837 | if (propiedad === 'cantidad') { |
| 819 | articulo.editCantidad = true; | 838 | articulo.editCantidad = true; |
| 820 | } else if (propiedad === 'precio') { | 839 | } else if (propiedad === 'precio') { |
| 821 | articulo.editPrecio = true; | 840 | articulo.editPrecio = true; |
| 822 | } | 841 | } |
| 823 | }; | 842 | }; |
| 824 | 843 | ||
| 825 | $scope.resetFilter = function() { | 844 | $scope.resetFilter = function () { |
| 826 | $scope.articuloACargar = {}; | 845 | $scope.articuloACargar = {}; |
| 827 | $scope.cargando = true; | 846 | $scope.cargando = true; |
| 828 | }; | 847 | }; |
| 829 | //Recibe aviso si el teclado está en uso | 848 | //Recibe aviso si el teclado está en uso |
| 830 | $rootScope.$on('usarTeclado', function(event, data) { | 849 | $rootScope.$on('usarTeclado', function (event, data) { |
| 831 | if (data) { | 850 | if (data) { |
| 832 | $scope.mostrarTeclado = true; | 851 | $scope.mostrarTeclado = true; |
| 833 | return; | 852 | return; |
| 834 | } | 853 | } |
| 835 | $scope.mostrarTeclado = false; | 854 | $scope.mostrarTeclado = false; |
| 836 | }); | 855 | }); |
| 837 | 856 | ||
| 838 | $scope.selectFocus = function($event) { | 857 | $scope.selectFocus = function ($event) { |
| 839 | // Si el teclado esta en uso no selecciona el valor | 858 | // Si el teclado esta en uso no selecciona el valor |
| 840 | if ($scope.mostrarTeclado) { | 859 | if ($scope.mostrarTeclado) { |
| 841 | return; | 860 | return; |
| 842 | } | 861 | } |
| 843 | $event.target.select(); | 862 | $event.target.select(); |
| 844 | }; | 863 | }; |
| 845 | 864 | ||
| 846 | $scope.salir = function() { | 865 | $scope.salir = function () { |
| 847 | $location.path('/'); | 866 | $location.path('/'); |
| 848 | }; | 867 | }; |
| 849 | 868 | ||
| 850 | $scope.parsearATexto = function(articulo) { | 869 | $scope.parsearATexto = function (articulo) { |
| 851 | articulo.cantidad = parseFloat(articulo.cantidad); | 870 | articulo.cantidad = parseFloat(articulo.cantidad); |
| 852 | articulo.precio = parseFloat(articulo.precio); | 871 | articulo.precio = parseFloat(articulo.precio); |
| 853 | }; | 872 | }; |
| 854 | 873 | ||
| 855 | // TODO: quitar watch usar función de articulos pedido cuando se haga | 874 | // TODO: quitar watch usar función de articulos pedido cuando se haga |
| 856 | $scope.$watch('notaPedido.articulosNotaPedido', function() { | 875 | $scope.$watch('notaPedido.articulosNotaPedido', function () { |
| 857 | if ($scope.notaPedido.articulosNotaPedido.length) { | 876 | if ($scope.notaPedido.articulosNotaPedido.length) { |
| 858 | $filter('filter')($scope.botonera, | 877 | $filter('filter')($scope.botonera, |
| 859 | { label: 'Productos'})[0].checked = true; | 878 | { label: 'Productos' })[0].checked = true; |
| 860 | } else { | 879 | } else { |
| 861 | $filter('filter')($scope.botonera, | 880 | $filter('filter')($scope.botonera, |
| 862 | { label: 'Productos'})[0].checked = false; | 881 | { label: 'Productos' })[0].checked = false; |
| 863 | } | 882 | } |
| 864 | }, true); | 883 | }, true); |
| 865 | 884 | ||
| 866 | function setearNotaPedido(notaPedido) { | 885 | function setearNotaPedido(notaPedido) { |
| 867 | //añado cabeceras | 886 | //añado cabeceras |
| 868 | $scope.notaPedido = notaPedido; | 887 | $scope.notaPedido = notaPedido; |
| 869 | if (!$scope.notaPedido.domicilio) { | 888 | if (!$scope.notaPedido.domicilio) { |
| 870 | $scope.notaPedido.domicilio = { | 889 | $scope.notaPedido.domicilio = { |
| 871 | id: $scope.notaPedido.idDomicilio | 890 | id: $scope.notaPedido.idDomicilio |
| 872 | }; | 891 | }; |
| 873 | } | 892 | } |
| 874 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 893 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
| 875 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 894 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
| 876 | $scope.$broadcast('cleanCabecera'); | 895 | $scope.$broadcast('cleanCabecera'); |
| 877 | 896 | ||
| 878 | var cabeceras = []; | 897 | var cabeceras = []; |
| 879 | 898 | ||
| 880 | if (notaPedido.cotizacion.moneda.CODIGO_AFIP !== 'PES') { | 899 | if (notaPedido.cotizacion.moneda.CODIGO_AFIP !== 'PES') { |
| 881 | cabeceras.push({ | 900 | cabeceras.push({ |
| 882 | label: 'Moneda:', | 901 | label: 'Moneda:', |
| 883 | valor: notaPedido.cotizacion.moneda.DETALLE | 902 | valor: notaPedido.cotizacion.moneda.DETALLE |
| 884 | }); | 903 | }); |
| 885 | cabeceras.push({ | 904 | cabeceras.push({ |
| 886 | label: 'Fecha cotizacion:', | 905 | label: 'Fecha cotizacion:', |
| 887 | valor: $filter('date')(notaPedido.cotizacion.FECHA, | 906 | valor: $filter('date')(notaPedido.cotizacion.FECHA, |
| 888 | 'dd/MM/yyyy') | 907 | 'dd/MM/yyyy') |
| 889 | }); | 908 | }); |
| 890 | cabeceras.push({ | 909 | cabeceras.push({ |
| 891 | label: 'Cotizacion:', | 910 | label: 'Cotizacion:', |
| 892 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, | 911 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, |
| 893 | '2') | 912 | '2') |
| 894 | }); | 913 | }); |
| 895 | } | 914 | } |
| 896 | 915 | ||
| 897 | if (notaPedido.cotizacion.moneda) { | 916 | if (notaPedido.cotizacion.moneda) { |
| 898 | $filter('filter')($scope.botonera, { label: 'Moneda'})[0].checked = true; | 917 | $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; |
| 899 | } | 918 | } |
| 900 | 919 | ||
| 901 | if (notaPedido.vendedor.NUM) { | 920 | if (notaPedido.vendedor.NUM) { |
| 902 | cabeceras.push({ | 921 | cabeceras.push({ |
| 903 | label: 'Vendedor:', | 922 | label: 'Vendedor:', |
| 904 | valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + | 923 | valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + |
| 905 | ' - ' + notaPedido.vendedor.NOM | 924 | ' - ' + notaPedido.vendedor.NOM |
| 906 | }); | 925 | }); |
| 907 | } | 926 | } |
| 908 | 927 | ||
| 909 | if (notaPedido.cliente.COD) { | 928 | if (notaPedido.cliente.COD) { |
| 910 | cabeceras.push({ | 929 | cabeceras.push({ |
| 911 | label: 'Cliente:', | 930 | label: 'Cliente:', |
| 912 | valor: notaPedido.cliente.NOM | 931 | valor: notaPedido.cliente.NOM |
| 913 | }); | 932 | }); |
| 914 | cabeceras.push({ | 933 | cabeceras.push({ |
| 915 | label: 'Domicilio:', | 934 | label: 'Domicilio:', |
| 916 | valor: notaPedido.domicilioStamp | 935 | valor: notaPedido.domicilioStamp |
| 917 | }); | 936 | }); |
| 918 | 937 | ||
| 919 | $filter('filter')($scope.botonera, { label: 'Cliente'})[0].checked = true; | 938 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; |
| 920 | } | 939 | } |
| 921 | 940 | ||
| 922 | if (notaPedido.proveedor.COD) { | 941 | if (notaPedido.proveedor.COD) { |
| 923 | cabeceras.push({ | 942 | cabeceras.push({ |
| 924 | label: 'Proveedor:', | 943 | label: 'Proveedor:', |
| 925 | valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) + | 944 | valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) + |
| 926 | ' - ' + notaPedido.proveedor.NOM | 945 | ' - ' + notaPedido.proveedor.NOM |
| 927 | }); | 946 | }); |
| 928 | 947 | ||
| 929 | $filter('filter')($scope.botonera, { label: 'Proveedor'})[0].checked = true; | 948 | $filter('filter')($scope.botonera, { label: 'Proveedor' })[0].checked = true; |
| 930 | } | 949 | } |
| 931 | 950 | ||
| 932 | if (notaPedido.notaPedidoPlazo.length) { | 951 | if (notaPedido.notaPedidoPlazo.length) { |
| 933 | cabeceras.push({ | 952 | cabeceras.push({ |
| 934 | label: 'Precios y condiciones:', | 953 | label: 'Precios y condiciones:', |
| 935 | valor: valorPrecioCondicion() + ' ' + | 954 | valor: valorPrecioCondicion() + ' ' + |
| 936 | notaPedidoBusinessService | 955 | notaPedidoBusinessService |
| 937 | .plazoToString(notaPedido.notaPedidoPlazo) | 956 | .plazoToString(notaPedido.notaPedidoPlazo) |
| 938 | }); | 957 | }); |
| 939 | 958 | ||
| 940 | $filter('filter')($scope.botonera, | 959 | $filter('filter')($scope.botonera, |
| 941 | { label: 'Precios y condiciones'})[0].checked = true; | 960 | { label: 'Precios y condiciones' })[0].checked = true; |
| 942 | } | 961 | } |
| 943 | 962 | ||
| 944 | if (notaPedido.flete !== undefined) { | 963 | if (notaPedido.flete !== undefined) { |
| 945 | cabeceras.push({ | 964 | cabeceras.push({ |
| 946 | label: 'Flete:', | 965 | label: 'Flete:', |
| 947 | valor: notaPedido.fob === 1 ? 'FOB' : ( | 966 | valor: notaPedido.fob === 1 ? 'FOB' : ( |
| 948 | notaPedido.flete === 1 ? 'Si' : 'No') | 967 | notaPedido.flete === 1 ? 'Si' : 'No') |
| 949 | }); | 968 | }); |
| 950 | } | 969 | } |
| 951 | 970 | ||
| 952 | function valorPrecioCondicion() { | 971 | function valorPrecioCondicion() { |
| 953 | if (notaPedido.idPrecioCondicion > 0) { | 972 | if (notaPedido.idPrecioCondicion > 0) { |
| 954 | return notaPedido.precioCondicion.nombre; | 973 | return notaPedido.precioCondicion.nombre; |
| 955 | } else { | 974 | } else { |
| 956 | return 'Ingreso Manual'; | 975 | return 'Ingreso Manual'; |
| 957 | } | 976 | } |
| 958 | } | 977 | } |
| 959 | 978 | ||
| 960 | if (notaPedido.flete === 1) { | 979 | if (notaPedido.flete === 1) { |
| 961 | var cabeceraBomba = { | 980 | var cabeceraBomba = { |
| 962 | label: 'Bomba:', | 981 | label: 'Bomba:', |
| 963 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 982 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
| 964 | }; | 983 | }; |
| 965 | if (notaPedido.kilometros) { | 984 | if (notaPedido.kilometros) { |
| 966 | var cabeceraKilometros = { | 985 | var cabeceraKilometros = { |
| 967 | label: 'Kilometros:', | 986 | label: 'Kilometros:', |
| 968 | valor: notaPedido.kilometros | 987 | valor: notaPedido.kilometros |
| 969 | }; | 988 | }; |
| 970 | cabeceras.push(cabeceraKilometros); | 989 | cabeceras.push(cabeceraKilometros); |
| 971 | } | 990 | } |
| 972 | cabeceras.push(cabeceraBomba); | 991 | cabeceras.push(cabeceraBomba); |
| 973 | } | 992 | } |
| 974 | 993 | ||
| 975 | if (notaPedido.idPrecioCondicion > 0) { | 994 | if (notaPedido.idPrecioCondicion > 0) { |
| 976 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | 995 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; |
| 977 | } else if (notaPedido.idPrecioCondicion) { | 996 | } else if (notaPedido.idPrecioCondicion) { |
| 978 | $scope.idLista = -1; | 997 | $scope.idLista = -1; |
| 979 | } | 998 | } |
| 980 | 999 | ||
| 981 | $scope.puntoVenta = $filter('rellenarDigitos')( | 1000 | $scope.puntoVenta = $filter('rellenarDigitos')( |
| 982 | notaPedido.sucursal, 4 | 1001 | notaPedido.sucursal, 4 |
| 983 | ); | 1002 | ); |
| 984 | 1003 | ||
| 985 | $scope.comprobante = $filter('rellenarDigitos')( | 1004 | $scope.comprobante = $filter('rellenarDigitos')( |
| 986 | notaPedido.numeroNotaPedido, 8 | 1005 | notaPedido.numeroNotaPedido, 8 |
| 987 | ); | 1006 | ); |
| 988 | 1007 | ||
| 989 | if (notaPedido.notaPedidoPuntoDescarga.length) { | 1008 | if (notaPedido.notaPedidoPuntoDescarga.length) { |
| 990 | var puntos = []; | 1009 | var puntos = []; |
| 991 | notaPedido.notaPedidoPuntoDescarga.forEach(function(notaPedidoPuntoDescarga) { | 1010 | notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedidoPuntoDescarga) { |
| 992 | puntos.push(notaPedidoPuntoDescarga.puntoDescarga); | 1011 | puntos.push(notaPedidoPuntoDescarga.puntoDescarga); |
| 993 | }); | 1012 | }); |
| 994 | cabeceras.push({ | 1013 | cabeceras.push({ |
| 995 | label: 'Puntos de descarga: ', | 1014 | label: 'Puntos de descarga: ', |
| 996 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) | 1015 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) |
| 997 | }); | 1016 | }); |
| 998 | } | 1017 | } |
| 999 | 1018 | ||
| 1000 | if ($scope.notaPedido.articulosNotaPedido.length) { | 1019 | if ($scope.notaPedido.articulosNotaPedido.length) { |
| 1001 | $scope.notaPedido.articulosNotaPedido.forEach(function (articulo) { | 1020 | $scope.notaPedido.articulosNotaPedido.forEach(function (articulo) { |
| 1002 | articulo.precio = | 1021 | articulo.precio = |
| 1003 | (articulo.precio / $scope.notaPedido.cotizacion.VENDEDOR).toFixed(4); | 1022 | (articulo.precio / $scope.notaPedido.cotizacion.VENDEDOR).toFixed(4); |
| 1004 | }); | 1023 | }); |
| 1005 | } | 1024 | } |
| 1006 | 1025 | ||
| 1007 | addArrayCabecera(cabeceras); | 1026 | addArrayCabecera(cabeceras); |
| 1008 | } | 1027 | } |
| 1009 | 1028 | ||
| 1010 | function getCabeceraPuntoDescarga(puntoDescarga) { | 1029 | function getCabeceraPuntoDescarga(puntoDescarga) { |
| 1011 | var puntosStamp = ''; | 1030 | var puntosStamp = ''; |
| 1012 | puntoDescarga.forEach(function(punto, idx, arr) { | 1031 | puntoDescarga.forEach(function (punto, idx, arr) { |
| 1013 | puntosStamp += punto.descripcion; | 1032 | puntosStamp += punto.descripcion; |
| 1014 | if ((idx + 1) !== arr.length) puntosStamp += ', '; | 1033 | if ((idx + 1) !== arr.length) puntosStamp += ', '; |
| 1015 | }); | 1034 | }); |
| 1016 | return puntosStamp; | 1035 | return puntosStamp; |
| 1017 | } | 1036 | } |
| 1018 | 1037 | ||
| 1019 | function addArrayCabecera(array) { | 1038 | function addArrayCabecera(array) { |
| 1020 | for (var i = 0; i < array.length; i++) { | 1039 | for (var i = 0; i < array.length; i++) { |
| 1021 | $scope.$broadcast('addCabecera', { | 1040 | $scope.$broadcast('addCabecera', { |
| 1022 | label: array[i].label, | 1041 | label: array[i].label, |
| 1023 | valor: array[i].valor | 1042 | valor: array[i].valor |
| 1024 | }); | 1043 | }); |
| 1025 | } | 1044 | } |
| 1026 | } | 1045 | } |
| 1027 | 1046 | ||
| 1028 | function validarNotaRemitada() { | 1047 | function validarNotaRemitada() { |
| 1029 | if (!$scope.notaPedido.idRemito) { | 1048 | if (!$scope.notaPedido.idRemito) { |
| 1030 | return true; | 1049 | return true; |
| 1031 | } else { | 1050 | } else { |
| 1032 | focaModalService.alert('No se puede editar una nota de pedido remitada'); | 1051 | focaModalService.alert('No se puede editar una nota de pedido remitada'); |
| 1033 | return false; | 1052 | return false; |
| 1034 | } | 1053 | } |
| 1035 | } | 1054 | } |
| 1036 | 1055 | ||
| 1037 | function salir() { | 1056 | function salir() { |
| 1038 | var confirmacion = false; | 1057 | var confirmacion = false; |
| 1039 | 1058 | ||
| 1040 | if (!angular.equals($scope.notaPedido, $scope.inicial)) { | 1059 | if (!angular.equals($scope.notaPedido, $scope.inicial)) { |
| 1041 | confirmacion = true; | 1060 | confirmacion = true; |
| 1042 | } | 1061 | } |
| 1043 | 1062 | ||
| 1044 | if (confirmacion) { | 1063 | if (confirmacion) { |
| 1045 | focaModalService.confirm( | 1064 | focaModalService.confirm( |
| 1046 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 1065 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
| 1047 | ).then(function(data) { | 1066 | ).then(function (data) { |
| 1048 | if (data) { | 1067 | if (data) { |
| 1049 | $location.path('/'); | 1068 | $location.path('/'); |
| 1050 | } | 1069 | } |
| 1051 | }); | 1070 | }); |
| 1052 | } else { | 1071 | } else { |
| 1053 | $location.path('/'); | 1072 | $location.path('/'); |
| 1054 | } | 1073 | } |
| 1055 | } | 1074 | } |
| 1056 | 1075 | ||
| 1057 | function getLSNotaPedido() { | 1076 | function getLSNotaPedido() { |
| 1058 | var notaPedido = JSON.parse($localStorage.notaPedido || null); | 1077 | var notaPedido = JSON.parse($localStorage.notaPedido || null); |
| 1059 | if (notaPedido) { | 1078 | if (notaPedido) { |
| 1060 | delete $localStorage.notaPedido; | 1079 | delete $localStorage.notaPedido; |
| 1061 | setearNotaPedido(notaPedido); | 1080 | setearNotaPedido(notaPedido); |
| 1062 | } | 1081 | } |
| 1063 | } | 1082 | } |
| 1064 | 1083 | ||
| 1065 | function deleteCliente() { | 1084 | function deleteCliente() { |
| 1066 | $scope.notaPedido.domicilioStamp = ''; | 1085 | $scope.notaPedido.domicilioStamp = ''; |
| 1067 | $scope.notaPedido.notaPedidoPuntoDescarga = []; | 1086 | $scope.notaPedido.notaPedidoPuntoDescarga = []; |
src/js/service.js
| 1 | angular.module('focaCrearNotaPedido') | 1 | angular.module('focaCrearNotaPedido') |
| 2 | .factory('crearNotaPedidoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | 2 | .factory('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: plazos}); | 47 | return $http.post(route + '/plazo-pago/nota-pedido', {plazos: plazos}); |
| 48 | }, | 48 | }, |
| 49 | getCotizacionByIdMoneda: function(id) { | 49 | getCotizacionByIdMoneda: function(id) { |
| 50 | return $http.get(route + '/moneda/' + id); | 50 | return $http.get(route + '/moneda/' + id); |
| 51 | }, | 51 | }, |
| 52 | crearEstadoParaNotaPedido: function(estado) { | 52 | crearEstadoParaNotaPedido: function(estado) { |
| 53 | return $http.post(route + '/estado', {estado: estado}); | 53 | return $http.post(route + '/estado', {estado: estado}); |
| 54 | }, | 54 | }, |
| 55 | getNumeroNotaPedido: function() { | 55 | getNumeroNotaPedido: function() { |
| 56 | return $http.get(route + '/nota-pedido/numero-siguiente'); | 56 | return $http.get(route + '/nota-pedido/numero-siguiente'); |
| 57 | }, | 57 | }, |
| 58 | getBotonera: function() { | 58 | getBotonera: function() { |
| 59 | var result = [ | 59 | var result = [ |
| 60 | { | 60 | { |
| 61 | label: 'Cliente', | 61 | label: 'Cliente', |
| 62 | image: 'cliente.png' | 62 | image: 'cliente.png' |
| 63 | }, | 63 | }, |
| 64 | { | 64 | { |
| 65 | label: 'Proveedor', | 65 | label: 'Proveedor', |
| 66 | image: 'proveedor.png' | 66 | image: 'proveedor.png' |
| 67 | }, | 67 | }, |
| 68 | { | 68 | { |
| 69 | label: 'Moneda', | 69 | label: 'Moneda', |
| 70 | image: 'moneda.png' | 70 | image: 'moneda.png' |
| 71 | }, | 71 | }, |
| 72 | { | 72 | { |
| 73 | label: 'Precios y condiciones', | 73 | label: 'Precios y condiciones', |
| 74 | image: 'precios-condiciones.png' | 74 | image: 'precios-condiciones.png' |
| 75 | }, | 75 | }, |
| 76 | { | 76 | { |
| 77 | label: 'Productos', | 77 | label: 'Productos', |
| 78 | image: 'productos.png' | 78 | image: 'productos.png' |
| 79 | }, | 79 | }, |
| 80 | { | 80 | { |
| 81 | label: 'Observaciones', | 81 | label: 'Observaciones', |
| 82 | image: 'botonObservaciones.png' | 82 | image: 'botonObservaciones.png' |
| 83 | } | 83 | } |
| 84 | ]; | 84 | ]; |
| 85 | return result; | 85 | return result; |
| 86 | }, | 86 | }, |
| 87 | crearPuntosDescarga: function(puntosDescarga) { | 87 | crearPuntosDescarga: function(puntosDescarga) { |
| 88 | return $http.post(route + '/puntos-descarga/nota-pedido', | 88 | return $http.post(route + '/puntos-descarga/nota-pedido', |
| 89 | {puntosDescarga: puntosDescarga}); | 89 | {puntosDescarga: puntosDescarga}); |
| 90 | }, | 90 | }, |
| 91 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { | 91 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { |
| 92 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + | 92 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + |
| 93 | idDomicilio + '/' + idCliente); | 93 | idDomicilio + '/' + idCliente); |
| 94 | }, | 94 | }, |
| 95 | getVendedorById: function(id) { | 95 | getVendedorById: function(id) { |
| 96 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + id); | 96 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + id); |
| 97 | }, | 97 | }, |
| 98 | getProveedorById: function(id) { | 98 | getProveedorById: function(id) { |
| 99 | return $http.get(API_ENDPOINT.URL + '/proveedor/' + id); | 99 | return $http.get(API_ENDPOINT.URL + '/proveedor/' + id); |
| 100 | }, | 100 | }, |
| 101 | getParametros: function() { | 101 | getParametros: function() { |
| 102 | return $http.get(API_ENDPOINT.URL + '/parametros/' + 'notaPedido') | 102 | return $http.get(API_ENDPOINT.URL + '/parametros/' + 'notaPedido'); |
| 103 | } | 103 | } |
| 104 | }; | 104 | }; |
| 105 | }]); | 105 | }]); |
| 106 | 106 |