Commit 5d714fb250ecca2646a322fbf1f9c3e2f0ea2be7

Authored by Eric Fernandez
1 parent 7f6fe7142f
Exists in master

no boton moneda

Showing 1 changed file with 1 additions and 1 deletions   Show diff stats
src/js/controller.js
1 angular.module('focaCrearFactura').controller('facturaController', [ 1 angular.module('focaCrearFactura').controller('facturaController', [
2 '$scope', '$uibModal', '$location', '$filter', 'crearFacturaService', '$timeout', 2 '$scope', '$uibModal', '$location', '$filter', 'crearFacturaService', '$timeout',
3 'focaModalService', 'crearRemitoService', '$rootScope', 'focaBotoneraLateralService', 3 'focaModalService', 'crearRemitoService', '$rootScope', 'focaBotoneraLateralService',
4 '$localStorage', 'APP', 'focaLoginService', 4 '$localStorage', 'APP', 'focaLoginService',
5 function ( 5 function (
6 $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService, 6 $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService,
7 crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP, loginServ) 7 crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP, loginServ)
8 { 8 {
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 = crearFacturaService.getBotonera(); 15 $scope.botonera = crearFacturaService.getBotonera();
16 $scope.botoneraProductos = []; 16 $scope.botoneraProductos = [];
17 $scope.isNumber = angular.isNumber; 17 $scope.isNumber = angular.isNumber;
18 $scope.datepickerAbierto = false; 18 $scope.datepickerAbierto = false;
19 $scope.show = false; 19 $scope.show = false;
20 $scope.cargando = true; 20 $scope.cargando = true;
21 $scope.now = new Date(); 21 $scope.now = new Date();
22 $scope.puntoVenta = rellenar(0, 4); 22 $scope.puntoVenta = rellenar(0, 4);
23 $scope.comprobante = rellenar(0, 8); 23 $scope.comprobante = rellenar(0, 8);
24 $scope.dateOptions = { 24 $scope.dateOptions = {
25 maxDate: new Date(), 25 maxDate: new Date(),
26 minDate: new Date(2010, 0, 1) 26 minDate: new Date(2010, 0, 1)
27 }; 27 };
28 $scope.cabeceras = []; 28 $scope.cabeceras = [];
29 crearFacturaService.getParametros().then(function (res) { 29 crearFacturaService.getParametros().then(function (res) {
30 30
31 var parametros = JSON.parse(res.data[0].jsonText); 31 var parametros = JSON.parse(res.data[0].jsonText);
32 32
33 if ($localStorage.factura) { 33 if ($localStorage.factura) {
34 34
35 $timeout(function () { getLSFactura(); }); 35 $timeout(function () { getLSFactura(); });
36 } else { 36 } else {
37 37
38 for (var property in parametros) { 38 for (var property in parametros) {
39 $scope.factura[property] = parametros[property]; 39 $scope.factura[property] = parametros[property];
40 $scope.inicial[property] = parametros[property]; 40 $scope.inicial[property] = parametros[property];
41 } 41 }
42 42
43 setearFactura($scope.factura); 43 setearFactura($scope.factura);
44 } 44 }
45 45
46 }); 46 });
47 47
48 //SETEO BOTONERA LATERAL 48 //SETEO BOTONERA LATERAL
49 $timeout(function () { 49 $timeout(function () {
50 focaBotoneraLateralService.showSalir(false); 50 focaBotoneraLateralService.showSalir(false);
51 focaBotoneraLateralService.showPausar(true); 51 focaBotoneraLateralService.showPausar(true);
52 focaBotoneraLateralService.showGuardar(true, $scope.seleccionarFormaDePago); 52 focaBotoneraLateralService.showGuardar(true, $scope.seleccionarFormaDePago);
53 focaBotoneraLateralService.addCustomButton('Salir', salir); 53 focaBotoneraLateralService.addCustomButton('Salir', salir);
54 }); 54 });
55 55
56 init(); 56 init();
57 57
58 } 58 }
59 59
60 function init() { 60 function init() {
61 61
62 $scope.$broadcast('cleanCabecera'); 62 $scope.$broadcast('cleanCabecera');
63 63
64 $scope.factura = { 64 $scope.factura = {
65 id: 0, 65 id: 0,
66 estado: 0, 66 estado: 0,
67 vendedor: {}, 67 vendedor: {},
68 cliente: {}, 68 cliente: {},
69 proveedor: {}, 69 proveedor: {},
70 domicilio: { dom: '' }, 70 domicilio: { dom: '' },
71 moneda: {}, 71 moneda: {},
72 cotizacion: $scope.cotizacionPorDefecto || {}, 72 cotizacion: $scope.cotizacionPorDefecto || {},
73 articulosFactura: [], 73 articulosFactura: [],
74 despachos: [] 74 despachos: []
75 }; 75 };
76 76
77 $scope.factura.articulosFactura = []; 77 $scope.factura.articulosFactura = [];
78 $scope.idLista = undefined; 78 $scope.idLista = undefined;
79 79
80 crearRemitoService.getNumeroRemito().then( 80 crearRemitoService.getNumeroRemito().then(
81 function (res) { 81 function (res) {
82 $scope.puntoVenta = rellenar(res.data.sucursal, 4); 82 $scope.puntoVenta = rellenar(res.data.sucursal, 4);
83 $scope.comprobante = rellenar(res.data.numeroRemito, 8); 83 $scope.comprobante = rellenar(res.data.numeroRemito, 8);
84 }, 84 },
85 function (err) { 85 function (err) {
86 focaModalService.alert('La terminal no esta configurada correctamente'); 86 focaModalService.alert('La terminal no esta configurada correctamente');
87 console.info(err); 87 console.info(err);
88 } 88 }
89 ); 89 );
90 90
91 $scope.inicial = angular.copy($scope.factura); 91 $scope.inicial = angular.copy($scope.factura);
92 92
93 if (APP == 'facturador') { 93 if (APP == 'facturador') {
94 crearFacturaService 94 crearFacturaService
95 .getVendedorPlayaById(loginServ.getLoginData().vendedorPlaya) 95 .getVendedorPlayaById(loginServ.getLoginData().vendedorPlaya)
96 .then(function (res) { 96 .then(function (res) {
97 97
98 validarPlanillaVendedor(res.data) 98 validarPlanillaVendedor(res.data)
99 .then(function () { 99 .then(function () {
100 100
101 $scope.$broadcast('addCabecera', { 101 $scope.$broadcast('addCabecera', {
102 label: 'Vendedor:', 102 label: 'Vendedor:',
103 valor: $filter('rellenarDigitos')(res.data.CodVen, 3) + 103 valor: $filter('rellenarDigitos')(res.data.CodVen, 3) +
104 ' - ' + 104 ' - ' +
105 res.data.NomVen 105 res.data.NomVen
106 }); 106 });
107 107
108 $scope.factura.vendedor = res.data; 108 $scope.factura.vendedor = res.data;
109 $scope.inicial.vendedor = res.data; 109 $scope.inicial.vendedor = res.data;
110 110
111 getProductosByPlanilla(res.data.NplVen); 111 getProductosByPlanilla(res.data.NplVen);
112 }) 112 })
113 .catch(function (err) { 113 .catch(function (err) {
114 console.log(err); 114 console.log(err);
115 focaModalService.alert('Ocurrió un error al intentar recuperar' + 115 focaModalService.alert('Ocurrió un error al intentar recuperar' +
116 'el vendedor logeado'); 116 'el vendedor logeado');
117 }); 117 });
118 }) 118 })
119 } 119 }
120 } 120 }
121 121
122 $scope.$watch('factura', function (newValue) { 122 $scope.$watch('factura', function (newValue) {
123 focaBotoneraLateralService.setPausarData({ 123 focaBotoneraLateralService.setPausarData({
124 label: 'factura', 124 label: 'factura',
125 val: newValue 125 val: newValue
126 }); 126 });
127 }, true); 127 }, true);
128 128
129 $scope.seleccionarFormaDePago = function () { 129 $scope.seleccionarFormaDePago = function () {
130 if (!validarGuardar()) return; 130 if (!validarGuardar()) return;
131 var modalInstance = $uibModal.open( 131 var modalInstance = $uibModal.open(
132 { 132 {
133 templateUrl: 'modal-forma-pago.html', 133 templateUrl: 'modal-forma-pago.html',
134 controller: 'focaModalFormaPagoController', 134 controller: 'focaModalFormaPagoController',
135 resolve: { 135 resolve: {
136 parametros: function () { 136 parametros: function () {
137 return { 137 return {
138 importe: $scope.getTotal() 138 importe: $scope.getTotal()
139 }; 139 };
140 }, 140 },
141 }, 141 },
142 size: 'lg', 142 size: 'lg',
143 } 143 }
144 ); 144 );
145 modalInstance.result 145 modalInstance.result
146 .then(function (data) { 146 .then(function (data) {
147 147
148 $scope.crearFactura(data); 148 $scope.crearFactura(data);
149 }) 149 })
150 .catch(function (e) { console.error(e); }); 150 .catch(function (e) { console.error(e); });
151 }; 151 };
152 152
153 $scope.crearFactura = function (formaPago) { 153 $scope.crearFactura = function (formaPago) {
154 154
155 var save = { 155 var save = {
156 factura: { 156 factura: {
157 157
158 BONIF: 0, 158 BONIF: 0,
159 CLI: $scope.factura.cliente.cod, 159 CLI: $scope.factura.cliente.cod,
160 CUI: $scope.factura.cliente.cuit, 160 CUI: $scope.factura.cliente.cuit,
161 CTA: $scope.factura.cliente.cod, 161 CTA: $scope.factura.cliente.cod,
162 DC1: '', 162 DC1: '',
163 DC2: '', 163 DC2: '',
164 DE1: '', 164 DE1: '',
165 DOM: $scope.factura.cliente.DOM, 165 DOM: $scope.factura.cliente.DOM,
166 FACAUT: 0, 166 FACAUT: 0,
167 DTO: 0, 167 DTO: 0,
168 FEC: $filter('date')($scope.now, 'yyyy-MM-dd HH:mm:ss'), 168 FEC: $filter('date')($scope.now, 'yyyy-MM-dd HH:mm:ss'),
169 FEC_ANT: '19000101', 169 FEC_ANT: '19000101',
170 FPA: 0, // 0 <- Múltiple formas de pago, 2 cta corriente 170 FPA: 0, // 0 <- Múltiple formas de pago, 2 cta corriente
171 IDEXCEPCION: 0, 171 IDEXCEPCION: 0,
172 IDLP: $scope.factura.cliente.mod.trim() || 0, 172 IDLP: $scope.factura.cliente.mod.trim() || 0,
173 IDPERSONERIA: 0, 173 IDPERSONERIA: 0,
174 IMI: 0, // TODO 174 IMI: 0, // TODO
175 IMI2: 0, // TODO 175 IMI2: 0, // TODO
176 IMI3: 0, // TODO 176 IMI3: 0, // TODO
177 IMP_LEY: 0, 177 IMP_LEY: 0,
178 IRI: 0, // TODO 178 IRI: 0, // TODO
179 IRS: 0, 179 IRS: 0,
180 LEG: '', 180 LEG: '',
181 LUG: $scope.factura.vendedor.LugVen, 181 LUG: $scope.factura.vendedor.LugVen,
182 MK_M: 0, 182 MK_M: 0,
183 NEE: 0, // TODO 183 NEE: 0, // TODO
184 NET: 0, // TODO 184 NET: 0, // TODO
185 NFI: '', 185 NFI: '',
186 NNP: 0, 186 NNP: 0,
187 NOM: $scope.factura.cliente.nom, 187 NOM: $scope.factura.cliente.nom,
188 OPE: $scope.factura.vendedor.CodVen, 188 OPE: $scope.factura.vendedor.CodVen,
189 PAG: $scope.getTotal(), 189 PAG: $scope.getTotal(),
190 PER: 0, 190 PER: 0,
191 PER_IVA: 0, 191 PER_IVA: 0,
192 PLA: $scope.factura.vendedor.NplVen, 192 PLA: $scope.factura.vendedor.NplVen,
193 PRO: '', 193 PRO: '',
194 REC_ANT: 0, 194 REC_ANT: 0,
195 SUC: parseInt($scope.puntoVenta), 195 SUC: parseInt($scope.puntoVenta),
196 TCA: 1, 196 TCA: 1,
197 TCO: 'FT', 197 TCO: 'FT',
198 TFI: '', 198 TFI: '',
199 TIP: $scope.factura.cliente.tipoFactura, 199 TIP: $scope.factura.cliente.tipoFactura,
200 TIV: 0, // TODO 200 TIV: 0, // TODO
201 TOT: $scope.getTotal(), 201 TOT: $scope.getTotal(),
202 TUR: 0, // TODO 202 TUR: 0, // TODO
203 VEN: $scope.factura.vendedor.CodVen, 203 VEN: $scope.factura.vendedor.CodVen,
204 VTO_CLI: '', 204 VTO_CLI: '',
205 ZON: 1, // TODO 205 ZON: 1, // TODO
206 OBSERVACIONES: $scope.factura.observaciones 206 OBSERVACIONES: $scope.factura.observaciones
207 }, 207 },
208 cuerpo: $scope.articulosFiltro(), 208 cuerpo: $scope.articulosFiltro(),
209 despachos: $scope.factura.despachos, 209 despachos: $scope.factura.despachos,
210 formaPago: formaPago 210 formaPago: formaPago
211 }; 211 };
212 212
213 crearFacturaService.guardarFactura(save).then(function (res) { 213 crearFacturaService.guardarFactura(save).then(function (res) {
214 214
215 focaBotoneraLateralService.endGuardar(true); 215 focaBotoneraLateralService.endGuardar(true);
216 216
217 focaModalService.alert('Comprobante guardado con éxito'); 217 focaModalService.alert('Comprobante guardado con éxito');
218 218
219 config(); 219 config();
220 220
221 }).catch(function (err) { 221 }).catch(function (err) {
222 focaModalService.alert('Hubo un error al guardar la factura'); 222 focaModalService.alert('Hubo un error al guardar la factura');
223 console.error(err); 223 console.error(err);
224 }); 224 });
225 225
226 }; 226 };
227 227
228 $scope.seleccionarCliente = function () { 228 $scope.seleccionarCliente = function () {
229 229
230 var modalInstance = $uibModal.open( 230 var modalInstance = $uibModal.open(
231 { 231 {
232 ariaLabelledBy: 'Busqueda de Cliente', 232 ariaLabelledBy: 'Busqueda de Cliente',
233 templateUrl: 'foca-busqueda-cliente-modal.html', 233 templateUrl: 'foca-busqueda-cliente-modal.html',
234 controller: 'focaBusquedaClienteModalController', 234 controller: 'focaBusquedaClienteModalController',
235 resolve: { 235 resolve: {
236 vendedor: function () { return null; }, 236 vendedor: function () { return null; },
237 cobrador: function () { return null; } 237 cobrador: function () { return null; }
238 }, 238 },
239 size: 'lg' 239 size: 'lg'
240 } 240 }
241 ); 241 );
242 modalInstance.result.then( 242 modalInstance.result.then(
243 function (cliente) { 243 function (cliente) {
244 var modalInstance = $uibModal.open( 244 var modalInstance = $uibModal.open(
245 { 245 {
246 templateUrl: 'modal-estado-cuenta.html', 246 templateUrl: 'modal-estado-cuenta.html',
247 controller: 'focaModalEstadoCuentaController', 247 controller: 'focaModalEstadoCuentaController',
248 size: 'lg', 248 size: 'lg',
249 resolve: { 249 resolve: {
250 parametros: function () { return { idCliente: cliente.cod }; }, 250 parametros: function () { return { idCliente: cliente.cod }; },
251 } 251 }
252 } 252 }
253 ); 253 );
254 modalInstance.result 254 modalInstance.result
255 .then(function (data) { 255 .then(function (data) {
256 256
257 $scope.factura.cliente = cliente; 257 $scope.factura.cliente = cliente;
258 258
259 $scope.$broadcast('addCabecera', { 259 $scope.$broadcast('addCabecera', {
260 label: 'Cliente:', 260 label: 'Cliente:',
261 valor: $filter('rellenarDigitos')(cliente.cod, 3) + 261 valor: $filter('rellenarDigitos')(cliente.cod, 3) +
262 ' - ' + cliente.nom 262 ' - ' + cliente.nom
263 }); 263 });
264 264
265 $filter('filter')($scope.botonera, 265 $filter('filter')($scope.botonera,
266 { label: 'Cliente' })[0].checked = true; 266 { label: 'Cliente' })[0].checked = true;
267 267
268 $scope.$broadcast('addCabecera', { 268 $scope.$broadcast('addCabecera', {
269 label: 'Tipo de pago: ', 269 label: 'Tipo de pago: ',
270 valor: data 270 valor: data
271 }); 271 });
272 }) 272 })
273 .catch(function () { 273 .catch(function () {
274 274
275 $scope.seleccionarCliente(); 275 $scope.seleccionarCliente();
276 }); 276 });
277 277
278 }, function () { 278 }, function () {
279 } 279 }
280 ); 280 );
281 281
282 }; 282 };
283 283
284 $scope.seleccionarVendedor = function () { 284 $scope.seleccionarVendedor = function () {
285 var parametrosModal = { 285 var parametrosModal = {
286 titulo: 'Búsqueda vendedores', 286 titulo: 'Búsqueda vendedores',
287 query: '/vendedor-playa', 287 query: '/vendedor-playa',
288 columnas: [ 288 columnas: [
289 { 289 {
290 propiedad: 'CodVen', 290 propiedad: 'CodVen',
291 nombre: 'Código', 291 nombre: 'Código',
292 filtro: { 292 filtro: {
293 nombre: 'rellenarDigitos', 293 nombre: 'rellenarDigitos',
294 parametro: 3 294 parametro: 3
295 } 295 }
296 }, 296 },
297 { 297 {
298 propiedad: 'NomVen', 298 propiedad: 'NomVen',
299 nombre: 'Nombre' 299 nombre: 'Nombre'
300 } 300 }
301 ], 301 ],
302 size: 'md' 302 size: 'md'
303 }; 303 };
304 focaModalService.modal(parametrosModal).then( 304 focaModalService.modal(parametrosModal).then(
305 function (vendedor) { 305 function (vendedor) {
306 306
307 indicarPassword(vendedor) 307 indicarPassword(vendedor)
308 .then(function () { 308 .then(function () {
309 validarPlanillaVendedor(vendedor) 309 validarPlanillaVendedor(vendedor)
310 .then(function () { 310 .then(function () {
311 311
312 $filter('filter')($scope.botonera, { 312 $filter('filter')($scope.botonera, {
313 label: 'Vendedor' 313 label: 'Vendedor'
314 })[0].checked = true; 314 })[0].checked = true;
315 315
316 $scope.$broadcast('addCabecera', { 316 $scope.$broadcast('addCabecera', {
317 label: 'Vendedor:', 317 label: 'Vendedor:',
318 valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + 318 valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) +
319 ' - ' + 319 ' - ' +
320 vendedor.NomVen 320 vendedor.NomVen
321 }); 321 });
322 322
323 $scope.factura.vendedor = vendedor; 323 $scope.factura.vendedor = vendedor;
324 324
325 getProductosByPlanilla(vendedor.NplVen); 325 getProductosByPlanilla(vendedor.NplVen);
326 }) 326 })
327 .catch($scope.seleccionarVendedor); 327 .catch($scope.seleccionarVendedor);
328 }) 328 })
329 .catch(function (err) { 329 .catch(function (err) {
330 console.error(err); 330 console.error(err);
331 }); 331 });
332 332
333 }, function () { } 333 }, function () { }
334 ); 334 );
335 }; 335 };
336 336
337 $scope.seleccionarMoneda = function () { 337 $scope.seleccionarMoneda = function () {
338 338
339 var parametrosModal = { 339 var parametrosModal = {
340 titulo: 'Búsqueda de monedas', 340 titulo: 'Búsqueda de monedas',
341 query: '/moneda', 341 query: '/moneda',
342 columnas: [ 342 columnas: [
343 { 343 {
344 propiedad: 'DETALLE', 344 propiedad: 'DETALLE',
345 nombre: 'Nombre' 345 nombre: 'Nombre'
346 }, 346 },
347 { 347 {
348 propiedad: 'SIMBOLO', 348 propiedad: 'SIMBOLO',
349 nombre: 'Símbolo' 349 nombre: 'Símbolo'
350 } 350 }
351 ], 351 ],
352 size: 'md' 352 size: 'md'
353 }; 353 };
354 focaModalService.modal(parametrosModal).then( 354 focaModalService.modal(parametrosModal).then(
355 function (moneda) { 355 function (moneda) {
356 356
357 if (moneda.ID !== 1) { 357 if (moneda.ID !== 1) {
358 $scope.abrirModalCotizacion(moneda); 358 $scope.abrirModalCotizacion(moneda);
359 return; 359 return;
360 } 360 }
361 361
362 crearRemitoService.getCotizacionByIdMoneda(1) 362 crearRemitoService.getCotizacionByIdMoneda(1)
363 .then(function (res) { 363 .then(function (res) {
364 364
365 var cotizacionPArgentino = res.data[0].cotizaciones[0]; 365 var cotizacionPArgentino = res.data[0].cotizaciones[0];
366 cotizacionPArgentino.moneda = moneda; 366 cotizacionPArgentino.moneda = moneda;
367 367
368 actualizarCabeceraMoneda(cotizacionPArgentino); 368 actualizarCabeceraMoneda(cotizacionPArgentino);
369 369
370 $scope.remito.cotizacion = cotizacionPArgentino; 370 $scope.remito.cotizacion = cotizacionPArgentino;
371 }); 371 });
372 }, function () { 372 }, function () {
373 373
374 } 374 }
375 ); 375 );
376 }; 376 };
377 377
378 $scope.abrirModalCotizacion = function (moneda) { 378 $scope.abrirModalCotizacion = function (moneda) {
379 var modalInstance = $uibModal.open( 379 var modalInstance = $uibModal.open(
380 { 380 {
381 ariaLabelledBy: 'Busqueda de Cotización', 381 ariaLabelledBy: 'Busqueda de Cotización',
382 templateUrl: 'modal-cotizacion.html', 382 templateUrl: 'modal-cotizacion.html',
383 controller: 'focaModalCotizacionController', 383 controller: 'focaModalCotizacionController',
384 size: 'lg', 384 size: 'lg',
385 resolve: { idMoneda: function () { return moneda.ID; } } 385 resolve: { idMoneda: function () { return moneda.ID; } }
386 } 386 }
387 ); 387 );
388 modalInstance.result.then( 388 modalInstance.result.then(
389 function (cotizacion) { 389 function (cotizacion) {
390 390
391 cotizacion.moneda = moneda; 391 cotizacion.moneda = moneda;
392 actualizarCabeceraMoneda(cotizacion); 392 actualizarCabeceraMoneda(cotizacion);
393 $scope.factura.cotizacion = cotizacion; 393 $scope.factura.cotizacion = cotizacion;
394 394
395 }, function () { 395 }, function () {
396 396
397 } 397 }
398 ); 398 );
399 }; 399 };
400 400
401 $scope.seleccionarObservaciones = function () { 401 $scope.seleccionarObservaciones = function () {
402 var observacion = { 402 var observacion = {
403 titulo: 'Ingrese Observaciones', 403 titulo: 'Ingrese Observaciones',
404 value: $scope.factura.observaciones, 404 value: $scope.factura.observaciones,
405 maxlength: 155, 405 maxlength: 155,
406 textarea: true 406 textarea: true
407 }; 407 };
408 408
409 focaModalService 409 focaModalService
410 .prompt(observacion) 410 .prompt(observacion)
411 .then(function (observaciones) { 411 .then(function (observaciones) {
412 $scope.factura.observaciones = observaciones; 412 $scope.factura.observaciones = observaciones;
413 }); 413 });
414 }; 414 };
415 415
416 $scope.articulosFiltro = function () { 416 $scope.articulosFiltro = function () {
417 return $scope.factura.articulosFactura.filter(function (articulo) { 417 return $scope.factura.articulosFactura.filter(function (articulo) {
418 return !articulo.desactivado; 418 return !articulo.desactivado;
419 }); 419 });
420 }; 420 };
421 421
422 $scope.getTotal = function () { 422 $scope.getTotal = function () {
423 423
424 var total = 0; 424 var total = 0;
425 425
426 $scope.articulosFiltro().forEach(function (articulo) { 426 $scope.articulosFiltro().forEach(function (articulo) {
427 total += articulo.PUN * articulo.CAN; 427 total += articulo.PUN * articulo.CAN;
428 }); 428 });
429 429
430 return parseFloat(total.toFixed(2)); 430 return parseFloat(total.toFixed(2));
431 }; 431 };
432 432
433 $scope.quitarDespacho = function (articulo, index) { 433 $scope.quitarDespacho = function (articulo, index) {
434 434
435 crearFacturaService 435 crearFacturaService
436 .setearDespachoDesocupado({ 436 .setearDespachoDesocupado({
437 surtidor: $scope.factura.despachos[index].SUR, 437 surtidor: $scope.factura.despachos[index].SUR,
438 producto: $scope.factura.despachos[index].PRO, 438 producto: $scope.factura.despachos[index].PRO,
439 carga: $scope.factura.despachos[index].CAR, 439 carga: $scope.factura.despachos[index].CAR,
440 planilla: $scope.factura.despachos[index].PLA 440 planilla: $scope.factura.despachos[index].PLA
441 }) 441 })
442 .then(function () { 442 .then(function () {
443 articulo.desactivado = true; 443 articulo.desactivado = true;
444 $scope.factura.despachos.splice(index, 1); 444 $scope.factura.despachos.splice(index, 1);
445 }) 445 })
446 .catch(function () { 446 .catch(function () {
447 focaModalService.alert('Hubo un error al desasociar este despacho'); 447 focaModalService.alert('Hubo un error al desasociar este despacho');
448 }); 448 });
449 }; 449 };
450 450
451 function getProductosByPlanilla(numeroPlanilla) { 451 function getProductosByPlanilla(numeroPlanilla) {
452 452
453 crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function (res) { 453 crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function (res) {
454 454
455 if (!res.data.length) { 455 if (!res.data.length) {
456 456
457 focaModalService.alert('No hay despachos disponibles por el momento'); 457 focaModalService.alert('No hay despachos disponibles por el momento');
458 return; 458 return;
459 } 459 }
460 460
461 $scope.botoneraProductos.length = 0; 461 $scope.botoneraProductos.length = 0;
462 res.data.forEach(function (producto) { 462 res.data.forEach(function (producto) {
463 463
464 $scope.botoneraProductos.push({ 464 $scope.botoneraProductos.push({
465 label: producto.DetArt, 465 label: producto.DetArt,
466 image: producto.nombreImagen, 466 image: producto.nombreImagen,
467 imageDefault: 'productoDefault.png' 467 imageDefault: 'productoDefault.png'
468 }); 468 });
469 469
470 470
471 crearFuncionesProductos(producto); 471 crearFuncionesProductos(producto);
472 472
473 }); 473 });
474 $scope.botoneraProductos.push({ 474 $scope.botoneraProductos.push({
475 label: 'Busqueda Productos', 475 label: 'Busqueda Productos',
476 image: 'buscarProductos.png', 476 image: 'buscarProductos.png',
477 imageDefault: 'productoDefault.png' 477 imageDefault: 'productoDefault.png'
478 }); 478 });
479 }); 479 });
480 } 480 }
481 481
482 $scope.seleccionarBusquedaProductos = function () { 482 $scope.seleccionarBusquedaProductos = function () {
483 483
484 var modalInstance = $uibModal.open( 484 var modalInstance = $uibModal.open(
485 { 485 {
486 ariaLabelledBy: 'Busqueda de Productos', 486 ariaLabelledBy: 'Busqueda de Productos',
487 templateUrl: 'modal-busqueda-productos.html', 487 templateUrl: 'modal-busqueda-productos.html',
488 controller: 'modalBusquedaProductosCtrl', 488 controller: 'modalBusquedaProductosCtrl',
489 resolve: { 489 resolve: {
490 parametroProducto: { 490 parametroProducto: {
491 idLista: null, 491 idLista: null,
492 cotizacion: $scope.factura.cotizacion.VENDEDOR, 492 cotizacion: $scope.factura.cotizacion.VENDEDOR,
493 simbolo: $scope.factura.cotizacion.moneda.SIMBOLO, 493 simbolo: $scope.factura.cotizacion.moneda.SIMBOLO,
494 buscarTodos: true 494 buscarTodos: true
495 } 495 }
496 }, 496 },
497 size: 'lg' 497 size: 'lg'
498 } 498 }
499 ); 499 );
500 500
501 modalInstance.result 501 modalInstance.result
502 .then(function (producto) { 502 .then(function (producto) {
503 503
504 var articulo = { 504 var articulo = {
505 TIP: $scope.factura.cliente.tipoFactura, 505 TIP: $scope.factura.cliente.tipoFactura,
506 TCO: 'FT', 506 TCO: 'FT',
507 SUC: parseInt($scope.puntoVenta), 507 SUC: parseInt($scope.puntoVenta),
508 ORD: $scope.articulosFiltro().length + 1, 508 ORD: $scope.articulosFiltro().length + 1,
509 SEC: producto.sector, 509 SEC: producto.sector,
510 ART: producto.codigo, 510 ART: producto.codigo,
511 RUB: producto.CodRub, 511 RUB: producto.CodRub,
512 DES: producto.descripcionLarga, 512 DES: producto.descripcionLarga,
513 PUN: producto.precio, // TODO 513 PUN: producto.precio, // TODO
514 IVA: producto.IMPIVA, // TODO 514 IVA: producto.IMPIVA, // TODO
515 NET: 0, // TODO 515 NET: 0, // TODO
516 NEX: 0, // TODO 516 NEX: 0, // TODO
517 IMI: producto.ImpInt, // TODO 517 IMI: producto.ImpInt, // TODO
518 IMI2: producto.ImpInt2, // TODO 518 IMI2: producto.ImpInt2, // TODO
519 IMI3: producto.ImpInt3, // TODO 519 IMI3: producto.ImpInt3, // TODO
520 PUT: producto.PreNet, // TODO 520 PUT: producto.PreNet, // TODO
521 SUR: 0, 521 SUR: 0,
522 PLA: $scope.factura.vendedor.NplVen, 522 PLA: $scope.factura.vendedor.NplVen,
523 LUG: $scope.factura.vendedor.LugVen, 523 LUG: $scope.factura.vendedor.LugVen,
524 LEG: $scope.factura.vendedor.CodVen, 524 LEG: $scope.factura.vendedor.CodVen,
525 TUR: $scope.factura.vendedor.TurVen, 525 TUR: $scope.factura.vendedor.TurVen,
526 ORDEN_PRECOMPRA: '', 526 ORDEN_PRECOMPRA: '',
527 ESC: producto.tipoFactura === 'L' ? 1 : 0, 527 ESC: producto.tipoFactura === 'L' ? 1 : 0,
528 CMF: 0, 528 CMF: 0,
529 PTA: 0, 529 PTA: 0,
530 IVS: 0, 530 IVS: 0,
531 TIVA: 0, 531 TIVA: 0,
532 CON: 0, 532 CON: 0,
533 SINO: '', 533 SINO: '',
534 ORD_TRA: 0, 534 ORD_TRA: 0,
535 IMP_DESP: 0, 535 IMP_DESP: 0,
536 PCD: 0, 536 PCD: 0,
537 RTO: '' 537 RTO: ''
538 }; 538 };
539 // crearFacturaService.setearDespachoOcupado({ 539 // crearFacturaService.setearDespachoOcupado({
540 // surtidor: articulo.SUR, 540 // surtidor: articulo.SUR,
541 // producto: articulo.PRO, 541 // producto: articulo.PRO,
542 // carga: articulo.CAR 542 // carga: articulo.CAR
543 // }) 543 // })
544 // .then(function () { 544 // .then(function () {
545 $scope.factura.articulosFactura.push(articulo); 545 $scope.factura.articulosFactura.push(articulo);
546 $scope.cambioEdit(articulo, 'cantidad'); 546 $scope.cambioEdit(articulo, 'cantidad');
547 // }) 547 // })
548 // .catch(function (err) { 548 // .catch(function (err) {
549 549
550 // focaModalService.alert('El despacho esta en uso'); 550 // focaModalService.alert('El despacho esta en uso');
551 // }); 551 // });
552 }) 552 })
553 .catch(function (e) { console.error(e); }); 553 .catch(function (e) { console.error(e); });
554 }; 554 };
555 555
556 function crearFuncionesProductos(producto) { 556 function crearFuncionesProductos(producto) {
557 557
558 $scope[nombreFuncion(producto.DetArt)] = function () { 558 $scope[nombreFuncion(producto.DetArt)] = function () {
559 559
560 if (angular.equals($scope.factura.cliente, {})) { 560 if (angular.equals($scope.factura.cliente, {})) {
561 focaModalService.alert('Seleccione cliente'); 561 focaModalService.alert('Seleccione cliente');
562 return; 562 return;
563 } 563 }
564 564
565 var modalInstance = $uibModal.open( 565 var modalInstance = $uibModal.open(
566 { 566 {
567 templateUrl: 'modal-combustibles.html', 567 templateUrl: 'modal-combustibles.html',
568 controller: 'focaModalCombustiblesController', 568 controller: 'focaModalCombustiblesController',
569 resolve: { 569 resolve: {
570 parametros: function () { 570 parametros: function () {
571 return { 571 return {
572 despachos: producto.despachos, 572 despachos: producto.despachos,
573 nombreProducto: producto.DetArt 573 nombreProducto: producto.DetArt
574 }; 574 };
575 } 575 }
576 }, 576 },
577 size: 'md' 577 size: 'md'
578 } 578 }
579 ); 579 );
580 580
581 modalInstance.result.then(function (despacho) { 581 modalInstance.result.then(function (despacho) {
582 582
583 var articulo = { 583 var articulo = {
584 TIP: $scope.factura.cliente.tipoFactura, 584 TIP: $scope.factura.cliente.tipoFactura,
585 TCO: 'FT', 585 TCO: 'FT',
586 SUC: parseInt($scope.puntoVenta), 586 SUC: parseInt($scope.puntoVenta),
587 ORD: $scope.articulosFiltro().length + 1, 587 ORD: $scope.articulosFiltro().length + 1,
588 SEC: despacho.SEC, 588 SEC: despacho.SEC,
589 ART: despacho.PRO, 589 ART: despacho.PRO,
590 RUB: producto.CodRub, 590 RUB: producto.CodRub,
591 DES: producto.DetArt, 591 DES: producto.DetArt,
592 CAN: despacho.LTS, 592 CAN: despacho.LTS,
593 PUN: producto.PreVen, // TODO 593 PUN: producto.PreVen, // TODO
594 IVA: producto.IMPIVA, // TODO 594 IVA: producto.IMPIVA, // TODO
595 NET: 0, // TODO 595 NET: 0, // TODO
596 NEX: 0, // TODO 596 NEX: 0, // TODO
597 IMI: producto.ImpInt, // TODO 597 IMI: producto.ImpInt, // TODO
598 IMI2: producto.ImpInt2, // TODO 598 IMI2: producto.ImpInt2, // TODO
599 IMI3: producto.ImpInt3, // TODO 599 IMI3: producto.ImpInt3, // TODO
600 PUT: producto.PreNet, // TODO 600 PUT: producto.PreNet, // TODO
601 SUR: despacho.SUR, 601 SUR: despacho.SUR,
602 PLA: despacho.PLA, 602 PLA: despacho.PLA,
603 LUG: despacho.LUG, 603 LUG: despacho.LUG,
604 LEG: $scope.factura.vendedor.CodVen, 604 LEG: $scope.factura.vendedor.CodVen,
605 TUR: $scope.factura.vendedor.TurVen, 605 TUR: $scope.factura.vendedor.TurVen,
606 ORDEN_PRECOMPRA: '', 606 ORDEN_PRECOMPRA: '',
607 ESC: producto.tipoFactura === 'L' ? 1 : 0, 607 ESC: producto.tipoFactura === 'L' ? 1 : 0,
608 CMF: 0, 608 CMF: 0,
609 PTA: 0, 609 PTA: 0,
610 IVS: 0, 610 IVS: 0,
611 TIVA: 0, 611 TIVA: 0,
612 CON: 0, 612 CON: 0,
613 SINO: '', 613 SINO: '',
614 ORD_TRA: 0, 614 ORD_TRA: 0,
615 IMP_DESP: 0, 615 IMP_DESP: 0,
616 PCD: 0, 616 PCD: 0,
617 RTO: '' 617 RTO: ''
618 }; 618 };
619 619
620 crearFacturaService.setearDespachoOcupado({ 620 crearFacturaService.setearDespachoOcupado({
621 surtidor: despacho.SUR, 621 surtidor: despacho.SUR,
622 producto: despacho.PRO, 622 producto: despacho.PRO,
623 carga: despacho.CAR 623 carga: despacho.CAR
624 }) 624 })
625 .then(function () { 625 .then(function () {
626 $scope.factura.articulosFactura.push(articulo); 626 $scope.factura.articulosFactura.push(articulo);
627 $scope.factura.despachos.push(despacho); 627 $scope.factura.despachos.push(despacho);
628 }) 628 })
629 .catch(function (err) { 629 .catch(function (err) {
630 630
631 console.error(err); 631 console.error(err);
632 focaModalService.alert('El despacho esta en uso'); 632 focaModalService.alert('El despacho esta en uso');
633 }); 633 });
634 634
635 }) 635 })
636 .catch(function (err) { 636 .catch(function (err) {
637 console.error(err); 637 console.error(err);
638 }); 638 });
639 639
640 }; 640 };
641 } 641 }
642 642
643 function nombreFuncion(string) { 643 function nombreFuncion(string) {
644 var texto = 'seleccionar'; 644 var texto = 'seleccionar';
645 var arr = string.split(' '); 645 var arr = string.split(' ');
646 arr.forEach(function (palabra) { 646 arr.forEach(function (palabra) {
647 palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); 647 palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1);
648 texto += palabra; 648 texto += palabra;
649 }); 649 });
650 return texto; 650 return texto;
651 } 651 }
652 652
653 function indicarPassword(vendedor) { 653 function indicarPassword(vendedor) {
654 654
655 return new Promise(function (resolve, reject) { 655 return new Promise(function (resolve, reject) {
656 656
657 function openPrompt() { 657 function openPrompt() {
658 return focaModalService 658 return focaModalService
659 .prompt({ 659 .prompt({
660 titulo: 'Indique Contraseña', 660 titulo: 'Indique Contraseña',
661 value: '' 661 value: ''
662 }) 662 })
663 .then(function (contraseña) { 663 .then(function (contraseña) {
664 664
665 if (contraseña !== vendedor.ClaVen.trim()) { 665 if (contraseña !== vendedor.ClaVen.trim()) {
666 666
667 focaModalService.alert('Clave incorrecta').then(function () { 667 focaModalService.alert('Clave incorrecta').then(function () {
668 openPrompt(vendedor); 668 openPrompt(vendedor);
669 }); 669 });
670 } else { 670 } else {
671 resolve(); 671 resolve();
672 } 672 }
673 }) 673 })
674 .catch(reject);; 674 .catch(reject);;
675 } 675 }
676 676
677 openPrompt() 677 openPrompt()
678 }); 678 });
679 } 679 }
680 680
681 function validarPlanillaVendedor(vendedor) { 681 function validarPlanillaVendedor(vendedor) {
682 682
683 return new Promise(function (resolve, reject) { 683 return new Promise(function (resolve, reject) {
684 684
685 crearFacturaService 685 crearFacturaService
686 .validarPlanillaVendedor(vendedor.CodVen.toString().trim()) 686 .validarPlanillaVendedor(vendedor.CodVen.toString().trim())
687 .then(function (res) { 687 .then(function (res) {
688 688
689 if (!res.data.length) { 689 if (!res.data.length) {
690 690
691 focaModalService 691 focaModalService
692 .alert('No se encontró planilla abierta para el vendedor') 692 .alert('No se encontró planilla abierta para el vendedor')
693 .then(reject); 693 .then(reject);
694 694
695 } else { 695 } else {
696 resolve(); 696 resolve();
697 } 697 }
698 698
699 }) 699 })
700 .catch(function (err) { 700 .catch(function (err) {
701 console.log(err) 701 console.log(err)
702 reject(); 702 reject();
703 }); 703 });
704 }); 704 });
705 } 705 }
706 706
707 function rellenar(relleno, longitud) { 707 function rellenar(relleno, longitud) {
708 relleno = '' + relleno; 708 relleno = '' + relleno;
709 while (relleno.length < longitud) { 709 while (relleno.length < longitud) {
710 relleno = '0' + relleno; 710 relleno = '0' + relleno;
711 } 711 }
712 return relleno; 712 return relleno;
713 } 713 }
714 714
715 function salir() { 715 function salir() {
716 var confirmacion = false; 716 var confirmacion = false;
717 717
718 if (!angular.equals($scope.factura, $scope.inicial)) { 718 if (!angular.equals($scope.factura, $scope.inicial)) {
719 confirmacion = true; 719 confirmacion = true;
720 } 720 }
721 721
722 if (confirmacion) { 722 if (confirmacion) {
723 focaModalService.confirm( 723 focaModalService.confirm(
724 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' 724 '¿Está seguro de que desea salir? Se perderán todos los datos cargados.'
725 ).then(function (data) { 725 ).then(function (data) {
726 if (data) { 726 if (data) {
727 $location.path('/'); 727 $location.path('/');
728 } 728 }
729 }); 729 });
730 } else { 730 } else {
731 $location.path('/'); 731 $location.path('/');
732 } 732 }
733 } 733 }
734 734
735 function setearFactura(factura) { 735 function setearFactura(factura) {
736 736
737 $scope.$broadcast('cleanCabecera'); 737 $scope.$broadcast('cleanCabecera');
738 738
739 $scope.cabeceras = []; 739 $scope.cabeceras = [];
740 740
741 if (factura.cotizacion && factura.cotizacion.moneda.CODIGO_AFIP !== 'PES') { 741 if (factura.cotizacion && factura.cotizacion.moneda.CODIGO_AFIP !== 'PES') {
742 $scope.cabeceras.push({ 742 $scope.cabeceras.push({
743 label: 'Moneda:', 743 label: 'Moneda:',
744 valor: factura.cotizacion.moneda.DETALLE 744 valor: factura.cotizacion.moneda.DETALLE
745 }); 745 });
746 $scope.cabeceras.push({ 746 $scope.cabeceras.push({
747 label: 'Fecha cotizacion:', 747 label: 'Fecha cotizacion:',
748 valor: $filter('date')(factura.cotizacion.FECHA, 748 valor: $filter('date')(factura.cotizacion.FECHA,
749 'dd/MM/yyyy') 749 'dd/MM/yyyy')
750 }); 750 });
751 $scope.cabeceras.push({ 751 $scope.cabeceras.push({
752 label: 'Cotizacion:', 752 label: 'Cotizacion:',
753 valor: $filter('number')(factura.cotizacion.VENDEDOR, 753 valor: $filter('number')(factura.cotizacion.VENDEDOR,
754 '2') 754 '2')
755 }); 755 });
756 } 756 }
757 757
758 if (factura.cotizacion && factura.cotizacion.moneda) { 758 if (factura.cotizacion && factura.cotizacion.moneda) {
759 $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; 759 // $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true;
760 } 760 }
761 761
762 if (factura.cliente && factura.cliente.cod) { 762 if (factura.cliente && factura.cliente.cod) {
763 $scope.cabeceras.push({ 763 $scope.cabeceras.push({
764 label: 'Cliente:', 764 label: 'Cliente:',
765 valor: $filter('rellenarDigitos')(factura.cliente.cod, 3) + ' - ' + 765 valor: $filter('rellenarDigitos')(factura.cliente.cod, 3) + ' - ' +
766 factura.cliente.nom 766 factura.cliente.nom
767 }); 767 });
768 768
769 $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; 769 $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true;
770 } 770 }
771 771
772 $scope.puntoVenta = rellenar(factura.sucursal, 4); 772 $scope.puntoVenta = rellenar(factura.sucursal, 4);
773 $scope.comprobante = rellenar(factura.numerofactura, 8); 773 $scope.comprobante = rellenar(factura.numerofactura, 8);
774 $scope.factura = factura; 774 $scope.factura = factura;
775 775
776 addArrayCabecera($scope.cabeceras); 776 addArrayCabecera($scope.cabeceras);
777 } 777 }
778 778
779 function getLSFactura() { 779 function getLSFactura() {
780 var factura = JSON.parse($localStorage.factura || null); 780 var factura = JSON.parse($localStorage.factura || null);
781 if (factura) { 781 if (factura) {
782 setearFactura(factura); 782 setearFactura(factura);
783 delete $localStorage.factura; 783 delete $localStorage.factura;
784 } 784 }
785 } 785 }
786 786
787 function addArrayCabecera(array) { 787 function addArrayCabecera(array) {
788 for (var i = 0; i < array.length; i++) { 788 for (var i = 0; i < array.length; i++) {
789 $scope.$broadcast('addCabecera', { 789 $scope.$broadcast('addCabecera', {
790 label: array[i].label, 790 label: array[i].label,
791 valor: array[i].valor 791 valor: array[i].valor
792 }); 792 });
793 } 793 }
794 } 794 }
795 795
796 $scope.cambioEdit = function (articulo, propiedad) { 796 $scope.cambioEdit = function (articulo, propiedad) {
797 if (propiedad === 'cantidad') { 797 if (propiedad === 'cantidad') {
798 articulo.editCantidad = true; 798 articulo.editCantidad = true;
799 } 799 }
800 }; 800 };
801 801
802 $scope.editarArticulo = function (key, articulo, tmpCantidad) { 802 $scope.editarArticulo = function (key, articulo, tmpCantidad) {
803 if (key === 13) { 803 if (key === 13) {
804 if (!articulo.cantidad && !tmpCantidad) { 804 if (!articulo.cantidad && !tmpCantidad) {
805 focaModalService.alert('Los valores deben ser al menos 1'); 805 focaModalService.alert('Los valores deben ser al menos 1');
806 return; 806 return;
807 } else if (tmpCantidad === '0') { 807 } else if (tmpCantidad === '0') {
808 focaModalService.alert('Esta ingresando un producto con valor 0'); 808 focaModalService.alert('Esta ingresando un producto con valor 0');
809 } else if (articulo.cantidad < 0) { 809 } else if (articulo.cantidad < 0) {
810 focaModalService.alert('Los valores no pueden ser negativos'); 810 focaModalService.alert('Los valores no pueden ser negativos');
811 return; 811 return;
812 } 812 }
813 articulo.CAN = parseInt(tmpCantidad); 813 articulo.CAN = parseInt(tmpCantidad);
814 $scope.getTotal(); 814 $scope.getTotal();
815 articulo.editCantidad = false; 815 articulo.editCantidad = false;
816 } 816 }
817 }; 817 };
818 818
819 $scope.cancelarEditar = function (articulo) { 819 $scope.cancelarEditar = function (articulo) {
820 $scope.tmpCantidad = articulo.CAN; 820 $scope.tmpCantidad = articulo.CAN;
821 articulo.editCantidad = false; 821 articulo.editCantidad = false;
822 }; 822 };
823 823
824 function actualizarCabeceraMoneda(cotizacion) { 824 function actualizarCabeceraMoneda(cotizacion) {
825 825
826 $scope.factura.articulosFactura.forEach(function (art) { 826 $scope.factura.articulosFactura.forEach(function (art) {
827 art.PUN = (art.PUN * $scope.factura.cotizacion.VENDEDOR).toFixed(4); 827 art.PUN = (art.PUN * $scope.factura.cotizacion.VENDEDOR).toFixed(4);
828 art.PUN = (art.PUN / cotizacion.VENDEDOR).toFixed(4); 828 art.PUN = (art.PUN / cotizacion.VENDEDOR).toFixed(4);
829 }); 829 });
830 830
831 if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { 831 if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') {
832 $scope.$broadcast('removeCabecera', 'Moneda:'); 832 $scope.$broadcast('removeCabecera', 'Moneda:');
833 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); 833 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
834 $scope.$broadcast('removeCabecera', 'Cotizacion:'); 834 $scope.$broadcast('removeCabecera', 'Cotizacion:');
835 } else { 835 } else {
836 $scope.$broadcast('addCabecera', { 836 $scope.$broadcast('addCabecera', {
837 label: 'Moneda:', 837 label: 'Moneda:',
838 valor: cotizacion.moneda.DETALLE 838 valor: cotizacion.moneda.DETALLE
839 }); 839 });
840 $scope.$broadcast('addCabecera', { 840 $scope.$broadcast('addCabecera', {
841 label: 'Fecha cotizacion:', 841 label: 'Fecha cotizacion:',
842 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 842 valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
843 }); 843 });
844 $scope.$broadcast('addCabecera', { 844 $scope.$broadcast('addCabecera', {
845 label: 'Cotizacion:', 845 label: 'Cotizacion:',
846 valor: $filter('number')(cotizacion.VENDEDOR, '2') 846 valor: $filter('number')(cotizacion.VENDEDOR, '2')
847 }); 847 });
848 } 848 }
849 } 849 }
850 850
851 function validarGuardar() { 851 function validarGuardar() {
852 852
853 if (angular.equals({}, $scope.factura.vendedor)) { 853 if (angular.equals({}, $scope.factura.vendedor)) {
854 854
855 focaModalService.alert('Seleccione Vendedor'); 855 focaModalService.alert('Seleccione Vendedor');
856 return false; 856 return false;
857 } else if (angular.equals({}, $scope.factura.cliente)) { 857 } else if (angular.equals({}, $scope.factura.cliente)) {
858 858
859 focaModalService.alert('Seleccione Cliente'); 859 focaModalService.alert('Seleccione Cliente');
860 return false; 860 return false;
861 } else if (!$scope.articulosFiltro().length) { 861 } else if (!$scope.articulosFiltro().length) {
862 862
863 focaModalService.alert('Seleccione al menos un Articulo'); 863 focaModalService.alert('Seleccione al menos un Articulo');
864 return false; 864 return false;
865 } 865 }
866 866
867 return true; 867 return true;
868 } 868 }
869 } 869 }
870 ]); 870 ]);
871 871