Commit 61b7b43e98f026a4ec256a7262dac40c0e61fa70
1 parent
36341c07ee
Exists in
master
guardo domicilio id
Showing
2 changed files
with
3 additions
and
3 deletions
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 git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git" | 11 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+https://debo.suite.repo/modulos-npm/foca-directivas.git git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git git+https://debo.suite.repo/modulos-npm/foca-modal-flete git+https://debo.suite.repo/modulos-npm/foca-modal.git git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git" |
12 | }, | 12 | }, |
13 | "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": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", | 25 | "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", |
26 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", | 26 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", |
27 | "foca-modal-cotizacion": "git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git", | 27 | "foca-modal-cotizacion": "git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git", |
28 | "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", | 28 | "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", |
29 | "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete", | 29 | "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete", |
30 | "foca-modal-moneda": "git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git", | 30 | "foca-modal-moneda": "git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git", |
31 | "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", | 31 | "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", |
32 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", | 32 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", |
33 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", | 33 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", |
34 | "foca-seguimiento": "git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git" | 34 | "foca-seguimiento": "git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git" |
35 | }, | 35 | }, |
36 | "devDependencies": { | 36 | "devDependencies": { |
37 | "angular": "^1.7.5", | 37 | "angular": "^1.7.5", |
38 | "angular-ladda": "^0.4.3", | 38 | "angular-ladda": "^0.4.3", |
39 | "angular-route": "^1.7.5", | 39 | "angular-route": "^1.7.5", |
40 | "bootstrap": "^4.1.3", | 40 | "bootstrap": "^4.1.3", |
41 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", | 41 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", |
42 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", | 42 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", |
43 | "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", | 43 | "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", |
44 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", | 44 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", |
45 | "foca-modal-cotizacion": "git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git", | 45 | "foca-modal-cotizacion": "git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git", |
46 | "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", | 46 | "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", |
47 | "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete", | 47 | "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete", |
48 | "foca-modal-moneda": "git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git", | 48 | "foca-modal-moneda": "git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git", |
49 | "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", | 49 | "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", |
50 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", | 50 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", |
51 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", | 51 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", |
52 | "foca-seguimiento": "git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git", | 52 | "foca-seguimiento": "git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git", |
53 | "font-awesome": "^4.7.0", | 53 | "font-awesome": "^4.7.0", |
54 | "gulp": "^3.9.1", | 54 | "gulp": "^3.9.1", |
55 | "gulp-angular-templatecache": "^2.2.3", | 55 | "gulp-angular-templatecache": "^2.2.5", |
56 | "gulp-clean": "^0.4.0", | 56 | "gulp-clean": "^0.4.0", |
57 | "gulp-concat": "^2.6.1", | 57 | "gulp-concat": "^2.6.1", |
58 | "gulp-connect": "^5.6.1", | 58 | "gulp-connect": "^5.6.1", |
59 | "gulp-htmlmin": "^5.0.1", | 59 | "gulp-htmlmin": "^5.0.1", |
60 | "gulp-jshint": "^2.1.0", | 60 | "gulp-jshint": "^2.1.0", |
61 | "gulp-rename": "^1.4.0", | 61 | "gulp-rename": "^1.4.0", |
62 | "gulp-replace": "^1.0.0", | 62 | "gulp-replace": "^1.0.0", |
63 | "gulp-sequence": "^1.0.0", | 63 | "gulp-sequence": "^1.0.0", |
64 | "gulp-uglify": "^3.0.1", | 64 | "gulp-uglify": "^3.0.1", |
65 | "gulp-uglify-es": "^1.0.4", | 65 | "gulp-uglify-es": "^1.0.4", |
66 | "jasmine-core": "^3.3.0", | 66 | "jasmine-core": "^3.3.0", |
67 | "jquery": "^3.3.1", | 67 | "jquery": "^3.3.1", |
68 | "jshint": "^2.9.6", | 68 | "jshint": "^2.9.6", |
69 | "ladda": "1.0.6", | 69 | "ladda": "1.0.6", |
70 | "pre-commit": "^1.2.2", | 70 | "pre-commit": "^1.2.2", |
71 | "pump": "^3.0.0", | 71 | "pump": "^3.0.0", |
72 | "ui-bootstrap4": "^3.0.5" | 72 | "ui-bootstrap4": "^3.0.5" |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 |
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', 'focaSeguimientoService', 'notaPedidoBusinessService', | 4 | 'focaModalService', 'focaSeguimientoService', 'notaPedidoBusinessService', |
5 | '$rootScope', | 5 | '$rootScope', |
6 | function( | 6 | function( |
7 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService, | 7 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService, |
8 | focaSeguimientoService, notaPedidoBusinessService, $rootScope | 8 | focaSeguimientoService, notaPedidoBusinessService, $rootScope |
9 | ) { | 9 | ) { |
10 | $scope.botonera = [ | 10 | $scope.botonera = [ |
11 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, | 11 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, |
12 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | 12 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
13 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, | 13 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, |
14 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | 14 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, |
15 | { | 15 | { |
16 | texto: 'Precios y condiciones', | 16 | texto: 'Precios y condiciones', |
17 | accion: function() {$scope.abrirModalListaPrecio();}}, | 17 | accion: function() {$scope.abrirModalListaPrecio();}}, |
18 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | 18 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, |
19 | {texto: '', accion: function() {}}, | 19 | {texto: '', accion: function() {}}, |
20 | {texto: '', accion: function() {}} | 20 | {texto: '', accion: function() {}} |
21 | ]; | 21 | ]; |
22 | $scope.datepickerAbierto = false; | 22 | $scope.datepickerAbierto = false; |
23 | 23 | ||
24 | $scope.show = false; | 24 | $scope.show = false; |
25 | $scope.cargando = true; | 25 | $scope.cargando = true; |
26 | $scope.dateOptions = { | 26 | $scope.dateOptions = { |
27 | maxDate: new Date(), | 27 | maxDate: new Date(), |
28 | minDate: new Date(2010, 0, 1) | 28 | minDate: new Date(2010, 0, 1) |
29 | }; | 29 | }; |
30 | 30 | ||
31 | $scope.notaPedido = { | 31 | $scope.notaPedido = { |
32 | vendedor: {}, | 32 | vendedor: {}, |
33 | cliente: {}, | 33 | cliente: {}, |
34 | proveedor: {}, | 34 | proveedor: {}, |
35 | domicilio: {dom: ''}, | 35 | domicilio: {dom: ''}, |
36 | moneda: {}, | 36 | moneda: {}, |
37 | cotizacion: {} | 37 | cotizacion: {} |
38 | }; | 38 | }; |
39 | var monedaPorDefecto; | 39 | var monedaPorDefecto; |
40 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 40 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
41 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | 41 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { |
42 | monedaPorDefecto = { | 42 | monedaPorDefecto = { |
43 | id: res.data[0].ID, | 43 | id: res.data[0].ID, |
44 | detalle: res.data[0].DETALLE, | 44 | detalle: res.data[0].DETALLE, |
45 | simbolo: res.data[0].SIMBOLO, | 45 | simbolo: res.data[0].SIMBOLO, |
46 | cotizaciones: res.data[0].cotizaciones | 46 | cotizaciones: res.data[0].cotizaciones |
47 | }; | 47 | }; |
48 | addCabecera('Moneda:', monedaPorDefecto.detalle); | 48 | addCabecera('Moneda:', monedaPorDefecto.detalle); |
49 | addCabecera('Fecha cotizacion:', | 49 | addCabecera('Fecha cotizacion:', |
50 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | 50 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); |
51 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].VENDEDOR); | 51 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].VENDEDOR); |
52 | $scope.notaPedido.moneda = monedaPorDefecto; | 52 | $scope.notaPedido.moneda = monedaPorDefecto; |
53 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; | 53 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; |
54 | }); | 54 | }); |
55 | 55 | ||
56 | $scope.cabecera = []; | 56 | $scope.cabecera = []; |
57 | $scope.showCabecera = true; | 57 | $scope.showCabecera = true; |
58 | 58 | ||
59 | $scope.now = new Date(); | 59 | $scope.now = new Date(); |
60 | $scope.puntoVenta = '0000'; | 60 | $scope.puntoVenta = '0000'; |
61 | $scope.comprobante = '00000000'; | 61 | $scope.comprobante = '00000000'; |
62 | $scope.articulosTabla = []; | 62 | $scope.articulosTabla = []; |
63 | $scope.idLista = undefined; | 63 | $scope.idLista = undefined; |
64 | //La pantalla solo se usa para cargar pedidos | 64 | //La pantalla solo se usa para cargar pedidos |
65 | //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | 65 | //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
66 | 66 | ||
67 | crearNotaPedidoService.getPrecioCondicion().then( | 67 | crearNotaPedidoService.getPrecioCondicion().then( |
68 | function(res) { | 68 | function(res) { |
69 | $scope.precioCondiciones = res.data; | 69 | $scope.precioCondiciones = res.data; |
70 | } | 70 | } |
71 | ); | 71 | ); |
72 | 72 | ||
73 | crearNotaPedidoService.getNumeroNotaPedido().then( | 73 | crearNotaPedidoService.getNumeroNotaPedido().then( |
74 | function(res) { | 74 | function(res) { |
75 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 75 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
76 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); | 76 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); |
77 | }, | 77 | }, |
78 | function(err) { | 78 | function(err) { |
79 | focaModalService.alert('La terminal no esta configurada correctamente'); | 79 | focaModalService.alert('La terminal no esta configurada correctamente'); |
80 | console.info(err); | 80 | console.info(err); |
81 | } | 81 | } |
82 | ); | 82 | ); |
83 | //La pantalla solo se usa para cargar pedidos | 83 | //La pantalla solo se usa para cargar pedidos |
84 | // if (notaPedidoTemp !== undefined) { | 84 | // if (notaPedidoTemp !== undefined) { |
85 | // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | 85 | // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
86 | // $scope.notaPedido = notaPedidoTemp; | 86 | // $scope.notaPedido = notaPedidoTemp; |
87 | // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | 87 | // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
88 | // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | 88 | // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
89 | // $scope.idLista = $scope.notaPedido.precioCondicion; | 89 | // $scope.idLista = $scope.notaPedido.precioCondicion; |
90 | // crearNotaPedidoService | 90 | // crearNotaPedidoService |
91 | // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | 91 | // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
92 | // function(res) { | 92 | // function(res) { |
93 | // $scope.articulosTabla = res.data; | 93 | // $scope.articulosTabla = res.data; |
94 | // } | 94 | // } |
95 | // ); | 95 | // ); |
96 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | 96 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
97 | //(NO REQUERIDO EN ESTA VERSION) | 97 | //(NO REQUERIDO EN ESTA VERSION) |
98 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 98 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
99 | // function(res) { | 99 | // function(res) { |
100 | // $scope.notaPedido.domicilio = res.data; | 100 | // $scope.notaPedido.domicilio = res.data; |
101 | // } | 101 | // } |
102 | // ); | 102 | // ); |
103 | // } else { | 103 | // } else { |
104 | // $scope.notaPedido.fechaCarga = new Date(); | 104 | // $scope.notaPedido.fechaCarga = new Date(); |
105 | // $scope.notaPedido.bomba = '0'; | 105 | // $scope.notaPedido.bomba = '0'; |
106 | // $scope.notaPedido.flete = '0'; | 106 | // $scope.notaPedido.flete = '0'; |
107 | // $scope.idLista = undefined; | 107 | // $scope.idLista = undefined; |
108 | // } | 108 | // } |
109 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 109 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
110 | // $scope.addNewDom = function() { | 110 | // $scope.addNewDom = function() { |
111 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); | 111 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); |
112 | // }; | 112 | // }; |
113 | // $scope.removeNewChoice = function(choice) { | 113 | // $scope.removeNewChoice = function(choice) { |
114 | // if ($scope.notaPedido.domicilio.length > 1) { | 114 | // if ($scope.notaPedido.domicilio.length > 1) { |
115 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | 115 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
116 | // function(c) { | 116 | // function(c) { |
117 | // return c.$$hashKey === choice.$$hashKey; | 117 | // return c.$$hashKey === choice.$$hashKey; |
118 | // } | 118 | // } |
119 | // ), 1); | 119 | // ), 1); |
120 | // } | 120 | // } |
121 | // }; | 121 | // }; |
122 | 122 | ||
123 | $scope.crearNotaPedido = function() { | 123 | $scope.crearNotaPedido = function() { |
124 | if(!$scope.notaPedido.vendedor.codigo) { | 124 | if(!$scope.notaPedido.vendedor.codigo) { |
125 | focaModalService.alert('Ingrese Vendedor'); | 125 | focaModalService.alert('Ingrese Vendedor'); |
126 | return; | 126 | return; |
127 | } else if(!$scope.notaPedido.cliente.cod) { | 127 | } else if(!$scope.notaPedido.cliente.cod) { |
128 | focaModalService.alert('Ingrese Cliente'); | 128 | focaModalService.alert('Ingrese Cliente'); |
129 | return; | 129 | return; |
130 | } else if(!$scope.notaPedido.proveedor.codigo) { | 130 | } else if(!$scope.notaPedido.proveedor.codigo) { |
131 | focaModalService.alert('Ingrese Proveedor'); | 131 | focaModalService.alert('Ingrese Proveedor'); |
132 | return; | 132 | return; |
133 | } else if(!$scope.notaPedido.moneda.id) { | 133 | } else if(!$scope.notaPedido.moneda.id) { |
134 | focaModalService.alert('Ingrese Moneda'); | 134 | focaModalService.alert('Ingrese Moneda'); |
135 | return; | 135 | return; |
136 | } else if(!$scope.notaPedido.cotizacion.ID) { | 136 | } else if(!$scope.notaPedido.cotizacion.ID) { |
137 | focaModalService.alert('Ingrese Cotización'); | 137 | focaModalService.alert('Ingrese Cotización'); |
138 | return; | 138 | return; |
139 | } else if(!$scope.plazosPagos) { | 139 | } else if(!$scope.plazosPagos) { |
140 | focaModalService.alert('Ingrese Precios y Condiciones'); | 140 | focaModalService.alert('Ingrese Precios y Condiciones'); |
141 | return; | 141 | return; |
142 | } else if( | 142 | } else if( |
143 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) | 143 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) |
144 | { | 144 | { |
145 | focaModalService.alert('Ingrese Flete'); | 145 | focaModalService.alert('Ingrese Flete'); |
146 | return; | 146 | return; |
147 | } else if(!$scope.notaPedido.domicilio.id) { | 147 | } else if(!$scope.notaPedido.domicilio.id) { |
148 | focaModalService.alert('Ingrese Domicilio'); | 148 | focaModalService.alert('Ingrese Domicilio'); |
149 | return; | 149 | return; |
150 | } else if($scope.articulosTabla.length === 0) { | 150 | } else if($scope.articulosTabla.length === 0) { |
151 | focaModalService.alert('Debe cargar al menos un articulo'); | 151 | focaModalService.alert('Debe cargar al menos un articulo'); |
152 | return; | 152 | return; |
153 | } | 153 | } |
154 | var date = new Date(); | 154 | var date = new Date(); |
155 | var notaPedido = { | 155 | var notaPedido = { |
156 | id: 0, | 156 | id: 0, |
157 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 157 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
158 | .toISOString().slice(0, 19).replace('T', ' '), | 158 | .toISOString().slice(0, 19).replace('T', ' '), |
159 | idVendedor: $scope.notaPedido.vendedor.codigo, | 159 | idVendedor: $scope.notaPedido.vendedor.codigo, |
160 | idCliente: $scope.notaPedido.cliente.cod, | 160 | idCliente: $scope.notaPedido.cliente.cod, |
161 | nombreCliente: $scope.notaPedido.cliente.nom, | 161 | nombreCliente: $scope.notaPedido.cliente.nom, |
162 | cuitCliente: $scope.notaPedido.cliente.cuit, | 162 | cuitCliente: $scope.notaPedido.cliente.cuit, |
163 | idProveedor: $scope.notaPedido.proveedor.codigo, | 163 | idProveedor: $scope.notaPedido.proveedor.codigo, |
164 | idDomicilio: $scope.notaPedido.domicilio.id, | 164 | idDomicilio: $scope.notaPedido.domicilio.id, |
165 | idCotizacion: $scope.notaPedido.cotizacion.ID, | 165 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
166 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 166 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
167 | flete: $scope.notaPedido.flete, | 167 | flete: $scope.notaPedido.flete, |
168 | fob: $scope.notaPedido.fob, | 168 | fob: $scope.notaPedido.fob, |
169 | bomba: $scope.notaPedido.bomba, | 169 | bomba: $scope.notaPedido.bomba, |
170 | kilometros: $scope.notaPedido.kilometros, | 170 | kilometros: $scope.notaPedido.kilometros, |
171 | estado: 0, | 171 | estado: 0, |
172 | total: $scope.getTotal() | 172 | total: $scope.getTotal() |
173 | }; | 173 | }; |
174 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 174 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
175 | function(data) { | 175 | function(data) { |
176 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, | 176 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, |
177 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); | 177 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); |
178 | focaSeguimientoService.guardarPosicion('crear nota pedido', ''); | 178 | focaSeguimientoService.guardarPosicion('crear nota pedido', ''); |
179 | var plazos = $scope.plazosPagos; | 179 | var plazos = $scope.plazosPagos; |
180 | 180 | ||
181 | for(var j = 0; j < plazos.length; j++) { | 181 | for(var j = 0; j < plazos.length; j++) { |
182 | var json = { | 182 | var json = { |
183 | idPedido: data.data.id, | 183 | idPedido: data.data.id, |
184 | dias: plazos[j].dias | 184 | dias: plazos[j].dias |
185 | }; | 185 | }; |
186 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); | 186 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); |
187 | } | 187 | } |
188 | notaPedidoBusinessService.addEstado(data.data.id, | 188 | notaPedidoBusinessService.addEstado(data.data.id, |
189 | $scope.notaPedido.vendedor.codigo); | 189 | $scope.notaPedido.vendedor.codigo); |
190 | 190 | ||
191 | focaModalService.alert('Nota pedido creada'); | 191 | focaModalService.alert('Nota pedido creada'); |
192 | $scope.cabecera = []; | 192 | $scope.cabecera = []; |
193 | addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); | 193 | addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); |
194 | addCabecera( | 194 | addCabecera( |
195 | 'Fecha cotizacion:', | 195 | 'Fecha cotizacion:', |
196 | $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') | 196 | $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') |
197 | ); | 197 | ); |
198 | addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.VENDEDOR); | 198 | addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.VENDEDOR); |
199 | $scope.notaPedido.vendedor = {}; | 199 | $scope.notaPedido.vendedor = {}; |
200 | $scope.notaPedido.cliente = {}; | 200 | $scope.notaPedido.cliente = {}; |
201 | $scope.notaPedido.proveedor = {}; | 201 | $scope.notaPedido.proveedor = {}; |
202 | $scope.notaPedido.domicilio = {}; | 202 | $scope.notaPedido.domicilio = {}; |
203 | $scope.notaPedido.flete = null; | 203 | $scope.notaPedido.flete = null; |
204 | $scope.notaPedido.fob = null; | 204 | $scope.notaPedido.fob = null; |
205 | $scope.notaPedido.bomba = null; | 205 | $scope.notaPedido.bomba = null; |
206 | $scope.notaPedido.kilometros = null; | 206 | $scope.notaPedido.kilometros = null; |
207 | $scope.articulosTabla = []; | 207 | $scope.articulosTabla = []; |
208 | }, | 208 | }, |
209 | function(error) { | 209 | function(error) { |
210 | focaModalService.alert('Hubo un error al crear la nota de pedido'); | 210 | focaModalService.alert('Hubo un error al crear la nota de pedido'); |
211 | console.info(error); | 211 | console.info(error); |
212 | } | 212 | } |
213 | ); | 213 | ); |
214 | }; | 214 | }; |
215 | 215 | ||
216 | $scope.seleccionarArticulo = function() { | 216 | $scope.seleccionarArticulo = function() { |
217 | if ($scope.idLista === undefined) { | 217 | if ($scope.idLista === undefined) { |
218 | focaModalService.alert( | 218 | focaModalService.alert( |
219 | 'Primero seleccione una lista de precio y condicion'); | 219 | 'Primero seleccione una lista de precio y condicion'); |
220 | return; | 220 | return; |
221 | } | 221 | } |
222 | var modalInstance = $uibModal.open( | 222 | var modalInstance = $uibModal.open( |
223 | { | 223 | { |
224 | ariaLabelledBy: 'Busqueda de Productos', | 224 | ariaLabelledBy: 'Busqueda de Productos', |
225 | templateUrl: 'modal-busqueda-productos.html', | 225 | templateUrl: 'modal-busqueda-productos.html', |
226 | controller: 'modalBusquedaProductosCtrl', | 226 | controller: 'modalBusquedaProductosCtrl', |
227 | resolve: { | 227 | resolve: { |
228 | parametroProducto: { | 228 | parametroProducto: { |
229 | idLista: $scope.idLista, | 229 | idLista: $scope.idLista, |
230 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 230 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
231 | simbolo: $scope.notaPedido.moneda.simbolo | 231 | simbolo: $scope.notaPedido.moneda.simbolo |
232 | } | 232 | } |
233 | }, | 233 | }, |
234 | size: 'lg' | 234 | size: 'lg' |
235 | } | 235 | } |
236 | ); | 236 | ); |
237 | modalInstance.result.then( | 237 | modalInstance.result.then( |
238 | function(producto) { | 238 | function(producto) { |
239 | var newArt = | 239 | var newArt = |
240 | { | 240 | { |
241 | id: 0, | 241 | id: 0, |
242 | codigo: producto.codigo, | 242 | codigo: producto.codigo, |
243 | sector: producto.sector, | 243 | sector: producto.sector, |
244 | sectorCodigo: producto.sector + '-' + producto.codigo, | 244 | sectorCodigo: producto.sector + '-' + producto.codigo, |
245 | descripcion: producto.descripcion, | 245 | descripcion: producto.descripcion, |
246 | item: $scope.articulosTabla.length + 1, | 246 | item: $scope.articulosTabla.length + 1, |
247 | nombre: producto.descripcion, | 247 | nombre: producto.descripcion, |
248 | precio: parseFloat(producto.precio.toFixed(4)), | 248 | precio: parseFloat(producto.precio.toFixed(4)), |
249 | precioUnitario: producto.costo, | 249 | precioUnitario: producto.costo, |
250 | editCantidad: false, | 250 | editCantidad: false, |
251 | editPrecio: false | 251 | editPrecio: false |
252 | }; | 252 | }; |
253 | $scope.articuloACargar = newArt; | 253 | $scope.articuloACargar = newArt; |
254 | $scope.cargando = false; | 254 | $scope.cargando = false; |
255 | }, function() { | 255 | }, function() { |
256 | // funcion ejecutada cuando se cancela el modal | 256 | // funcion ejecutada cuando se cancela el modal |
257 | } | 257 | } |
258 | ); | 258 | ); |
259 | }; | 259 | }; |
260 | 260 | ||
261 | $scope.seleccionarVendedor = function() { | 261 | $scope.seleccionarVendedor = function() { |
262 | var modalInstance = $uibModal.open( | 262 | var modalInstance = $uibModal.open( |
263 | { | 263 | { |
264 | ariaLabelledBy: 'Busqueda de Vendedores', | 264 | ariaLabelledBy: 'Busqueda de Vendedores', |
265 | templateUrl: 'modal-vendedores.html', | 265 | templateUrl: 'modal-vendedores.html', |
266 | controller: 'modalVendedoresCtrl', | 266 | controller: 'modalVendedoresCtrl', |
267 | size: 'lg' | 267 | size: 'lg' |
268 | } | 268 | } |
269 | ); | 269 | ); |
270 | modalInstance.result.then( | 270 | modalInstance.result.then( |
271 | function(vendedor) { | 271 | function(vendedor) { |
272 | addCabecera('Vendedor:', vendedor.NomVen); | 272 | addCabecera('Vendedor:', vendedor.NomVen); |
273 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; | 273 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; |
274 | }, function() { | 274 | }, function() { |
275 | 275 | ||
276 | } | 276 | } |
277 | ); | 277 | ); |
278 | }; | 278 | }; |
279 | 279 | ||
280 | $scope.seleccionarProveedor = function() { | 280 | $scope.seleccionarProveedor = function() { |
281 | var modalInstance = $uibModal.open( | 281 | var modalInstance = $uibModal.open( |
282 | { | 282 | { |
283 | ariaLabelledBy: 'Busqueda de Proveedor', | 283 | ariaLabelledBy: 'Busqueda de Proveedor', |
284 | templateUrl: 'modal-proveedor.html', | 284 | templateUrl: 'modal-proveedor.html', |
285 | controller: 'focaModalProveedorCtrl', | 285 | controller: 'focaModalProveedorCtrl', |
286 | size: 'lg' | 286 | size: 'lg' |
287 | } | 287 | } |
288 | ); | 288 | ); |
289 | modalInstance.result.then( | 289 | modalInstance.result.then( |
290 | function(proveedor) { | 290 | function(proveedor) { |
291 | $scope.notaPedido.proveedor.codigo = proveedor.COD; | 291 | $scope.notaPedido.proveedor.codigo = proveedor.COD; |
292 | addCabecera('Proveedor:', proveedor.NOM); | 292 | addCabecera('Proveedor:', proveedor.NOM); |
293 | }, function() { | 293 | }, function() { |
294 | 294 | ||
295 | } | 295 | } |
296 | ); | 296 | ); |
297 | }; | 297 | }; |
298 | 298 | ||
299 | $scope.seleccionarCliente = function() { | 299 | $scope.seleccionarCliente = function() { |
300 | 300 | ||
301 | var modalInstance = $uibModal.open( | 301 | var modalInstance = $uibModal.open( |
302 | { | 302 | { |
303 | ariaLabelledBy: 'Busqueda de Cliente', | 303 | ariaLabelledBy: 'Busqueda de Cliente', |
304 | templateUrl: 'foca-busqueda-cliente-modal.html', | 304 | templateUrl: 'foca-busqueda-cliente-modal.html', |
305 | controller: 'focaBusquedaClienteModalController', | 305 | controller: 'focaBusquedaClienteModalController', |
306 | size: 'lg' | 306 | size: 'lg' |
307 | } | 307 | } |
308 | ); | 308 | ); |
309 | modalInstance.result.then( | 309 | modalInstance.result.then( |
310 | function(cliente) { | 310 | function(cliente) { |
311 | $scope.abrirModalDomicilios(cliente); | 311 | $scope.abrirModalDomicilios(cliente); |
312 | }, function() { | 312 | }, function() { |
313 | 313 | ||
314 | } | 314 | } |
315 | ); | 315 | ); |
316 | }; | 316 | }; |
317 | 317 | ||
318 | $scope.abrirModalDomicilios = function(cliente) { | 318 | $scope.abrirModalDomicilios = function(cliente) { |
319 | var modalInstanceDomicilio = $uibModal.open( | 319 | var modalInstanceDomicilio = $uibModal.open( |
320 | { | 320 | { |
321 | ariaLabelledBy: 'Busqueda de Domicilios', | 321 | ariaLabelledBy: 'Busqueda de Domicilios', |
322 | templateUrl: 'modal-domicilio.html', | 322 | templateUrl: 'modal-domicilio.html', |
323 | controller: 'focaModalDomicilioController', | 323 | controller: 'focaModalDomicilioController', |
324 | resolve: { idCliente: function() { return cliente.cod; }}, | 324 | resolve: { idCliente: function() { return cliente.cod; }}, |
325 | size: 'lg', | 325 | size: 'lg', |
326 | } | 326 | } |
327 | ); | 327 | ); |
328 | modalInstanceDomicilio.result.then( | 328 | modalInstanceDomicilio.result.then( |
329 | function(domicilio) { | 329 | function(domicilio) { |
330 | $scope.notaPedido.domicilio.id = domicilio.nivel2; | 330 | $scope.notaPedido.domicilio.id = domicilio.id; |
331 | $scope.notaPedido.cliente = cliente; | 331 | $scope.notaPedido.cliente = cliente; |
332 | 332 | ||
333 | addCabecera('Cliente:', cliente.nom); | 333 | addCabecera('Cliente:', cliente.nom); |
334 | addCabecera('Domicilio:', domicilio.Calle + ' ' + domicilio.Numero); | 334 | addCabecera('Domicilio:', domicilio.Calle + ' ' + domicilio.Numero); |
335 | }, function() { | 335 | }, function() { |
336 | $scope.seleccionarCliente(); | 336 | $scope.seleccionarCliente(); |
337 | return; | 337 | return; |
338 | } | 338 | } |
339 | ); | 339 | ); |
340 | }; | 340 | }; |
341 | 341 | ||
342 | $scope.mostrarFichaCliente = function() { | 342 | $scope.mostrarFichaCliente = function() { |
343 | $uibModal.open( | 343 | $uibModal.open( |
344 | { | 344 | { |
345 | ariaLabelledBy: 'Datos del Cliente', | 345 | ariaLabelledBy: 'Datos del Cliente', |
346 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 346 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
347 | controller: 'focaCrearNotaPedidoFichaClienteController', | 347 | controller: 'focaCrearNotaPedidoFichaClienteController', |
348 | size: 'lg' | 348 | size: 'lg' |
349 | } | 349 | } |
350 | ); | 350 | ); |
351 | }; | 351 | }; |
352 | 352 | ||
353 | $scope.getTotal = function() { | 353 | $scope.getTotal = function() { |
354 | var total = 0; | 354 | var total = 0; |
355 | var arrayTempArticulos = $scope.articulosTabla; | 355 | var arrayTempArticulos = $scope.articulosTabla; |
356 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 356 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
357 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 357 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
358 | } | 358 | } |
359 | return parseFloat(total.toFixed(2)); | 359 | return parseFloat(total.toFixed(2)); |
360 | }; | 360 | }; |
361 | 361 | ||
362 | $scope.getSubTotal = function() { | 362 | $scope.getSubTotal = function() { |
363 | if($scope.articuloACargar) { | 363 | if($scope.articuloACargar) { |
364 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 364 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
365 | } | 365 | } |
366 | }; | 366 | }; |
367 | 367 | ||
368 | $scope.abrirModalListaPrecio = function() { | 368 | $scope.abrirModalListaPrecio = function() { |
369 | var modalInstance = $uibModal.open( | 369 | var modalInstance = $uibModal.open( |
370 | { | 370 | { |
371 | ariaLabelledBy: 'Busqueda de Precio Condición', | 371 | ariaLabelledBy: 'Busqueda de Precio Condición', |
372 | templateUrl: 'modal-precio-condicion.html', | 372 | templateUrl: 'modal-precio-condicion.html', |
373 | controller: 'focaModalPrecioCondicionController', | 373 | controller: 'focaModalPrecioCondicionController', |
374 | size: 'lg' | 374 | size: 'lg' |
375 | } | 375 | } |
376 | ); | 376 | ); |
377 | modalInstance.result.then( | 377 | modalInstance.result.then( |
378 | function(precioCondicion) { | 378 | function(precioCondicion) { |
379 | var cabecera = ''; | 379 | var cabecera = ''; |
380 | var plazosConcat = ''; | 380 | var plazosConcat = ''; |
381 | if(!Array.isArray(precioCondicion)) { | 381 | if(!Array.isArray(precioCondicion)) { |
382 | $scope.plazosPagos = precioCondicion.plazoPago; | 382 | $scope.plazosPagos = precioCondicion.plazoPago; |
383 | $scope.idLista = precioCondicion.idListaPrecio; | 383 | $scope.idLista = precioCondicion.idListaPrecio; |
384 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 384 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
385 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 385 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
386 | } | 386 | } |
387 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 387 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
388 | } else { //Cuando se ingresan los plazos manualmente | 388 | } else { //Cuando se ingresan los plazos manualmente |
389 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 389 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
390 | $scope.plazosPagos = precioCondicion; | 390 | $scope.plazosPagos = precioCondicion; |
391 | for(var j = 0; j < precioCondicion.length; j++) { | 391 | for(var j = 0; j < precioCondicion.length; j++) { |
392 | plazosConcat += precioCondicion[j].dias + ' '; | 392 | plazosConcat += precioCondicion[j].dias + ' '; |
393 | } | 393 | } |
394 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 394 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
395 | } | 395 | } |
396 | $scope.articulosTabla = []; | 396 | $scope.articulosTabla = []; |
397 | addCabecera('Precios y condiciones:', cabecera); | 397 | addCabecera('Precios y condiciones:', cabecera); |
398 | }, function() { | 398 | }, function() { |
399 | 399 | ||
400 | } | 400 | } |
401 | ); | 401 | ); |
402 | }; | 402 | }; |
403 | 403 | ||
404 | $scope.abrirModalFlete = function() { | 404 | $scope.abrirModalFlete = function() { |
405 | var modalInstance = $uibModal.open( | 405 | var modalInstance = $uibModal.open( |
406 | { | 406 | { |
407 | ariaLabelledBy: 'Busqueda de Flete', | 407 | ariaLabelledBy: 'Busqueda de Flete', |
408 | templateUrl: 'modal-flete.html', | 408 | templateUrl: 'modal-flete.html', |
409 | controller: 'focaModalFleteController', | 409 | controller: 'focaModalFleteController', |
410 | size: 'lg', | 410 | size: 'lg', |
411 | resolve: { | 411 | resolve: { |
412 | parametrosFlete: | 412 | parametrosFlete: |
413 | function() { | 413 | function() { |
414 | return { | 414 | return { |
415 | flete: $scope.notaPedido.flete ? '1' : | 415 | flete: $scope.notaPedido.flete ? '1' : |
416 | ($scope.notaPedido.fob ? 'FOB' : | 416 | ($scope.notaPedido.fob ? 'FOB' : |
417 | ($scope.notaPedido.flete === undefined ? null : '0')), | 417 | ($scope.notaPedido.flete === undefined ? null : '0')), |
418 | bomba: $scope.notaPedido.bomba ? '1' : | 418 | bomba: $scope.notaPedido.bomba ? '1' : |
419 | ($scope.notaPedido.bomba === undefined ? null : '0'), | 419 | ($scope.notaPedido.bomba === undefined ? null : '0'), |
420 | kilometros: $scope.notaPedido.kilometros | 420 | kilometros: $scope.notaPedido.kilometros |
421 | }; | 421 | }; |
422 | } | 422 | } |
423 | } | 423 | } |
424 | } | 424 | } |
425 | ); | 425 | ); |
426 | modalInstance.result.then( | 426 | modalInstance.result.then( |
427 | function(datos) { | 427 | function(datos) { |
428 | $scope.notaPedido.flete = datos.flete; | 428 | $scope.notaPedido.flete = datos.flete; |
429 | $scope.notaPedido.fob = datos.FOB; | 429 | $scope.notaPedido.fob = datos.FOB; |
430 | $scope.notaPedido.bomba = datos.bomba; | 430 | $scope.notaPedido.bomba = datos.bomba; |
431 | $scope.notaPedido.kilometros = datos.kilometros; | 431 | $scope.notaPedido.kilometros = datos.kilometros; |
432 | 432 | ||
433 | addCabecera('Flete:', datos.flete ? 'Si' : | 433 | addCabecera('Flete:', datos.flete ? 'Si' : |
434 | ($scope.notaPedido.fob ? 'FOB' : 'No')); | 434 | ($scope.notaPedido.fob ? 'FOB' : 'No')); |
435 | if(datos.flete) { | 435 | if(datos.flete) { |
436 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | 436 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); |
437 | addCabecera('Kilometros:', datos.kilometros); | 437 | addCabecera('Kilometros:', datos.kilometros); |
438 | } else { | 438 | } else { |
439 | removeCabecera('Bomba:'); | 439 | removeCabecera('Bomba:'); |
440 | removeCabecera('Kilometros:'); | 440 | removeCabecera('Kilometros:'); |
441 | $scope.notaPedido.fob = false; | 441 | $scope.notaPedido.fob = false; |
442 | $scope.notaPedido.bomba = false; | 442 | $scope.notaPedido.bomba = false; |
443 | $scope.notaPedido.kilometros = null; | 443 | $scope.notaPedido.kilometros = null; |
444 | } | 444 | } |
445 | }, function() { | 445 | }, function() { |
446 | 446 | ||
447 | } | 447 | } |
448 | ); | 448 | ); |
449 | }; | 449 | }; |
450 | 450 | ||
451 | $scope.abrirModalMoneda = function() { | 451 | $scope.abrirModalMoneda = function() { |
452 | var modalInstance = $uibModal.open( | 452 | var modalInstance = $uibModal.open( |
453 | { | 453 | { |
454 | ariaLabelledBy: 'Busqueda de Moneda', | 454 | ariaLabelledBy: 'Busqueda de Moneda', |
455 | templateUrl: 'modal-moneda.html', | 455 | templateUrl: 'modal-moneda.html', |
456 | controller: 'focaModalMonedaController', | 456 | controller: 'focaModalMonedaController', |
457 | size: 'lg' | 457 | size: 'lg' |
458 | } | 458 | } |
459 | ); | 459 | ); |
460 | modalInstance.result.then( | 460 | modalInstance.result.then( |
461 | function(moneda) { | 461 | function(moneda) { |
462 | $scope.abrirModalCotizacion(moneda); | 462 | $scope.abrirModalCotizacion(moneda); |
463 | }, function() { | 463 | }, function() { |
464 | 464 | ||
465 | } | 465 | } |
466 | ); | 466 | ); |
467 | }; | 467 | }; |
468 | 468 | ||
469 | $scope.abrirModalCotizacion = function(moneda) { | 469 | $scope.abrirModalCotizacion = function(moneda) { |
470 | var modalInstance = $uibModal.open( | 470 | var modalInstance = $uibModal.open( |
471 | { | 471 | { |
472 | ariaLabelledBy: 'Busqueda de Cotización', | 472 | ariaLabelledBy: 'Busqueda de Cotización', |
473 | templateUrl: 'modal-cotizacion.html', | 473 | templateUrl: 'modal-cotizacion.html', |
474 | controller: 'focaModalCotizacionController', | 474 | controller: 'focaModalCotizacionController', |
475 | size: 'lg', | 475 | size: 'lg', |
476 | resolve: {idMoneda: function() {return moneda.ID;}} | 476 | resolve: {idMoneda: function() {return moneda.ID;}} |
477 | } | 477 | } |
478 | ); | 478 | ); |
479 | modalInstance.result.then( | 479 | modalInstance.result.then( |
480 | function(cotizacion) { | 480 | function(cotizacion) { |
481 | var articulosTablaTemp = $scope.articulosTabla; | 481 | var articulosTablaTemp = $scope.articulosTabla; |
482 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 482 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
483 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 483 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
484 | $scope.notaPedido.cotizacion.VENDEDOR; | 484 | $scope.notaPedido.cotizacion.VENDEDOR; |
485 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 485 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
486 | cotizacion.VENDEDOR; | 486 | cotizacion.VENDEDOR; |
487 | } | 487 | } |
488 | $scope.articulosTabla = articulosTablaTemp; | 488 | $scope.articulosTabla = articulosTablaTemp; |
489 | $scope.notaPedido.moneda = { | 489 | $scope.notaPedido.moneda = { |
490 | id: moneda.ID, | 490 | id: moneda.ID, |
491 | detalle: moneda.DETALLE, | 491 | detalle: moneda.DETALLE, |
492 | simbolo: moneda.SIMBOLO | 492 | simbolo: moneda.SIMBOLO |
493 | }; | 493 | }; |
494 | $scope.notaPedido.cotizacion = cotizacion; | 494 | $scope.notaPedido.cotizacion = cotizacion; |
495 | addCabecera('Moneda:', moneda.DETALLE); | 495 | addCabecera('Moneda:', moneda.DETALLE); |
496 | addCabecera( | 496 | addCabecera( |
497 | 'Fecha cotizacion:', | 497 | 'Fecha cotizacion:', |
498 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 498 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
499 | ); | 499 | ); |
500 | addCabecera('Cotizacion:', cotizacion.VENDEDOR); | 500 | addCabecera('Cotizacion:', cotizacion.VENDEDOR); |
501 | }, function() { | 501 | }, function() { |
502 | 502 | ||
503 | } | 503 | } |
504 | ); | 504 | ); |
505 | }; | 505 | }; |
506 | 506 | ||
507 | $scope.agregarATabla = function(key) { | 507 | $scope.agregarATabla = function(key) { |
508 | if(key === 13) { | 508 | if(key === 13) { |
509 | if($scope.articuloACargar.cantidad === undefined || | 509 | if($scope.articuloACargar.cantidad === undefined || |
510 | $scope.articuloACargar.cantidad === 0 || | 510 | $scope.articuloACargar.cantidad === 0 || |
511 | $scope.articuloACargar.cantidad === null ) { | 511 | $scope.articuloACargar.cantidad === null ) { |
512 | focaModalService.alert('El valor debe ser al menos 1'); | 512 | focaModalService.alert('El valor debe ser al menos 1'); |
513 | return; | 513 | return; |
514 | } | 514 | } |
515 | delete $scope.articuloACargar.sectorCodigo; | 515 | delete $scope.articuloACargar.sectorCodigo; |
516 | $scope.articulosTabla.push($scope.articuloACargar); | 516 | $scope.articulosTabla.push($scope.articuloACargar); |
517 | $scope.cargando = true; | 517 | $scope.cargando = true; |
518 | } | 518 | } |
519 | }; | 519 | }; |
520 | 520 | ||
521 | $scope.quitarArticulo = function(key) { | 521 | $scope.quitarArticulo = function(key) { |
522 | $scope.articulosTabla.splice(key, 1); | 522 | $scope.articulosTabla.splice(key, 1); |
523 | }; | 523 | }; |
524 | 524 | ||
525 | $scope.editarArticulo = function(key, articulo) { | 525 | $scope.editarArticulo = function(key, articulo) { |
526 | if(key === 13) { | 526 | if(key === 13) { |
527 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 527 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
528 | articulo.cantidad === undefined) { | 528 | articulo.cantidad === undefined) { |
529 | focaModalService.alert('El valor debe ser al menos 1'); | 529 | focaModalService.alert('El valor debe ser al menos 1'); |
530 | return; | 530 | return; |
531 | } | 531 | } |
532 | articulo.editCantidad = false; | 532 | articulo.editCantidad = false; |
533 | articulo.editPrecio = false; | 533 | articulo.editPrecio = false; |
534 | } | 534 | } |
535 | }; | 535 | }; |
536 | 536 | ||
537 | $scope.cambioEdit = function(articulo, propiedad) { | 537 | $scope.cambioEdit = function(articulo, propiedad) { |
538 | if(propiedad === 'cantidad') { | 538 | if(propiedad === 'cantidad') { |
539 | articulo.editCantidad = true; | 539 | articulo.editCantidad = true; |
540 | } else if(propiedad === 'precio') { | 540 | } else if(propiedad === 'precio') { |
541 | articulo.editPrecio = true; | 541 | articulo.editPrecio = true; |
542 | } | 542 | } |
543 | }; | 543 | }; |
544 | 544 | ||
545 | $scope.limpiarFlete = function() { | 545 | $scope.limpiarFlete = function() { |
546 | $scope.notaPedido.fleteNombre = ''; | 546 | $scope.notaPedido.fleteNombre = ''; |
547 | $scope.notaPedido.chofer = ''; | 547 | $scope.notaPedido.chofer = ''; |
548 | $scope.notaPedido.vehiculo = ''; | 548 | $scope.notaPedido.vehiculo = ''; |
549 | $scope.notaPedido.kilometros = ''; | 549 | $scope.notaPedido.kilometros = ''; |
550 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 550 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
551 | $scope.choferes = ''; | 551 | $scope.choferes = ''; |
552 | $scope.vehiculos = ''; | 552 | $scope.vehiculos = ''; |
553 | }; | 553 | }; |
554 | 554 | ||
555 | $scope.limpiarPantalla = function() { | 555 | $scope.limpiarPantalla = function() { |
556 | $scope.limpiarFlete(); | 556 | $scope.limpiarFlete(); |
557 | $scope.notaPedido.flete = '0'; | 557 | $scope.notaPedido.flete = '0'; |
558 | $scope.notaPedido.bomba = '0'; | 558 | $scope.notaPedido.bomba = '0'; |
559 | $scope.notaPedido.precioCondicion = ''; | 559 | $scope.notaPedido.precioCondicion = ''; |
560 | $scope.articulosTabla = []; | 560 | $scope.articulosTabla = []; |
561 | $scope.notaPedido.vendedor.nombre = ''; | 561 | $scope.notaPedido.vendedor.nombre = ''; |
562 | $scope.notaPedido.cliente = {nombre: ''}; | 562 | $scope.notaPedido.cliente = {nombre: ''}; |
563 | $scope.notaPedido.domicilio = {dom: ''}; | 563 | $scope.notaPedido.domicilio = {dom: ''}; |
564 | $scope.domiciliosCliente = []; | 564 | $scope.domiciliosCliente = []; |
565 | }; | 565 | }; |
566 | 566 | ||
567 | $scope.resetFilter = function() { | 567 | $scope.resetFilter = function() { |
568 | $scope.articuloACargar = {}; | 568 | $scope.articuloACargar = {}; |
569 | $scope.cargando = true; | 569 | $scope.cargando = true; |
570 | }; | 570 | }; |
571 | //Recibe aviso si el teclado está en uso | 571 | //Recibe aviso si el teclado está en uso |
572 | $rootScope.$on('usarTeclado', function(event, data) { | 572 | $rootScope.$on('usarTeclado', function(event, data) { |
573 | if(data) { | 573 | if(data) { |
574 | $scope.mostrarTeclado = true; | 574 | $scope.mostrarTeclado = true; |
575 | return; | 575 | return; |
576 | } | 576 | } |
577 | $scope.mostrarTeclado = false; | 577 | $scope.mostrarTeclado = false; |
578 | }) | 578 | }) |
579 | $scope.selectFocus = function($event) { | 579 | $scope.selectFocus = function($event) { |
580 | // Si el teclado esta en uso no selecciona el valor | 580 | // Si el teclado esta en uso no selecciona el valor |
581 | if($scope.mostrarTeclado) { | 581 | if($scope.mostrarTeclado) { |
582 | return; | 582 | return; |
583 | } | 583 | } |
584 | $event.target.select(); | 584 | $event.target.select(); |
585 | }; | 585 | }; |
586 | 586 | ||
587 | $scope.salir = function() { | 587 | $scope.salir = function() { |
588 | $location.path('/'); | 588 | $location.path('/'); |
589 | }; | 589 | }; |
590 | 590 | ||
591 | $scope.parsearATexto = function(articulo) { | 591 | $scope.parsearATexto = function(articulo) { |
592 | articulo.cantidad = parseFloat(articulo.cantidad); | 592 | articulo.cantidad = parseFloat(articulo.cantidad); |
593 | articulo.precio = parseFloat(articulo.precio); | 593 | articulo.precio = parseFloat(articulo.precio); |
594 | }; | 594 | }; |
595 | 595 | ||
596 | function addCabecera(label, valor) { | 596 | function addCabecera(label, valor) { |
597 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 597 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
598 | if(propiedad.length === 1) { | 598 | if(propiedad.length === 1) { |
599 | propiedad[0].valor = valor; | 599 | propiedad[0].valor = valor; |
600 | } else { | 600 | } else { |
601 | $scope.cabecera.push({label: label, valor: valor}); | 601 | $scope.cabecera.push({label: label, valor: valor}); |
602 | } | 602 | } |
603 | } | 603 | } |
604 | 604 | ||
605 | function removeCabecera(label) { | 605 | function removeCabecera(label) { |
606 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 606 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
607 | if(propiedad.length === 1) { | 607 | if(propiedad.length === 1) { |
608 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 608 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
609 | } | 609 | } |
610 | } | 610 | } |
611 | 611 | ||
612 | function rellenar(relleno, longitud) { | 612 | function rellenar(relleno, longitud) { |
613 | relleno = '' + relleno; | 613 | relleno = '' + relleno; |
614 | while (relleno.length < longitud) { | 614 | while (relleno.length < longitud) { |
615 | relleno = '0' + relleno; | 615 | relleno = '0' + relleno; |
616 | } | 616 | } |
617 | 617 | ||
618 | return relleno; | 618 | return relleno; |
619 | } | 619 | } |
620 | } | 620 | } |
621 | ] | 621 | ] |
622 | ) | 622 | ) |
623 | .controller('notaPedidoListaCtrl', [ | 623 | .controller('notaPedidoListaCtrl', [ |
624 | '$scope', | 624 | '$scope', |
625 | 'crearNotaPedidoService', | 625 | 'crearNotaPedidoService', |
626 | '$location', | 626 | '$location', |
627 | function($scope, crearNotaPedidoService, $location) { | 627 | function($scope, crearNotaPedidoService, $location) { |
628 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 628 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
629 | $scope.notaPedidos = datos.data; | 629 | $scope.notaPedidos = datos.data; |
630 | }); | 630 | }); |
631 | $scope.editar = function(notaPedido) { | 631 | $scope.editar = function(notaPedido) { |
632 | crearNotaPedidoService.setNotaPedido(notaPedido); | 632 | crearNotaPedidoService.setNotaPedido(notaPedido); |
633 | $location.path('/venta-nota-pedido/abm/'); | 633 | $location.path('/venta-nota-pedido/abm/'); |
634 | }; | 634 | }; |
635 | $scope.crearPedido = function() { | 635 | $scope.crearPedido = function() { |
636 | crearNotaPedidoService.clearNotaPedido(); | 636 | crearNotaPedidoService.clearNotaPedido(); |
637 | $location.path('/venta-nota-pedido/abm/'); | 637 | $location.path('/venta-nota-pedido/abm/'); |
638 | }; | 638 | }; |
639 | } | 639 | } |
640 | ]) | 640 | ]) |
641 | .controller('focaCrearNotaPedidoFichaClienteController', [ | 641 | .controller('focaCrearNotaPedidoFichaClienteController', [ |
642 | '$scope', | 642 | '$scope', |
643 | 'crearNotaPedidoService', | 643 | 'crearNotaPedidoService', |
644 | '$location', | 644 | '$location', |
645 | function($scope, crearNotaPedidoService, $location) { | 645 | function($scope, crearNotaPedidoService, $location) { |
646 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 646 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
647 | $scope.notaPedidos = datos.data; | 647 | $scope.notaPedidos = datos.data; |
648 | }); | 648 | }); |
649 | $scope.editar = function(notaPedido) { | 649 | $scope.editar = function(notaPedido) { |
650 | crearNotaPedidoService.setNotaPedido(notaPedido); | 650 | crearNotaPedidoService.setNotaPedido(notaPedido); |
651 | $location.path('/venta-nota-pedido/abm/'); | 651 | $location.path('/venta-nota-pedido/abm/'); |
652 | }; | 652 | }; |
653 | $scope.crearPedido = function() { | 653 | $scope.crearPedido = function() { |
654 | crearNotaPedidoService.clearNotaPedido(); | 654 | crearNotaPedidoService.clearNotaPedido(); |
655 | $location.path('/venta-nota-pedido/abm/'); | 655 | $location.path('/venta-nota-pedido/abm/'); |
656 | }; | 656 | }; |
657 | } | 657 | } |
658 | ]); | 658 | ]); |
659 | 659 |