Commit 63a790ee499346c97240c4c577fcc9af980cc30c
Exists in
master
Merge branch 'master' into 'master'
Master(efernandez) See merge request !1
Showing
1 changed file
Show diff stats
src/js/controller.js
| 1 | angular.module('focaCrearCobranza') .controller('cobranzaController', | 1 | angular.module('focaCrearCobranza') .controller('cobranzaController', |
| 2 | [ | 2 | [ |
| 3 | '$scope', | 3 | '$scope', |
| 4 | '$uibModal', | 4 | '$uibModal', |
| 5 | '$location', | 5 | '$location', |
| 6 | '$filter', | 6 | '$filter', |
| 7 | 'focaCrearCobranzaService', | 7 | 'focaCrearCobranzaService', |
| 8 | 'focaModalService', | 8 | 'focaModalService', |
| 9 | function($scope, $uibModal, $location, $filter, focaCrearCobranzaService, focaModalService) | 9 | function($scope, $uibModal, $location, $filter, focaCrearCobranzaService, focaModalService) |
| 10 | { | 10 | { |
| 11 | $scope.botonera = [ | 11 | $scope.botonera = [ |
| 12 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | 12 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
| 13 | {texto: 'Cobrador', accion: function() {$scope.seleccionarCobrador();}}, | 13 | {texto: 'Cobrador', accion: function() {$scope.seleccionarCobrador();}}, |
| 14 | {texto: 'Deuda', accion: function() {$scope.swichDeuda();}}, | 14 | {texto: 'Deuda', accion: function() {$scope.swichDeuda();}}, |
| 15 | {texto: 'Cobros', accion: function() {$scope.swichCobro();}}, | 15 | {texto: 'Cobros', accion: function() {$scope.swichCobro();}}, |
| 16 | {texto: 'Moneda', accion: function() {$scope.seleccionarMoneda();}}, | 16 | {texto: 'Moneda', accion: function() {$scope.seleccionarMoneda();}}, |
| 17 | {texto: '', accion: function() {}}, | 17 | {texto: '', accion: function() {}}, |
| 18 | {texto: '', accion: function() {}}, | 18 | {texto: '', accion: function() {}}, |
| 19 | {texto: '', accion: function() {}} | 19 | {texto: '', accion: function() {}} |
| 20 | ]; | 20 | ]; |
| 21 | $scope.datepickerAbierto = false; | 21 | $scope.datepickerAbierto = false; |
| 22 | $scope.cobroDeuda = true; | 22 | $scope.cobroDeuda = true; |
| 23 | $scope.show = false; | 23 | $scope.show = false; |
| 24 | $scope.cargando = true; | 24 | $scope.cargando = true; |
| 25 | $scope.dateOptions = { | 25 | $scope.dateOptions = { |
| 26 | maxDate: new Date(), | 26 | maxDate: new Date(), |
| 27 | minDate: new Date(2010, 0, 1) | 27 | minDate: new Date(2010, 0, 1) |
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | $scope.cobranza = { | 30 | $scope.cobranza = { |
| 31 | fecha: new Date() | 31 | fecha: new Date() |
| 32 | }; | 32 | }; |
| 33 | 33 | ||
| 34 | $scope.cabecera = []; | 34 | $scope.cabecera = []; |
| 35 | $scope.showCabecera = true; | 35 | $scope.showCabecera = true; |
| 36 | 36 | ||
| 37 | $scope.now = new Date(); | 37 | $scope.now = new Date(); |
| 38 | $scope.puntoVenta = '0000'; | 38 | $scope.puntoVenta = '0000'; |
| 39 | $scope.comprobante = '00000000'; | 39 | $scope.comprobante = '00000000'; |
| 40 | $scope.facturaTabla = []; | 40 | $scope.facturaTabla = []; |
| 41 | $scope.cobrosTabla = []; | 41 | $scope.cobrosTabla = []; |
| 42 | 42 | ||
| 43 | var monedaPorDefecto; | 43 | var monedaPorDefecto; |
| 44 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 44 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
| 45 | focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) { | 45 | focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) { |
| 46 | monedaPorDefecto = res.data[0]; | 46 | monedaPorDefecto = res.data[0]; |
| 47 | addCabecera('Moneda:', monedaPorDefecto.DETALLE); | 47 | addCabecera('Moneda:', monedaPorDefecto.DETALLE); |
| 48 | addCabecera('Fecha cotizacion:', | 48 | addCabecera('Fecha cotizacion:', |
| 49 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | 49 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); |
| 50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].VENDEDOR); | 50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].VENDEDOR); |
| 51 | $scope.cobranza.moneda = monedaPorDefecto; | 51 | $scope.cobranza.moneda = monedaPorDefecto; |
| 52 | $scope.cobranza.cotizacion = monedaPorDefecto.cotizaciones[0]; | 52 | $scope.cobranza.cotizacion = monedaPorDefecto.cotizaciones[0]; |
| 53 | }); | 53 | }); |
| 54 | 54 | ||
| 55 | focaCrearCobranzaService.getNumeroRecibo().then( | 55 | focaCrearCobranzaService.getNumeroRecibo().then( |
| 56 | function(res) { | 56 | function(res) { |
| 57 | $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4); | 57 | $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4); |
| 58 | $scope.comprobante = $scope.rellenar(res.data.numeroRecibo, 8); | 58 | $scope.comprobante = $scope.rellenar(res.data.numeroRecibo, 8); |
| 59 | }, | 59 | }, |
| 60 | function(err) { | 60 | function(err) { |
| 61 | focaModalService.alert('La terminal no esta configurada correctamente'); | 61 | focaModalService.alert('La terminal no esta configurada correctamente'); |
| 62 | console.info(err); | 62 | console.info(err); |
| 63 | } | 63 | } |
| 64 | ); | 64 | ); |
| 65 | $scope.crearCobranza = function() { | 65 | $scope.crearCobranza = function() { |
| 66 | if(!$scope.cliente.COD) { | 66 | if(!$scope.cliente.COD) { |
| 67 | focaModalService.alert('Ingrese Cliente'); | 67 | focaModalService.alert('Ingrese Cliente'); |
| 68 | return; | 68 | return; |
| 69 | }else if($scope.facturaTabla.length < 1) { | 69 | }else if($scope.facturaTabla.length < 1) { |
| 70 | focaModalService.alert('Ingrese al menos una factura'); | 70 | focaModalService.alert('Ingrese al menos una factura'); |
| 71 | return; | 71 | return; |
| 72 | } | 72 | } |
| 73 | //TODO: Guarda cobranza | 73 | //TODO: Guarda cobranza |
| 74 | // var date = new Date(); | 74 | // var date = new Date(); |
| 75 | // var cobranza = { | 75 | // var cobranza = { |
| 76 | // }; | 76 | // }; |
| 77 | }; | 77 | }; |
| 78 | 78 | ||
| 79 | $scope.swichCobro = function() { | 79 | $scope.swichCobro = function() { |
| 80 | $scope.cobroDeuda = false; | 80 | $scope.cobroDeuda = false; |
| 81 | }; | 81 | }; |
| 82 | 82 | ||
| 83 | $scope.swichDeuda = function() { | 83 | $scope.swichDeuda = function() { |
| 84 | $scope.cobroDeuda = true; | 84 | $scope.cobroDeuda = true; |
| 85 | }; | 85 | }; |
| 86 | 86 | ||
| 87 | $scope.seleccionarCliente = function() { | 87 | $scope.seleccionarCliente = function() { |
| 88 | 88 | ||
| 89 | var modalInstance = $uibModal.open( | 89 | var modalInstance = $uibModal.open( |
| 90 | { | 90 | { |
| 91 | ariaLabelledBy: 'Busqueda de Cliente', | 91 | ariaLabelledBy: 'Busqueda de Cliente', |
| 92 | templateUrl: 'foca-busqueda-cliente-modal.html', | 92 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 93 | controller: 'focaBusquedaClienteModalController', | 93 | controller: 'focaBusquedaClienteModalController', |
| 94 | size: 'lg' | 94 | size: 'lg' |
| 95 | } | 95 | } |
| 96 | ); | 96 | ); |
| 97 | modalInstance.result.then( | 97 | modalInstance.result.then( |
| 98 | function(cliente) { | 98 | function(cliente) { |
| 99 | addCabecera('Cliente:', cliente.nom); | 99 | addCabecera('Cliente:', cliente.nom); |
| 100 | $scope.cobranza.cliente = { | 100 | $scope.cobranza.cliente = { |
| 101 | COD: cliente.cod, | 101 | COD: cliente.cod, |
| 102 | CUIT: cliente.cuit, | 102 | CUIT: cliente.cuit, |
| 103 | NOM: cliente.nom | 103 | NOM: cliente.nom |
| 104 | }; | 104 | }; |
| 105 | }, function() { | 105 | }, function() { |
| 106 | 106 | ||
| 107 | } | 107 | } |
| 108 | ); | 108 | ); |
| 109 | }; | 109 | }; |
| 110 | 110 | ||
| 111 | $scope.seleccionarFactura = function() { | 111 | $scope.seleccionarFactura = function() { |
| 112 | if(!$scope.cobranza.cliente) { | 112 | if(!$scope.cobranza.cliente) { |
| 113 | focaModalService.alert('Seleccione primero un cliente'); | 113 | focaModalService.alert('Seleccione primero un cliente'); |
| 114 | return; | 114 | return; |
| 115 | } | 115 | } |
| 116 | var modalInstance = $uibModal.open( | 116 | var modalInstance = $uibModal.open( |
| 117 | { | 117 | { |
| 118 | ariaLabelledBy: 'Busqueda de Facturas', | 118 | ariaLabelledBy: 'Busqueda de Facturas', |
| 119 | templateUrl: 'foca-modal-factura.html', | 119 | templateUrl: 'foca-modal-factura.html', |
| 120 | controller: 'focaModalFacturaController', | 120 | controller: 'focaModalFacturaController', |
| 121 | size: 'lg', | 121 | size: 'lg', |
| 122 | resolve: { | 122 | resolve: { |
| 123 | cliente: function() {return $scope.cobranza.cliente.COD;} | 123 | parametrosFactura: { |
| 124 | cliente: $scope.cobranza.cliente.COD, | ||
| 125 | simbolo: $scope.cobranza.moneda.SIMBOLO, | ||
| 126 | cotizacion: $scope.cobranza.cotizacion.VENDEDOR | ||
| 127 | } | ||
| 124 | } | 128 | } |
| 125 | } | 129 | } |
| 126 | ); | 130 | ); |
| 127 | modalInstance.result.then( | 131 | modalInstance.result.then( |
| 128 | function(facturas) { | 132 | function(facturas) { |
| 129 | $scope.facturaTabla = $scope.facturaTabla.concat(facturas); | 133 | $scope.facturaTabla = $scope.facturaTabla.concat(facturas); |
| 130 | }, function() { | 134 | }, function() { |
| 131 | 135 | ||
| 132 | } | 136 | } |
| 133 | ); | 137 | ); |
| 134 | }; | 138 | }; |
| 135 | 139 | ||
| 136 | $scope.seleccionarCheque = function() { | 140 | $scope.seleccionarCheque = function() { |
| 137 | var modalInstance = $uibModal.open( | 141 | var modalInstance = $uibModal.open( |
| 138 | { | 142 | { |
| 139 | ariaLabelledBy: 'Carga de cheques', | 143 | ariaLabelledBy: 'Carga de cheques', |
| 140 | templateUrl: 'modal-cheque.html', | 144 | templateUrl: 'modal-cheque.html', |
| 141 | controller: 'focaModalChequeController', | 145 | controller: 'focaModalChequeController', |
| 142 | size: 'lg' | 146 | size: 'lg' |
| 143 | } | 147 | } |
| 144 | ); | 148 | ); |
| 145 | modalInstance.result.then( | 149 | modalInstance.result.then( |
| 146 | function(cheque) { | 150 | function(cheque) { |
| 147 | var cobro = { | 151 | var cobro = { |
| 148 | tipo: 'Cheque', | 152 | tipo: 'Cheque', |
| 149 | fecha: cheque.fechaValor, | 153 | fecha: cheque.fechaValor, |
| 150 | importe: cheque.importe | 154 | importe: cheque.importe |
| 151 | }; | 155 | }; |
| 152 | $scope.cobrosTabla.push(cobro); | 156 | $scope.cobrosTabla.push(cobro); |
| 153 | }, function() { | 157 | }, function() { |
| 154 | 158 | ||
| 155 | } | 159 | } |
| 156 | ); | 160 | ); |
| 157 | }; | 161 | }; |
| 158 | 162 | ||
| 159 | $scope.seleccionarEfectivo = function() { | 163 | $scope.seleccionarEfectivo = function() { |
| 160 | var modalInstance = $uibModal.open( | 164 | var modalInstance = $uibModal.open( |
| 161 | { | 165 | { |
| 162 | ariaLabelledBy: 'Carga de cheques', | 166 | ariaLabelledBy: 'Carga de cheques', |
| 163 | templateUrl: 'modal-efectivo.html', | 167 | templateUrl: 'modal-efectivo.html', |
| 164 | controller: 'focaModalEfectivoController', | 168 | controller: 'focaModalEfectivoController', |
| 165 | size: 'sm' | 169 | size: 'sm' |
| 166 | } | 170 | } |
| 167 | ); | 171 | ); |
| 168 | modalInstance.result.then( | 172 | modalInstance.result.then( |
| 169 | function(efectivo) { | 173 | function(efectivo) { |
| 170 | var cobro = { | 174 | var cobro = { |
| 171 | tipo: 'Efectivo', | 175 | tipo: 'Efectivo', |
| 172 | fecha: new Date(), | 176 | fecha: new Date(), |
| 173 | importe: efectivo | 177 | importe: efectivo |
| 174 | }; | 178 | }; |
| 175 | $scope.cobrosTabla.push(cobro); | 179 | $scope.cobrosTabla.push(cobro); |
| 176 | }, function() { | 180 | }, function() { |
| 177 | 181 | ||
| 178 | } | 182 | } |
| 179 | ); | 183 | ); |
| 180 | }; | 184 | }; |
| 181 | 185 | ||
| 182 | $scope.seleccionarMoneda = function() { | 186 | $scope.seleccionarMoneda = function() { |
| 183 | var modalInstance = $uibModal.open( | 187 | var modalInstance = $uibModal.open( |
| 184 | { | 188 | { |
| 185 | ariaLabelledBy: 'Busqueda de Moneda', | 189 | ariaLabelledBy: 'Busqueda de Moneda', |
| 186 | templateUrl: 'modal-moneda.html', | 190 | templateUrl: 'modal-moneda.html', |
| 187 | controller: 'focaModalMonedaController', | 191 | controller: 'focaModalMonedaController', |
| 188 | size: 'lg' | 192 | size: 'lg' |
| 189 | } | 193 | } |
| 190 | ); | 194 | ); |
| 191 | modalInstance.result.then( | 195 | modalInstance.result.then( |
| 192 | function(moneda) { | 196 | function(moneda) { |
| 193 | $scope.seleccionarCotizacion(moneda); | 197 | $scope.seleccionarCotizacion(moneda); |
| 194 | }, function() { | 198 | }, function() { |
| 195 | 199 | ||
| 196 | } | 200 | } |
| 197 | ); | 201 | ); |
| 198 | }; | 202 | }; |
| 199 | 203 | ||
| 200 | $scope.seleccionarCobrador = function() { | 204 | $scope.seleccionarCobrador = function() { |
| 201 | var modalInstance = $uibModal.open( | 205 | var modalInstance = $uibModal.open( |
| 202 | { | 206 | { |
| 203 | ariaLabelledBy: 'Busqueda de Cobradores', | 207 | ariaLabelledBy: 'Busqueda de Cobradores', |
| 204 | templateUrl: 'modal-cobradores.html', | 208 | templateUrl: 'modal-cobradores.html', |
| 205 | controller: 'focaModalCobradoresController', | 209 | controller: 'focaModalCobradoresController', |
| 206 | size: 'lg' | 210 | size: 'lg' |
| 207 | } | 211 | } |
| 208 | ); | 212 | ); |
| 209 | modalInstance.result.then( | 213 | modalInstance.result.then( |
| 210 | function(cobrador) { | 214 | function(cobrador) { |
| 211 | addCabecera('Cobrador:', cobrador.nombre); | 215 | addCabecera('Cobrador:', cobrador.nombre); |
| 212 | $scope.cobranza.cobrador = cobrador; | 216 | $scope.cobranza.cobrador = cobrador; |
| 213 | }, function() { | 217 | }, function() { |
| 214 | 218 | ||
| 215 | } | 219 | } |
| 216 | ); | 220 | ); |
| 217 | }; | 221 | }; |
| 218 | 222 | ||
| 219 | $scope.seleccionarCotizacion = function(moneda) { | 223 | $scope.seleccionarCotizacion = function(moneda) { |
| 220 | var modalInstance = $uibModal.open( | 224 | var modalInstance = $uibModal.open( |
| 221 | { | 225 | { |
| 222 | ariaLabelledBy: 'Busqueda de Cotización', | 226 | ariaLabelledBy: 'Busqueda de Cotización', |
| 223 | templateUrl: 'modal-cotizacion.html', | 227 | templateUrl: 'modal-cotizacion.html', |
| 224 | controller: 'focaModalCotizacionController', | 228 | controller: 'focaModalCotizacionController', |
| 225 | size: 'lg', | 229 | size: 'lg', |
| 226 | resolve: {idMoneda: function() {return moneda.ID;}} | 230 | resolve: {idMoneda: function() {return moneda.ID;}} |
| 227 | } | 231 | } |
| 228 | ); | 232 | ); |
| 229 | modalInstance.result.then( | 233 | modalInstance.result.then( |
| 230 | function(cotizacion) { | 234 | function(cotizacion) { |
| 231 | $scope.cobranza.moneda = moneda; | 235 | $scope.cobranza.moneda = moneda; |
| 232 | $scope.cobranza.cotizacion = cotizacion; | 236 | $scope.cobranza.cotizacion = cotizacion; |
| 233 | addCabecera('Moneda:', moneda.DETALLE); | 237 | addCabecera('Moneda:', moneda.DETALLE); |
| 234 | addCabecera( | 238 | addCabecera( |
| 235 | 'Fecha cotizacion:', | 239 | 'Fecha cotizacion:', |
| 236 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 240 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
| 237 | ); | 241 | ); |
| 238 | addCabecera('Cotizacion:', cotizacion.VENDEDOR); | 242 | addCabecera('Cotizacion:', cotizacion.VENDEDOR); |
| 239 | }, function() { | 243 | }, function() { |
| 240 | 244 | ||
| 241 | } | 245 | } |
| 242 | ); | 246 | ); |
| 243 | }; | 247 | }; |
| 244 | 248 | ||
| 245 | $scope.agregarCobro = function(key) { | 249 | $scope.agregarCobro = function(key) { |
| 246 | if(key === 13) { | 250 | if(key === 13) { |
| 247 | var cobro = { | 251 | var cobro = { |
| 248 | cobro: 'Efectivo', | 252 | cobro: 'Efectivo', |
| 249 | fecha: new Date(), | 253 | fecha: new Date(), |
| 250 | importe: $scope.cobroEfectivo | 254 | importe: $scope.cobroEfectivo |
| 251 | }; | 255 | }; |
| 252 | $scope.cobrosTabla.push(cobro); | 256 | $scope.cobrosTabla.push(cobro); |
| 253 | } | 257 | } |
| 254 | }; | 258 | }; |
| 255 | 259 | ||
| 256 | $scope.getTotalDeuda = function() { | 260 | $scope.getTotalDeuda = function() { |
| 257 | var total = 0; | 261 | var total = 0; |
| 258 | for (var i = 0; i < $scope.facturaTabla.length; i++) { | 262 | for (var i = 0; i < $scope.facturaTabla.length; i++) { |
| 259 | total += $scope.facturaTabla[i].IPA; | 263 | total += $scope.facturaTabla[i].IPA; |
| 260 | } | 264 | } |
| 261 | return parseFloat(total.toFixed(2)); | 265 | return parseFloat(total.toFixed(2)); |
| 262 | }; | 266 | }; |
| 263 | 267 | ||
| 264 | $scope.getTotalCobrado = function() { | 268 | $scope.getTotalCobrado = function() { |
| 265 | var total = 0; | 269 | var total = 0; |
| 266 | for (var i = 0; i < $scope.cobrosTabla.length; i++) { | 270 | for (var i = 0; i < $scope.cobrosTabla.length; i++) { |
| 267 | total += $scope.cobrosTabla[i].importe; | 271 | total += $scope.cobrosTabla[i].importe; |
| 268 | } | 272 | } |
| 269 | return parseFloat(total.toFixed(2)); | 273 | return parseFloat(total.toFixed(2)); |
| 270 | }; | 274 | }; |
| 271 | 275 | ||
| 272 | $scope.getSubTotal = function() { | 276 | $scope.getSubTotal = function() { |
| 273 | if($scope.articuloACargar) { | 277 | if($scope.articuloACargar) { |
| 274 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 278 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 275 | } | 279 | } |
| 276 | }; | 280 | }; |
| 277 | //Recibe aviso si el teclado está en uso | 281 | //Recibe aviso si el teclado está en uso |
| 278 | // $rootScope.$on('usarTeclado', function(event, data) { | 282 | // $rootScope.$on('usarTeclado', function(event, data) { |
| 279 | // if(data) { | 283 | // if(data) { |
| 280 | // $scope.mostrarTeclado = true; | 284 | // $scope.mostrarTeclado = true; |
| 281 | // return; | 285 | // return; |
| 282 | // } | 286 | // } |
| 283 | // $scope.mostrarTeclado = false; | 287 | // $scope.mostrarTeclado = false; |
| 284 | // }) | 288 | // }) |
| 285 | $scope.selectFocus = function($event) { | 289 | $scope.selectFocus = function($event) { |
| 286 | //Si el teclado esta en uso no selecciona el valor | 290 | //Si el teclado esta en uso no selecciona el valor |
| 287 | // if($scope.mostrarTeclado) { | 291 | // if($scope.mostrarTeclado) { |
| 288 | // return; | 292 | // return; |
| 289 | // } | 293 | // } |
| 290 | $event.target.select(); | 294 | $event.target.select(); |
| 291 | }; | 295 | }; |
| 292 | 296 | ||
| 293 | $scope.salir = function() { | 297 | $scope.salir = function() { |
| 294 | $location.path('/'); | 298 | $location.path('/'); |
| 295 | }; | 299 | }; |
| 296 | 300 | ||
| 297 | $scope.parsearATexto = function(articulo) { | 301 | $scope.parsearATexto = function(articulo) { |
| 298 | articulo.cantidad = parseFloat(articulo.cantidad); | 302 | articulo.cantidad = parseFloat(articulo.cantidad); |
| 299 | articulo.precio = parseFloat(articulo.precio); | 303 | articulo.precio = parseFloat(articulo.precio); |
| 300 | }; | 304 | }; |
| 301 | 305 | ||
| 302 | $scope.rellenar = function(relleno, longitud) { | 306 | $scope.rellenar = function(relleno, longitud) { |
| 303 | relleno = '' + relleno; | 307 | relleno = '' + relleno; |
| 304 | while (relleno.length < longitud) { | 308 | while (relleno.length < longitud) { |
| 305 | relleno = '0' + relleno; | 309 | relleno = '0' + relleno; |
| 306 | } | 310 | } |
| 307 | 311 | ||
| 308 | return relleno; | 312 | return relleno; |
| 309 | }; | 313 | }; |
| 310 | 314 | ||
| 311 | $scope.quitarFactura = function(key) { | 315 | $scope.quitarFactura = function(key) { |
| 312 | $scope.facturaTabla.splice(key, 1); | 316 | $scope.facturaTabla.splice(key, 1); |
| 313 | }; | 317 | }; |
| 314 | 318 | ||
| 315 | $scope.quitarCobro = function(key) { | 319 | $scope.quitarCobro = function(key) { |
| 316 | $scope.cobrosTabla.splice(key, 1); | 320 | $scope.cobrosTabla.splice(key, 1); |
| 317 | }; | 321 | }; |
| 318 | 322 | ||
| 319 | function addCabecera(label, valor) { | 323 | function addCabecera(label, valor) { |
| 320 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 324 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
| 321 | if(propiedad.length === 1) { | 325 | if(propiedad.length === 1) { |
| 322 | propiedad[0].valor = valor; | 326 | propiedad[0].valor = valor; |
| 323 | } else { | 327 | } else { |
| 324 | $scope.cabecera.push({label: label, valor: valor}); | 328 | $scope.cabecera.push({label: label, valor: valor}); |
| 325 | } | 329 | } |
| 326 | } | 330 | } |
| 327 | // TODO: descomentar cuando se use | 331 | // TODO: descomentar cuando se use |
| 328 | /*function removeCabecera(label) { | 332 | /*function removeCabecera(label) { |
| 329 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 333 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
| 330 | if(propiedad.length === 1){ | 334 | if(propiedad.length === 1){ |
| 331 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 335 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
| 332 | } | 336 | } |
| 333 | }*/ | 337 | }*/ |
| 334 | } | 338 | } |
| 335 | ]); | 339 | ]); |
| 336 | 340 |