Commit 6dcb83cd870a4f2a55d488d8acd03a11379ea37e

Authored by Pablo Marco del Pont
Exists in master

Merge branch 'master' into 'master'

guardo id precio condicion

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