Commit 6e07670ab83659285c835ef29d99e60367506fd2

Authored by Marcelo Puebla
1 parent 45bc7e520b
Exists in master

Cambio para seleccionar cliente en nota pedido.

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