Commit 117ea07ec640f6e6b64d602a3a72dba592ed386d

Authored by Marcelo Puebla
1 parent 7b846d2e71
Exists in master

agregada botonera de productos

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