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