Commit 9ab132e96ba19fd02bb3ed3f25ea5c38b7ab5e8e

Authored by Marcelo Puebla
1 parent 117ea07ec6
Exists in master and in 1 other branch develop

Agegada logica para buscar y seleccionar un producto.

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