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