Commit a682b3f4e381f8f6a01392a9f5de8579cb025d15

Authored by Jose Pinto
1 parent 34519c4b29
Exists in master

espacios

Showing 1 changed file with 14 additions and 14 deletions   Show diff stats
src/js/controller.js
1 angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', 1 angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
2 [ 2 [
3 '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', 3 '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService',
4 'focaModalService', 'notaPedidoBusinessService', '$rootScope', 'focaSeguimientoService', 4 'focaModalService', 'notaPedidoBusinessService', '$rootScope', 'focaSeguimientoService',
5 function( 5 function(
6 $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService, 6 $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService,
7 notaPedidoBusinessService, $rootScope, focaSeguimientoService) 7 notaPedidoBusinessService, $rootScope, focaSeguimientoService)
8 { 8 {
9 9
10 $scope.botonera = crearNotaPedidoService.getBotonera(); 10 $scope.botonera = crearNotaPedidoService.getBotonera();
11 11
12 $scope.isNumber = angular.isNumber; 12 $scope.isNumber = angular.isNumber;
13 $scope.datepickerAbierto = false; 13 $scope.datepickerAbierto = false;
14 $scope.show = false; 14 $scope.show = false;
15 $scope.cargando = true; 15 $scope.cargando = true;
16 $scope.dateOptions = { 16 $scope.dateOptions = {
17 maxDate: new Date(), 17 maxDate: new Date(),
18 minDate: new Date(2010, 0, 1) 18 minDate: new Date(2010, 0, 1)
19 }; 19 };
20 20
21 $scope.notaPedido = { 21 $scope.notaPedido = {
22 id: 0, 22 id: 0,
23 vendedor: {}, 23 vendedor: {},
24 cliente: {}, 24 cliente: {},
25 proveedor: {}, 25 proveedor: {},
26 domicilio: {dom: ''}, 26 domicilio: {dom: ''},
27 moneda: {}, 27 moneda: {},
28 cotizacion: {} 28 cotizacion: {}
29 }; 29 };
30 var monedaPorDefecto; 30 var monedaPorDefecto;
31 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' 31 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
32 crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { 32 crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) {
33 monedaPorDefecto = res.data[0]; 33 monedaPorDefecto = res.data[0];
34 $scope.notaPedido.moneda = monedaPorDefecto; 34 $scope.notaPedido.moneda = monedaPorDefecto;
35 $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; 35 $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0];
36 }); 36 });
37 37
38 $scope.cabecera = []; 38 $scope.cabecera = [];
39 $scope.showCabecera = true; 39 $scope.showCabecera = true;
40 40
41 $scope.now = new Date(); 41 $scope.now = new Date();
42 $scope.puntoVenta = '0000'; 42 $scope.puntoVenta = '0000';
43 $scope.comprobante = '00000000'; 43 $scope.comprobante = '00000000';
44 $scope.articulosTabla = []; 44 $scope.articulosTabla = [];
45 $scope.idLista = undefined; 45 $scope.idLista = undefined;
46 46
47 crearNotaPedidoService.getPrecioCondicion().then( 47 crearNotaPedidoService.getPrecioCondicion().then(
48 function(res) { 48 function(res) {
49 $scope.precioCondiciones = res.data; 49 $scope.precioCondiciones = res.data;
50 } 50 }
51 ); 51 );
52 52
53 crearNotaPedidoService.getNumeroNotaPedido().then( 53 crearNotaPedidoService.getNumeroNotaPedido().then(
54 function(res) { 54 function(res) {
55 $scope.puntoVenta = rellenar(res.data.sucursal, 4); 55 $scope.puntoVenta = rellenar(res.data.sucursal, 4);
56 $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); 56 $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8);
57 }, 57 },
58 function(err) { 58 function(err) {
59 focaModalService.alert('La terminal no esta configurada correctamente'); 59 focaModalService.alert('La terminal no esta configurada correctamente');
60 console.info(err); 60 console.info(err);
61 } 61 }
62 ); 62 );
63 63
64 $scope.crearNotaPedido = function() { 64 $scope.crearNotaPedido = function() {
65 if(!$scope.notaPedido.vendedor.CodVen) { 65 if(!$scope.notaPedido.vendedor.CodVen) {
66 focaModalService.alert('Ingrese Vendedor'); 66 focaModalService.alert('Ingrese Vendedor');
67 return; 67 return;
68 } else if(!$scope.notaPedido.cliente.COD) { 68 } else if(!$scope.notaPedido.cliente.COD) {
69 focaModalService.alert('Ingrese Cliente'); 69 focaModalService.alert('Ingrese Cliente');
70 return; 70 return;
71 } else if(!$scope.notaPedido.proveedor.COD) { 71 } else if(!$scope.notaPedido.proveedor.COD) {
72 focaModalService.alert('Ingrese Proveedor'); 72 focaModalService.alert('Ingrese Proveedor');
73 return; 73 return;
74 } else if(!$scope.notaPedido.moneda.ID) { 74 } else if(!$scope.notaPedido.moneda.ID) {
75 focaModalService.alert('Ingrese Moneda'); 75 focaModalService.alert('Ingrese Moneda');
76 return; 76 return;
77 } else if(!$scope.notaPedido.cotizacion.ID) { 77 } else if(!$scope.notaPedido.cotizacion.ID) {
78 focaModalService.alert('Ingrese Cotización'); 78 focaModalService.alert('Ingrese Cotización');
79 return; 79 return;
80 } else if(!$scope.plazosPagos) { 80 } else if(!$scope.plazosPagos) {
81 focaModalService.alert('Ingrese Precios y Condiciones'); 81 focaModalService.alert('Ingrese Precios y Condiciones');
82 return; 82 return;
83 } else if( 83 } else if(
84 $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) 84 $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null)
85 { 85 {
86 focaModalService.alert('Ingrese Flete'); 86 focaModalService.alert('Ingrese Flete');
87 return; 87 return;
88 } else if(!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto 88 } else if(!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto
89 focaModalService.alert('Ingrese Domicilio'); 89 focaModalService.alert('Ingrese Domicilio');
90 return; 90 return;
91 } else if($scope.articulosTabla.length === 0) { 91 } else if($scope.articulosTabla.length === 0) {
92 focaModalService.alert('Debe cargar al menos un articulo'); 92 focaModalService.alert('Debe cargar al menos un articulo');
93 return; 93 return;
94 } 94 }
95 $scope.saveLoading = true; 95 $scope.saveLoading = true;
96 var notaPedido = { 96 var notaPedido = {
97 id: $scope.notaPedido.id, 97 id: $scope.notaPedido.id,
98 fechaCarga: $scope.now.toISOString().slice(0, 19).replace('T', ' '), 98 fechaCarga: $scope.now.toISOString().slice(0, 19).replace('T', ' '),
99 idVendedor: $scope.notaPedido.vendedor.CodVen, 99 idVendedor: $scope.notaPedido.vendedor.CodVen,
100 idCliente: $scope.notaPedido.cliente.COD, 100 idCliente: $scope.notaPedido.cliente.COD,
101 nombreCliente: $scope.notaPedido.cliente.NOM, 101 nombreCliente: $scope.notaPedido.cliente.NOM,
102 cuitCliente: $scope.notaPedido.cliente.CUIT, 102 cuitCliente: $scope.notaPedido.cliente.CUIT,
103 idProveedor: $scope.notaPedido.proveedor.COD, 103 idProveedor: $scope.notaPedido.proveedor.COD,
104 //idDomicilio: $scope.notaPedido.domicilio.id,TODO GUARDAR DOMICILIO ID 104 //idDomicilio: $scope.notaPedido.domicilio.id,TODO GUARDAR DOMICILIO ID
105 idCotizacion: $scope.notaPedido.cotizacion.ID, 105 idCotizacion: $scope.notaPedido.cotizacion.ID,
106 idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, 106 idPrecioCondicion: $scope.notaPedido.idPrecioCondicion,
107 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, 107 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR,
108 flete: $scope.notaPedido.flete, 108 flete: $scope.notaPedido.flete,
109 fob: $scope.notaPedido.fob, 109 fob: $scope.notaPedido.fob,
110 bomba: $scope.notaPedido.bomba, 110 bomba: $scope.notaPedido.bomba,
111 kilometros: $scope.notaPedido.kilometros, 111 kilometros: $scope.notaPedido.kilometros,
112 domicilioStamp: $scope.notaPedido.domicilioStamp, 112 domicilioStamp: $scope.notaPedido.domicilioStamp,
113 estado: 0, 113 estado: 0,
114 total: $scope.getTotal() 114 total: $scope.getTotal()
115 }; 115 };
116 crearNotaPedidoService.crearNotaPedido(notaPedido).then( 116 crearNotaPedidoService.crearNotaPedido(notaPedido).then(
117 function(data) { 117 function(data) {
118 // Al guardar los datos de la nota de pedido logueamos la 118 // Al guardar los datos de la nota de pedido logueamos la
119 // actividad para su seguimiento. 119 // actividad para su seguimiento.
120 //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? 120 //TODO: GUARDAR POSISIONAMIENTO AL EDITAR?
121 focaSeguimientoService.guardarPosicion( 121 focaSeguimientoService.guardarPosicion(
122 data.data.id, 122 data.data.id,
123 'Nota de pedido', 123 'Nota de pedido',
124 'Nº: ' + $filter('comprobante')([ 124 'Nº: ' + $filter('comprobante')([
125 $scope.puntoVenta, 125 $scope.puntoVenta,
126 $scope.comprobante 126 $scope.comprobante
127 ]) + '<br/>' + 127 ]) + '<br/>' +
128 'Vendedor: ' + $scope.notaPedido.vendedor.NomVen + '<br/>' + 128 'Vendedor: ' + $scope.notaPedido.vendedor.NomVen + '<br/>' +
129 'Total: ' + $filter('currency')($scope.getTotal()) 129 'Total: ' + $filter('currency')($scope.getTotal())
130 ); 130 );
131 notaPedidoBusinessService.addArticulos($scope.articulosTabla, 131 notaPedidoBusinessService.addArticulos($scope.articulosTabla,
132 data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); 132 data.data.id, $scope.notaPedido.cotizacion.VENDEDOR);
133 var plazos = $scope.plazosPagos; 133 var plazos = $scope.plazosPagos;
134 134
135 for(var j = 0; j < plazos.length; j++) { 135 for(var j = 0; j < plazos.length; j++) {
136 var json = { 136 var json = {
137 idPedido: data.data.id, 137 idPedido: data.data.id,
138 dias: plazos[j].dias 138 dias: plazos[j].dias
139 }; 139 };
140 crearNotaPedidoService.crearPlazosParaNotaPedido(json); 140 crearNotaPedidoService.crearPlazosParaNotaPedido(json);
141 } 141 }
142 notaPedidoBusinessService.addEstado(data.data.id, 142 notaPedidoBusinessService.addEstado(data.data.id,
143 $scope.notaPedido.vendedor.CodVen); 143 $scope.notaPedido.vendedor.CodVen);
144 144
145 focaModalService.alert('Nota pedido creada'); 145 focaModalService.alert('Nota pedido creada');
146 $scope.saveLoading = false; 146 $scope.saveLoading = false;
147 $scope.$broadcast('cleanCabecera'); 147 $scope.$broadcast('cleanCabecera');
148 $scope.$broadcast('addCabecera', { 148 $scope.$broadcast('addCabecera', {
149 label: 'Moneda:', 149 label: 'Moneda:',
150 valor: $scope.notaPedido.moneda.DETALLE 150 valor: $scope.notaPedido.moneda.DETALLE
151 }); 151 });
152 $scope.$broadcast('addCabecera', { 152 $scope.$broadcast('addCabecera', {
153 label: 'Fecha cotizacion:', 153 label: 'Fecha cotizacion:',
154 valor: $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') 154 valor: $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy')
155 }); 155 });
156 $scope.$broadcast('addCabecera', { 156 $scope.$broadcast('addCabecera', {
157 label: 'Moneda:', 157 label: 'Moneda:',
158 valor: $scope.notaPedido.moneda.DETALLE 158 valor: $scope.notaPedido.moneda.DETALLE
159 }); 159 });
160 $scope.$broadcast('addCabecera', { 160 $scope.$broadcast('addCabecera', {
161 label: 'Cotizacion:', 161 label: 'Cotizacion:',
162 valor: $scope.notaPedido.cotizacion.VENDEDOR 162 valor: $scope.notaPedido.cotizacion.VENDEDOR
163 }); 163 });
164 crearNotaPedidoService.getNumeroNotaPedido().then( 164 crearNotaPedidoService.getNumeroNotaPedido().then(
165 function(res) { 165 function(res) {
166 $scope.puntoVenta = rellenar(res.data.sucursal, 4); 166 $scope.puntoVenta = rellenar(res.data.sucursal, 4);
167 $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); 167 $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8);
168 }, 168 },
169 function(err) { 169 function(err) {
170 focaModalService.alert( 170 focaModalService.alert(
171 'La terminal no esta configurada correctamente'); 171 'La terminal no esta configurada correctamente');
172 console.info(err); 172 console.info(err);
173 } 173 }
174 ); 174 );
175 $scope.notaPedido.vendedor = {}; 175 $scope.notaPedido.vendedor = {};
176 $scope.notaPedido.cliente = {}; 176 $scope.notaPedido.cliente = {};
177 $scope.notaPedido.proveedor = {}; 177 $scope.notaPedido.proveedor = {};
178 $scope.notaPedido.domicilio = {}; 178 $scope.notaPedido.domicilio = {};
179 $scope.notaPedido.flete = null; 179 $scope.notaPedido.flete = null;
180 $scope.notaPedido.fob = null; 180 $scope.notaPedido.fob = null;
181 $scope.notaPedido.bomba = null; 181 $scope.notaPedido.bomba = null;
182 $scope.notaPedido.kilometros = null; 182 $scope.notaPedido.kilometros = null;
183 $scope.articulosTabla = []; 183 $scope.articulosTabla = [];
184 }, 184 },
185 function(error) { 185 function(error) {
186 focaModalService.alert('Hubo un error al crear la nota de pedido'); 186 focaModalService.alert('Hubo un error al crear la nota de pedido');
187 $scope.saveLoading = false; 187 $scope.saveLoading = false;
188 console.info(error); 188 console.info(error);
189 } 189 }
190 ); 190 );
191 }; 191 };
192 192
193 $scope.seleccionarNotaPedido = function() { 193 $scope.seleccionarNotaPedido = function() {
194 var modalInstance = $uibModal.open( 194 var modalInstance = $uibModal.open(
195 { 195 {
196 ariaLabelledBy: 'Busqueda de Nota de Pedido', 196 ariaLabelledBy: 'Busqueda de Nota de Pedido',
197 templateUrl: 'foca-modal-nota-pedido.html', 197 templateUrl: 'foca-modal-nota-pedido.html',
198 controller: 'focaModalNotaPedidoController', 198 controller: 'focaModalNotaPedidoController',
199 size: 'lg', 199 size: 'lg',
200 resolve: {usadoPor: function() {return 'notaPedido';}} 200 resolve: {usadoPor: function() {return 'notaPedido';}}
201 } 201 }
202 ); 202 );
203 modalInstance.result.then( 203 modalInstance.result.then(
204 function(notaPedido) { 204 function(notaPedido) {
205 $scope.now = new Date(notaPedido.fechaCarga); 205 $scope.now = new Date(notaPedido.fechaCarga);
206 //añado cabeceras 206 //añado cabeceras
207 $scope.notaPedido.id = notaPedido.id; 207 $scope.notaPedido.id = notaPedido.id;
208 $scope.$broadcast('removeCabecera', 'Bomba:'); 208 $scope.$broadcast('removeCabecera', 'Bomba:');
209 $scope.$broadcast('removeCabecera', 'Kilometros:'); 209 $scope.$broadcast('removeCabecera', 'Kilometros:');
210 var cabeceras = [ 210 var cabeceras = [
211 { 211 {
212 label: 'Moneda:', 212 label: 'Moneda:',
213 valor: notaPedido.cotizacion.moneda.DETALLE 213 valor: notaPedido.cotizacion.moneda.DETALLE
214 }, 214 },
215 { 215 {
216 label: 'Fecha cotizacion:', 216 label: 'Fecha cotizacion:',
217 valor: $filter('date')(notaPedido.cotizacion.FECHA, 217 valor: $filter('date')(notaPedido.cotizacion.FECHA,
218 'dd/MM/yyyy') 218 'dd/MM/yyyy')
219 }, 219 },
220 { 220 {
221 label: 'Cotizacion:', 221 label: 'Cotizacion:',
222 valor: notaPedido.cotizacion.VENDEDOR 222 valor: notaPedido.cotizacion.VENDEDOR
223 }, 223 },
224 { 224 {
225 label: 'Cliente:', 225 label: 'Cliente:',
226 valor: notaPedido.cliente.NOM 226 valor: notaPedido.cliente.NOM
227 }, 227 },
228 { 228 {
229 label: 'Domicilio:', 229 label: 'Domicilio:',
230 valor: notaPedido.domicilioStamp 230 valor: notaPedido.domicilioStamp
231 }, 231 },
232 { 232 {
233 label: 'Vendedor:', 233 label: 'Vendedor:',
234 valor: notaPedido.vendedor.NomVen 234 valor: notaPedido.vendedor.NomVen
235 }, 235 },
236 { 236 {
237 label: 'Proveedor:', 237 label: 'Proveedor:',
238 valor: notaPedido.proveedor.NOM 238 valor: notaPedido.proveedor.NOM
239 }, 239 },
240 { 240 {
241 label: 'Precio condicion:', 241 label: 'Precio condicion:',
242 valor: valorPrecioCondicion() + ' ' + 242 valor: valorPrecioCondicion() + ' ' +
243 notaPedidoBusinessService 243 notaPedidoBusinessService
244 .plazoToString(notaPedido.notaPedidoPlazo) 244 .plazoToString(notaPedido.notaPedidoPlazo)
245 }, 245 },
246 { 246 {
247 label: 'Flete:', 247 label: 'Flete:',
248 valor: notaPedido.fob === 1 ? 'FOB' : ( 248 valor: notaPedido.fob === 1 ? 'FOB' : (
249 notaPedido.flete === 1 ? 'Si' : 'No') 249 notaPedido.flete === 1 ? 'Si' : 'No')
250 } 250 }
251 ]; 251 ];
252 252
253 function valorPrecioCondicion() { 253 function valorPrecioCondicion() {
254 if(notaPedido.idPrecioCondicion > 0) { 254 if(notaPedido.idPrecioCondicion > 0) {
255 return notaPedido.precioCondicion.nombre; 255 return notaPedido.precioCondicion.nombre;
256 } else { 256 } else {
257 return 'Ingreso Manual'; 257 return 'Ingreso Manual';
258 } 258 }
259 } 259 }
260 260
261 if(notaPedido.flete === 1) { 261 if(notaPedido.flete === 1) {
262 var cabeceraBomba = { 262 var cabeceraBomba = {
263 label: 'Bomba:', 263 label: 'Bomba:',
264 valor: notaPedido.bomba === 1 ? 'Si' : 'No' 264 valor: notaPedido.bomba === 1 ? 'Si' : 'No'
265 }; 265 };
266 if(notaPedido.kilometros) { 266 if(notaPedido.kilometros) {
267 var cabeceraKilometros = { 267 var cabeceraKilometros = {
268 label: 'Kilometros:', 268 label: 'Kilometros:',
269 valor: notaPedido.kilometros 269 valor: notaPedido.kilometros
270 }; 270 };
271 cabeceras.push(cabeceraKilometros); 271 cabeceras.push(cabeceraKilometros);
272 } 272 }
273 cabeceras.push(cabeceraBomba); 273 cabeceras.push(cabeceraBomba);
274 } 274 }
275 $scope.articulosTabla = notaPedido.articulosNotaPedido; 275 $scope.articulosTabla = notaPedido.articulosNotaPedido;
276 notaPedidoBusinessService.calcularArticulos($scope.articulosTabla, 276 notaPedidoBusinessService.calcularArticulos($scope.articulosTabla,
277 notaPedido.cotizacion.VENDEDOR); 277 notaPedido.cotizacion.VENDEDOR);
278 if(notaPedido.idPrecioCondicion > 0) { 278 if(notaPedido.idPrecioCondicion > 0) {
279 $scope.idLista = notaPedido.precioCondicion.idListaPrecio; 279 $scope.idLista = notaPedido.precioCondicion.idListaPrecio;
280 } else { 280 } else {
281 $scope.idLista = -1; 281 $scope.idLista = -1;
282 } 282 }
283 $scope.puntoVenta = rellenar(notaPedido.sucursal, 4); 283 $scope.puntoVenta = rellenar(notaPedido.sucursal, 4);
284 $scope.comprobante = rellenar(notaPedido.numeroNotaPedido, 8); 284 $scope.comprobante = rellenar(notaPedido.numeroNotaPedido, 8);
285 $scope.notaPedido = notaPedido; 285 $scope.notaPedido = notaPedido;
286 $scope.notaPedido.moneda = notaPedido.cotizacion.moneda; 286 $scope.notaPedido.moneda = notaPedido.cotizacion.moneda;
287 $scope.plazosPagos = notaPedido.notaPedidoPlazo; 287 $scope.plazosPagos = notaPedido.notaPedidoPlazo;
288 addArrayCabecera(cabeceras); 288 addArrayCabecera(cabeceras);
289 289
290 }, function() { 290 }, function() {
291 // funcion ejecutada cuando se cancela el modal 291 // funcion ejecutada cuando se cancela el modal
292 } 292 }
293 ); 293 );
294 }; 294 };
295 295
296 $scope.seleccionarProductos = function() { 296 $scope.seleccionarProductos = function() {
297 if ($scope.idLista === undefined) { 297 if ($scope.idLista === undefined) {
298 focaModalService.alert( 298 focaModalService.alert(
299 'Primero seleccione una lista de precio y condicion'); 299 'Primero seleccione una lista de precio y condicion');
300 return; 300 return;
301 } 301 }
302 var modalInstance = $uibModal.open( 302 var modalInstance = $uibModal.open(
303 { 303 {
304 ariaLabelledBy: 'Busqueda de Productos', 304 ariaLabelledBy: 'Busqueda de Productos',
305 templateUrl: 'modal-busqueda-productos.html', 305 templateUrl: 'modal-busqueda-productos.html',
306 controller: 'modalBusquedaProductosCtrl', 306 controller: 'modalBusquedaProductosCtrl',
307 resolve: { 307 resolve: {
308 parametroProducto: { 308 parametroProducto: {
309 idLista: $scope.idLista, 309 idLista: $scope.idLista,
310 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, 310 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR,
311 simbolo: $scope.notaPedido.moneda.SIMBOLO 311 simbolo: $scope.notaPedido.moneda.SIMBOLO
312 } 312 }
313 }, 313 },
314 size: 'lg' 314 size: 'lg'
315 } 315 }
316 ); 316 );
317 modalInstance.result.then( 317 modalInstance.result.then(
318 function(producto) { 318 function(producto) {
319 var newArt = 319 var newArt =
320 { 320 {
321 id: 0, 321 id: 0,
322 codigo: producto.codigo, 322 codigo: producto.codigo,
323 sector: producto.sector, 323 sector: producto.sector,
324 sectorCodigo: producto.sector + '-' + producto.codigo, 324 sectorCodigo: producto.sector + '-' + producto.codigo,
325 descripcion: producto.descripcion, 325 descripcion: producto.descripcion,
326 item: $scope.articulosTabla.length + 1, 326 item: $scope.articulosTabla.length + 1,
327 nombre: producto.descripcion, 327 nombre: producto.descripcion,
328 precio: parseFloat(producto.precio.toFixed(4)), 328 precio: parseFloat(producto.precio.toFixed(4)),
329 costoUnitario: producto.costo, 329 costoUnitario: producto.costo,
330 editCantidad: false, 330 editCantidad: false,
331 editPrecio: false, 331 editPrecio: false,
332 rubro: producto.CodRub, 332 rubro: producto.CodRub,
333 exentoUnitario: producto.precio, 333 exentoUnitario: producto.precio,
334 ivaUnitario: producto.IMPIVA, 334 ivaUnitario: producto.IMPIVA,
335 impuestoInternoUnitario: producto.ImpInt, 335 impuestoInternoUnitario: producto.ImpInt,
336 impuestoInterno1Unitario: producto.ImpInt2, 336 impuestoInterno1Unitario: producto.ImpInt2,
337 impuestoInterno2Unitario: producto.ImpInt3, 337 impuestoInterno2Unitario: producto.ImpInt3,
338 precioLista: producto.precio, 338 precioLista: producto.precio,
339 combustible: 1, 339 combustible: 1,
340 facturado: 0 340 facturado: 0
341 }; 341 };
342 $scope.articuloACargar = newArt; 342 $scope.articuloACargar = newArt;
343 $scope.cargando = false; 343 $scope.cargando = false;
344 }, function() { 344 }, function() {
345 // funcion ejecutada cuando se cancela el modal 345 // funcion ejecutada cuando se cancela el modal
346 } 346 }
347 ); 347 );
348 }; 348 };
349 349
350 $scope.seleccionarVendedor = function() { 350 $scope.seleccionarVendedor = function() {
351 if(validarNotaRemitada()) { 351 if(validarNotaRemitada()) {
352 var modalInstance = $uibModal.open( 352 var modalInstance = $uibModal.open(
353 { 353 {
354 ariaLabelledBy: 'Busqueda de Vendedores', 354 ariaLabelledBy: 'Busqueda de Vendedores',
355 templateUrl: 'modal-vendedores.html', 355 templateUrl: 'modal-vendedores.html',
356 controller: 'modalVendedoresCtrl', 356 controller: 'modalVendedoresCtrl',
357 size: 'lg' 357 size: 'lg'
358 } 358 }
359 ); 359 );
360 modalInstance.result.then( 360 modalInstance.result.then(
361 function(vendedor) { 361 function(vendedor) {
362 $scope.$broadcast('addCabecera',{ 362 $scope.$broadcast('addCabecera', {
363 label: 'Vendedor:', 363 label: 'Vendedor:',
364 valor: vendedor.NomVen 364 valor: vendedor.NomVen
365 }); 365 });
366 $scope.notaPedido.vendedor = vendedor; 366 $scope.notaPedido.vendedor = vendedor;
367 }, function() { 367 }, function() {
368 368
369 } 369 }
370 ); 370 );
371 } 371 }
372 }; 372 };
373 373
374 $scope.seleccionarProveedor = function() { 374 $scope.seleccionarProveedor = function() {
375 if(validarNotaRemitada()) { 375 if(validarNotaRemitada()) {
376 var modalInstance = $uibModal.open( 376 var modalInstance = $uibModal.open(
377 { 377 {
378 ariaLabelledBy: 'Busqueda de Proveedor', 378 ariaLabelledBy: 'Busqueda de Proveedor',
379 templateUrl: 'modal-proveedor.html', 379 templateUrl: 'modal-proveedor.html',
380 controller: 'focaModalProveedorCtrl', 380 controller: 'focaModalProveedorCtrl',
381 size: 'lg', 381 size: 'lg',
382 resolve: { 382 resolve: {
383 transportista: function() { 383 transportista: function() {
384 return false; 384 return false;
385 } 385 }
386 } 386 }
387 } 387 }
388 ); 388 );
389 modalInstance.result.then( 389 modalInstance.result.then(
390 function(proveedor) { 390 function(proveedor) {
391 $scope.notaPedido.proveedor = proveedor; 391 $scope.notaPedido.proveedor = proveedor;
392 $scope.$broadcast('addCabecera',{ 392 $scope.$broadcast('addCabecera', {
393 label: 'Proveedor:', 393 label: 'Proveedor:',
394 valor: proveedor.NOM 394 valor: proveedor.NOM
395 }); 395 });
396 }, function() { 396 }, function() {
397 397
398 } 398 }
399 ); 399 );
400 } 400 }
401 }; 401 };
402 402
403 $scope.seleccionarCliente = function() { 403 $scope.seleccionarCliente = function() {
404 if(validarNotaRemitada()) { 404 if(validarNotaRemitada()) {
405 var modalInstance = $uibModal.open( 405 var modalInstance = $uibModal.open(
406 { 406 {
407 ariaLabelledBy: 'Busqueda de Cliente', 407 ariaLabelledBy: 'Busqueda de Cliente',
408 templateUrl: 'foca-busqueda-cliente-modal.html', 408 templateUrl: 'foca-busqueda-cliente-modal.html',
409 controller: 'focaBusquedaClienteModalController', 409 controller: 'focaBusquedaClienteModalController',
410 size: 'lg' 410 size: 'lg'
411 } 411 }
412 ); 412 );
413 modalInstance.result.then( 413 modalInstance.result.then(
414 function(cliente) { 414 function(cliente) {
415 $scope.abrirModalDomicilios(cliente); 415 $scope.abrirModalDomicilios(cliente);
416 }, function() { 416 }, function() {
417 417
418 } 418 }
419 ); 419 );
420 } 420 }
421 }; 421 };
422 422
423 $scope.abrirModalDomicilios = function(cliente) { 423 $scope.abrirModalDomicilios = function(cliente) {
424 var modalInstanceDomicilio = $uibModal.open( 424 var modalInstanceDomicilio = $uibModal.open(
425 { 425 {
426 ariaLabelledBy: 'Busqueda de Domicilios', 426 ariaLabelledBy: 'Busqueda de Domicilios',
427 templateUrl: 'modal-domicilio.html', 427 templateUrl: 'modal-domicilio.html',
428 controller: 'focaModalDomicilioController', 428 controller: 'focaModalDomicilioController',
429 resolve: { idCliente: function() { return cliente.cod; }}, 429 resolve: { idCliente: function() { return cliente.cod; }},
430 size: 'lg', 430 size: 'lg',
431 } 431 }
432 ); 432 );
433 modalInstanceDomicilio.result.then( 433 modalInstanceDomicilio.result.then(
434 function(domicilio) { 434 function(domicilio) {
435 $scope.notaPedido.domicilio = domicilio; 435 $scope.notaPedido.domicilio = domicilio;
436 $scope.notaPedido.cliente = { 436 $scope.notaPedido.cliente = {
437 COD: cliente.cod, 437 COD: cliente.cod,
438 CUIT: cliente.cuit, 438 CUIT: cliente.cuit,
439 NOM: cliente.nom 439 NOM: cliente.nom
440 }; 440 };
441 var domicilioStamp = 441 var domicilioStamp =
442 domicilio.Calle + ' ' + domicilio.Numero + ', ' + 442 domicilio.Calle + ' ' + domicilio.Numero + ', ' +
443 domicilio.Localidad + ', ' + domicilio.Provincia; 443 domicilio.Localidad + ', ' + domicilio.Provincia;
444 $scope.notaPedido.domicilioStamp = domicilioStamp; 444 $scope.notaPedido.domicilioStamp = domicilioStamp;
445 445
446 $scope.$broadcast('addCabecera',{ 446 $scope.$broadcast('addCabecera', {
447 label: 'Cliente:', 447 label: 'Cliente:',
448 valor: cliente.nom 448 valor: cliente.nom
449 }); 449 });
450 $scope.$broadcast('addCabecera',{ 450 $scope.$broadcast('addCabecera', {
451 label: 'Domicilio:', 451 label: 'Domicilio:',
452 valor: domicilioStamp 452 valor: domicilioStamp
453 }); 453 });
454 }, function() { 454 }, function() {
455 $scope.seleccionarCliente(); 455 $scope.seleccionarCliente();
456 return; 456 return;
457 } 457 }
458 ); 458 );
459 }; 459 };
460 460
461 $scope.getTotal = function() { 461 $scope.getTotal = function() {
462 var total = 0; 462 var total = 0;
463 var arrayTempArticulos = $scope.articulosTabla; 463 var arrayTempArticulos = $scope.articulosTabla;
464 for (var i = 0; i < arrayTempArticulos.length; i++) { 464 for (var i = 0; i < arrayTempArticulos.length; i++) {
465 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 465 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
466 } 466 }
467 return parseFloat(total.toFixed(2)); 467 return parseFloat(total.toFixed(2));
468 }; 468 };
469 469
470 $scope.getSubTotal = function() { 470 $scope.getSubTotal = function() {
471 if($scope.articuloACargar) { 471 if($scope.articuloACargar) {
472 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 472 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
473 } 473 }
474 }; 474 };
475 475
476 $scope.seleccionarPreciosYCondiciones = function() { 476 $scope.seleccionarPreciosYCondiciones = function() {
477 if(validarNotaRemitada()) { 477 if(validarNotaRemitada()) {
478 var modalInstance = $uibModal.open( 478 var modalInstance = $uibModal.open(
479 { 479 {
480 ariaLabelledBy: 'Busqueda de Precio Condición', 480 ariaLabelledBy: 'Busqueda de Precio Condición',
481 templateUrl: 'modal-precio-condicion.html', 481 templateUrl: 'modal-precio-condicion.html',
482 controller: 'focaModalPrecioCondicionController', 482 controller: 'focaModalPrecioCondicionController',
483 size: 'lg' 483 size: 'lg'
484 } 484 }
485 ); 485 );
486 modalInstance.result.then( 486 modalInstance.result.then(
487 function(precioCondicion) { 487 function(precioCondicion) {
488 var cabecera = ''; 488 var cabecera = '';
489 var plazosConcat = ''; 489 var plazosConcat = '';
490 if(!Array.isArray(precioCondicion)) { 490 if(!Array.isArray(precioCondicion)) {
491 $scope.notaPedido.idPrecioCondicion = precioCondicion.id; 491 $scope.notaPedido.idPrecioCondicion = precioCondicion.id;
492 $scope.plazosPagos = precioCondicion.plazoPago; 492 $scope.plazosPagos = precioCondicion.plazoPago;
493 $scope.idLista = precioCondicion.idListaPrecio; 493 $scope.idLista = precioCondicion.idListaPrecio;
494 for(var i = 0; i < precioCondicion.plazoPago.length; i++) { 494 for(var i = 0; i < precioCondicion.plazoPago.length; i++) {
495 plazosConcat += precioCondicion.plazoPago[i].dias + ' '; 495 plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
496 } 496 }
497 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); 497 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim();
498 } else { //Cuando se ingresan los plazos manualmente 498 } else { //Cuando se ingresan los plazos manualmente
499 $scope.notaPedido.idPrecioCondicion = 0; 499 $scope.notaPedido.idPrecioCondicion = 0;
500 //-1, el modal productos busca todos los productos 500 //-1, el modal productos busca todos los productos
501 $scope.idLista = -1; 501 $scope.idLista = -1;
502 $scope.plazosPagos = precioCondicion; 502 $scope.plazosPagos = precioCondicion;
503 for(var j = 0; j < precioCondicion.length; j++) { 503 for(var j = 0; j < precioCondicion.length; j++) {
504 plazosConcat += precioCondicion[j].dias + ' '; 504 plazosConcat += precioCondicion[j].dias + ' ';
505 } 505 }
506 cabecera = 'Ingreso manual ' + plazosConcat.trim(); 506 cabecera = 'Ingreso manual ' + plazosConcat.trim();
507 } 507 }
508 $scope.articulosTabla = []; 508 $scope.articulosTabla = [];
509 $scope.$broadcast('addCabecera',{ 509 $scope.$broadcast('addCabecera', {
510 label: 'Precios y condiciones:', 510 label: 'Precios y condiciones:',
511 valor: cabecera 511 valor: cabecera
512 }); 512 });
513 }, function() { 513 }, function() {
514 514
515 } 515 }
516 ); 516 );
517 } 517 }
518 }; 518 };
519 519
520 $scope.seleccionarFlete = function() { 520 $scope.seleccionarFlete = function() {
521 if(validarNotaRemitada()) { 521 if(validarNotaRemitada()) {
522 var modalInstance = $uibModal.open( 522 var modalInstance = $uibModal.open(
523 { 523 {
524 ariaLabelledBy: 'Busqueda de Flete', 524 ariaLabelledBy: 'Busqueda de Flete',
525 templateUrl: 'modal-flete.html', 525 templateUrl: 'modal-flete.html',
526 controller: 'focaModalFleteController', 526 controller: 'focaModalFleteController',
527 size: 'lg', 527 size: 'lg',
528 resolve: { 528 resolve: {
529 parametrosFlete: 529 parametrosFlete:
530 function() { 530 function() {
531 return { 531 return {
532 flete: $scope.notaPedido.fob ? 'FOB' : 532 flete: $scope.notaPedido.fob ? 'FOB' :
533 ( $scope.notaPedido.flete ? '1' : 533 ( $scope.notaPedido.flete ? '1' :
534 ($scope.notaPedido.flete === undefined ? 534 ($scope.notaPedido.flete === undefined ?
535 null : '0')), 535 null : '0')),
536 bomba: $scope.notaPedido.bomba ? '1' : 536 bomba: $scope.notaPedido.bomba ? '1' :
537 ($scope.notaPedido.bomba === undefined ? 537 ($scope.notaPedido.bomba === undefined ?
538 null : '0'), 538 null : '0'),
539 kilometros: $scope.notaPedido.kilometros 539 kilometros: $scope.notaPedido.kilometros
540 }; 540 };
541 } 541 }
542 } 542 }
543 } 543 }
544 ); 544 );
545 modalInstance.result.then( 545 modalInstance.result.then(
546 function(datos) { 546 function(datos) {
547 $scope.notaPedido.flete = datos.flete; 547 $scope.notaPedido.flete = datos.flete;
548 $scope.notaPedido.fob = datos.FOB; 548 $scope.notaPedido.fob = datos.FOB;
549 $scope.notaPedido.bomba = datos.bomba; 549 $scope.notaPedido.bomba = datos.bomba;
550 $scope.notaPedido.kilometros = datos.kilometros; 550 $scope.notaPedido.kilometros = datos.kilometros;
551 $scope.$broadcast('addCabecera',{ 551 $scope.$broadcast('addCabecera', {
552 label: 'Flete:', 552 label: 'Flete:',
553 valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') 553 valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No')
554 }); 554 });
555 if(datos.flete) { 555 if(datos.flete) {
556 $scope.$broadcast('addCabecera',{ 556 $scope.$broadcast('addCabecera', {
557 label: 'Bomba:', 557 label: 'Bomba:',
558 valor: datos.bomba ? 'Si' : 'No' 558 valor: datos.bomba ? 'Si' : 'No'
559 }); 559 });
560 $scope.$broadcast('addCabecera',{ 560 $scope.$broadcast('addCabecera', {
561 label: 'Kilometros:', 561 label: 'Kilometros:',
562 valor: datos.kilometros 562 valor: datos.kilometros
563 }); 563 });
564 } else { 564 } else {
565 $scope.$broadcast('removeCabecera', 'Bomba:'); 565 $scope.$broadcast('removeCabecera', 'Bomba:');
566 $scope.$broadcast('removeCabecera', 'Kilometros:'); 566 $scope.$broadcast('removeCabecera', 'Kilometros:');
567 $scope.notaPedido.bomba = false; 567 $scope.notaPedido.bomba = false;
568 $scope.notaPedido.kilometros = null; 568 $scope.notaPedido.kilometros = null;
569 } 569 }
570 }, function() { 570 }, function() {
571 571
572 } 572 }
573 ); 573 );
574 } 574 }
575 }; 575 };
576 576
577 $scope.seleccionarMoneda = function() { 577 $scope.seleccionarMoneda = function() {
578 if(validarNotaRemitada()) { 578 if(validarNotaRemitada()) {
579 var modalInstance = $uibModal.open( 579 var modalInstance = $uibModal.open(
580 { 580 {
581 ariaLabelledBy: 'Busqueda de Moneda', 581 ariaLabelledBy: 'Busqueda de Moneda',
582 templateUrl: 'modal-moneda.html', 582 templateUrl: 'modal-moneda.html',
583 controller: 'focaModalMonedaController', 583 controller: 'focaModalMonedaController',
584 size: 'lg' 584 size: 'lg'
585 } 585 }
586 ); 586 );
587 modalInstance.result.then( 587 modalInstance.result.then(
588 function(moneda) { 588 function(moneda) {
589 $scope.abrirModalCotizacion(moneda); 589 $scope.abrirModalCotizacion(moneda);
590 }, function() { 590 }, function() {
591 591
592 } 592 }
593 ); 593 );
594 } 594 }
595 }; 595 };
596 596
597 $scope.abrirModalCotizacion = function(moneda) { 597 $scope.abrirModalCotizacion = function(moneda) {
598 var modalInstance = $uibModal.open( 598 var modalInstance = $uibModal.open(
599 { 599 {
600 ariaLabelledBy: 'Busqueda de Cotización', 600 ariaLabelledBy: 'Busqueda de Cotización',
601 templateUrl: 'modal-cotizacion.html', 601 templateUrl: 'modal-cotizacion.html',
602 controller: 'focaModalCotizacionController', 602 controller: 'focaModalCotizacionController',
603 size: 'lg', 603 size: 'lg',
604 resolve: {idMoneda: function() {return moneda.ID;}} 604 resolve: {idMoneda: function() {return moneda.ID;}}
605 } 605 }
606 ); 606 );
607 modalInstance.result.then( 607 modalInstance.result.then(
608 function(cotizacion) { 608 function(cotizacion) {
609 var articulosTablaTemp = $scope.articulosTabla; 609 var articulosTablaTemp = $scope.articulosTabla;
610 for(var i = 0; i < articulosTablaTemp.length; i++) { 610 for(var i = 0; i < articulosTablaTemp.length; i++) {
611 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * 611 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
612 $scope.notaPedido.cotizacion.VENDEDOR; 612 $scope.notaPedido.cotizacion.VENDEDOR;
613 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / 613 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio /
614 cotizacion.VENDEDOR; 614 cotizacion.VENDEDOR;
615 } 615 }
616 $scope.articulosTabla = articulosTablaTemp; 616 $scope.articulosTabla = articulosTablaTemp;
617 $scope.notaPedido.moneda = moneda; 617 $scope.notaPedido.moneda = moneda;
618 $scope.notaPedido.cotizacion = cotizacion; 618 $scope.notaPedido.cotizacion = cotizacion;
619 if(moneda.DETALLE === 'PESOS ARGENTINOS'){ 619 if(moneda.DETALLE === 'PESOS ARGENTINOS') {
620 $scope.$broadcast('removeCabecera', 'Moneda:'); 620 $scope.$broadcast('removeCabecera', 'Moneda:');
621 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); 621 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
622 $scope.$broadcast('removeCabecera', 'Cotizacion:'); 622 $scope.$broadcast('removeCabecera', 'Cotizacion:');
623 }else{ 623 }else {
624 $scope.$broadcast('addCabecera',{ 624 $scope.$broadcast('addCabecera', {
625 label: 'Moneda:', 625 label: 'Moneda:',
626 valor: moneda.DETALLE 626 valor: moneda.DETALLE
627 }); 627 });
628 $scope.$broadcast('addCabecera',{ 628 $scope.$broadcast('addCabecera', {
629 label: 'Fecha cotizacion:', 629 label: 'Fecha cotizacion:',
630 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 630 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
631 }); 631 });
632 $scope.$broadcast('addCabecera',{ 632 $scope.$broadcast('addCabecera', {
633 label: 'Cotizacion:', 633 label: 'Cotizacion:',
634 valor: cotizacion.VENDEDOR 634 valor: cotizacion.VENDEDOR
635 }); 635 });
636 } 636 }
637 }, function() { 637 }, function() {
638 638
639 } 639 }
640 ); 640 );
641 }; 641 };
642 642
643 $scope.agregarATabla = function(key) { 643 $scope.agregarATabla = function(key) {
644 if(key === 13) { 644 if(key === 13) {
645 if($scope.articuloACargar.cantidad === undefined || 645 if($scope.articuloACargar.cantidad === undefined ||
646 $scope.articuloACargar.cantidad === 0 || 646 $scope.articuloACargar.cantidad === 0 ||
647 $scope.articuloACargar.cantidad === null ) { 647 $scope.articuloACargar.cantidad === null ) {
648 focaModalService.alert('El valor debe ser al menos 1'); 648 focaModalService.alert('El valor debe ser al menos 1');
649 return; 649 return;
650 } 650 }
651 delete $scope.articuloACargar.sectorCodigo; 651 delete $scope.articuloACargar.sectorCodigo;
652 $scope.articulosTabla.push($scope.articuloACargar); 652 $scope.articulosTabla.push($scope.articuloACargar);
653 $scope.cargando = true; 653 $scope.cargando = true;
654 } 654 }
655 }; 655 };
656 656
657 $scope.quitarArticulo = function(key) { 657 $scope.quitarArticulo = function(key) {
658 $scope.articulosTabla.splice(key, 1); 658 $scope.articulosTabla.splice(key, 1);
659 }; 659 };
660 660
661 $scope.editarArticulo = function(key, articulo) { 661 $scope.editarArticulo = function(key, articulo) {
662 if(key === 13) { 662 if(key === 13) {
663 if(articulo.cantidad === null || articulo.cantidad === 0 || 663 if(articulo.cantidad === null || articulo.cantidad === 0 ||
664 articulo.cantidad === undefined) { 664 articulo.cantidad === undefined) {
665 focaModalService.alert('El valor debe ser al menos 1'); 665 focaModalService.alert('El valor debe ser al menos 1');
666 return; 666 return;
667 } 667 }
668 articulo.editCantidad = false; 668 articulo.editCantidad = false;
669 articulo.editPrecio = false; 669 articulo.editPrecio = false;
670 } 670 }
671 }; 671 };
672 672
673 $scope.cambioEdit = function(articulo, propiedad) { 673 $scope.cambioEdit = function(articulo, propiedad) {
674 if(propiedad === 'cantidad') { 674 if(propiedad === 'cantidad') {
675 articulo.editCantidad = true; 675 articulo.editCantidad = true;
676 } else if(propiedad === 'precio') { 676 } else if(propiedad === 'precio') {
677 articulo.editPrecio = true; 677 articulo.editPrecio = true;
678 } 678 }
679 }; 679 };
680 680
681 $scope.resetFilter = function() { 681 $scope.resetFilter = function() {
682 $scope.articuloACargar = {}; 682 $scope.articuloACargar = {};
683 $scope.cargando = true; 683 $scope.cargando = true;
684 }; 684 };
685 //Recibe aviso si el teclado está en uso 685 //Recibe aviso si el teclado está en uso
686 $rootScope.$on('usarTeclado', function(event, data) { 686 $rootScope.$on('usarTeclado', function(event, data) {
687 if(data) { 687 if(data) {
688 $scope.mostrarTeclado = true; 688 $scope.mostrarTeclado = true;
689 return; 689 return;
690 } 690 }
691 $scope.mostrarTeclado = false; 691 $scope.mostrarTeclado = false;
692 }); 692 });
693 693
694 $scope.selectFocus = function($event) { 694 $scope.selectFocus = function($event) {
695 // Si el teclado esta en uso no selecciona el valor 695 // Si el teclado esta en uso no selecciona el valor
696 if($scope.mostrarTeclado) { 696 if($scope.mostrarTeclado) {
697 return; 697 return;
698 } 698 }
699 $event.target.select(); 699 $event.target.select();
700 }; 700 };
701 701
702 $scope.salir = function() { 702 $scope.salir = function() {
703 $location.path('/'); 703 $location.path('/');
704 }; 704 };
705 705
706 $scope.parsearATexto = function(articulo) { 706 $scope.parsearATexto = function(articulo) {
707 articulo.cantidad = parseFloat(articulo.cantidad); 707 articulo.cantidad = parseFloat(articulo.cantidad);
708 articulo.precio = parseFloat(articulo.precio); 708 articulo.precio = parseFloat(articulo.precio);
709 }; 709 };
710 710
711 function addArrayCabecera(array) { 711 function addArrayCabecera(array) {
712 for(var i = 0; i < array.length; i++) { 712 for(var i = 0; i < array.length; i++) {
713 $scope.$broadcast('addCabecera',{ 713 $scope.$broadcast('addCabecera', {
714 label: array[i].label, 714 label: array[i].label,
715 valor: array[i].valor 715 valor: array[i].valor
716 }); 716 });
717 } 717 }
718 } 718 }
719 719
720 function rellenar(relleno, longitud) { 720 function rellenar(relleno, longitud) {
721 relleno = '' + relleno; 721 relleno = '' + relleno;
722 while (relleno.length < longitud) { 722 while (relleno.length < longitud) {
723 relleno = '0' + relleno; 723 relleno = '0' + relleno;
724 } 724 }
725 725
726 return relleno; 726 return relleno;
727 } 727 }
728 728
729 function validarNotaRemitada() { 729 function validarNotaRemitada() {
730 if(!$scope.notaPedido.idRemito) { 730 if(!$scope.notaPedido.idRemito) {
731 return true; 731 return true;
732 }else{ 732 }else{
733 focaModalService.alert('No se puede editar una nota de pedido remitada'); 733 focaModalService.alert('No se puede editar una nota de pedido remitada');
734 return false; 734 return false;
735 } 735 }
736 } 736 }
737 } 737 }
738 ]); 738 ]);
739 739