Commit ace98508163b7c15c5d4941eed574a6591204cb4

Authored by Eric Fernandez
Exists in master and in 1 other branch develop

Merge branch 'master' into 'develop'

Agregados puntos de descarga a la cabecera de remito cuando selecciono nota pedido.

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