Commit 353cd87214d93aa23ea55afb84cfa421be26925a
Exists in
master
Merge branch 'develop' of http://git.focasoftware.com/npm/foca-crear-factura
Showing
3 changed files
Show diff stats
package.json
| 1 | { | 1 | { |
| 2 | "name": "foca-crear-factura", | 2 | "name": "foca-crear-factura", |
| 3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
| 4 | "description": "", | 4 | "description": "", |
| 5 | "main": "index.js", | 5 | "main": "index.js", |
| 6 | "scripts": { | 6 | "scripts": { |
| 7 | "refresh": "gulp uglify && cp tmp/foca-crear-factura.js ../wrapper-demo/node_modules/foca-crear-factura/dist/foca-crear-factura.min.js", | ||
| 7 | "test": "echo \"Error: no test specified\" && exit 1", | 8 | "test": "echo \"Error: no test specified\" && exit 1", |
| 8 | "compile": "gulp uglify", | 9 | "compile": "gulp uglify", |
| 9 | "postinstall": "npm run compile && gulp clean-post-install", | 10 | "postinstall": "npm run compile && gulp clean-post-install", |
| 10 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route angular-cookies bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump" | 11 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route angular-cookies bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump" |
| 11 | }, | 12 | }, |
| 12 | "repository": { | 13 | "repository": { |
| 13 | "type": "git", | 14 | "type": "git", |
| 14 | "url": "http://git.focasoftware.com/npm/foca-crear-factura.git" | 15 | "url": "http://git.focasoftware.com/npm/foca-crear-factura.git" |
| 15 | }, | 16 | }, |
| 16 | "author": "Foca Software", | 17 | "author": "Foca Software", |
| 17 | "license": "ISC", | 18 | "license": "ISC", |
| 18 | "devDependencies": { | 19 | "devDependencies": { |
| 19 | "angular": "^1.7.8", | 20 | "angular": "^1.7.8", |
| 20 | "angular-cookies": "^1.7.8", | 21 | "angular-cookies": "^1.7.8", |
| 21 | "angular-ladda": "^0.4.3", | 22 | "angular-ladda": "^0.4.3", |
| 22 | "angular-route": "^1.7.8", | 23 | "angular-route": "^1.7.8", |
| 23 | "bootstrap": "^4.3.1", | 24 | "bootstrap": "^4.3.1", |
| 24 | "font-awesome": "^4.7.0", | 25 | "font-awesome": "^4.7.0", |
| 25 | "gulp": "^3.9.1", | 26 | "gulp": "^3.9.1", |
| 26 | "gulp-angular-templatecache": "^3.0.0", | 27 | "gulp-angular-templatecache": "^3.0.0", |
| 27 | "gulp-clean": "^0.4.0", | 28 | "gulp-clean": "^0.4.0", |
| 28 | "gulp-connect": "^5.7.0", | 29 | "gulp-connect": "^5.7.0", |
| 29 | "gulp-htmlmin": "^5.0.1", | 30 | "gulp-htmlmin": "^5.0.1", |
| 30 | "gulp-jshint": "^2.1.0", | 31 | "gulp-jshint": "^2.1.0", |
| 31 | "gulp-rename": "^1.4.0", | 32 | "gulp-rename": "^1.4.0", |
| 32 | "gulp-replace": "^1.0.0", | 33 | "gulp-replace": "^1.0.0", |
| 33 | "gulp-sequence": "^1.0.0", | 34 | "gulp-sequence": "^1.0.0", |
| 34 | "gulp-uglify": "^3.0.2", | 35 | "gulp-uglify": "^3.0.2", |
| 35 | "gulp-uglify-es": "^1.0.4", | 36 | "gulp-uglify-es": "^1.0.4", |
| 36 | "jasmine-core": "^3.4.0", | 37 | "jasmine-core": "^3.4.0", |
| 37 | "jquery": "^3.4.1", | 38 | "jquery": "^3.4.1", |
| 38 | "jshint": "^2.10.2", | 39 | "jshint": "^2.10.2", |
| 39 | "ladda": "^1.0.6", | 40 | "ladda": "^1.0.6", |
| 40 | "pre-commit": "^1.2.2", | 41 | "pre-commit": "^1.2.2", |
| 41 | "pump": "^3.0.0", | 42 | "pump": "^3.0.0", |
| 42 | "ui-bootstrap4": "^3.0.6" | 43 | "ui-bootstrap4": "^3.0.6" |
| 43 | } | 44 | } |
| 44 | } | 45 | } |
| 45 | 46 |
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 | despachos: [] | 72 | despachos: [] |
| 73 | }; | 73 | }; |
| 74 | 74 | ||
| 75 | $scope.factura.articulosFactura = []; | 75 | $scope.factura.articulosFactura = []; |
| 76 | $scope.idLista = undefined; | 76 | $scope.idLista = undefined; |
| 77 | 77 | ||
| 78 | crearRemitoService.getNumeroRemito().then( | 78 | crearRemitoService.getNumeroRemito().then( |
| 79 | function (res) { | 79 | function (res) { |
| 80 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 80 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
| 81 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); | 81 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); |
| 82 | }, | 82 | }, |
| 83 | function (err) { | 83 | function (err) { |
| 84 | focaModalService.alert('La terminal no esta configurada correctamente'); | 84 | focaModalService.alert('La terminal no esta configurada correctamente'); |
| 85 | console.info(err); | 85 | console.info(err); |
| 86 | } | 86 | } |
| 87 | ); | 87 | ); |
| 88 | 88 | ||
| 89 | $scope.inicial = angular.copy($scope.factura); | 89 | $scope.inicial = angular.copy($scope.factura); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | $scope.$watch('factura', function (newValue) { | 92 | $scope.$watch('factura', function (newValue) { |
| 93 | focaBotoneraLateralService.setPausarData({ | 93 | focaBotoneraLateralService.setPausarData({ |
| 94 | label: 'factura', | 94 | label: 'factura', |
| 95 | val: newValue | 95 | val: newValue |
| 96 | }); | 96 | }); |
| 97 | }, true); | 97 | }, true); |
| 98 | 98 | ||
| 99 | $scope.crearFactura = function () { | ||
| 100 | 99 | $scope.seleccionarFormaDePago = function () { | |
| 100 | if (!validarGuardar()) return; | ||
| 101 | var modalInstance = $uibModal.open( | ||
| 102 | { | ||
| 103 | templateUrl: 'modal-forma-pago.html', | ||
| 104 | controller: 'focaModalFormaPagoController', | ||
| 105 | resolve: { | ||
| 106 | filters: function () { return null; }, | ||
| 107 | }, | ||
| 108 | size: 'lg', | ||
| 109 | } | ||
| 110 | ); | ||
| 111 | modalInstance.result | ||
| 112 | .then(function (data) { | ||
| 113 | console.log(data); | ||
| 114 | $scope.crearFactura(); | ||
| 115 | }) | ||
| 116 | .catch(function (e) { console.error(e); }); | ||
| 117 | }; | ||
| 118 | |||
| 101 | if (!validarGuardar()) return; | 119 | $scope.crearFactura = function () { |
| 102 | 120 | ||
| 103 | var save = { | 121 | var save = { |
| 104 | factura: { | 122 | factura: { |
| 105 | 123 | ||
| 106 | BONIF: 0, | 124 | BONIF: 0, |
| 107 | CLI: $scope.factura.cliente.cod, | 125 | CLI: $scope.factura.cliente.cod, |
| 108 | CUI: $scope.factura.cliente.cuit, | 126 | CUI: $scope.factura.cliente.cuit, |
| 109 | CTA: $scope.factura.cliente.cod, | 127 | CTA: $scope.factura.cliente.cod, |
| 110 | DC1: '', | 128 | DC1: '', |
| 111 | DC2: '', | 129 | DC2: '', |
| 112 | DE1: '', | 130 | DE1: '', |
| 113 | DOM: $scope.factura.cliente.DOM, | 131 | DOM: $scope.factura.cliente.DOM, |
| 114 | FACAUT: 0, | 132 | FACAUT: 0, |
| 115 | DTO: 0, | 133 | DTO: 0, |
| 116 | FEC: $filter('date')($scope.now, 'yyyy-MM-dd HH:mm:ss'), | 134 | FEC: $filter('date')($scope.now, 'yyyy-MM-dd HH:mm:ss'), |
| 117 | FEC_ANT: '19000101', | 135 | FEC_ANT: '19000101', |
| 118 | FPA: 2, | 136 | FPA: 2, |
| 119 | IDEXCEPCION: 0, | 137 | IDEXCEPCION: 0, |
| 120 | IDLP: $scope.factura.cliente.mod.trim() || 0, | 138 | IDLP: $scope.factura.cliente.mod.trim() || 0, |
| 121 | IDPERSONERIA: 0, | 139 | IDPERSONERIA: 0, |
| 122 | IMI: 0, // TODO | 140 | IMI: 0, // TODO |
| 123 | IMI2: 0, // TODO | 141 | IMI2: 0, // TODO |
| 124 | IMI3: 0, // TODO | 142 | IMI3: 0, // TODO |
| 125 | IMP_LEY: 0, | 143 | IMP_LEY: 0, |
| 126 | IRI: 0, // TODO | 144 | IRI: 0, // TODO |
| 127 | IRS: 0, | 145 | IRS: 0, |
| 128 | LEG: '', | 146 | LEG: '', |
| 129 | LUG: $scope.factura.vendedor.LugVen, | 147 | LUG: $scope.factura.vendedor.LugVen, |
| 130 | MK_M: 0, | 148 | MK_M: 0, |
| 131 | NEE: 0, // TODO | 149 | NEE: 0, // TODO |
| 132 | NET: 0, // TODO | 150 | NET: 0, // TODO |
| 133 | NFI: '', | 151 | NFI: '', |
| 134 | NNP: 0, | 152 | NNP: 0, |
| 135 | NOM: $scope.factura.cliente.nom, | 153 | NOM: $scope.factura.cliente.nom, |
| 136 | OPE: $scope.factura.vendedor.CodVen, | 154 | OPE: $scope.factura.vendedor.CodVen, |
| 137 | PAG: $scope.getTotal(), | 155 | PAG: $scope.getTotal(), |
| 138 | PER: 0, | 156 | PER: 0, |
| 139 | PER_IVA: 0, | 157 | PER_IVA: 0, |
| 140 | PLA: $scope.factura.vendedor.NplVen, | 158 | PLA: $scope.factura.vendedor.NplVen, |
| 141 | PRO: '', | 159 | PRO: '', |
| 142 | REC_ANT: 0, | 160 | REC_ANT: 0, |
| 143 | SUC: parseInt($scope.puntoVenta), | 161 | SUC: parseInt($scope.puntoVenta), |
| 144 | TCA: 1, | 162 | TCA: 1, |
| 145 | TCO: 'FT', | 163 | TCO: 'FT', |
| 146 | TFI: '', | 164 | TFI: '', |
| 147 | TIP: $scope.factura.cliente.tipoFactura, | 165 | TIP: $scope.factura.cliente.tipoFactura, |
| 148 | TIV: 0, // TODO | 166 | TIV: 0, // TODO |
| 149 | TOT: $scope.getTotal(), | 167 | TOT: $scope.getTotal(), |
| 150 | TUR: 0, // TODO | 168 | TUR: 0, // TODO |
| 151 | VEN: $scope.factura.vendedor.CodVen, | 169 | VEN: $scope.factura.vendedor.CodVen, |
| 152 | VTO_CLI: '', | 170 | VTO_CLI: '', |
| 153 | ZON: 1, // TODO | 171 | ZON: 1, // TODO |
| 154 | OBSERVACIONES: $scope.factura.observaciones | 172 | OBSERVACIONES: $scope.factura.observaciones |
| 155 | }, | 173 | }, |
| 156 | cuerpo: $scope.articulosFiltro(), | 174 | cuerpo: $scope.articulosFiltro(), |
| 157 | despachos: $scope.factura.despachos | 175 | despachos: $scope.factura.despachos |
| 158 | }; | 176 | }; |
| 159 | 177 | ||
| 160 | crearFacturaService.guardarFactura(save).then(function(res) { | 178 | crearFacturaService.guardarFactura(save).then(function(res) { |
| 161 | 179 | ||
| 162 | focaBotoneraLateralService.endGuardar(true); | 180 | focaBotoneraLateralService.endGuardar(true); |
| 163 | 181 | ||
| 164 | focaModalService.alert('Comprobante guardado con éxito'); | 182 | focaModalService.alert('Comprobante guardado con éxito'); |
| 165 | 183 | ||
| 166 | config(); | 184 | config(); |
| 167 | 185 | ||
| 168 | }).catch(function(err) { | 186 | }).catch(function(err) { |
| 169 | focaModalService.alert('Hubo un error al guardar la factura'); | 187 | focaModalService.alert('Hubo un error al guardar la factura'); |
| 170 | console.log(err); | 188 | console.log(err); |
| 171 | }); | 189 | }); |
| 172 | 190 | ||
| 173 | }; | 191 | }; |
| 174 | 192 | ||
| 175 | $scope.seleccionarCliente = function () { | 193 | $scope.seleccionarCliente = function () { |
| 176 | 194 | ||
| 177 | var modalInstance = $uibModal.open( | 195 | var modalInstance = $uibModal.open( |
| 178 | { | 196 | { |
| 179 | ariaLabelledBy: 'Busqueda de Cliente', | 197 | ariaLabelledBy: 'Busqueda de Cliente', |
| 180 | templateUrl: 'foca-busqueda-cliente-modal.html', | 198 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 181 | controller: 'focaBusquedaClienteModalController', | 199 | controller: 'focaBusquedaClienteModalController', |
| 182 | resolve: { | 200 | resolve: { |
| 183 | vendedor: function () { return null; }, | 201 | vendedor: function () { return null; }, |
| 184 | cobrador: function () { return null; } | 202 | cobrador: function () { return null; } |
| 185 | }, | 203 | }, |
| 186 | size: 'lg' | 204 | size: 'lg' |
| 187 | } | 205 | } |
| 188 | ); | 206 | ); |
| 189 | modalInstance.result.then( | 207 | modalInstance.result.then( |
| 190 | function (cliente) { | 208 | function (cliente) { |
| 191 | $scope.factura.cliente = cliente; | 209 | $scope.factura.cliente = cliente; |
| 192 | 210 | ||
| 193 | $scope.$broadcast('addCabecera', { | 211 | $scope.$broadcast('addCabecera', { |
| 194 | label: 'Cliente:', | 212 | label: 'Cliente:', |
| 195 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom | 213 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom |
| 196 | }); | 214 | }); |
| 197 | 215 | ||
| 198 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; | 216 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; |
| 199 | 217 | ||
| 200 | }, function () { | 218 | }, function () { |
| 201 | } | 219 | } |
| 202 | ); | 220 | ); |
| 203 | 221 | ||
| 204 | }; | 222 | }; |
| 205 | 223 | ||
| 206 | $scope.seleccionarVendedor = function() { | 224 | $scope.seleccionarVendedor = function() { |
| 207 | var parametrosModal = { | 225 | var parametrosModal = { |
| 208 | titulo: 'Búsqueda vendedores', | 226 | titulo: 'Búsqueda vendedores', |
| 209 | query: '/vendedor-playa', | 227 | query: '/vendedor-playa', |
| 210 | columnas: [ | 228 | columnas: [ |
| 211 | { | 229 | { |
| 212 | propiedad: 'CodVen', | 230 | propiedad: 'CodVen', |
| 213 | nombre: 'Código', | 231 | nombre: 'Código', |
| 214 | filtro: { | 232 | filtro: { |
| 215 | nombre: 'rellenarDigitos', | 233 | nombre: 'rellenarDigitos', |
| 216 | parametro: 3 | 234 | parametro: 3 |
| 217 | } | 235 | } |
| 218 | }, | 236 | }, |
| 219 | { | 237 | { |
| 220 | propiedad: 'NomVen', | 238 | propiedad: 'NomVen', |
| 221 | nombre: 'Nombre' | 239 | nombre: 'Nombre' |
| 222 | } | 240 | } |
| 223 | ], | 241 | ], |
| 224 | size: 'md' | 242 | size: 'md' |
| 225 | }; | 243 | }; |
| 226 | focaModalService.modal(parametrosModal).then( | 244 | focaModalService.modal(parametrosModal).then( |
| 227 | function (vendedor) { | 245 | function (vendedor) { |
| 228 | 246 | ||
| 229 | indicarPassword(vendedor) | 247 | indicarPassword(vendedor) |
| 230 | .then(function() { | 248 | .then(function() { |
| 231 | validarPlanillaVendedor(vendedor) | 249 | validarPlanillaVendedor(vendedor) |
| 232 | .then(function() { | 250 | .then(function() { |
| 233 | 251 | ||
| 234 | $filter('filter')($scope.botonera, { | 252 | $filter('filter')($scope.botonera, { |
| 235 | label: 'Vendedor' | 253 | label: 'Vendedor' |
| 236 | })[0].checked = true; | 254 | })[0].checked = true; |
| 237 | 255 | ||
| 238 | $scope.$broadcast('addCabecera', { | 256 | $scope.$broadcast('addCabecera', { |
| 239 | label: 'Vendedor:', | 257 | label: 'Vendedor:', |
| 240 | valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + | 258 | valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + |
| 241 | ' - ' + | 259 | ' - ' + |
| 242 | vendedor.NomVen | 260 | vendedor.NomVen |
| 243 | }); | 261 | }); |
| 244 | 262 | ||
| 245 | $scope.factura.vendedor = vendedor; | 263 | $scope.factura.vendedor = vendedor; |
| 246 | 264 | ||
| 247 | getProductosByPlanilla(vendedor.NplVen); | 265 | getProductosByPlanilla(vendedor.NplVen); |
| 248 | }) | 266 | }) |
| 249 | .catch($scope.seleccionarVendedor); | 267 | .catch($scope.seleccionarVendedor); |
| 250 | }) | 268 | }) |
| 251 | .catch(function(err) { | 269 | .catch(function(err) { |
| 252 | console.log(err) | 270 | console.log(err) |
| 253 | }); | 271 | }); |
| 254 | 272 | ||
| 255 | }, function () { } | 273 | }, function () { } |
| 256 | ); | 274 | ); |
| 257 | }; | 275 | }; |
| 258 | 276 | ||
| 259 | $scope.seleccionarMoneda = function () { | 277 | $scope.seleccionarMoneda = function () { |
| 260 | 278 | ||
| 261 | var parametrosModal = { | 279 | var parametrosModal = { |
| 262 | titulo: 'Búsqueda de monedas', | 280 | titulo: 'Búsqueda de monedas', |
| 263 | query: '/moneda', | 281 | query: '/moneda', |
| 264 | columnas: [ | 282 | columnas: [ |
| 265 | { | 283 | { |
| 266 | propiedad: 'DETALLE', | 284 | propiedad: 'DETALLE', |
| 267 | nombre: 'Nombre' | 285 | nombre: 'Nombre' |
| 268 | }, | 286 | }, |
| 269 | { | 287 | { |
| 270 | propiedad: 'SIMBOLO', | 288 | propiedad: 'SIMBOLO', |
| 271 | nombre: 'Símbolo' | 289 | nombre: 'Símbolo' |
| 272 | } | 290 | } |
| 273 | ], | 291 | ], |
| 274 | size: 'md' | 292 | size: 'md' |
| 275 | }; | 293 | }; |
| 276 | focaModalService.modal(parametrosModal).then( | 294 | focaModalService.modal(parametrosModal).then( |
| 277 | function (moneda) { | 295 | function (moneda) { |
| 278 | 296 | ||
| 279 | if (moneda.ID !== 1) { | 297 | if (moneda.ID !== 1) { |
| 280 | $scope.abrirModalCotizacion(moneda); | 298 | $scope.abrirModalCotizacion(moneda); |
| 281 | return; | 299 | return; |
| 282 | } | 300 | } |
| 283 | 301 | ||
| 284 | crearRemitoService.getCotizacionByIdMoneda(1) | 302 | crearRemitoService.getCotizacionByIdMoneda(1) |
| 285 | .then(function (res) { | 303 | .then(function (res) { |
| 286 | 304 | ||
| 287 | cotizacionPArgentino = res.data[0].cotizaciones[0]; | 305 | cotizacionPArgentino = res.data[0].cotizaciones[0]; |
| 288 | cotizacionPArgentino.moneda = moneda; | 306 | cotizacionPArgentino.moneda = moneda; |
| 289 | 307 | ||
| 290 | actualizarCabeceraMoneda(cotizacionPArgentino); | 308 | actualizarCabeceraMoneda(cotizacionPArgentino); |
| 291 | 309 | ||
| 292 | $scope.remito.cotizacion = cotizacionPArgentino; | 310 | $scope.remito.cotizacion = cotizacionPArgentino; |
| 293 | }); | 311 | }); |
| 294 | }, function () { | 312 | }, function () { |
| 295 | 313 | ||
| 296 | } | 314 | } |
| 297 | ); | 315 | ); |
| 298 | }; | 316 | }; |
| 299 | 317 | ||
| 300 | $scope.abrirModalCotizacion = function (moneda) { | 318 | $scope.abrirModalCotizacion = function (moneda) { |
| 301 | var modalInstance = $uibModal.open( | 319 | var modalInstance = $uibModal.open( |
| 302 | { | 320 | { |
| 303 | ariaLabelledBy: 'Busqueda de Cotización', | 321 | ariaLabelledBy: 'Busqueda de Cotización', |
| 304 | templateUrl: 'modal-cotizacion.html', | 322 | templateUrl: 'modal-cotizacion.html', |
| 305 | controller: 'focaModalCotizacionController', | 323 | controller: 'focaModalCotizacionController', |
| 306 | size: 'lg', | 324 | size: 'lg', |
| 307 | resolve: { idMoneda: function () { return moneda.ID; } } | 325 | resolve: { idMoneda: function () { return moneda.ID; } } |
| 308 | } | 326 | } |
| 309 | ); | 327 | ); |
| 310 | modalInstance.result.then( | 328 | modalInstance.result.then( |
| 311 | function (cotizacion) { | 329 | function (cotizacion) { |
| 312 | 330 | ||
| 313 | cotizacion.moneda = moneda; | 331 | cotizacion.moneda = moneda; |
| 314 | actualizarCabeceraMoneda(cotizacion); | 332 | actualizarCabeceraMoneda(cotizacion); |
| 315 | $scope.factura.cotizacion = cotizacion; | 333 | $scope.factura.cotizacion = cotizacion; |
| 316 | 334 | ||
| 317 | }, function () { | 335 | }, function () { |
| 318 | 336 | ||
| 319 | } | 337 | } |
| 320 | ); | 338 | ); |
| 321 | }; | 339 | }; |
| 322 | 340 | ||
| 323 | $scope.seleccionarObservaciones = function () { | 341 | $scope.seleccionarObservaciones = function () { |
| 324 | var observacion = { | 342 | var observacion = { |
| 325 | titulo: 'Ingrese Observaciones', | 343 | titulo: 'Ingrese Observaciones', |
| 326 | value: $scope.factura.observaciones, | 344 | value: $scope.factura.observaciones, |
| 327 | maxlength: 155, | 345 | maxlength: 155, |
| 328 | textarea: true | 346 | textarea: true |
| 329 | }; | 347 | }; |
| 330 | 348 | ||
| 331 | focaModalService | 349 | focaModalService |
| 332 | .prompt(observacion) | 350 | .prompt(observacion) |
| 333 | .then(function (observaciones) { | 351 | .then(function (observaciones) { |
| 334 | $scope.factura.observaciones = observaciones; | 352 | $scope.factura.observaciones = observaciones; |
| 335 | }); | 353 | }); |
| 336 | }; | 354 | }; |
| 337 | 355 | ||
| 338 | $scope.articulosFiltro = function () { | 356 | $scope.articulosFiltro = function () { |
| 339 | return $scope.factura.articulosFactura; | 357 | return $scope.factura.articulosFactura; |
| 340 | }; | 358 | }; |
| 341 | 359 | ||
| 342 | $scope.getTotal = function () { | 360 | $scope.getTotal = function () { |
| 343 | 361 | ||
| 344 | var total = 0; | 362 | var total = 0; |
| 345 | 363 | ||
| 346 | $scope.articulosFiltro().forEach(function (articulo) { | 364 | $scope.articulosFiltro().forEach(function (articulo) { |
| 347 | total += articulo.PUN * articulo.CAN; | 365 | total += articulo.PUN * articulo.CAN; |
| 348 | }); | 366 | }); |
| 349 | 367 | ||
| 350 | return parseFloat(total.toFixed(2)); | 368 | return parseFloat(total.toFixed(2)); |
| 351 | }; | 369 | }; |
| 352 | 370 | ||
| 353 | function getProductosByPlanilla(numeroPlanilla) { | 371 | function getProductosByPlanilla(numeroPlanilla) { |
| 354 | 372 | ||
| 355 | crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function(res) { | 373 | crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function(res) { |
| 356 | 374 | ||
| 357 | res.data.forEach(function (producto) { | 375 | res.data.forEach(function (producto) { |
| 358 | 376 | ||
| 359 | $scope.botonera.push({ | 377 | $scope.botonera.push({ |
| 360 | label: producto.DetArt, | 378 | label: producto.DetArt, |
| 361 | image: 'productos.png' | 379 | image: 'productos.png' |
| 362 | }); | 380 | }); |
| 363 | 381 | ||
| 364 | 382 | ||
| 365 | crearFuncionesProductos(producto); | 383 | crearFuncionesProductos(producto); |
| 366 | 384 | ||
| 367 | }); | 385 | }); |
| 368 | }); | 386 | }); |
| 369 | } | 387 | } |
| 370 | 388 | ||
| 371 | function crearFuncionesProductos(producto) { | 389 | function crearFuncionesProductos(producto) { |
| 372 | 390 | ||
| 373 | $scope[nombreFuncion(producto.DetArt)] = function() { | 391 | $scope[nombreFuncion(producto.DetArt)] = function() { |
| 374 | 392 | ||
| 375 | if (angular.equals($scope.factura.cliente, {})) { | 393 | if (angular.equals($scope.factura.cliente, {})) { |
| 376 | focaModalService.alert('Seleccione cliente'); | 394 | focaModalService.alert('Seleccione cliente'); |
| 377 | return; | 395 | return; |
| 378 | } | 396 | } |
| 379 | 397 | ||
| 380 | var parametrosModal = { | 398 | var parametrosModal = { |
| 381 | titulo: 'Despachos ' + producto.DetArt, | 399 | titulo: 'Despachos ' + producto.DetArt, |
| 382 | data: producto.despachos, | 400 | data: producto.despachos, |
| 383 | columnas: [ | 401 | columnas: [ |
| 384 | { | 402 | { |
| 385 | propiedad: 'FEC', | 403 | propiedad: 'FEC', |
| 386 | nombre: 'Fecha', | 404 | nombre: 'Fecha', |
| 387 | filtro: { | 405 | filtro: { |
| 388 | nombre: 'date', | 406 | nombre: 'date', |
| 389 | parametro: 'dd/MM/yyyy HH:mm' | 407 | parametro: 'dd/MM/yyyy HH:mm' |
| 390 | } | 408 | } |
| 391 | }, | 409 | }, |
| 392 | { | 410 | { |
| 393 | propiedad: 'IMP', | 411 | propiedad: 'IMP', |
| 394 | nombre: 'Importe' | 412 | nombre: 'Importe' |
| 395 | }, | 413 | }, |
| 396 | { | 414 | { |
| 397 | propiedad: 'LTS', | 415 | propiedad: 'LTS', |
| 398 | nombre: 'Litros' | 416 | nombre: 'Litros' |
| 399 | } | 417 | } |
| 400 | ], | 418 | ], |
| 401 | size: 'md' | 419 | size: 'md' |
| 402 | }; | 420 | }; |
| 403 | 421 | ||
| 404 | focaModalService.modal(parametrosModal).then(function(despacho) { | 422 | focaModalService.modal(parametrosModal).then(function(despacho) { |
| 405 | 423 | ||
| 406 | var articulo = { | 424 | var articulo = { |
| 407 | TIP: $scope.factura.cliente.tipoFactura, | 425 | TIP: $scope.factura.cliente.tipoFactura, |
| 408 | TCO: 'FT', | 426 | TCO: 'FT', |
| 409 | SUC: parseInt($scope.puntoVenta), | 427 | SUC: parseInt($scope.puntoVenta), |
| 410 | ORD: $scope.articulosFiltro().length + 1, | 428 | ORD: $scope.articulosFiltro().length + 1, |
| 411 | SEC: despacho.SEC, | 429 | SEC: despacho.SEC, |
| 412 | ART: despacho.PRO, | 430 | ART: despacho.PRO, |
| 413 | RUB: producto.CodRub, | 431 | RUB: producto.CodRub, |
| 414 | DES: producto.DetArt, | 432 | DES: producto.DetArt, |
| 415 | CAN: despacho.LTS, | 433 | CAN: despacho.LTS, |
| 416 | PUN: producto.PreVen, // TODO | 434 | PUN: producto.PreVen, // TODO |
| 417 | IVA: producto.IMPIVA, // TODO | 435 | IVA: producto.IMPIVA, // TODO |
| 418 | NET: 0, // TODO | 436 | NET: 0, // TODO |
| 419 | NEX: 0, // TODO | 437 | NEX: 0, // TODO |
| 420 | IMI: producto.ImpInt, // TODO | 438 | IMI: producto.ImpInt, // TODO |
| 421 | IMI2: producto.ImpInt2, // TODO | 439 | IMI2: producto.ImpInt2, // TODO |
| 422 | IMI3: producto.ImpInt3, // TODO | 440 | IMI3: producto.ImpInt3, // TODO |
| 423 | PUT: producto.PreNet, // TODO | 441 | PUT: producto.PreNet, // TODO |
| 424 | SUR: despacho.SUR, | 442 | SUR: despacho.SUR, |
| 425 | PLA: despacho.PLA, | 443 | PLA: despacho.PLA, |
| 426 | LUG: despacho.LUG, | 444 | LUG: despacho.LUG, |
| 427 | LEG: $scope.factura.vendedor.CodVen, | 445 | LEG: $scope.factura.vendedor.CodVen, |
| 428 | TUR: $scope.factura.vendedor.TurVen, | 446 | TUR: $scope.factura.vendedor.TurVen, |
| 429 | ORDEN_PRECOMPRA: '', | 447 | ORDEN_PRECOMPRA: '', |
| 430 | ESC: producto.tipoFactura == 'L' ? 1 : 0, | 448 | ESC: producto.tipoFactura == 'L' ? 1 : 0, |
| 431 | CMF: 0, | 449 | CMF: 0, |
| 432 | PTA: 0, | 450 | PTA: 0, |
| 433 | IVS: 0, | 451 | IVS: 0, |
| 434 | TIVA: 0, | 452 | TIVA: 0, |
| 435 | CON: 0, | 453 | CON: 0, |
| 436 | SINO: '', | 454 | SINO: '', |
| 437 | ORD_TRA: 0, | 455 | ORD_TRA: 0, |
| 438 | IMP_DESP: 0, | 456 | IMP_DESP: 0, |
| 439 | PCD: 0, | 457 | PCD: 0, |
| 440 | RTO: '' | 458 | RTO: '' |
| 441 | }; | 459 | }; |
| 442 | 460 | ||
| 443 | crearFacturaService.setearDespachoOcupado({ | 461 | crearFacturaService.setearDespachoOcupado({ |
| 444 | surtidor: despacho.SUR, | 462 | surtidor: despacho.SUR, |
| 445 | producto: despacho.PRO, | 463 | producto: despacho.PRO, |
| 446 | carga: despacho.CAR | 464 | carga: despacho.CAR |
| 447 | }) | 465 | }) |
| 448 | .then(function () { | 466 | .then(function () { |
| 449 | $scope.factura.articulosFactura.push(articulo); | 467 | $scope.factura.articulosFactura.push(articulo); |
| 450 | $scope.factura.despachos.push(despacho); | 468 | $scope.factura.despachos.push(despacho); |
| 451 | }) | 469 | }) |
| 452 | .catch(function (err) { | 470 | .catch(function (err) { |
| 453 | 471 | ||
| 454 | focaModalService.alert('El despacho esta en uso'); | 472 | focaModalService.alert('El despacho esta en uso'); |
| 455 | }); | 473 | }); |
| 456 | 474 | ||
| 457 | }) | 475 | }) |
| 458 | .catch(function (err) { | 476 | .catch(function (err) { |
| 459 | console.log(err); | 477 | console.log(err); |
| 460 | }); | 478 | }); |
| 461 | 479 | ||
| 462 | }; | 480 | }; |
| 463 | } | 481 | } |
| 464 | 482 | ||
| 465 | function nombreFuncion(string) { | 483 | function nombreFuncion(string) { |
| 466 | var texto = 'seleccionar'; | 484 | var texto = 'seleccionar'; |
| 467 | var arr = string.split(' '); | 485 | var arr = string.split(' '); |
| 468 | arr.forEach(function(palabra) { | 486 | arr.forEach(function(palabra) { |
| 469 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); | 487 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); |
| 470 | texto += palabra; | 488 | texto += palabra; |
| 471 | }); | 489 | }); |
| 472 | return texto; | 490 | return texto; |
| 473 | } | 491 | } |
| 474 | 492 | ||
| 475 | function indicarPassword(vendedor) { | 493 | function indicarPassword(vendedor) { |
| 476 | 494 | ||
| 477 | return new Promise(function(resolve, reject) { | 495 | return new Promise(function(resolve, reject) { |
| 478 | 496 | ||
| 479 | focaModalService | 497 | focaModalService |
| 480 | .prompt({ | 498 | .prompt({ |
| 481 | titulo: 'Indique Contraseña', | 499 | titulo: 'Indique Contraseña', |
| 482 | value: '' | 500 | value: '' |
| 483 | }) | 501 | }) |
| 484 | .then(function (contraseña) { | 502 | .then(function (contraseña) { |
| 485 | 503 | ||
| 486 | if (contraseña != vendedor.ClaVen.trim()) { | 504 | if (contraseña != vendedor.ClaVen.trim()) { |
| 487 | 505 | ||
| 488 | focaModalService.alert('Clave incorrecta').then(function() { | 506 | focaModalService.alert('Clave incorrecta').then(function() { |
| 489 | indicarPassword(vendedor); | 507 | indicarPassword(vendedor); |
| 490 | }); | 508 | }); |
| 491 | } else { | 509 | } else { |
| 492 | resolve(); | 510 | resolve(); |
| 493 | } | 511 | } |
| 494 | }) | 512 | }) |
| 495 | .catch(reject); | 513 | .catch(reject); |
| 496 | }); | 514 | }); |
| 497 | } | 515 | } |
| 498 | 516 | ||
| 499 | function validarPlanillaVendedor(vendedor) { | 517 | function validarPlanillaVendedor(vendedor) { |
| 500 | 518 | ||
| 501 | return new Promise(function(resolve, reject) { | 519 | return new Promise(function(resolve, reject) { |
| 502 | 520 | ||
| 503 | crearFacturaService | 521 | crearFacturaService |
| 504 | .validarPlanillaVendedor(vendedor.CodVen.trim()) | 522 | .validarPlanillaVendedor(vendedor.CodVen.trim()) |
| 505 | .then(function (res) { | 523 | .then(function (res) { |
| 506 | 524 | ||
| 507 | if (!res.data.length) { | 525 | if (!res.data.length) { |
| 508 | 526 | ||
| 509 | focaModalService | 527 | focaModalService |
| 510 | .alert('No se encontró planilla abierta para el vendedor') | 528 | .alert('No se encontró planilla abierta para el vendedor') |
| 511 | .then(reject); | 529 | .then(reject); |
| 512 | 530 | ||
| 513 | } else { | 531 | } else { |
| 514 | resolve(); | 532 | resolve(); |
| 515 | } | 533 | } |
| 516 | 534 | ||
| 517 | }) | 535 | }) |
| 518 | .catch(reject); | 536 | .catch(reject); |
| 519 | }); | 537 | }); |
| 520 | } | 538 | } |
| 521 | 539 | ||
| 522 | function rellenar(relleno, longitud) { | 540 | function rellenar(relleno, longitud) { |
| 523 | relleno = '' + relleno; | 541 | relleno = '' + relleno; |
| 524 | while (relleno.length < longitud) { | 542 | while (relleno.length < longitud) { |
| 525 | relleno = '0' + relleno; | 543 | relleno = '0' + relleno; |
| 526 | } | 544 | } |
| 527 | return relleno; | 545 | return relleno; |
| 528 | } | 546 | } |
| 529 | 547 | ||
| 530 | function salir() { | 548 | function salir() { |
| 531 | var confirmacion = false; | 549 | var confirmacion = false; |
| 532 | 550 | ||
| 533 | if (!angular.equals($scope.factura, $scope.inicial)) { | 551 | if (!angular.equals($scope.factura, $scope.inicial)) { |
| 534 | confirmacion = true; | 552 | confirmacion = true; |
| 535 | } | 553 | } |
| 536 | 554 | ||
| 537 | if (confirmacion) { | 555 | if (confirmacion) { |
| 538 | focaModalService.confirm( | 556 | focaModalService.confirm( |
| 539 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 557 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
| 540 | ).then(function (data) { | 558 | ).then(function (data) { |
| 541 | if (data) { | 559 | if (data) { |
| 542 | $location.path('/'); | 560 | $location.path('/'); |
| 543 | } | 561 | } |
| 544 | }); | 562 | }); |
| 545 | } else { | 563 | } else { |
| 546 | $location.path('/'); | 564 | $location.path('/'); |
| 547 | } | 565 | } |
| 548 | } | 566 | } |
| 549 | 567 | ||
| 550 | function setearFactura(factura) { | 568 | function setearFactura(factura) { |
| 551 | 569 | ||
| 552 | $scope.$broadcast('cleanCabecera'); | 570 | $scope.$broadcast('cleanCabecera'); |
| 553 | 571 | ||
| 554 | $scope.cabeceras = []; | 572 | $scope.cabeceras = []; |
| 555 | 573 | ||
| 556 | if (factura.cotizacion && factura.cotizacion.moneda.CODIGO_AFIP !== 'PES') { | 574 | if (factura.cotizacion && factura.cotizacion.moneda.CODIGO_AFIP !== 'PES') { |
| 557 | $scope.cabeceras.push({ | 575 | $scope.cabeceras.push({ |
| 558 | label: 'Moneda:', | 576 | label: 'Moneda:', |
| 559 | valor: factura.cotizacion.moneda.DETALLE | 577 | valor: factura.cotizacion.moneda.DETALLE |
| 560 | }); | 578 | }); |
| 561 | $scope.cabeceras.push({ | 579 | $scope.cabeceras.push({ |
| 562 | label: 'Fecha cotizacion:', | 580 | label: 'Fecha cotizacion:', |
| 563 | valor: $filter('date')(factura.cotizacion.FECHA, | 581 | valor: $filter('date')(factura.cotizacion.FECHA, |
| 564 | 'dd/MM/yyyy') | 582 | 'dd/MM/yyyy') |
| 565 | }); | 583 | }); |
| 566 | $scope.cabeceras.push({ | 584 | $scope.cabeceras.push({ |
| 567 | label: 'Cotizacion:', | 585 | label: 'Cotizacion:', |
| 568 | valor: $filter('number')(factura.cotizacion.VENDEDOR, | 586 | valor: $filter('number')(factura.cotizacion.VENDEDOR, |
| 569 | '2') | 587 | '2') |
| 570 | }); | 588 | }); |
| 571 | } | 589 | } |
| 572 | 590 | ||
| 573 | if (factura.cotizacion && factura.cotizacion.moneda) { | 591 | if (factura.cotizacion && factura.cotizacion.moneda) { |
| 574 | $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; | 592 | $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; |
| 575 | } | 593 | } |
| 576 | 594 | ||
| 577 | if (factura.cliente && factura.cliente.cod) { | 595 | if (factura.cliente && factura.cliente.cod) { |
| 578 | $scope.cabeceras.push({ | 596 | $scope.cabeceras.push({ |
| 579 | label: 'Cliente:', | 597 | label: 'Cliente:', |
| 580 | valor: $filter('rellenarDigitos')(factura.cliente.cod, 3) + ' - ' + | 598 | valor: $filter('rellenarDigitos')(factura.cliente.cod, 3) + ' - ' + |
| 581 | factura.cliente.nom | 599 | factura.cliente.nom |
| 582 | }); | 600 | }); |
| 583 | 601 | ||
| 584 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; | 602 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; |
| 585 | } | 603 | } |
| 586 | 604 | ||
| 587 | $scope.puntoVenta = rellenar(factura.sucursal, 4); | 605 | $scope.puntoVenta = rellenar(factura.sucursal, 4); |
| 588 | $scope.comprobante = rellenar(factura.numerofactura, 8); | 606 | $scope.comprobante = rellenar(factura.numerofactura, 8); |
| 589 | $scope.factura = factura; | 607 | $scope.factura = factura; |
| 590 | 608 | ||
| 591 | addArrayCabecera($scope.cabeceras); | 609 | addArrayCabecera($scope.cabeceras); |
| 592 | } | 610 | } |
| 593 | 611 | ||
| 594 | function getLSFactura() { | 612 | function getLSFactura() { |
| 595 | var factura = JSON.parse($localStorage.factura || null); | 613 | var factura = JSON.parse($localStorage.factura || null); |
| 596 | if (factura) { | 614 | if (factura) { |
| 597 | setearFactura(factura); | 615 | setearFactura(factura); |
| 598 | delete $localStorage.factura; | 616 | delete $localStorage.factura; |
| 599 | } | 617 | } |
| 600 | } | 618 | } |
| 601 | 619 | ||
| 602 | function addArrayCabecera(array) { | 620 | function addArrayCabecera(array) { |
| 603 | for (var i = 0; i < array.length; i++) { | 621 | for (var i = 0; i < array.length; i++) { |
| 604 | $scope.$broadcast('addCabecera', { | 622 | $scope.$broadcast('addCabecera', { |
| 605 | label: array[i].label, | 623 | label: array[i].label, |
| 606 | valor: array[i].valor | 624 | valor: array[i].valor |
| 607 | }); | 625 | }); |
| 608 | } | 626 | } |
| 609 | } | 627 | } |
| 610 | 628 | ||
| 611 | function actualizarCabeceraMoneda(cotizacion) { | 629 | function actualizarCabeceraMoneda(cotizacion) { |
| 612 | 630 | ||
| 613 | $scope.factura.articulosFactura.forEach(function (art) { | 631 | $scope.factura.articulosFactura.forEach(function (art) { |
| 614 | art.PUN = (art.PUN * $scope.factura.cotizacion.VENDEDOR).toFixed(4); | 632 | art.PUN = (art.PUN * $scope.factura.cotizacion.VENDEDOR).toFixed(4); |
| 615 | art.PUN = (art.PUN / cotizacion.VENDEDOR).toFixed(4); | 633 | art.PUN = (art.PUN / cotizacion.VENDEDOR).toFixed(4); |
| 616 | }); | 634 | }); |
| 617 | 635 | ||
| 618 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { | 636 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { |
| 619 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 637 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
| 620 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 638 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
| 621 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 639 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
| 622 | } else { | 640 | } else { |
| 623 | $scope.$broadcast('addCabecera', { | 641 | $scope.$broadcast('addCabecera', { |
| 624 | label: 'Moneda:', | 642 | label: 'Moneda:', |
| 625 | valor: cotizacion.moneda.DETALLE | 643 | valor: cotizacion.moneda.DETALLE |
| 626 | }); | 644 | }); |
| 627 | $scope.$broadcast('addCabecera', { | 645 | $scope.$broadcast('addCabecera', { |
| 628 | label: 'Fecha cotizacion:', | 646 | label: 'Fecha cotizacion:', |
| 629 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 647 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
| 630 | }); | 648 | }); |
| 631 | $scope.$broadcast('addCabecera', { | 649 | $scope.$broadcast('addCabecera', { |
| 632 | label: 'Cotizacion:', | 650 | label: 'Cotizacion:', |
| 633 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 651 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
| 634 | }); | 652 | }); |
| 635 | } | 653 | } |
| 636 | } | 654 | } |
| 637 | 655 | ||
| 638 | function validarGuardar() { | 656 | function validarGuardar() { |
| 639 | 657 | ||
| 640 | if (angular.equals({}, $scope.factura.vendedor)) { | 658 | if (angular.equals({}, $scope.factura.vendedor)) { |
| 641 | 659 | ||
| 642 | focaModalService.alert('Seleccione Vendedor'); | 660 | focaModalService.alert('Seleccione Vendedor'); |
| 643 | return false; | 661 | return false; |
| 644 | } else if (angular.equals({}, $scope.factura.cliente)) { | 662 | } else if (angular.equals({}, $scope.factura.cliente)) { |
| 645 | 663 | ||
| 646 | focaModalService.alert('Seleccione Cliente') | 664 | focaModalService.alert('Seleccione Cliente') |
| 647 | return false; | 665 | return false; |
| 648 | } else if (!$scope.articulosFiltro().length) { | 666 | } else if (!$scope.articulosFiltro().length) { |
| 649 | 667 | ||
| 650 | focaModalService.alert('Seleccione al menos un Articulo'); | 668 | focaModalService.alert('Seleccione al menos un Articulo'); |
| 651 | return false; | 669 | return false; |
| 652 | } | 670 | } |
| 653 | 671 | ||
| 654 | return true; | 672 | return true; |
| 655 | } | 673 | } |
| 656 | } | 674 | } |
| 657 | ]); | 675 | ]); |
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 |