Commit 45bc7e520b39ecd2b70266feacacabd25d693da1

Authored by Marcelo Puebla
1 parent 9d4ac61c34
Exists in master

Codigo indentado.

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