Commit aed57b90d83e17b85b06cee737f48a83fc09d94c

Authored by Jose Pinto
1 parent 7d983cb5e6
Exists in master

envia parametro 'esNuevo' a modal domicilio

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