Commit e5e28ec46905fc44ba520aca07884b3a7d997f5d

Authored by Luigi
Exists in master

Merge remote-tracking branch 'upstream/develop'

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