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