Commit e36049f3355bd246a692cb58dc25f9ca58353d5b

Authored by Luigi
1 parent bfc34ac167
Exists in master and in 1 other branch develop

Validar remito facturado

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