Commit 1b4a23820bd5c6d874a275a3b0e9e130b8ba1c2e

Authored by Jose Pinto
1 parent 2dfbf4c261
Exists in master

espacio despues de else

Showing 1 changed file with 1 additions and 1 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', 3 '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService',
4 'focaModalService', 'remitoBusinessService', '$rootScope', 4 'focaModalService', 'remitoBusinessService', '$rootScope',
5 function( 5 function(
6 $scope, $uibModal, $location, $filter, crearRemitoService, focaModalService, 6 $scope, $uibModal, $location, $filter, crearRemitoService, focaModalService,
7 remitoBusinessService, $rootScope) 7 remitoBusinessService, $rootScope)
8 { 8 {
9 $scope.botonera = crearRemitoService.getBotonera(); 9 $scope.botonera = crearRemitoService.getBotonera();
10 $scope.isNumber = angular.isNumber; 10 $scope.isNumber = angular.isNumber;
11 $scope.datepickerAbierto = false; 11 $scope.datepickerAbierto = false;
12 $scope.show = false; 12 $scope.show = false;
13 $scope.cargando = true; 13 $scope.cargando = true;
14 $scope.dateOptions = { 14 $scope.dateOptions = {
15 maxDate: new Date(), 15 maxDate: new Date(),
16 minDate: new Date(2010, 0, 1) 16 minDate: new Date(2010, 0, 1)
17 }; 17 };
18 18
19 $scope.remito = { 19 $scope.remito = {
20 id: 0, 20 id: 0,
21 estado: 0, 21 estado: 0,
22 vendedor: {}, 22 vendedor: {},
23 cliente: {}, 23 cliente: {},
24 proveedor: {}, 24 proveedor: {},
25 domicilio: {dom: ''}, 25 domicilio: {dom: ''},
26 moneda: {}, 26 moneda: {},
27 cotizacion: {} 27 cotizacion: {}
28 }; 28 };
29 29
30 $scope.notaPedido = { 30 $scope.notaPedido = {
31 id: 0 31 id: 0
32 }; 32 };
33 var monedaPorDefecto; 33 var monedaPorDefecto;
34 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' 34 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
35 crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { 35 crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) {
36 monedaPorDefecto = res.data[0]; 36 monedaPorDefecto = res.data[0];
37 $scope.remito.moneda = monedaPorDefecto; 37 $scope.remito.moneda = monedaPorDefecto;
38 $scope.remito.cotizacion = monedaPorDefecto.cotizaciones[0]; 38 $scope.remito.cotizacion = monedaPorDefecto.cotizaciones[0];
39 }); 39 });
40 40
41 $scope.cabecera = []; 41 $scope.cabecera = [];
42 $scope.showCabecera = true; 42 $scope.showCabecera = true;
43 43
44 $scope.now = new Date(); 44 $scope.now = new Date();
45 $scope.puntoVenta = rellenar(0, 4); 45 $scope.puntoVenta = rellenar(0, 4);
46 $scope.comprobante = rellenar(0, 8); 46 $scope.comprobante = rellenar(0, 8);
47 47
48 $scope.articulosTabla = []; 48 $scope.articulosTabla = [];
49 $scope.idLista = undefined; 49 $scope.idLista = undefined;
50 50
51 crearRemitoService.getPrecioCondicion().then( 51 crearRemitoService.getPrecioCondicion().then(
52 function(res) { 52 function(res) {
53 $scope.precioCondiciones = res.data; 53 $scope.precioCondiciones = res.data;
54 } 54 }
55 ); 55 );
56 56
57 crearRemitoService.getNumeroRemito().then( 57 crearRemitoService.getNumeroRemito().then(
58 function(res) { 58 function(res) {
59 $scope.puntoVenta = rellenar(res.data.sucursal, 4); 59 $scope.puntoVenta = rellenar(res.data.sucursal, 4);
60 $scope.comprobante = rellenar(res.data.numeroRemito, 8); 60 $scope.comprobante = rellenar(res.data.numeroRemito, 8);
61 }, 61 },
62 function(err) { 62 function(err) {
63 focaModalService.alert('La terminal no esta configurada correctamente'); 63 focaModalService.alert('La terminal no esta configurada correctamente');
64 console.info(err); 64 console.info(err);
65 } 65 }
66 ); 66 );
67 67
68 $scope.seleccionarNotaPedido = function() { 68 $scope.seleccionarNotaPedido = function() {
69 if(varlidarRemitoFacturado()) { 69 if(varlidarRemitoFacturado()) {
70 var modalInstance = $uibModal.open( 70 var modalInstance = $uibModal.open(
71 { 71 {
72 ariaLabelledBy: 'Busqueda de Nota de Pedido', 72 ariaLabelledBy: 'Busqueda de Nota de Pedido',
73 templateUrl: 'foca-modal-nota-pedido.html', 73 templateUrl: 'foca-modal-nota-pedido.html',
74 controller: 'focaModalNotaPedidoController', 74 controller: 'focaModalNotaPedidoController',
75 size: 'lg', 75 size: 'lg',
76 resolve: { 76 resolve: {
77 usadoPor: function() { 77 usadoPor: function() {
78 return 'remito'; 78 return 'remito';
79 } 79 }
80 } 80 }
81 } 81 }
82 ); 82 );
83 modalInstance.result.then( 83 modalInstance.result.then(
84 function(notaPedido) { 84 function(notaPedido) {
85 //añado cabeceras 85 //añado cabeceras
86 $scope.notaPedido.id = notaPedido.id; 86 $scope.notaPedido.id = notaPedido.id;
87 removeCabecera('Bomba:'); 87 removeCabecera('Bomba:');
88 removeCabecera('Kilometros:'); 88 removeCabecera('Kilometros:');
89 var cabeceras = [ 89 var cabeceras = [
90 { 90 {
91 label: 'Moneda:', 91 label: 'Moneda:',
92 valor: notaPedido.cotizacion.moneda.DETALLE 92 valor: notaPedido.cotizacion.moneda.DETALLE
93 }, 93 },
94 { 94 {
95 label: 'Fecha cotizacion:', 95 label: 'Fecha cotizacion:',
96 valor: $filter('date')(notaPedido.cotizacion.FECHA, 96 valor: $filter('date')(notaPedido.cotizacion.FECHA,
97 'dd/MM/yyyy') 97 'dd/MM/yyyy')
98 }, 98 },
99 { 99 {
100 label: 'Cotizacion:', 100 label: 'Cotizacion:',
101 valor: notaPedido.cotizacion.VENDEDOR 101 valor: notaPedido.cotizacion.VENDEDOR
102 }, 102 },
103 { 103 {
104 label: 'Cliente:', 104 label: 'Cliente:',
105 valor: notaPedido.cliente.NOM 105 valor: notaPedido.cliente.NOM
106 }, 106 },
107 { 107 {
108 label: 'Domicilio:', 108 label: 'Domicilio:',
109 valor: notaPedido.domicilioStamp 109 valor: notaPedido.domicilioStamp
110 }, 110 },
111 { 111 {
112 label: 'Vendedor:', 112 label: 'Vendedor:',
113 valor: notaPedido.vendedor.NomVen 113 valor: notaPedido.vendedor.NomVen
114 }, 114 },
115 { 115 {
116 label: 'Proveedor:', 116 label: 'Proveedor:',
117 valor: notaPedido.proveedor.NOM 117 valor: notaPedido.proveedor.NOM
118 }, 118 },
119 { 119 {
120 label: 'Precio condicion:', 120 label: 'Precio condicion:',
121 valor: valorPrecioCondicion() + ' ' + 121 valor: valorPrecioCondicion() + ' ' +
122 remitoBusinessService 122 remitoBusinessService
123 .plazoToString(notaPedido.notaPedidoPlazo) 123 .plazoToString(notaPedido.notaPedidoPlazo)
124 }, 124 },
125 { 125 {
126 label: 'Flete:', 126 label: 'Flete:',
127 valor: notaPedido.fob === 1 ? 'FOB' : ( 127 valor: notaPedido.fob === 1 ? 'FOB' : (
128 notaPedido.flete === 1 ? 'Si' : 'No') 128 notaPedido.flete === 1 ? 'Si' : 'No')
129 } 129 }
130 ]; 130 ];
131 131
132 function valorPrecioCondicion() { 132 function valorPrecioCondicion() {
133 if(notaPedido.idPrecioCondicion > 0) { 133 if(notaPedido.idPrecioCondicion > 0) {
134 return notaPedido.precioCondicion.nombre; 134 return notaPedido.precioCondicion.nombre;
135 } else { 135 } else {
136 return 'Ingreso Manual'; 136 return 'Ingreso Manual';
137 } 137 }
138 } 138 }
139 139
140 if(notaPedido.flete === 1) { 140 if(notaPedido.flete === 1) {
141 var cabeceraBomba = { 141 var cabeceraBomba = {
142 label: 'Bomba:', 142 label: 'Bomba:',
143 valor: notaPedido.bomba === 1 ? 'Si' : 'No' 143 valor: notaPedido.bomba === 1 ? 'Si' : 'No'
144 }; 144 };
145 if(notaPedido.kilometros) { 145 if(notaPedido.kilometros) {
146 var cabeceraKilometros = { 146 var cabeceraKilometros = {
147 label: 'Kilometros:', 147 label: 'Kilometros:',
148 valor: notaPedido.kilometros 148 valor: notaPedido.kilometros
149 }; 149 };
150 cabeceras.push(cabeceraKilometros); 150 cabeceras.push(cabeceraKilometros);
151 } 151 }
152 cabeceras.push(cabeceraBomba); 152 cabeceras.push(cabeceraBomba);
153 } 153 }
154 154
155 for (var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) { 155 for (var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) {
156 notaPedido.articulosNotaPedido[i].id = 0; 156 notaPedido.articulosNotaPedido[i].id = 0;
157 } 157 }
158 158
159 $scope.articulosTabla = notaPedido.articulosNotaPedido; 159 $scope.articulosTabla = notaPedido.articulosNotaPedido;
160 remitoBusinessService.calcularArticulos($scope.articulosTabla, 160 remitoBusinessService.calcularArticulos($scope.articulosTabla,
161 notaPedido.cotizacion.VENDEDOR); 161 notaPedido.cotizacion.VENDEDOR);
162 162
163 if(notaPedido.idPrecioCondicion > 0) { 163 if(notaPedido.idPrecioCondicion > 0) {
164 $scope.idLista = notaPedido.precioCondicion.idListaPrecio; 164 $scope.idLista = notaPedido.precioCondicion.idListaPrecio;
165 } else { 165 } else {
166 $scope.idLista = -1; 166 $scope.idLista = -1;
167 } 167 }
168 168
169 delete notaPedido.id; 169 delete notaPedido.id;
170 $scope.remito = notaPedido; 170 $scope.remito = notaPedido;
171 $scope.remito.id = 0; 171 $scope.remito.id = 0;
172 $scope.remito.moneda = notaPedido.cotizacion.moneda; 172 $scope.remito.moneda = notaPedido.cotizacion.moneda;
173 $scope.plazosPagos = notaPedido.notaPedidoPlazo; 173 $scope.plazosPagos = notaPedido.notaPedidoPlazo;
174 addArrayCabecera(cabeceras); 174 addArrayCabecera(cabeceras);
175 175
176 }, function() { 176 }, function() {
177 // funcion ejecutada cuando se cancela el modal 177 // funcion ejecutada cuando se cancela el modal
178 } 178 }
179 ); 179 );
180 } 180 }
181 }; 181 };
182 182
183 $scope.seleccionarRemito = function() { 183 $scope.seleccionarRemito = function() {
184 var modalInstance = $uibModal.open( 184 var modalInstance = $uibModal.open(
185 { 185 {
186 ariaLabelledBy: 'Busqueda de Remito', 186 ariaLabelledBy: 'Busqueda de Remito',
187 templateUrl: 'foca-modal-remito.html', 187 templateUrl: 'foca-modal-remito.html',
188 controller: 'focaModalRemitoController', 188 controller: 'focaModalRemitoController',
189 size: 'lg', 189 size: 'lg',
190 resolve: {usadoPor: function() {return 'remito';}} 190 resolve: {usadoPor: function() {return 'remito';}}
191 } 191 }
192 ); 192 );
193 modalInstance.result.then( 193 modalInstance.result.then(
194 function(remito) { 194 function(remito) {
195 //añado cabeceras 195 //añado cabeceras
196 removeCabecera('Moneda:'); 196 removeCabecera('Moneda:');
197 removeCabecera('Fecha cotizacion:'); 197 removeCabecera('Fecha cotizacion:');
198 removeCabecera('Cotizacion:'); 198 removeCabecera('Cotizacion:');
199 var cabeceras = [ 199 var cabeceras = [
200 { 200 {
201 label: 'Moneda:', 201 label: 'Moneda:',
202 valor: remito.cotizacion.moneda.DETALLE 202 valor: remito.cotizacion.moneda.DETALLE
203 }, 203 },
204 { 204 {
205 label: 'Fecha cotizacion:', 205 label: 'Fecha cotizacion:',
206 valor: $filter('date')(remito.cotizacion.FECHA, 206 valor: $filter('date')(remito.cotizacion.FECHA,
207 'dd/MM/yyyy') 207 'dd/MM/yyyy')
208 }, 208 },
209 { 209 {
210 label: 'Cotizacion:', 210 label: 'Cotizacion:',
211 valor: remito.cotizacion.VENDEDOR 211 valor: remito.cotizacion.VENDEDOR
212 }, 212 },
213 { 213 {
214 label: 'Cliente:', 214 label: 'Cliente:',
215 valor: remito.cliente.NOM 215 valor: remito.cliente.NOM
216 }, 216 },
217 { 217 {
218 label: 'Domicilio:', 218 label: 'Domicilio:',
219 valor: remito.domicilioStamp 219 valor: remito.domicilioStamp
220 }, 220 },
221 { 221 {
222 label: 'Vendedor:', 222 label: 'Vendedor:',
223 valor: remito.vendedor.NomVen 223 valor: remito.vendedor.NomVen
224 }, 224 },
225 { 225 {
226 label: 'Proveedor:', 226 label: 'Proveedor:',
227 valor: remito.proveedor.NOM 227 valor: remito.proveedor.NOM
228 }, 228 },
229 { 229 {
230 label: 'Flete:', 230 label: 'Flete:',
231 valor: remito.fob === 1 ? 'FOB' : ( 231 valor: remito.fob === 1 ? 'FOB' : (
232 remito.flete === 1 ? 'Si' : 'No') 232 remito.flete === 1 ? 'Si' : 'No')
233 }, 233 },
234 { 234 {
235 label: 'Precio condicion:', 235 label: 'Precio condicion:',
236 valor: valorPrecioCondicion() + ' ' + 236 valor: valorPrecioCondicion() + ' ' +
237 remitoBusinessService.plazoToString(remito.remitoPlazo) 237 remitoBusinessService.plazoToString(remito.remitoPlazo)
238 } 238 }
239 ]; 239 ];
240 function valorPrecioCondicion() { 240 function valorPrecioCondicion() {
241 if(remito.idPrecioCondicion > 0) { 241 if(remito.idPrecioCondicion > 0) {
242 return remito.precioCondicion.nombre; 242 return remito.precioCondicion.nombre;
243 } else { 243 } else {
244 return 'Ingreso Manual'; 244 return 'Ingreso Manual';
245 } 245 }
246 } 246 }
247 247
248 if(remito.flete === 1) { 248 if(remito.flete === 1) {
249 var cabeceraBomba = { 249 var cabeceraBomba = {
250 label: 'Bomba', 250 label: 'Bomba',
251 valor: remito.bomba === 1 ? 'Si' : 'No' 251 valor: remito.bomba === 1 ? 'Si' : 'No'
252 }; 252 };
253 if(remito.kilometros) { 253 if(remito.kilometros) {
254 var cabeceraKilometros = { 254 var cabeceraKilometros = {
255 label: 'Kilometros', 255 label: 'Kilometros',
256 valor: remito.kilometros 256 valor: remito.kilometros
257 }; 257 };
258 cabeceras.push(cabeceraKilometros); 258 cabeceras.push(cabeceraKilometros);
259 } 259 }
260 cabeceras.push(cabeceraBomba); 260 cabeceras.push(cabeceraBomba);
261 } 261 }
262 $scope.articulosTabla = remito.articulosRemito; 262 $scope.articulosTabla = remito.articulosRemito;
263 remitoBusinessService.calcularArticulos($scope.articulosTabla, 263 remitoBusinessService.calcularArticulos($scope.articulosTabla,
264 remito.cotizacion.VENDEDOR); 264 remito.cotizacion.VENDEDOR);
265 if(remito.idPrecioCondicion > 0) { 265 if(remito.idPrecioCondicion > 0) {
266 $scope.idLista = remito.precioCondicion.idListaPrecio; 266 $scope.idLista = remito.precioCondicion.idListaPrecio;
267 } else { 267 } else {
268 $scope.idLista = -1; 268 $scope.idLista = -1;
269 } 269 }
270 $scope.puntoVenta = rellenar(remito.sucursal, 4); 270 $scope.puntoVenta = rellenar(remito.sucursal, 4);
271 $scope.comprobante = rellenar(remito.numeroRemito, 8); 271 $scope.comprobante = rellenar(remito.numeroRemito, 8);
272 $scope.remito = remito; 272 $scope.remito = remito;
273 $scope.remito.moneda = remito.cotizacion.moneda; 273 $scope.remito.moneda = remito.cotizacion.moneda;
274 $scope.plazosPagos = remito.remitoPlazo; 274 $scope.plazosPagos = remito.remitoPlazo;
275 addArrayCabecera(cabeceras); 275 addArrayCabecera(cabeceras);
276 }, function() { 276 }, function() {
277 // funcion ejecutada cuando se cancela el modal 277 // funcion ejecutada cuando se cancela el modal
278 } 278 }
279 ); 279 );
280 }; 280 };
281 281
282 //validacion por domicilio y por plazo pago 282 //validacion por domicilio y por plazo pago
283 $scope.crearRemito = function() { 283 $scope.crearRemito = function() {
284 if(!$scope.remito.vendedor) { 284 if(!$scope.remito.vendedor) {
285 focaModalService.alert('Ingrese Vendedor'); 285 focaModalService.alert('Ingrese Vendedor');
286 return; 286 return;
287 } else if(!$scope.remito.cliente) { 287 } else if(!$scope.remito.cliente) {
288 focaModalService.alert('Ingrese Cliente'); 288 focaModalService.alert('Ingrese Cliente');
289 return; 289 return;
290 } else if(!$scope.remito.proveedor) { 290 } else if(!$scope.remito.proveedor) {
291 focaModalService.alert('Ingrese Proveedor'); 291 focaModalService.alert('Ingrese Proveedor');
292 return; 292 return;
293 } else if(!$scope.remito.moneda.id && !$scope.remito.moneda.ID) { 293 } else if(!$scope.remito.moneda.id && !$scope.remito.moneda.ID) {
294 focaModalService.alert('Ingrese Moneda'); 294 focaModalService.alert('Ingrese Moneda');
295 return; 295 return;
296 } else if(!$scope.remito.cotizacion.ID) { 296 } else if(!$scope.remito.cotizacion.ID) {
297 focaModalService.alert('Ingrese Cotización'); 297 focaModalService.alert('Ingrese Cotización');
298 return; 298 return;
299 } else if( 299 } else if(
300 $scope.remito.flete === undefined || $scope.remito.flete === null) 300 $scope.remito.flete === undefined || $scope.remito.flete === null)
301 { 301 {
302 focaModalService.alert('Ingrese Flete'); 302 focaModalService.alert('Ingrese Flete');
303 return; 303 return;
304 } else if($scope.articulosTabla.length === 0) { 304 } else if($scope.articulosTabla.length === 0) {
305 focaModalService.alert('Debe cargar al menos un articulo'); 305 focaModalService.alert('Debe cargar al menos un articulo');
306 return; 306 return;
307 } 307 }
308 $scope.saveLoading = true; 308 $scope.saveLoading = true;
309 var save = { 309 var save = {
310 remito: { 310 remito: {
311 id: $scope.remito.id, 311 id: $scope.remito.id,
312 fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), 312 fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '),
313 idCliente: $scope.remito.cliente.COD, 313 idCliente: $scope.remito.cliente.COD,
314 nombreCliente: $scope.remito.cliente.NOM, 314 nombreCliente: $scope.remito.cliente.NOM,
315 cuitCliente: $scope.remito.cliente.CUIT, 315 cuitCliente: $scope.remito.cliente.CUIT,
316 responsabilidadIvaCliente: 0,//TODO, 316 responsabilidadIvaCliente: 0,//TODO,
317 descuento: 0,//TODO, 317 descuento: 0,//TODO,
318 importeNeto: 0,//TODO 318 importeNeto: 0,//TODO
319 importeExento: 0,//TODO 319 importeExento: 0,//TODO
320 importeIva: 0,//TODO 320 importeIva: 0,//TODO
321 importeIvaServicios: 0,//TODO 321 importeIvaServicios: 0,//TODO
322 importeImpuestoInterno: 0,//TODO 322 importeImpuestoInterno: 0,//TODO
323 importeImpuestoInterno1: 0,//TODO 323 importeImpuestoInterno1: 0,//TODO
324 importeImpuestoInterno2: 0,//TODO 324 importeImpuestoInterno2: 0,//TODO
325 percepcion: 0,//TODO 325 percepcion: 0,//TODO
326 percepcionIva: 0,//TODO 326 percepcionIva: 0,//TODO
327 redondeo: 0,//TODO 327 redondeo: 0,//TODO
328 total: $scope.getTotal(), 328 total: $scope.getTotal(),
329 numeroNotaPedido: $scope.remito.numeroNotaPedido, 329 numeroNotaPedido: $scope.remito.numeroNotaPedido,
330 anulado: false, 330 anulado: false,
331 planilla: 0,//TODO 331 planilla: 0,//TODO
332 lugar: 0,//TODO 332 lugar: 0,//TODO
333 cuentaMadre: 0,// 333 cuentaMadre: 0,//
334 cuentaContable: 0,//TODO 334 cuentaContable: 0,//TODO
335 asiento: 0,//TODO 335 asiento: 0,//TODO
336 e_hd: '',//TODO 336 e_hd: '',//TODO
337 c_hd: '', 337 c_hd: '',
338 numeroLiquidoProducto: 0,//TODO 338 numeroLiquidoProducto: 0,//TODO
339 idVendedor: $scope.remito.idVendedor, 339 idVendedor: $scope.remito.idVendedor,
340 idProveedor: $scope.remito.idProveedor, 340 idProveedor: $scope.remito.idProveedor,
341 idDomicilio: 0,//TODO 341 idDomicilio: 0,//TODO
342 idCotizacion: $scope.remito.cotizacion.ID, 342 idCotizacion: $scope.remito.cotizacion.ID,
343 idPrecioCondicion: $scope.remito.idPrecioCondicion, 343 idPrecioCondicion: $scope.remito.idPrecioCondicion,
344 flete: $scope.remito.flete, 344 flete: $scope.remito.flete,
345 fob: $scope.remito.fob, 345 fob: $scope.remito.fob,
346 bomba: $scope.remito.bomba, 346 bomba: $scope.remito.bomba,
347 kilometros: $scope.remito.kilometros, 347 kilometros: $scope.remito.kilometros,
348 domicilioStamp: $scope.remito.domicilioStamp, 348 domicilioStamp: $scope.remito.domicilioStamp,
349 estado: 0,//TODO 349 estado: 0,//TODO
350 destinoVenta: 0,//TODO 350 destinoVenta: 0,//TODO
351 operacionTipo: 0//TODO 351 operacionTipo: 0//TODO
352 }, 352 },
353 notaPedido: $scope.notaPedido 353 notaPedido: $scope.notaPedido
354 }; 354 };
355 crearRemitoService.crearRemito(save).then( 355 crearRemitoService.crearRemito(save).then(
356 function(data) { 356 function(data) {
357 remitoBusinessService.addArticulos($scope.articulosTabla, 357 remitoBusinessService.addArticulos($scope.articulosTabla,
358 data.data.id, $scope.remito.cotizacion.COTIZACION); 358 data.data.id, $scope.remito.cotizacion.COTIZACION);
359 359
360 focaModalService.alert('Remito creado'); 360 focaModalService.alert('Remito creado');
361 $scope.saveLoading = false; 361 $scope.saveLoading = false;
362 //TODO: updatear plazos 362 //TODO: updatear plazos
363 if($scope.remito.id === 0) { 363 if($scope.remito.id === 0) {
364 var plazos = $scope.plazosPagos; 364 var plazos = $scope.plazosPagos;
365 365
366 for(var j = 0; j < plazos.length; j++) { 366 for(var j = 0; j < plazos.length; j++) {
367 var json = { 367 var json = {
368 idRemito: data.data.id, 368 idRemito: data.data.id,
369 dias: plazos[j].dias 369 dias: plazos[j].dias
370 }; 370 };
371 crearRemitoService.crearPlazosParaRemito(json); 371 crearRemitoService.crearPlazosParaRemito(json);
372 } 372 }
373 } 373 }
374 374
375 $scope.cabecera = []; 375 $scope.cabecera = [];
376 376
377 addCabecera('Moneda:', $scope.remito.moneda.DETALLE); 377 addCabecera('Moneda:', $scope.remito.moneda.DETALLE);
378 addCabecera( 378 addCabecera(
379 'Fecha cotizacion:', 379 'Fecha cotizacion:',
380 $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') 380 $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy')
381 ); 381 );
382 addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); 382 addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION);
383 $scope.remito.vendedor = {}; 383 $scope.remito.vendedor = {};
384 $scope.remito.cliente = {}; 384 $scope.remito.cliente = {};
385 $scope.remito.proveedor = {}; 385 $scope.remito.proveedor = {};
386 $scope.remito.domicilio = {}; 386 $scope.remito.domicilio = {};
387 $scope.remito.flete = null; 387 $scope.remito.flete = null;
388 $scope.remito.fob = null; 388 $scope.remito.fob = null;
389 $scope.remito.bomba = null; 389 $scope.remito.bomba = null;
390 $scope.remito.kilometros = null; 390 $scope.remito.kilometros = null;
391 $scope.articulosTabla = []; 391 $scope.articulosTabla = [];
392 crearRemitoService.getNumeroRemito().then( 392 crearRemitoService.getNumeroRemito().then(
393 function(res) { 393 function(res) {
394 $scope.puntoVenta = rellenar(res.data.sucursal, 4); 394 $scope.puntoVenta = rellenar(res.data.sucursal, 4);
395 $scope.comprobante = rellenar(res.data.numeroRemito, 8); 395 $scope.comprobante = rellenar(res.data.numeroRemito, 8);
396 }, 396 },
397 function(err) { 397 function(err) {
398 focaModalService 398 focaModalService
399 .alert('La terminal no esta configurada correctamente'); 399 .alert('La terminal no esta configurada correctamente');
400 console.info(err); 400 console.info(err);
401 } 401 }
402 ); 402 );
403 $scope.notaPedido = { 403 $scope.notaPedido = {
404 id: 0 404 id: 0
405 }; 405 };
406 }, function(error) { 406 }, function(error) {
407 focaModalService.alert('Hubo un error al crear el remito'); 407 focaModalService.alert('Hubo un error al crear el remito');
408 $scope.saveLoading = false; 408 $scope.saveLoading = false;
409 console.info(error); 409 console.info(error);
410 } 410 }
411 ); 411 );
412 }; 412 };
413 413
414 $scope.seleccionarProductos = function() { 414 $scope.seleccionarProductos = function() {
415 if ($scope.idLista === undefined) { 415 if ($scope.idLista === undefined) {
416 focaModalService.alert( 416 focaModalService.alert(
417 'Primero seleccione una lista de precio y condicion'); 417 'Primero seleccione una lista de precio y condicion');
418 return; 418 return;
419 } 419 }
420 var modalInstance = $uibModal.open( 420 var modalInstance = $uibModal.open(
421 { 421 {
422 ariaLabelledBy: 'Busqueda de Productos', 422 ariaLabelledBy: 'Busqueda de Productos',
423 templateUrl: 'modal-busqueda-productos.html', 423 templateUrl: 'modal-busqueda-productos.html',
424 controller: 'modalBusquedaProductosCtrl', 424 controller: 'modalBusquedaProductosCtrl',
425 resolve: { 425 resolve: {
426 parametroProducto: { 426 parametroProducto: {
427 idLista: $scope.idLista, 427 idLista: $scope.idLista,
428 cotizacion: $scope.remito.cotizacion.COTIZACION, 428 cotizacion: $scope.remito.cotizacion.COTIZACION,
429 simbolo: $scope.remito.moneda.simbolo 429 simbolo: $scope.remito.moneda.simbolo
430 } 430 }
431 }, 431 },
432 size: 'lg' 432 size: 'lg'
433 } 433 }
434 ); 434 );
435 modalInstance.result.then( 435 modalInstance.result.then(
436 function(producto) { 436 function(producto) {
437 var newArt = 437 var newArt =
438 { 438 {
439 id: 0, 439 id: 0,
440 codigo: producto.codigo, 440 codigo: producto.codigo,
441 sector: producto.sector, 441 sector: producto.sector,
442 sectorCodigo: producto.sector + '-' + producto.codigo, 442 sectorCodigo: producto.sector + '-' + producto.codigo,
443 descripcion: producto.descripcion, 443 descripcion: producto.descripcion,
444 item: $scope.articulosTabla.length + 1, 444 item: $scope.articulosTabla.length + 1,
445 nombre: producto.descripcion, 445 nombre: producto.descripcion,
446 precio: parseFloat(producto.precio.toFixed(4)), 446 precio: parseFloat(producto.precio.toFixed(4)),
447 costoUnitario: producto.costo, 447 costoUnitario: producto.costo,
448 editCantidad: false, 448 editCantidad: false,
449 editPrecio: false, 449 editPrecio: false,
450 rubro: producto.CodRub, 450 rubro: producto.CodRub,
451 exentoUnitario: producto.precio, 451 exentoUnitario: producto.precio,
452 ivaUnitario: producto.IMPIVA, 452 ivaUnitario: producto.IMPIVA,
453 impuestoInternoUnitario: producto.ImpInt, 453 impuestoInternoUnitario: producto.ImpInt,
454 impuestoInterno1Unitario: producto.ImpInt2, 454 impuestoInterno1Unitario: producto.ImpInt2,
455 impuestoInterno2Unitario: producto.ImpInt3, 455 impuestoInterno2Unitario: producto.ImpInt3,
456 precioLista: producto.precio, 456 precioLista: producto.precio,
457 combustible: 1, 457 combustible: 1,
458 facturado: 0 458 facturado: 0
459 }; 459 };
460 $scope.articuloACargar = newArt; 460 $scope.articuloACargar = newArt;
461 $scope.cargando = false; 461 $scope.cargando = false;
462 }, function() { 462 }, function() {
463 // funcion ejecutada cuando se cancela el modal 463 // funcion ejecutada cuando se cancela el modal
464 } 464 }
465 ); 465 );
466 }; 466 };
467 467
468 $scope.seleccionarVendedor = function() { 468 $scope.seleccionarVendedor = function() {
469 if(varlidarRemitoFacturado()) { 469 if(varlidarRemitoFacturado()) {
470 var modalInstance = $uibModal.open( 470 var modalInstance = $uibModal.open(
471 { 471 {
472 ariaLabelledBy: 'Busqueda de Vendedores', 472 ariaLabelledBy: 'Busqueda de Vendedores',
473 templateUrl: 'modal-vendedores.html', 473 templateUrl: 'modal-vendedores.html',
474 controller: 'modalVendedoresCtrl', 474 controller: 'modalVendedoresCtrl',
475 size: 'lg' 475 size: 'lg'
476 } 476 }
477 ); 477 );
478 modalInstance.result.then( 478 modalInstance.result.then(
479 function(vendedor) { 479 function(vendedor) {
480 addCabecera('Vendedor:', vendedor.NomVen); 480 addCabecera('Vendedor:', vendedor.NomVen);
481 $scope.remito.idVendedor = vendedor.CodVen; 481 $scope.remito.idVendedor = vendedor.CodVen;
482 }, function() { 482 }, function() {
483 483
484 } 484 }
485 ); 485 );
486 } 486 }
487 }; 487 };
488 488
489 $scope.seleccionarProveedor = function() { 489 $scope.seleccionarProveedor = function() {
490 if(varlidarRemitoFacturado()) { 490 if(varlidarRemitoFacturado()) {
491 var modalInstance = $uibModal.open( 491 var modalInstance = $uibModal.open(
492 { 492 {
493 ariaLabelledBy: 'Busqueda de Proveedor', 493 ariaLabelledBy: 'Busqueda de Proveedor',
494 templateUrl: 'modal-proveedor.html', 494 templateUrl: 'modal-proveedor.html',
495 controller: 'focaModalProveedorCtrl', 495 controller: 'focaModalProveedorCtrl',
496 size: 'lg', 496 size: 'lg',
497 resolve: { 497 resolve: {
498 transportista: function() { 498 transportista: function() {
499 return false; 499 return false;
500 } 500 }
501 } 501 }
502 } 502 }
503 ); 503 );
504 modalInstance.result.then( 504 modalInstance.result.then(
505 function(proveedor) { 505 function(proveedor) {
506 $scope.remito.idProveedor = proveedor.COD; 506 $scope.remito.idProveedor = proveedor.COD;
507 addCabecera('Proveedor:', proveedor.NOM); 507 addCabecera('Proveedor:', proveedor.NOM);
508 }, function() { 508 }, function() {
509 509
510 } 510 }
511 ); 511 );
512 } 512 }
513 }; 513 };
514 514
515 $scope.seleccionarCliente = function() { 515 $scope.seleccionarCliente = function() {
516 if(varlidarRemitoFacturado()) { 516 if(varlidarRemitoFacturado()) {
517 var modalInstance = $uibModal.open( 517 var modalInstance = $uibModal.open(
518 { 518 {
519 ariaLabelledBy: 'Busqueda de Cliente', 519 ariaLabelledBy: 'Busqueda de Cliente',
520 templateUrl: 'foca-busqueda-cliente-modal.html', 520 templateUrl: 'foca-busqueda-cliente-modal.html',
521 controller: 'focaBusquedaClienteModalController', 521 controller: 'focaBusquedaClienteModalController',
522 size: 'lg' 522 size: 'lg'
523 } 523 }
524 ); 524 );
525 modalInstance.result.then( 525 modalInstance.result.then(
526 function(cliente) { 526 function(cliente) {
527 $scope.abrirModalDomicilios(cliente); 527 $scope.abrirModalDomicilios(cliente);
528 }, function() { 528 }, function() {
529 529
530 } 530 }
531 ); 531 );
532 } 532 }
533 }; 533 };
534 534
535 $scope.abrirModalDomicilios = function(cliente) { 535 $scope.abrirModalDomicilios = function(cliente) {
536 var modalInstanceDomicilio = $uibModal.open( 536 var modalInstanceDomicilio = $uibModal.open(
537 { 537 {
538 ariaLabelledBy: 'Busqueda de Domicilios', 538 ariaLabelledBy: 'Busqueda de Domicilios',
539 templateUrl: 'modal-domicilio.html', 539 templateUrl: 'modal-domicilio.html',
540 controller: 'focaModalDomicilioController', 540 controller: 'focaModalDomicilioController',
541 size: 'lg', 541 size: 'lg',
542 resolve: { idCliente: function() { return cliente.cod; }} 542 resolve: { idCliente: function() { return cliente.cod; }}
543 } 543 }
544 ); 544 );
545 modalInstanceDomicilio.result.then( 545 modalInstanceDomicilio.result.then(
546 function(domicilio) { 546 function(domicilio) {
547 //$scope.remito.domicilio.id = domicilio.nivel2; 547 //$scope.remito.domicilio.id = domicilio.nivel2;
548 $scope.remito.cliente = { 548 $scope.remito.cliente = {
549 COD: cliente.cod, 549 COD: cliente.cod,
550 CUIT: cliente.cuit, 550 CUIT: cliente.cuit,
551 NOM: cliente.nom 551 NOM: cliente.nom
552 }; 552 };
553 553
554 addCabecera('Cliente:', cliente.nom); 554 addCabecera('Cliente:', cliente.nom);
555 var domicilioStamp = 555 var domicilioStamp =
556 domicilio.Calle + ' ' + domicilio.Numero + ', ' + 556 domicilio.Calle + ' ' + domicilio.Numero + ', ' +
557 domicilio.Localidad + ', ' + domicilio.Provincia; 557 domicilio.Localidad + ', ' + domicilio.Provincia;
558 $scope.remito.domicilioStamp = domicilioStamp; 558 $scope.remito.domicilioStamp = domicilioStamp;
559 addCabecera('Domicilio:', domicilioStamp); 559 addCabecera('Domicilio:', domicilioStamp);
560 }, function() { 560 }, function() {
561 $scope.seleccionarCliente(); 561 $scope.seleccionarCliente();
562 return; 562 return;
563 } 563 }
564 ); 564 );
565 }; 565 };
566 566
567 $scope.mostrarFichaCliente = function() { 567 $scope.mostrarFichaCliente = function() {
568 $uibModal.open( 568 $uibModal.open(
569 { 569 {
570 ariaLabelledBy: 'Datos del Cliente', 570 ariaLabelledBy: 'Datos del Cliente',
571 templateUrl: 'foca-crear-remito-ficha-cliente.html', 571 templateUrl: 'foca-crear-remito-ficha-cliente.html',
572 controller: 'focaCrearRemitoFichaClienteController', 572 controller: 'focaCrearRemitoFichaClienteController',
573 size: 'lg' 573 size: 'lg'
574 } 574 }
575 ); 575 );
576 }; 576 };
577 577
578 $scope.getTotal = function() { 578 $scope.getTotal = function() {
579 var total = 0; 579 var total = 0;
580 var arrayTempArticulos = $scope.articulosTabla; 580 var arrayTempArticulos = $scope.articulosTabla;
581 for (var i = 0; i < arrayTempArticulos.length; i++) { 581 for (var i = 0; i < arrayTempArticulos.length; i++) {
582 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 582 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
583 } 583 }
584 return parseFloat(total.toFixed(2)); 584 return parseFloat(total.toFixed(2));
585 }; 585 };
586 586
587 $scope.getSubTotal = function() { 587 $scope.getSubTotal = function() {
588 if($scope.articuloACargar) { 588 if($scope.articuloACargar) {
589 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 589 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
590 } 590 }
591 }; 591 };
592 592
593 $scope.seleccionarPreciosYCondiciones = function() { 593 $scope.seleccionarPreciosYCondiciones = function() {
594 if(varlidarRemitoFacturado()) { 594 if(varlidarRemitoFacturado()) {
595 var modalInstance = $uibModal.open( 595 var modalInstance = $uibModal.open(
596 { 596 {
597 ariaLabelledBy: 'Busqueda de Precio Condición', 597 ariaLabelledBy: 'Busqueda de Precio Condición',
598 templateUrl: 'modal-precio-condicion.html', 598 templateUrl: 'modal-precio-condicion.html',
599 controller: 'focaModalPrecioCondicionController', 599 controller: 'focaModalPrecioCondicionController',
600 size: 'lg' 600 size: 'lg'
601 } 601 }
602 ); 602 );
603 modalInstance.result.then( 603 modalInstance.result.then(
604 function(precioCondicion) { 604 function(precioCondicion) {
605 var cabecera = ''; 605 var cabecera = '';
606 var plazosConcat = ''; 606 var plazosConcat = '';
607 if(!Array.isArray(precioCondicion)) { 607 if(!Array.isArray(precioCondicion)) {
608 $scope.remito.idPrecioCondicion = precioCondicion.id; 608 $scope.remito.idPrecioCondicion = precioCondicion.id;
609 $scope.plazosPagos = precioCondicion.plazoPago; 609 $scope.plazosPagos = precioCondicion.plazoPago;
610 $scope.idLista = precioCondicion.idListaPrecio; 610 $scope.idLista = precioCondicion.idListaPrecio;
611 for(var i = 0; i < precioCondicion.plazoPago.length; i++) { 611 for(var i = 0; i < precioCondicion.plazoPago.length; i++) {
612 plazosConcat += precioCondicion.plazoPago[i].dias + ' '; 612 plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
613 } 613 }
614 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); 614 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim();
615 } else { //Cuando se ingresan los plazos manualmente 615 } else { //Cuando se ingresan los plazos manualmente
616 $scope.remito.idPrecioCondicion = 0; 616 $scope.remito.idPrecioCondicion = 0;
617 //-1, el modal productos busca todos los productos 617 //-1, el modal productos busca todos los productos
618 $scope.idLista = -1; 618 $scope.idLista = -1;
619 $scope.plazosPagos = precioCondicion; 619 $scope.plazosPagos = precioCondicion;
620 for(var j = 0; j < precioCondicion.length; j++) { 620 for(var j = 0; j < precioCondicion.length; j++) {
621 plazosConcat += precioCondicion[j].dias + ' '; 621 plazosConcat += precioCondicion[j].dias + ' ';
622 } 622 }
623 cabecera = 'Ingreso manual ' + plazosConcat.trim(); 623 cabecera = 'Ingreso manual ' + plazosConcat.trim();
624 } 624 }
625 $scope.articulosTabla = []; 625 $scope.articulosTabla = [];
626 addCabecera('Precios y condiciones:', cabecera); 626 addCabecera('Precios y condiciones:', cabecera);
627 }, function() { 627 }, function() {
628 628
629 } 629 }
630 ); 630 );
631 } 631 }
632 }; 632 };
633 633
634 $scope.seleccionarFlete = function() { 634 $scope.seleccionarFlete = function() {
635 if(varlidarRemitoFacturado()) { 635 if(varlidarRemitoFacturado()) {
636 var modalInstance = $uibModal.open( 636 var modalInstance = $uibModal.open(
637 { 637 {
638 ariaLabelledBy: 'Busqueda de Flete', 638 ariaLabelledBy: 'Busqueda de Flete',
639 templateUrl: 'modal-flete.html', 639 templateUrl: 'modal-flete.html',
640 controller: 'focaModalFleteController', 640 controller: 'focaModalFleteController',
641 size: 'lg', 641 size: 'lg',
642 resolve: { 642 resolve: {
643 parametrosFlete: 643 parametrosFlete:
644 function() { 644 function() {
645 return { 645 return {
646 flete: $scope.remito.flete ? '1' : 646 flete: $scope.remito.flete ? '1' :
647 ($scope.remito.fob ? 'FOB' : 647 ($scope.remito.fob ? 'FOB' :
648 ($scope.remito.flete === undefined ? null : '0')), 648 ($scope.remito.flete === undefined ? null : '0')),
649 bomba: $scope.remito.bomba ? '1' : 649 bomba: $scope.remito.bomba ? '1' :
650 ($scope.remito.bomba === undefined ? null : '0'), 650 ($scope.remito.bomba === undefined ? null : '0'),
651 kilometros: $scope.remito.kilometros 651 kilometros: $scope.remito.kilometros
652 }; 652 };
653 } 653 }
654 } 654 }
655 } 655 }
656 ); 656 );
657 modalInstance.result.then( 657 modalInstance.result.then(
658 function(datos) { 658 function(datos) {
659 $scope.remito.flete = datos.flete; 659 $scope.remito.flete = datos.flete;
660 $scope.remito.fob = datos.FOB; 660 $scope.remito.fob = datos.FOB;
661 $scope.remito.bomba = datos.bomba; 661 $scope.remito.bomba = datos.bomba;
662 $scope.remito.kilometros = datos.kilometros; 662 $scope.remito.kilometros = datos.kilometros;
663 663
664 addCabecera('Flete:', datos.flete ? 'Si' : 664 addCabecera('Flete:', datos.flete ? 'Si' :
665 ($scope.remito.fob ? 'FOB' : 'No')); 665 ($scope.remito.fob ? 'FOB' : 'No'));
666 if(datos.flete) { 666 if(datos.flete) {
667 addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); 667 addCabecera('Bomba:', datos.bomba ? 'Si' : 'No');
668 addCabecera('Kilometros:', datos.kilometros); 668 addCabecera('Kilometros:', datos.kilometros);
669 } else { 669 } else {
670 removeCabecera('Bomba:'); 670 removeCabecera('Bomba:');
671 removeCabecera('Kilometros:'); 671 removeCabecera('Kilometros:');
672 $scope.remito.fob = false; 672 $scope.remito.fob = false;
673 $scope.remito.bomba = false; 673 $scope.remito.bomba = false;
674 $scope.remito.kilometros = null; 674 $scope.remito.kilometros = null;
675 } 675 }
676 }, function() { 676 }, function() {
677 677
678 } 678 }
679 ); 679 );
680 } 680 }
681 }; 681 };
682 682
683 $scope.seleccionarMoneda = function() { 683 $scope.seleccionarMoneda = function() {
684 if(varlidarRemitoFacturado()) { 684 if(varlidarRemitoFacturado()) {
685 var modalInstance = $uibModal.open( 685 var modalInstance = $uibModal.open(
686 { 686 {
687 ariaLabelledBy: 'Busqueda de Moneda', 687 ariaLabelledBy: 'Busqueda de Moneda',
688 templateUrl: 'modal-moneda.html', 688 templateUrl: 'modal-moneda.html',
689 controller: 'focaModalMonedaController', 689 controller: 'focaModalMonedaController',
690 size: 'lg' 690 size: 'lg'
691 } 691 }
692 ); 692 );
693 modalInstance.result.then( 693 modalInstance.result.then(
694 function(moneda) { 694 function(moneda) {
695 $scope.abrirModalCotizacion(moneda); 695 $scope.abrirModalCotizacion(moneda);
696 }, function() { 696 }, function() {
697 697
698 } 698 }
699 ); 699 );
700 } 700 }
701 }; 701 };
702 702
703 $scope.abrirModalCotizacion = function(moneda) { 703 $scope.abrirModalCotizacion = function(moneda) {
704 var modalInstance = $uibModal.open( 704 var modalInstance = $uibModal.open(
705 { 705 {
706 ariaLabelledBy: 'Busqueda de Cotización', 706 ariaLabelledBy: 'Busqueda de Cotización',
707 templateUrl: 'modal-cotizacion.html', 707 templateUrl: 'modal-cotizacion.html',
708 controller: 'focaModalCotizacionController', 708 controller: 'focaModalCotizacionController',
709 size: 'lg', 709 size: 'lg',
710 resolve: {idMoneda: function() {return moneda.ID;}} 710 resolve: {idMoneda: function() {return moneda.ID;}}
711 } 711 }
712 ); 712 );
713 modalInstance.result.then( 713 modalInstance.result.then(
714 function(cotizacion) { 714 function(cotizacion) {
715 var articulosTablaTemp = $scope.articulosTabla; 715 var articulosTablaTemp = $scope.articulosTabla;
716 for(var i = 0; i < articulosTablaTemp.length; i++) { 716 for(var i = 0; i < articulosTablaTemp.length; i++) {
717 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * 717 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
718 $scope.remito.cotizacion.COTIZACION; 718 $scope.remito.cotizacion.COTIZACION;
719 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / 719 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio /
720 cotizacion.COTIZACION; 720 cotizacion.COTIZACION;
721 } 721 }
722 $scope.articulosTabla = articulosTablaTemp; 722 $scope.articulosTabla = articulosTablaTemp;
723 $scope.remito.moneda = moneda; 723 $scope.remito.moneda = moneda;
724 $scope.remito.cotizacion = cotizacion; 724 $scope.remito.cotizacion = cotizacion;
725 if(moneda.DETALLE === 'PESOS ARGENTINOS') { 725 if(moneda.DETALLE === 'PESOS ARGENTINOS') {
726 removeCabecera('Moneda:'); 726 removeCabecera('Moneda:');
727 removeCabecera('Fecha cotizacion:'); 727 removeCabecera('Fecha cotizacion:');
728 removeCabecera('Cotizacion:'); 728 removeCabecera('Cotizacion:');
729 }else { 729 }else {
730 addCabecera('Moneda:', moneda.DETALLE); 730 addCabecera('Moneda:', moneda.DETALLE);
731 addCabecera( 731 addCabecera(
732 'Fecha cotizacion:', 732 'Fecha cotizacion:',
733 $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 733 $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
734 ); 734 );
735 addCabecera('Cotizacion:', cotizacion.COTIZACION); 735 addCabecera('Cotizacion:', cotizacion.COTIZACION);
736 } 736 }
737 }, function() { 737 }, function() {
738 738
739 } 739 }
740 ); 740 );
741 }; 741 };
742 742
743 $scope.agregarATabla = function(key) { 743 $scope.agregarATabla = function(key) {
744 if(key === 13) { 744 if(key === 13) {
745 if($scope.articuloACargar.cantidad === undefined || 745 if($scope.articuloACargar.cantidad === undefined ||
746 $scope.articuloACargar.cantidad === 0 || 746 $scope.articuloACargar.cantidad === 0 ||
747 $scope.articuloACargar.cantidad === null ) { 747 $scope.articuloACargar.cantidad === null ) {
748 focaModalService.alert('El valor debe ser al menos 1'); 748 focaModalService.alert('El valor debe ser al menos 1');
749 return; 749 return;
750 } 750 }
751 delete $scope.articuloACargar.sectorCodigo; 751 delete $scope.articuloACargar.sectorCodigo;
752 $scope.articulosTabla.push($scope.articuloACargar); 752 $scope.articulosTabla.push($scope.articuloACargar);
753 $scope.cargando = true; 753 $scope.cargando = true;
754 } 754 }
755 }; 755 };
756 756
757 $scope.quitarArticulo = function(key) { 757 $scope.quitarArticulo = function(key) {
758 $scope.articulosTabla.splice(key, 1); 758 $scope.articulosTabla.splice(key, 1);
759 }; 759 };
760 760
761 $scope.editarArticulo = function(key, articulo) { 761 $scope.editarArticulo = function(key, articulo) {
762 if(key === 13) { 762 if(key === 13) {
763 if(articulo.cantidad === null || articulo.cantidad === 0 || 763 if(articulo.cantidad === null || articulo.cantidad === 0 ||
764 articulo.cantidad === undefined) { 764 articulo.cantidad === undefined) {
765 focaModalService.alert('El valor debe ser al menos 1'); 765 focaModalService.alert('El valor debe ser al menos 1');
766 return; 766 return;
767 } 767 }
768 articulo.editCantidad = false; 768 articulo.editCantidad = false;
769 articulo.editPrecio = false; 769 articulo.editPrecio = false;
770 } 770 }
771 }; 771 };
772 772
773 $scope.cambioEdit = function(articulo, propiedad) { 773 $scope.cambioEdit = function(articulo, propiedad) {
774 if(propiedad === 'cantidad') { 774 if(propiedad === 'cantidad') {
775 articulo.editCantidad = true; 775 articulo.editCantidad = true;
776 } else if(propiedad === 'precio') { 776 } else if(propiedad === 'precio') {
777 articulo.editPrecio = true; 777 articulo.editPrecio = true;
778 } 778 }
779 }; 779 };
780 780
781 $scope.limpiarFlete = function() { 781 $scope.limpiarFlete = function() {
782 $scope.remito.fleteNombre = ''; 782 $scope.remito.fleteNombre = '';
783 $scope.remito.chofer = ''; 783 $scope.remito.chofer = '';
784 $scope.remito.vehiculo = ''; 784 $scope.remito.vehiculo = '';
785 $scope.remito.kilometros = ''; 785 $scope.remito.kilometros = '';
786 $scope.remito.costoUnitarioKmFlete = ''; 786 $scope.remito.costoUnitarioKmFlete = '';
787 $scope.choferes = ''; 787 $scope.choferes = '';
788 $scope.vehiculos = ''; 788 $scope.vehiculos = '';
789 }; 789 };
790 790
791 $scope.limpiarPantalla = function() { 791 $scope.limpiarPantalla = function() {
792 $scope.limpiarFlete(); 792 $scope.limpiarFlete();
793 $scope.remito.flete = '0'; 793 $scope.remito.flete = '0';
794 $scope.remito.bomba = '0'; 794 $scope.remito.bomba = '0';
795 $scope.remito.precioCondicion = ''; 795 $scope.remito.precioCondicion = '';
796 $scope.articulosTabla = []; 796 $scope.articulosTabla = [];
797 $scope.remito.vendedor.nombre = ''; 797 $scope.remito.vendedor.nombre = '';
798 $scope.remito.cliente = {nombre: ''}; 798 $scope.remito.cliente = {nombre: ''};
799 $scope.remito.domicilio = {dom: ''}; 799 $scope.remito.domicilio = {dom: ''};
800 $scope.domiciliosCliente = []; 800 $scope.domiciliosCliente = [];
801 }; 801 };
802 802
803 $scope.resetFilter = function() { 803 $scope.resetFilter = function() {
804 $scope.articuloACargar = {}; 804 $scope.articuloACargar = {};
805 $scope.cargando = true; 805 $scope.cargando = true;
806 }; 806 };
807 //Recibe aviso si el teclado está en uso 807 //Recibe aviso si el teclado está en uso
808 $rootScope.$on('usarTeclado', function(event, data) { 808 $rootScope.$on('usarTeclado', function(event, data) {
809 if(data) { 809 if(data) {
810 $scope.mostrarTeclado = true; 810 $scope.mostrarTeclado = true;
811 return; 811 return;
812 } 812 }
813 $scope.mostrarTeclado = false; 813 $scope.mostrarTeclado = false;
814 }); 814 });
815 815
816 $scope.selectFocus = function($event) { 816 $scope.selectFocus = function($event) {
817 // Si el teclado esta en uso no selecciona el valor 817 // Si el teclado esta en uso no selecciona el valor
818 if($scope.mostrarTeclado) { 818 if($scope.mostrarTeclado) {
819 return; 819 return;
820 } 820 }
821 $event.target.select(); 821 $event.target.select();
822 }; 822 };
823 823
824 $scope.salir = function() { 824 $scope.salir = function() {
825 $location.path('/'); 825 $location.path('/');
826 }; 826 };
827 function addArrayCabecera(array) { 827 function addArrayCabecera(array) {
828 for(var i = 0; i < array.length; i++) { 828 for(var i = 0; i < array.length; i++) {
829 addCabecera(array[i].label, array[i].valor); 829 addCabecera(array[i].label, array[i].valor);
830 } 830 }
831 } 831 }
832 832
833 function addCabecera(label, valor) { 833 function addCabecera(label, valor) {
834 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 834 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
835 if(propiedad.length === 1) { 835 if(propiedad.length === 1) {
836 propiedad[0].valor = valor; 836 propiedad[0].valor = valor;
837 } else { 837 } else {
838 $scope.cabecera.push({label: label, valor: valor}); 838 $scope.cabecera.push({label: label, valor: valor});
839 } 839 }
840 } 840 }
841 841
842 function removeCabecera(label) { 842 function removeCabecera(label) {
843 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 843 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
844 if(propiedad.length === 1) { 844 if(propiedad.length === 1) {
845 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 845 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
846 } 846 }
847 } 847 }
848 848
849 function rellenar(relleno, longitud) { 849 function rellenar(relleno, longitud) {
850 relleno = '' + relleno; 850 relleno = '' + relleno;
851 while (relleno.length < longitud) { 851 while (relleno.length < longitud) {
852 relleno = '0' + relleno; 852 relleno = '0' + relleno;
853 } 853 }
854 854
855 return relleno; 855 return relleno;
856 } 856 }
857 857
858 function varlidarRemitoFacturado() { 858 function varlidarRemitoFacturado() {
859 if($scope.remito.estado !== 5) { 859 if($scope.remito.estado !== 5) {
860 return true; 860 return true;
861 }else{ 861 }else {
862 focaModalService.alert('No se puede editar un remito facturado'); 862 focaModalService.alert('No se puede editar un remito facturado');
863 return false(); 863 return false();
864 } 864 }
865 } 865 }
866 } 866 }
867 ]); 867 ]);
868 868