Commit 315870f6d71385f993575d76206cbd2a05bb76ed

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'develop'

Master(mpuebla)

See merge request !91
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 if (validarNotaRemitada()) {
467 if (validarNotaRemitada()) { 465 var modalInstance = $uibModal.open(
468 var modalInstance = $uibModal.open( 466 {
469 { 467 ariaLabelledBy: 'Busqueda de Cliente',
470 ariaLabelledBy: 'Busqueda de Cliente', 468 templateUrl: 'foca-busqueda-cliente-modal.html',
471 templateUrl: 'foca-busqueda-cliente-modal.html', 469 controller: 'focaBusquedaClienteModalController',
472 controller: 'focaBusquedaClienteModalController', 470 resolve: {
473 resolve: { 471 vendedor: function () { return null; },
474 vendedor: function() { return $scope.notaPedido.vendedor; }, 472 cobrador: function () { return null; }
475 cobrador: function() { return null; } 473 },
476 }, 474 size: 'lg'
477 size: 'lg' 475 }
478 } 476 );
479 ); 477 modalInstance.result.then(
480 modalInstance.result.then( 478 function (cliente) {
481 function(cliente) { 479 $scope.abrirModalDomicilios(cliente);
482 $scope.abrirModalDomicilios(cliente); 480 $scope.cliente = cliente;
483 $scope.cliente = cliente; 481 }, function () { }
484 }, function() { 482 );
485 if (APP !== 'distribuidor') $scope.seleccionarCliente(); 483 }
486 }
487 );
488 }
489 }, ocultarVendedor);
490 }; 484 };
491 485
492 $scope.abrirModalProveedores = function(callback) { 486 $scope.abrirModalProveedores = function (callback) {
493 if (validarNotaRemitada()) { 487 if (validarNotaRemitada()) {
494 var parametrosModal = { 488 var parametrosModal = {
495 titulo: 'Búsqueda de Proveedor', 489 titulo: 'Búsqueda de Proveedor',
496 query: '/proveedor', 490 query: '/proveedor',
497 columnas: [ 491 columnas: [
498 { 492 {
499 nombre: 'Código', 493 nombre: 'Código',
500 propiedad: 'COD', 494 propiedad: 'COD',
501 filtro: { 495 filtro: {
502 nombre: 'rellenarDigitos', 496 nombre: 'rellenarDigitos',
503 parametro: 5 497 parametro: 5
504 } 498 }
505 }, 499 },
506 { 500 {
507 nombre: 'Nombre', 501 nombre: 'Nombre',
508 propiedad: 'NOM' 502 propiedad: 'NOM'
509 }, 503 },
510 { 504 {
511 nombre: 'CUIT', 505 nombre: 'CUIT',
512 propiedad: 'CUIT' 506 propiedad: 'CUIT'
513 } 507 }
514 ], 508 ],
515 tipo: 'POST', 509 tipo: 'POST',
516 json: {razonCuitCod: ''} 510 json: { razonCuitCod: '' }
517 }; 511 };
518 focaModalService.modal(parametrosModal).then( 512 focaModalService.modal(parametrosModal).then(
519 function(proveedor) { 513 function (proveedor) {
520 $scope.notaPedido.proveedor = proveedor; 514 $scope.notaPedido.proveedor = proveedor;
521 $scope.$broadcast('addCabecera', { 515 $scope.$broadcast('addCabecera', {
522 label: 'Proveedor:', 516 label: 'Proveedor:',
523 valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + 517 valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' +
524 proveedor.NOM 518 proveedor.NOM
525 }); 519 });
526 callback(); 520 callback();
527 }, function() { 521 }, function () {
528 522
529 } 523 }
530 ); 524 );
531 } 525 }
532 }; 526 };
533 527
534 $scope.abrirModalDomicilios = function(cliente) { 528 $scope.abrirModalDomicilios = function (cliente) {
535 var modalInstanceDomicilio = $uibModal.open( 529 var modalInstanceDomicilio = $uibModal.open(
536 { 530 {
537 ariaLabelledBy: 'Busqueda de Domicilios', 531 ariaLabelledBy: 'Busqueda de Domicilios',
538 templateUrl: 'modal-domicilio.html', 532 templateUrl: 'modal-domicilio.html',
539 controller: 'focaModalDomicilioController', 533 controller: 'focaModalDomicilioController',
540 resolve: { 534 resolve: {
541 idCliente: function() { return cliente.cod; }, 535 idCliente: function () { return cliente.cod; },
542 esNuevo: function() { return cliente.esNuevo; } 536 esNuevo: function () { return cliente.esNuevo; }
543 }, 537 },
544 size: 'lg', 538 size: 'lg',
545 } 539 }
546 ); 540 );
547 modalInstanceDomicilio.result.then( 541 modalInstanceDomicilio.result.then(
548 function(domicilio) { 542 function (domicilio) {
549 $scope.notaPedido.domicilio = domicilio; 543 $scope.notaPedido.domicilio = domicilio;
550 $scope.notaPedido.cliente = { 544 $scope.notaPedido.cliente = {
551 COD: cliente.cod, 545 COD: cliente.cod,
552 CUIT: cliente.cuit, 546 CUIT: cliente.cuit,
553 NOM: cliente.nom, 547 NOM: cliente.nom,
554 MOD: cliente.mod 548 MOD: cliente.mod,
549 VEN: cliente.ven
555 }; 550 };
556 var domicilioStamp = 551 crearNotaPedidoService.getVendedorById($scope.notaPedido.cliente.VEN)
557 domicilio.Calle + ' ' + domicilio.Numero + ', ' + 552 .then(function (res) {
558 domicilio.Localidad + ', ' + domicilio.Provincia; 553 if (res.data !== '') {
559 $scope.notaPedido.domicilioStamp = domicilioStamp; 554 $scope.notaPedido.vendedor = res.data;
560 555 $scope.$broadcast('addCabecera', {
561 $scope.$broadcast('addCabecera', { 556 label: 'Vendedor:',
562 label: 'Cliente:', 557 valor: $filter('rellenarDigitos')($scope.notaPedido.vendedor.NUM, 3) + ' - ' +
563 valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom 558 $scope.notaPedido.vendedor.NOM
564 }); 559 });
560 }
561 var domicilioStamp =
562 domicilio.Calle + ' ' + domicilio.Numero + ', ' +
563 domicilio.Localidad + ', ' + domicilio.Provincia;
564 $scope.notaPedido.domicilioStamp = domicilioStamp;
565 565
566 $scope.$broadcast('addCabecera', { 566 $scope.$broadcast('addCabecera', {
567 label: 'Domicilio:', 567 label: 'Cliente:',
568 valor: domicilioStamp 568 valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom
569 }); 569 });
570 570
571 if (domicilio.verPuntos) { 571 $scope.$broadcast('addCabecera', {
572 delete $scope.notaPedido.domicilio.verPuntos; 572 label: 'Domicilio:',
573 $scope.seleccionarPuntosDeDescarga(); 573 valor: domicilioStamp
574 } 574 });
575 575
576 // Seteo checked en botonera 576 if (domicilio.verPuntos) {
577 $filter('filter')($scope.botonera, { label: 'Cliente'})[0].checked = true; 577 delete $scope.notaPedido.domicilio.verPuntos;
578 $scope.seleccionarPuntosDeDescarga();
579 }
578 580
579 }, function() { 581 // Seteo checked en botonera
582 $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true;
583 })
584 .catch(function (e) { console.log(e); })
585 }, function () {
580 $scope.seleccionarCliente(true); 586 $scope.seleccionarCliente(true);
581 return; 587 return;
582 } 588 }
583 ); 589 );
584 }; 590 };
585 591
586 $scope.getTotal = function() { 592 $scope.getTotal = function () {
587 var total = 0; 593 var total = 0;
588 if ($scope.notaPedido.articulosNotaPedido) { 594 if ($scope.notaPedido.articulosNotaPedido) {
589 var arrayTempArticulos = $scope.notaPedido.articulosNotaPedido; 595 var arrayTempArticulos = $scope.notaPedido.articulosNotaPedido;
590 for (var i = 0; i < arrayTempArticulos.length; i++) { 596 for (var i = 0; i < arrayTempArticulos.length; i++) {
591 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 597 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
592 } 598 }
593 } 599 }
594 return parseFloat(total.toFixed(2)); 600 return parseFloat(total.toFixed(2));
595 }; 601 };
596 602
597 $scope.getSubTotal = function() { 603 $scope.getSubTotal = function () {
598 if ($scope.articuloACargar) { 604 if ($scope.articuloACargar) {
599 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 605 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
600 } 606 }
601 }; 607 };
602 608
603 $scope.seleccionarPreciosYCondiciones = function() { 609 $scope.seleccionarPreciosYCondiciones = function () {
604 610
605 if (!validarNotaRemitada()) { 611 if (!validarNotaRemitada()) {
606 return; 612 return;
607 } 613 }
608 614
609 if (!$scope.notaPedido.cliente.COD) { 615 if (!$scope.notaPedido.cliente.COD) {
610 focaModalService.alert('Primero seleccione un cliente'); 616 focaModalService.alert('Primero seleccione un cliente');
611 return; 617 return;
612 } 618 }
613 if ($scope.notaPedido.articulosNotaPedido.length !== 0) { 619 if ($scope.notaPedido.articulosNotaPedido.length !== 0) {
614 focaModalService.confirm('Se perderan los productos ingresados') 620 focaModalService.confirm('Se perderan los productos ingresados')
615 .then(function(data) { 621 .then(function (data) {
616 if (data) { 622 if (data) {
617 abrirModal(); 623 abrirModal();
618 } 624 }
619 }); 625 });
620 } else if (validarNotaRemitada()) { 626 } else if (validarNotaRemitada()) {
621 abrirModal(); 627 abrirModal();
622 } 628 }
623 function abrirModal() { 629 function abrirModal() {
624 var modalInstance = $uibModal.open( 630 var modalInstance = $uibModal.open(
625 { 631 {
626 ariaLabelledBy: 'Busqueda de Precio Condición', 632 ariaLabelledBy: 'Busqueda de Precio Condición',
627 templateUrl: 'modal-precio-condicion.html', 633 templateUrl: 'modal-precio-condicion.html',
628 controller: 'focaModalPrecioCondicionController', 634 controller: 'focaModalPrecioCondicionController',
629 size: 'lg', 635 size: 'lg',
630 resolve: { 636 resolve: {
631 idListaPrecio: function() { 637 idListaPrecio: function () {
632 return $scope.notaPedido.cliente.MOD || null; 638 return $scope.notaPedido.cliente.MOD || null;
633 } 639 }
634 } 640 }
635 } 641 }
636 ); 642 );
637 643
638 modalInstance.result.then( 644 modalInstance.result.then(
639 function(precioCondicion) { 645 function (precioCondicion) {
640 var cabecera = ''; 646 var cabecera = '';
641 var plazosConcat = ''; 647 var plazosConcat = '';
642 if (!Array.isArray(precioCondicion)) { 648 if (!Array.isArray(precioCondicion)) {
643 $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; 649 $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago;
644 $scope.notaPedido.precioCondicion = precioCondicion; 650 $scope.notaPedido.precioCondicion = precioCondicion;
645 $scope.notaPedido.idPrecioCondicion = precioCondicion.id; 651 $scope.notaPedido.idPrecioCondicion = precioCondicion.id;
646 $scope.idLista = precioCondicion.idListaPrecio; 652 $scope.idLista = precioCondicion.idListaPrecio;
647 for (var i = 0; i < precioCondicion.plazoPago.length; i++) { 653 for (var i = 0; i < precioCondicion.plazoPago.length; i++) {
648 plazosConcat += precioCondicion.plazoPago[i].dias + ' '; 654 plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
649 } 655 }
650 cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + 656 cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) +
651 ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); 657 ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim();
652 } else { //Cuando se ingresan los plazos manualmente 658 } else { //Cuando se ingresan los plazos manualmente
653 $scope.notaPedido.idPrecioCondicion = 0; 659 $scope.notaPedido.idPrecioCondicion = 0;
654 //-1, el modal productos busca todos los productos 660 //-1, el modal productos busca todos los productos
655 $scope.idLista = -1; 661 $scope.idLista = -1;
656 $scope.notaPedido.notaPedidoPlazo = precioCondicion; 662 $scope.notaPedido.notaPedidoPlazo = precioCondicion;
657 for (var j = 0; j < precioCondicion.length; j++) { 663 for (var j = 0; j < precioCondicion.length; j++) {
658 plazosConcat += precioCondicion[j].dias + ' '; 664 plazosConcat += precioCondicion[j].dias + ' ';
659 } 665 }
660 cabecera = 'Ingreso manual ' + plazosConcat.trim(); 666 cabecera = 'Ingreso manual ' + plazosConcat.trim();
661 } 667 }
662 $scope.notaPedido.articulosNotaPedido = []; 668 $scope.notaPedido.articulosNotaPedido = [];
663 $scope.$broadcast('addCabecera', { 669 $scope.$broadcast('addCabecera', {
664 label: 'Precios y condiciones:', 670 label: 'Precios y condiciones:',
665 valor: cabecera 671 valor: cabecera
666 }); 672 });
667 673
668 $filter('filter')($scope.botonera, 674 $filter('filter')($scope.botonera,
669 { label: 'Precios y Condiciones'})[0].checked = true; 675 { label: 'Precios y Condiciones' })[0].checked = true;
670 }, function() { 676 }, function () {
671 677
672 } 678 }
673 ); 679 );
674 } 680 }
675 }; 681 };
676 682
677 $scope.seleccionarMoneda = function() { 683 $scope.seleccionarMoneda = function () {
678 if (validarNotaRemitada()) { 684 if (validarNotaRemitada()) {
679 var parametrosModal = { 685 var parametrosModal = {
680 titulo: 'Búsqueda de monedas', 686 titulo: 'Búsqueda de monedas',
681 query: '/moneda', 687 query: '/moneda',
682 columnas: [ 688 columnas: [
683 { 689 {
684 propiedad: 'DETALLE', 690 propiedad: 'DETALLE',
685 nombre: 'Nombre' 691 nombre: 'Nombre'
686 }, 692 },
687 { 693 {
688 propiedad: 'SIMBOLO', 694 propiedad: 'SIMBOLO',
689 nombre: 'Símbolo' 695 nombre: 'Símbolo'
690 } 696 }
691 ], 697 ],
692 size: 'md' 698 size: 'md'
693 }; 699 };
694 focaModalService.modal(parametrosModal).then( 700 focaModalService.modal(parametrosModal).then(
695 function(moneda) { 701 function (moneda) {
696 702
697 if (moneda.ID !== 1) { 703 if (moneda.ID !== 1) {
698 $scope.abrirModalCotizacion(moneda); 704 $scope.abrirModalCotizacion(moneda);
699 return; 705 return;
700 } 706 }
701 707
702 crearNotaPedidoService.getCotizacionByIdMoneda(1) 708 crearNotaPedidoService.getCotizacionByIdMoneda(1)
703 .then(function (res) { 709 .then(function (res) {
704 710
705 cotizacionPArgentino = res.data[0].cotizaciones[0]; 711 cotizacionPArgentino = res.data[0].cotizaciones[0];
706 cotizacionPArgentino.moneda = moneda; 712 cotizacionPArgentino.moneda = moneda;
707 713
708 actualizarCabeceraMoneda(cotizacionPArgentino); 714 actualizarCabeceraMoneda(cotizacionPArgentino);
709 $scope.notaPedido.cotizacion = cotizacionPArgentino; 715 $scope.notaPedido.cotizacion = cotizacionPArgentino;
710 }); 716 });
711 } 717 }
712 ); 718 );
713 } 719 }
714 }; 720 };
715 721
716 $scope.seleccionarObservaciones = function() { 722 $scope.seleccionarObservaciones = function () {
717 var observacion = { 723 var observacion = {
718 titulo: 'Ingrese Observaciones', 724 titulo: 'Ingrese Observaciones',
719 value: $scope.notaPedido.observaciones, 725 value: $scope.notaPedido.observaciones,
720 maxlength: 155, 726 maxlength: 155,
721 textarea: true 727 textarea: true
722 }; 728 };
723 729
724 focaModalService 730 focaModalService
725 .prompt(observacion) 731 .prompt(observacion)
726 .then(function(observaciones) { 732 .then(function (observaciones) {
727 $scope.notaPedido.observaciones = observaciones; 733 $scope.notaPedido.observaciones = observaciones;
728 }); 734 });
729 }; 735 };
730 736
731 $scope.abrirModalCotizacion = function(moneda) { 737 $scope.abrirModalCotizacion = function (moneda) {
732 var modalInstance = $uibModal.open( 738 var modalInstance = $uibModal.open(
733 { 739 {
734 ariaLabelledBy: 'Busqueda de Cotización', 740 ariaLabelledBy: 'Busqueda de Cotización',
735 templateUrl: 'modal-cotizacion.html', 741 templateUrl: 'modal-cotizacion.html',
736 controller: 'focaModalCotizacionController', 742 controller: 'focaModalCotizacionController',
737 size: 'lg', 743 size: 'lg',
738 resolve: { 744 resolve: {
739 idMoneda: function() { 745 idMoneda: function () {
740 return moneda.ID; 746 return moneda.ID;
741 } 747 }
742 } 748 }
743 } 749 }
744 ); 750 );
745 modalInstance.result.then( 751 modalInstance.result.then(
746 function(cotizacion) { 752 function (cotizacion) {
747 753
748 cotizacion.moneda = moneda; 754 cotizacion.moneda = moneda;
749 actualizarCabeceraMoneda(cotizacion); 755 actualizarCabeceraMoneda(cotizacion);
750 756
751 $scope.notaPedido.cotizacion = cotizacion; 757 $scope.notaPedido.cotizacion = cotizacion;
752 $filter('filter')($scope.botonera, { label: 'Moneda'})[0].checked = true; 758 $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true;
753 }, function() { 759 }, function () {
754 760
755 } 761 }
756 ); 762 );
757 }; 763 };
758 764
759 function actualizarCabeceraMoneda (cotizacion) { 765 function actualizarCabeceraMoneda(cotizacion) {
760 766
761 $scope.notaPedido.articulosNotaPedido.forEach(function(art) { 767 $scope.notaPedido.articulosNotaPedido.forEach(function (art) {
762 art.precio = (art.precio * $scope.notaPedido.cotizacion.VENDEDOR).toFixed(4); 768 art.precio = (art.precio * $scope.notaPedido.cotizacion.VENDEDOR).toFixed(4);
763 art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4); 769 art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4);
764 }); 770 });
765 771
766 if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { 772 if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') {
767 $scope.$broadcast('removeCabecera', 'Moneda:'); 773 $scope.$broadcast('removeCabecera', 'Moneda:');
768 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); 774 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
769 $scope.$broadcast('removeCabecera', 'Cotizacion:'); 775 $scope.$broadcast('removeCabecera', 'Cotizacion:');
770 } else { 776 } else {
771 $scope.$broadcast('addCabecera', { 777 $scope.$broadcast('addCabecera', {
772 label: 'Moneda:', 778 label: 'Moneda:',
773 valor: cotizacion.moneda.DETALLE 779 valor: cotizacion.moneda.DETALLE
774 }); 780 });
775 $scope.$broadcast('addCabecera', { 781 $scope.$broadcast('addCabecera', {
776 label: 'Fecha cotizacion:', 782 label: 'Fecha cotizacion:',
777 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 783 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
778 }); 784 });
779 $scope.$broadcast('addCabecera', { 785 $scope.$broadcast('addCabecera', {
780 label: 'Cotizacion:', 786 label: 'Cotizacion:',
781 valor: $filter('number')(cotizacion.VENDEDOR, '2') 787 valor: $filter('number')(cotizacion.VENDEDOR, '2')
782 }); 788 });
783 } 789 }
784 } 790 }
785 791
786 $scope.agregarATabla = function(key) { 792 $scope.agregarATabla = function (key) {
787 if (key === 13) { 793 if (key === 13) {
788 if ($scope.articuloACargar.cantidad === undefined || 794 if ($scope.articuloACargar.cantidad === undefined ||
789 $scope.articuloACargar.cantidad === 0 || 795 $scope.articuloACargar.cantidad === 0 ||
790 $scope.articuloACargar.cantidad === null ) { 796 $scope.articuloACargar.cantidad === null) {
791 focaModalService.alert('El valor debe ser al menos 1'); 797 focaModalService.alert('El valor debe ser al menos 1');
792 return; 798 return;
793 } 799 }
794 delete $scope.articuloACargar.sectorCodigo; 800 delete $scope.articuloACargar.sectorCodigo;
795 $scope.notaPedido.articulosNotaPedido.push($scope.articuloACargar); 801 $scope.notaPedido.articulosNotaPedido.push($scope.articuloACargar);
796 $scope.cargando = true; 802 $scope.cargando = true;
797 } 803 }
798 }; 804 };
799 805
800 $scope.quitarArticulo = function(key) { 806 $scope.quitarArticulo = function (key) {
801 if (validarNotaRemitada()) { 807 if (validarNotaRemitada()) {
802 $scope.notaPedido.articulosNotaPedido.splice(key, 1); 808 $scope.notaPedido.articulosNotaPedido.splice(key, 1);
803 } 809 }
804 }; 810 };
805 811
806 $scope.editarArticulo = function(key, articulo, tmpCantidad, tmpPrecio) { 812 $scope.editarArticulo = function (key, articulo, tmpCantidad, tmpPrecio) {
807 if (key === 13) { 813 if (key === 13) {
808 if (!articulo.cantidad || !articulo.precio) { 814 if (!articulo.cantidad || !articulo.precio) {
809 focaModalService.alert('Los valores deben ser al menos 1'); 815 focaModalService.alert('Los valores deben ser al menos 1');
810 return; 816 return;
811 } else if (articulo.cantidad < 0 || articulo.precio < 0) { 817 } else if (articulo.cantidad < 0 || articulo.precio < 0) {
812 focaModalService.alert('Los valores no pueden ser negativos'); 818 focaModalService.alert('Los valores no pueden ser negativos');
813 return; 819 return;
814 } 820 }
815 articulo.cantidad = tmpCantidad; 821 articulo.cantidad = tmpCantidad;
816 articulo.precio = tmpPrecio; 822 articulo.precio = tmpPrecio;
817 $scope.getTotal(); 823 $scope.getTotal();
818 articulo.editCantidad = articulo.editPrecio = false; 824 articulo.editCantidad = articulo.editPrecio = false;
819 } 825 }
820 }; 826 };
821 827
822 $scope.cancelarEditar = function(articulo) { 828 $scope.cancelarEditar = function (articulo) {
823 $scope.tmpCantidad = articulo.cantidad; 829 $scope.tmpCantidad = articulo.cantidad;
824 $scope.tmpPrecio = articulo.precio; 830 $scope.tmpPrecio = articulo.precio;
825 articulo.editCantidad = articulo.editPrecio = false; 831 articulo.editCantidad = articulo.editPrecio = false;
826 }; 832 };
827 833
828 $scope.cambioEdit = function(articulo, propiedad) { 834 $scope.cambioEdit = function (articulo, propiedad) {
829 if (propiedad === 'cantidad') { 835 if (propiedad === 'cantidad') {
830 articulo.editCantidad = true; 836 articulo.editCantidad = true;
831 } else if (propiedad === 'precio') { 837 } else if (propiedad === 'precio') {
832 articulo.editPrecio = true; 838 articulo.editPrecio = true;
833 } 839 }
834 }; 840 };
835 841
836 $scope.resetFilter = function() { 842 $scope.resetFilter = function () {
837 $scope.articuloACargar = {}; 843 $scope.articuloACargar = {};
838 $scope.cargando = true; 844 $scope.cargando = true;
839 }; 845 };
840 //Recibe aviso si el teclado está en uso 846 //Recibe aviso si el teclado está en uso
841 $rootScope.$on('usarTeclado', function(event, data) { 847 $rootScope.$on('usarTeclado', function (event, data) {
842 if (data) { 848 if (data) {
843 $scope.mostrarTeclado = true; 849 $scope.mostrarTeclado = true;
844 return; 850 return;
845 } 851 }
846 $scope.mostrarTeclado = false; 852 $scope.mostrarTeclado = false;
847 }); 853 });
848 854
849 $scope.selectFocus = function($event) { 855 $scope.selectFocus = function ($event) {
850 // Si el teclado esta en uso no selecciona el valor 856 // Si el teclado esta en uso no selecciona el valor
851 if ($scope.mostrarTeclado) { 857 if ($scope.mostrarTeclado) {
852 return; 858 return;
853 } 859 }
854 $event.target.select(); 860 $event.target.select();
855 }; 861 };
856 862
857 $scope.salir = function() { 863 $scope.salir = function () {
858 $location.path('/'); 864 $location.path('/');
859 }; 865 };
860 866
861 $scope.parsearATexto = function(articulo) { 867 $scope.parsearATexto = function (articulo) {
862 articulo.cantidad = parseFloat(articulo.cantidad); 868 articulo.cantidad = parseFloat(articulo.cantidad);
863 articulo.precio = parseFloat(articulo.precio); 869 articulo.precio = parseFloat(articulo.precio);
864 }; 870 };
865 871
866 // TODO: quitar watch usar función de articulos pedido cuando se haga 872 // TODO: quitar watch usar función de articulos pedido cuando se haga
867 $scope.$watch('notaPedido.articulosNotaPedido', function() { 873 $scope.$watch('notaPedido.articulosNotaPedido', function () {
868 if ($scope.notaPedido.articulosNotaPedido.length) { 874 if ($scope.notaPedido.articulosNotaPedido.length) {
869 $filter('filter')($scope.botonera, 875 $filter('filter')($scope.botonera,
870 { label: 'Productos'})[0].checked = true; 876 { label: 'Productos' })[0].checked = true;
871 } else { 877 } else {
872 $filter('filter')($scope.botonera, 878 $filter('filter')($scope.botonera,
873 { label: 'Productos'})[0].checked = false; 879 { label: 'Productos' })[0].checked = false;
874 } 880 }
875 }, true); 881 }, true);
876 882
877 function setearNotaPedido(notaPedido) { 883 function setearNotaPedido(notaPedido) {
878 //añado cabeceras 884 //añado cabeceras
879 $scope.notaPedido = notaPedido; 885 $scope.notaPedido = notaPedido;
880 if (!$scope.notaPedido.domicilio) { 886 if (!$scope.notaPedido.domicilio) {
881 $scope.notaPedido.domicilio = { 887 $scope.notaPedido.domicilio = {
882 id: $scope.notaPedido.idDomicilio 888 id: $scope.notaPedido.idDomicilio
883 }; 889 };
884 } 890 }
885 $scope.$broadcast('removeCabecera', 'Bomba:'); 891 $scope.$broadcast('removeCabecera', 'Bomba:');
886 $scope.$broadcast('removeCabecera', 'Kilometros:'); 892 $scope.$broadcast('removeCabecera', 'Kilometros:');
887 $scope.$broadcast('cleanCabecera'); 893 $scope.$broadcast('cleanCabecera');
888 894
889 var cabeceras = []; 895 var cabeceras = [];
890 896
891 if (notaPedido.cotizacion.moneda.CODIGO_AFIP !== 'PES') { 897 if (notaPedido.cotizacion.moneda.CODIGO_AFIP !== 'PES') {
892 cabeceras.push({ 898 cabeceras.push({
893 label: 'Moneda:', 899 label: 'Moneda:',
894 valor: notaPedido.cotizacion.moneda.DETALLE 900 valor: notaPedido.cotizacion.moneda.DETALLE
895 }); 901 });
896 cabeceras.push({ 902 cabeceras.push({
897 label: 'Fecha cotizacion:', 903 label: 'Fecha cotizacion:',
898 valor: $filter('date')(notaPedido.cotizacion.FECHA, 904 valor: $filter('date')(notaPedido.cotizacion.FECHA,
899 'dd/MM/yyyy') 905 'dd/MM/yyyy')
900 }); 906 });
901 cabeceras.push({ 907 cabeceras.push({
902 label: 'Cotizacion:', 908 label: 'Cotizacion:',
903 valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, 909 valor: $filter('number')(notaPedido.cotizacion.VENDEDOR,
904 '2') 910 '2')
905 }); 911 });
906 } 912 }
907 913
908 if (notaPedido.cotizacion.moneda) { 914 if (notaPedido.cotizacion.moneda) {
909 $filter('filter')($scope.botonera, { label: 'Moneda'})[0].checked = true; 915 $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true;
910 } 916 }
911 917
912 if (notaPedido.vendedor.NUM) { 918 if (notaPedido.vendedor.NUM) {
913 cabeceras.push({ 919 cabeceras.push({
914 label: 'Vendedor:', 920 label: 'Vendedor:',
915 valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + 921 valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) +
916 ' - ' + notaPedido.vendedor.NOM 922 ' - ' + notaPedido.vendedor.NOM
917 }); 923 });
918 } 924 }
919 925
920 if (notaPedido.cliente.COD) { 926 if (notaPedido.cliente.COD) {
921 cabeceras.push({ 927 cabeceras.push({
922 label: 'Cliente:', 928 label: 'Cliente:',
923 valor: notaPedido.cliente.NOM 929 valor: notaPedido.cliente.NOM
924 }); 930 });
925 cabeceras.push({ 931 cabeceras.push({
926 label: 'Domicilio:', 932 label: 'Domicilio:',
927 valor: notaPedido.domicilioStamp 933 valor: notaPedido.domicilioStamp
928 }); 934 });
929 935
930 $filter('filter')($scope.botonera, { label: 'Cliente'})[0].checked = true; 936 $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true;
931 } 937 }
932 938
933 if (notaPedido.proveedor.COD) { 939 if (notaPedido.proveedor.COD) {
934 cabeceras.push({ 940 cabeceras.push({
935 label: 'Proveedor:', 941 label: 'Proveedor:',
936 valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) + 942 valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) +
937 ' - ' + notaPedido.proveedor.NOM 943 ' - ' + notaPedido.proveedor.NOM
938 }); 944 });
939 945
940 $filter('filter')($scope.botonera, { label: 'Proveedor'})[0].checked = true; 946 $filter('filter')($scope.botonera, { label: 'Proveedor' })[0].checked = true;
941 } 947 }
942 948
943 if (notaPedido.notaPedidoPlazo.length) { 949 if (notaPedido.notaPedidoPlazo.length) {
944 cabeceras.push({ 950 cabeceras.push({
945 label: 'Precios y condiciones:', 951 label: 'Precios y condiciones:',
946 valor: valorPrecioCondicion() + ' ' + 952 valor: valorPrecioCondicion() + ' ' +
947 notaPedidoBusinessService 953 notaPedidoBusinessService
948 .plazoToString(notaPedido.notaPedidoPlazo) 954 .plazoToString(notaPedido.notaPedidoPlazo)
949 }); 955 });
950 956
951 $filter('filter')($scope.botonera, 957 $filter('filter')($scope.botonera,
952 { label: 'Precios y condiciones'})[0].checked = true; 958 { label: 'Precios y condiciones' })[0].checked = true;
953 } 959 }
954 960
955 if (notaPedido.flete !== undefined) { 961 if (notaPedido.flete !== undefined) {
956 cabeceras.push({ 962 cabeceras.push({
957 label: 'Flete:', 963 label: 'Flete:',
958 valor: notaPedido.fob === 1 ? 'FOB' : ( 964 valor: notaPedido.fob === 1 ? 'FOB' : (
959 notaPedido.flete === 1 ? 'Si' : 'No') 965 notaPedido.flete === 1 ? 'Si' : 'No')
960 }); 966 });
961 } 967 }
962 968
963 function valorPrecioCondicion() { 969 function valorPrecioCondicion() {
964 if (notaPedido.idPrecioCondicion > 0) { 970 if (notaPedido.idPrecioCondicion > 0) {
965 return notaPedido.precioCondicion.nombre; 971 return notaPedido.precioCondicion.nombre;
966 } else { 972 } else {
967 return 'Ingreso Manual'; 973 return 'Ingreso Manual';
968 } 974 }
969 } 975 }
970 976
971 if (notaPedido.flete === 1) { 977 if (notaPedido.flete === 1) {
972 var cabeceraBomba = { 978 var cabeceraBomba = {
973 label: 'Bomba:', 979 label: 'Bomba:',
974 valor: notaPedido.bomba === 1 ? 'Si' : 'No' 980 valor: notaPedido.bomba === 1 ? 'Si' : 'No'
975 }; 981 };
976 if (notaPedido.kilometros) { 982 if (notaPedido.kilometros) {
977 var cabeceraKilometros = { 983 var cabeceraKilometros = {
978 label: 'Kilometros:', 984 label: 'Kilometros:',
979 valor: notaPedido.kilometros 985 valor: notaPedido.kilometros
980 }; 986 };
981 cabeceras.push(cabeceraKilometros); 987 cabeceras.push(cabeceraKilometros);
982 } 988 }
983 cabeceras.push(cabeceraBomba); 989 cabeceras.push(cabeceraBomba);
984 } 990 }
985 991
986 if (notaPedido.idPrecioCondicion > 0) { 992 if (notaPedido.idPrecioCondicion > 0) {
987 $scope.idLista = notaPedido.precioCondicion.idListaPrecio; 993 $scope.idLista = notaPedido.precioCondicion.idListaPrecio;
988 } else if (notaPedido.idPrecioCondicion) { 994 } else if (notaPedido.idPrecioCondicion) {
989 $scope.idLista = -1; 995 $scope.idLista = -1;
990 } 996 }
991 997
992 $scope.puntoVenta = $filter('rellenarDigitos')( 998 $scope.puntoVenta = $filter('rellenarDigitos')(
993 notaPedido.sucursal, 4 999 notaPedido.sucursal, 4
994 ); 1000 );
995 1001
996 $scope.comprobante = $filter('rellenarDigitos')( 1002 $scope.comprobante = $filter('rellenarDigitos')(
997 notaPedido.numeroNotaPedido, 8 1003 notaPedido.numeroNotaPedido, 8
998 ); 1004 );
999 1005
1000 if (notaPedido.notaPedidoPuntoDescarga.length) { 1006 if (notaPedido.notaPedidoPuntoDescarga.length) {
1001 var puntos = []; 1007 var puntos = [];
1002 notaPedido.notaPedidoPuntoDescarga.forEach(function(notaPedidoPuntoDescarga) { 1008 notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedidoPuntoDescarga) {
1003 puntos.push(notaPedidoPuntoDescarga.puntoDescarga); 1009 puntos.push(notaPedidoPuntoDescarga.puntoDescarga);
1004 }); 1010 });
1005 cabeceras.push({ 1011 cabeceras.push({
1006 label: 'Puntos de descarga: ', 1012 label: 'Puntos de descarga: ',
1007 valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) 1013 valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos))
1008 }); 1014 });
1009 } 1015 }
1010 1016
1011 if ($scope.notaPedido.articulosNotaPedido.length) { 1017 if ($scope.notaPedido.articulosNotaPedido.length) {
1012 $scope.notaPedido.articulosNotaPedido.forEach(function (articulo) { 1018 $scope.notaPedido.articulosNotaPedido.forEach(function (articulo) {
1013 articulo.precio = 1019 articulo.precio =
1014 (articulo.precio / $scope.notaPedido.cotizacion.VENDEDOR).toFixed(4); 1020 (articulo.precio / $scope.notaPedido.cotizacion.VENDEDOR).toFixed(4);
1015 }); 1021 });
1016 } 1022 }
1017 1023
1018 addArrayCabecera(cabeceras); 1024 addArrayCabecera(cabeceras);
1019 } 1025 }
1020 1026
1021 function getCabeceraPuntoDescarga(puntoDescarga) { 1027 function getCabeceraPuntoDescarga(puntoDescarga) {
1022 var puntosStamp = ''; 1028 var puntosStamp = '';
1023 puntoDescarga.forEach(function(punto, idx, arr) { 1029 puntoDescarga.forEach(function (punto, idx, arr) {
1024 puntosStamp += punto.descripcion; 1030 puntosStamp += punto.descripcion;
1025 if ((idx + 1) !== arr.length) puntosStamp += ', '; 1031 if ((idx + 1) !== arr.length) puntosStamp += ', ';
1026 }); 1032 });
1027 return puntosStamp; 1033 return puntosStamp;
1028 } 1034 }
1029 1035
1030 function addArrayCabecera(array) { 1036 function addArrayCabecera(array) {
1031 for (var i = 0; i < array.length; i++) { 1037 for (var i = 0; i < array.length; i++) {
1032 $scope.$broadcast('addCabecera', { 1038 $scope.$broadcast('addCabecera', {
1033 label: array[i].label, 1039 label: array[i].label,
1034 valor: array[i].valor 1040 valor: array[i].valor
1035 }); 1041 });
1036 } 1042 }
1037 } 1043 }
1038 1044
1039 function validarNotaRemitada() { 1045 function validarNotaRemitada() {
1040 if (!$scope.notaPedido.idRemito) { 1046 if (!$scope.notaPedido.idRemito) {
1041 return true; 1047 return true;
1042 } else { 1048 } else {
1043 focaModalService.alert('No se puede editar una nota de pedido remitada'); 1049 focaModalService.alert('No se puede editar una nota de pedido remitada');
1044 return false; 1050 return false;
1045 } 1051 }
1046 } 1052 }
1047 1053
1048 function salir() { 1054 function salir() {
1049 var confirmacion = false; 1055 var confirmacion = false;
1050 1056
1051 if (!angular.equals($scope.notaPedido, $scope.inicial)) { 1057 if (!angular.equals($scope.notaPedido, $scope.inicial)) {
1052 confirmacion = true; 1058 confirmacion = true;
1053 } 1059 }
1054 1060
1055 if (confirmacion) { 1061 if (confirmacion) {
1056 focaModalService.confirm( 1062 focaModalService.confirm(
1057 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' 1063 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.'
1058 ).then(function(data) { 1064 ).then(function (data) {
1059 if (data) { 1065 if (data) {
1060 $location.path('/'); 1066 $location.path('/');
1061 } 1067 }
1062 }); 1068 });
1063 } else { 1069 } else {
1064 $location.path('/'); 1070 $location.path('/');
1065 } 1071 }
1066 } 1072 }
1067 1073
1068 function getLSNotaPedido() { 1074 function getLSNotaPedido() {
1069 var notaPedido = JSON.parse($localStorage.notaPedido || null); 1075 var notaPedido = JSON.parse($localStorage.notaPedido || null);
1070 if (notaPedido) { 1076 if (notaPedido) {
1071 delete $localStorage.notaPedido; 1077 delete $localStorage.notaPedido;
1072 setearNotaPedido(notaPedido); 1078 setearNotaPedido(notaPedido);
1073 } 1079 }
1074 } 1080 }
1075 1081
1076 function deleteCliente() { 1082 function deleteCliente() {
1077 $scope.notaPedido.domicilioStamp = ''; 1083 $scope.notaPedido.domicilioStamp = '';
1078 $scope.notaPedido.notaPedidoPuntoDescarga = []; 1084 $scope.notaPedido.notaPedidoPuntoDescarga = [];
1079 $scope.notaPedido.domicilio = {dom: ''}; 1085 $scope.notaPedido.domicilio = { dom: '' };
1080 $scope.notaPedido.cliente = {}; 1086 $scope.notaPedido.cliente = {};
1081 $scope.$broadcast('removeCabecera', 'Cliente:'); 1087 $scope.$broadcast('removeCabecera', 'Cliente:');
1082 $scope.$broadcast('removeCabecera', 'Domicilio:'); 1088 $scope.$broadcast('removeCabecera', 'Domicilio:');