Commit 2cb4e129c9048c8e623ec58d74cdda0543a779b7
Exists in
ultimos_despachos
and in
1 other branch
Merge branch 'master' into 'develop'
Master(mpuebla) See merge request !27
Showing
4 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 | "frefresh": "gulp uglify && cp tmp/foca-crear-factura.js ../wrapper-facturador/node_modules/foca-crear-factura/dist/foca-crear-factura.min.js", | ||
| 7 | "refresh": "gulp uglify && cp tmp/foca-crear-factura.js ../wrapper-demo/node_modules/foca-crear-factura/dist/foca-crear-factura.min.js", | 8 | "refresh": "gulp uglify && cp tmp/foca-crear-factura.js ../wrapper-demo/node_modules/foca-crear-factura/dist/foca-crear-factura.min.js", | 
| 8 | "test": "echo \"Error: no test specified\" && exit 1", | 9 | "test": "echo \"Error: no test specified\" && exit 1", | 
| 9 | "compile": "gulp uglify", | 10 | "compile": "gulp uglify", | 
| 10 | "postinstall": "npm run compile && gulp clean-post-install", | 11 | "postinstall": "npm run compile && gulp clean-post-install", | 
| 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" | 12 | "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" | 
| 12 | }, | 13 | }, | 
| 13 | "repository": { | 14 | "repository": { | 
| 14 | "type": "git", | 15 | "type": "git", | 
| 15 | "url": "http://git.focasoftware.com/npm/foca-crear-factura.git" | 16 | "url": "http://git.focasoftware.com/npm/foca-crear-factura.git" | 
| 16 | }, | 17 | }, | 
| 17 | "author": "Foca Software", | 18 | "author": "Foca Software", | 
| 18 | "license": "ISC", | 19 | "license": "ISC", | 
| 19 | "devDependencies": { | 20 | "devDependencies": { | 
| 20 | "angular": "^1.7.8", | 21 | "angular": "^1.7.8", | 
| 21 | "angular-cookies": "^1.7.8", | 22 | "angular-cookies": "^1.7.8", | 
| 22 | "angular-ladda": "^0.4.3", | 23 | "angular-ladda": "^0.4.3", | 
| 23 | "angular-route": "^1.7.8", | 24 | "angular-route": "^1.7.8", | 
| 24 | "bootstrap": "^4.3.1", | 25 | "bootstrap": "^4.3.1", | 
| 25 | "font-awesome": "^4.7.0", | 26 | "font-awesome": "^4.7.0", | 
| 26 | "gulp": "^3.9.1", | 27 | "gulp": "^3.9.1", | 
| 27 | "gulp-angular-templatecache": "^3.0.0", | 28 | "gulp-angular-templatecache": "^3.0.0", | 
| 28 | "gulp-clean": "^0.4.0", | 29 | "gulp-clean": "^0.4.0", | 
| 29 | "gulp-connect": "^5.7.0", | 30 | "gulp-connect": "^5.7.0", | 
| 30 | "gulp-htmlmin": "^5.0.1", | 31 | "gulp-htmlmin": "^5.0.1", | 
| 31 | "gulp-jshint": "^2.1.0", | 32 | "gulp-jshint": "^2.1.0", | 
| 32 | "gulp-rename": "^1.4.0", | 33 | "gulp-rename": "^1.4.0", | 
| 33 | "gulp-replace": "^1.0.0", | 34 | "gulp-replace": "^1.0.0", | 
| 34 | "gulp-sequence": "^1.0.0", | 35 | "gulp-sequence": "^1.0.0", | 
| 35 | "gulp-uglify": "^3.0.2", | 36 | "gulp-uglify": "^3.0.2", | 
| 36 | "gulp-uglify-es": "^1.0.4", | 37 | "gulp-uglify-es": "^1.0.4", | 
| 37 | "jasmine-core": "^3.4.0", | 38 | "jasmine-core": "^3.4.0", | 
| 38 | "jquery": "^3.4.1", | 39 | "jquery": "^3.4.1", | 
| 39 | "jshint": "^2.10.2", | 40 | "jshint": "^2.10.2", | 
| 40 | "ladda": "^1.0.6", | 41 | "ladda": "^1.0.6", | 
| 41 | "pre-commit": "^1.2.2", | 42 | "pre-commit": "^1.2.2", | 
| 42 | "pump": "^3.0.0", | 43 | "pump": "^3.0.0", | 
| 43 | "ui-bootstrap4": "^3.0.6" | 44 | "ui-bootstrap4": "^3.0.6" | 
| 44 | } | 45 | } | 
| 45 | } | 46 | } | 
| 46 | 47 | 
src/js/controller.js
| 1 | angular.module('focaCrearFactura').controller('facturaController', [ | 1 | angular.module('focaCrearFactura').controller('facturaController', [ | 
| 2 | '$scope', '$uibModal', '$location', '$filter', 'crearFacturaService', '$timeout', | 2 | '$scope', '$uibModal', '$location', '$filter', 'crearFacturaService', '$timeout', | 
| 3 | 'focaModalService', 'crearRemitoService', '$rootScope', 'focaBotoneraLateralService', | 3 | 'focaModalService', 'crearRemitoService', '$rootScope', 'focaBotoneraLateralService', | 
| 4 | '$localStorage', 'APP', 'focaLoginService', | 4 | '$localStorage', 'APP', 'focaLoginService', | 
| 5 | function ( | 5 | function ( | 
| 6 | $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService, | 6 | $scope, $uibModal, $location, $filter, crearFacturaService, $timeout, focaModalService, | 
| 7 | crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP, loginServ) { | 7 | crearRemitoService, $rootScope, focaBotoneraLateralService, $localStorage, APP, loginServ) { | 
| 8 | 8 | ||
| 9 | config(); | 9 | config(); | 
| 10 | 10 | ||
| 11 | function config() { | 11 | function config() { | 
| 12 | $scope.tmpCantidad = '0'; | 12 | $scope.tmpCantidad = '0'; | 
| 13 | $scope.botonera = crearFacturaService.getBotonera(); | 13 | $scope.botonera = crearFacturaService.getBotonera(); | 
| 14 | $scope.botoneraProductos = []; | 14 | $scope.botoneraProductos = []; | 
| 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.seleccionarFormaDePago); | 50 | focaBotoneraLateralService.showGuardar(true, $scope.seleccionarFormaDePago); | 
| 51 | focaBotoneraLateralService.addCustomButton('Salir', $scope.salir); | 51 | focaBotoneraLateralService.addCustomButton('Salir', $scope.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 | formaPago: 1, // Por defecto paga contado | 70 | formaPago: 1, // Por defecto paga contado | 
| 71 | cotizacion: $scope.cotizacionPorDefecto || {}, | 71 | cotizacion: $scope.cotizacionPorDefecto || {}, | 
| 72 | articulosFactura: [], | 72 | articulosFactura: [], | 
| 73 | despachos: [] | 73 | despachos: [] | 
| 74 | }; | 74 | }; | 
| 75 | 75 | ||
| 76 | $scope.factura.articulosFactura = []; | 76 | $scope.factura.articulosFactura = []; | 
| 77 | $scope.idLista = undefined; | 77 | $scope.idLista = undefined; | 
| 78 | 78 | ||
| 79 | crearRemitoService.getNumeroRemito().then( | 79 | crearRemitoService.getNumeroRemito().then( | 
| 80 | function (res) { | 80 | function (res) { | 
| 81 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 81 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 
| 82 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); | 82 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); | 
| 83 | }, | 83 | }, | 
| 84 | function (err) { | 84 | function (err) { | 
| 85 | focaModalService.alert('La terminal no esta configurada correctamente'); | 85 | focaModalService.alert('La terminal no esta configurada correctamente'); | 
| 86 | console.info(err); | 86 | console.info(err); | 
| 87 | } | 87 | } | 
| 88 | ); | 88 | ); | 
| 89 | 89 | ||
| 90 | $scope.inicial = angular.copy($scope.factura); | 90 | $scope.inicial = angular.copy($scope.factura); | 
| 91 | 91 | ||
| 92 | if (APP == 'facturador') { | 92 | if (APP == 'facturador') { | 
| 93 | crearFacturaService | 93 | crearFacturaService | 
| 94 | .getVendedorPlayaById(loginServ.getLoginData().vendedorPlaya) | 94 | .getVendedorPlayaById(loginServ.getLoginData().vendedorPlaya) | 
| 95 | .then(function (res) { | 95 | .then(function (res) { | 
| 96 | 96 | ||
| 97 | validarPlanillaVendedor(res.data) | 97 | validarPlanillaVendedor(res.data) | 
| 98 | .then(function () { | 98 | .then(function () { | 
| 99 | 99 | ||
| 100 | $scope.$broadcast('addCabecera', { | 100 | $scope.$broadcast('addCabecera', { | 
| 101 | label: 'Vendedor:', | 101 | label: 'Vendedor:', | 
| 102 | valor: $filter('rellenarDigitos')(res.data.CodVen, 3) + | 102 | valor: $filter('rellenarDigitos')(res.data.CodVen, 3) + | 
| 103 | ' - ' + | 103 | ' - ' + | 
| 104 | res.data.NomVen | 104 | res.data.NomVen | 
| 105 | }); | 105 | }); | 
| 106 | 106 | ||
| 107 | $scope.factura.vendedor = res.data; | 107 | $scope.factura.vendedor = res.data; | 
| 108 | $scope.inicial.vendedor = res.data; | 108 | $scope.inicial.vendedor = res.data; | 
| 109 | 109 | ||
| 110 | getProductosByPlanilla(res.data.NplVen); | 110 | getProductosByPlanilla(res.data.NplVen); | 
| 111 | }) | 111 | }) | 
| 112 | .catch(function (err) { | 112 | .catch(function (err) { | 
| 113 | console.log(err); | 113 | console.log(err); | 
| 114 | focaModalService.alert('Ocurrió un error al intentar recuperar' + | 114 | focaModalService.alert('Ocurrió un error al intentar recuperar' + | 
| 115 | 'el vendedor logeado'); | 115 | 'el vendedor logeado'); | 
| 116 | }); | 116 | }); | 
| 117 | }) | 117 | }) | 
| 118 | } | 118 | } | 
| 119 | } | 119 | } | 
| 120 | 120 | ||
| 121 | $scope.$watch('factura', function (newValue) { | 121 | $scope.$watch('factura', function (newValue) { | 
| 122 | focaBotoneraLateralService.setPausarData({ | 122 | focaBotoneraLateralService.setPausarData({ | 
| 123 | label: 'factura', | 123 | label: 'factura', | 
| 124 | val: newValue | 124 | val: newValue | 
| 125 | }); | 125 | }); | 
| 126 | }, true); | 126 | }, true); | 
| 127 | 127 | ||
| 128 | $scope.seleccionarFormaDePago = function () { | 128 | $scope.seleccionarFormaDePago = function () { | 
| 129 | 129 | ||
| 130 | if (!validarGuardar()) return; | 130 | if (!validarGuardar()) return; | 
| 131 | 131 | ||
| 132 | if ($scope.factura.formaPago == 2) { | 132 | if ($scope.factura.formaPago == 2) { | 
| 133 | $scope.crearFactura(); | 133 | $scope.crearFactura(); | 
| 134 | return; | 134 | return; | 
| 135 | } | 135 | } | 
| 136 | 136 | ||
| 137 | var modalInstance = $uibModal.open( | 137 | var modalInstance = $uibModal.open( | 
| 138 | { | 138 | { | 
| 139 | templateUrl: 'modal-forma-pago.html', | 139 | templateUrl: 'modal-forma-pago.html', | 
| 140 | controller: 'focaModalFormaPagoController', | 140 | controller: 'focaModalFormaPagoController', | 
| 141 | resolve: { | 141 | resolve: { | 
| 142 | parametros: function () { | 142 | parametros: function () { | 
| 143 | return { | 143 | return { | 
| 144 | importe: $scope.getTotal() | 144 | importe: $scope.getTotal() | 
| 145 | }; | 145 | }; | 
| 146 | }, | 146 | }, | 
| 147 | }, | 147 | }, | 
| 148 | size: 'lg', | 148 | size: 'lg', | 
| 149 | } | 149 | } | 
| 150 | ); | 150 | ); | 
| 151 | modalInstance.result | 151 | modalInstance.result | 
| 152 | .then(function (data) { | 152 | .then(function (data) { | 
| 153 | 153 | ||
| 154 | if (data.tipo == 'tarjeta') { | 154 | if (data.tipo == 'tarjeta') { | 
| 155 | $scope.factura.formaPago = 4; | 155 | $scope.factura.formaPago = 4; | 
| 156 | } else { | 156 | } else { | 
| 157 | $scope.factura.formaPago = 1; | 157 | $scope.factura.formaPago = 1; | 
| 158 | } | 158 | } | 
| 159 | 159 | ||
| 160 | $scope.crearFactura(data); | 160 | $scope.crearFactura(data); | 
| 161 | }) | 161 | }) | 
| 162 | .catch(function (e) { console.error(e); }); | 162 | .catch(function (e) { console.error(e); }); | 
| 163 | }; | 163 | }; | 
| 164 | 164 | ||
| 165 | $scope.crearFactura = function (formaPago) { | 165 | $scope.crearFactura = function (formaPago) { | 
| 166 | 166 | ||
| 167 | var save = { | 167 | var save = { | 
| 168 | factura: { | 168 | factura: { | 
| 169 | 169 | ||
| 170 | BONIF: 0, | 170 | BONIF: 0, | 
| 171 | CLI: $scope.factura.cliente.cod, | 171 | CLI: $scope.factura.cliente.cod, | 
| 172 | CUI: $scope.factura.cliente.cuit, | 172 | CUI: $scope.factura.cliente.cuit, | 
| 173 | CTA: $scope.factura.cliente.cod, | 173 | CTA: $scope.factura.cliente.cod, | 
| 174 | DC1: '', | 174 | DC1: '', | 
| 175 | DC2: '', | 175 | DC2: '', | 
| 176 | DE1: '', | 176 | DE1: '', | 
| 177 | DOM: $scope.factura.cliente.DOM, | 177 | DOM: $scope.factura.cliente.DOM, | 
| 178 | FACAUT: 0, | 178 | FACAUT: 0, | 
| 179 | DTO: 0, | 179 | DTO: 0, | 
| 180 | FEC: $filter('date')($scope.now, 'yyyy-MM-dd HH:mm:ss'), | 180 | FEC: $filter('date')($scope.now, 'yyyy-MM-dd HH:mm:ss'), | 
| 181 | FEC_ANT: '19000101', | 181 | FEC_ANT: '19000101', | 
| 182 | FPA: $scope.factura.formaPago, | 182 | FPA: $scope.factura.formaPago, | 
| 183 | IDEXCEPCION: 0, | 183 | IDEXCEPCION: 0, | 
| 184 | IDLP: $scope.factura.cliente.mod.trim() || 0, | 184 | IDLP: $scope.factura.cliente.mod.trim() || 0, | 
| 185 | IDPERSONERIA: 0, | 185 | IDPERSONERIA: 0, | 
| 186 | IMI: getImporte('IMI'), | 186 | IMI: getImporte('IMI'), | 
| 187 | IMI2: getImporte('IMI2'), | 187 | IMI2: getImporte('IMI2'), | 
| 188 | IMI3: getImporte('IMI3'), | 188 | IMI3: getImporte('IMI3'), | 
| 189 | IMP_LEY: 0, | 189 | IMP_LEY: 0, | 
| 190 | IRI: getImporte('IVA'), | 190 | IRI: getImporte('IVA'), | 
| 191 | IRS: 0, | 191 | IRS: 0, | 
| 192 | LEG: '', | 192 | LEG: '', | 
| 193 | LUG: $scope.factura.vendedor.LugVen, | 193 | LUG: $scope.factura.vendedor.LugVen, | 
| 194 | MK_M: 0, | 194 | MK_M: 0, | 
| 195 | NEE: getImporte('NEX'), | 195 | NEE: getImporte('NEX'), | 
| 196 | NET: getImporte('NET'), | 196 | NET: getImporte('NET'), | 
| 197 | NFI: '', | 197 | NFI: '', | 
| 198 | NNP: 0, | 198 | NNP: 0, | 
| 199 | NOM: $scope.factura.cliente.nom, | 199 | NOM: $scope.factura.cliente.nom, | 
| 200 | OPE: $scope.factura.vendedor.CodVen, | 200 | OPE: $scope.factura.vendedor.CodVen, | 
| 201 | PAG: $scope.getTotal(), | 201 | PAG: $scope.getTotal(), | 
| 202 | PER: 0, | 202 | PER: 0, | 
| 203 | PER_IVA: 0, | 203 | PER_IVA: 0, | 
| 204 | PLA: $scope.factura.vendedor.NplVen, | 204 | PLA: $scope.factura.vendedor.NplVen, | 
| 205 | PRO: '', | 205 | PRO: '', | 
| 206 | REC_ANT: 0, | 206 | REC_ANT: 0, | 
| 207 | SUC: parseInt($scope.puntoVenta), | 207 | SUC: parseInt($scope.puntoVenta), | 
| 208 | TCA: 1, | 208 | TCA: 1, | 
| 209 | TCO: 'FT', | 209 | TCO: 'FT', | 
| 210 | TFI: '', | 210 | TFI: '', | 
| 211 | TIP: $scope.factura.cliente.tipoFactura, | 211 | TIP: $scope.factura.cliente.tipoFactura, | 
| 212 | TIV: $scope.factura.cliente.iva, | 212 | TIV: $scope.factura.cliente.iva, | 
| 213 | TOT: $scope.getTotal(), | 213 | TOT: $scope.getTotal(), | 
| 214 | TUR: $scope.factura.vendedor.TurVen, | 214 | TUR: $scope.factura.vendedor.TurVen, | 
| 215 | VEN: $scope.factura.vendedor.CodVen, | 215 | VEN: $scope.factura.vendedor.CodVen, | 
| 216 | VTO_CLI: '', | 216 | VTO_CLI: '', | 
| 217 | ZON: 1, // TODO: ZON DE APAREMP | 217 | ZON: 1, // TODO: ZON DE APAREMP | 
| 218 | OBSERVACIONES: $scope.factura.observaciones | 218 | OBSERVACIONES: $scope.factura.observaciones | 
| 219 | }, | 219 | }, | 
| 220 | cuerpo: $scope.articulosFiltro(), | 220 | cuerpo: $scope.articulosFiltro(), | 
| 221 | despachos: $scope.factura.despachos, | 221 | despachos: $scope.factura.despachos, | 
| 222 | formaPago: formaPago | 222 | formaPago: formaPago | 
| 223 | }; | 223 | }; | 
| 224 | 224 | ||
| 225 | crearFacturaService.guardarFactura(save).then(function (res) { | 225 | crearFacturaService.guardarFactura(save).then(function (res) { | 
| 226 | 226 | ||
| 227 | focaBotoneraLateralService.endGuardar(true); | 227 | focaBotoneraLateralService.endGuardar(true); | 
| 228 | 228 | ||
| 229 | focaModalService.alert('Comprobante guardado con éxito'); | 229 | focaModalService.alert('Comprobante guardado con éxito'); | 
| 230 | 230 | ||
| 231 | config(); | 231 | config(); | 
| 232 | 232 | ||
| 233 | }).catch(function (err) { | 233 | }).catch(function (err) { | 
| 234 | focaModalService.alert('Hubo un error al guardar la factura'); | 234 | focaModalService.alert('Hubo un error al guardar la factura'); | 
| 235 | console.error(err); | 235 | console.error(err); | 
| 236 | }); | 236 | }); | 
| 237 | 237 | ||
| 238 | }; | 238 | }; | 
| 239 | 239 | ||
| 240 | $scope.seleccionarCliente = function () { | 240 | $scope.seleccionarCliente = function () { | 
| 241 | 241 | ||
| 242 | var modalInstance = $uibModal.open( | 242 | var modalInstance = $uibModal.open( | 
| 243 | { | 243 | { | 
| 244 | ariaLabelledBy: 'Busqueda de Cliente', | 244 | ariaLabelledBy: 'Busqueda de Cliente', | 
| 245 | templateUrl: 'foca-busqueda-cliente-modal.html', | 245 | templateUrl: 'foca-busqueda-cliente-modal.html', | 
| 246 | controller: 'focaBusquedaClienteModalController', | 246 | controller: 'focaBusquedaClienteModalController', | 
| 247 | resolve: { | 247 | resolve: { | 
| 248 | vendedor: function () { return null; }, | 248 | vendedor: function () { return null; }, | 
| 249 | cobrador: function () { return null; } | 249 | cobrador: function () { return null; } | 
| 250 | }, | 250 | }, | 
| 251 | size: 'lg' | 251 | size: 'lg' | 
| 252 | } | 252 | } | 
| 253 | ); | 253 | ); | 
| 254 | modalInstance.result.then( | 254 | modalInstance.result.then( | 
| 255 | function (cliente) { | 255 | function (cliente) { | 
| 256 | var modalInstance = $uibModal.open( | 256 | var modalInstance = $uibModal.open( | 
| 257 | { | ||
| 258 | templateUrl: 'modal-estado-cuenta.html', | ||
| 259 | controller: 'focaModalEstadoCuentaController', | ||
| 260 | size: 'lg', | ||
| 261 | resolve: { | ||
| 257 | { | 262 | parametros: function () { | 
| 258 | templateUrl: 'modal-estado-cuenta.html', | 263 | return { | 
| 259 | controller: 'focaModalEstadoCuentaController', | 264 | idCliente: cliente.cod, | 
| 260 | size: 'lg', | 265 | nombreCliente: cliente.nom | 
| 261 | resolve: { | 266 | }; | 
| 262 | parametros: function () { return { idCliente: cliente.cod }; }, | 267 | }, | 
| 263 | } | 268 | } | 
| 264 | } | 269 | } | 
| 265 | ); | 270 | ); | 
| 266 | modalInstance.result | 271 | modalInstance.result | 
| 267 | .then(function (data) { | 272 | .then(function (data) { | 
| 268 | 273 | ||
| 269 | $scope.factura.formaPago = data.formaDePago; | 274 | $scope.factura.formaPago = data.formaDePago; | 
| 270 | 275 | ||
| 271 | $scope.factura.cliente = cliente; | 276 | $scope.factura.cliente = cliente; | 
| 272 | 277 | ||
| 273 | $scope.$broadcast('addCabecera', { | 278 | $scope.$broadcast('addCabecera', { | 
| 274 | label: 'Cliente:', | 279 | label: 'Cliente:', | 
| 275 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + | 280 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + | 
| 276 | ' - ' + cliente.nom | 281 | ' - ' + cliente.nom | 
| 277 | }); | 282 | }); | 
| 278 | 283 | ||
| 279 | $filter('filter')($scope.botonera, | 284 | $filter('filter')($scope.botonera, | 
| 280 | { label: 'Cliente' })[0].checked = true; | 285 | { label: 'Cliente' })[0].checked = true; | 
| 281 | 286 | ||
| 282 | $scope.$broadcast('addCabecera', { | 287 | $scope.$broadcast('addCabecera', { | 
| 283 | label: 'Tipo de pago: ', | 288 | label: 'Tipo de pago: ', | 
| 284 | valor: data.tipo | 289 | valor: data.tipo | 
| 285 | }); | 290 | }); | 
| 286 | }) | 291 | }) | 
| 287 | .catch(function () { | 292 | .catch(function () { | 
| 288 | 293 | ||
| 289 | $scope.seleccionarCliente(); | 294 | $scope.seleccionarCliente(); | 
| 290 | }); | 295 | }); | 
| 291 | 296 | ||
| 292 | }, function () { | 297 | }, function () { | 
| 293 | } | 298 | } | 
| 294 | ); | 299 | ); | 
| 295 | 300 | ||
| 296 | }; | 301 | }; | 
| 297 | 302 | ||
| 298 | $scope.seleccionarVendedor = function () { | 303 | $scope.seleccionarVendedor = function () { | 
| 299 | var parametrosModal = { | 304 | var parametrosModal = { | 
| 300 | titulo: 'Búsqueda vendedores', | 305 | titulo: 'Búsqueda vendedores', | 
| 301 | query: '/vendedor-playa', | 306 | query: '/vendedor-playa', | 
| 302 | columnas: [ | 307 | columnas: [ | 
| 303 | { | 308 | { | 
| 304 | propiedad: 'CodVen', | 309 | propiedad: 'CodVen', | 
| 305 | nombre: 'Código', | 310 | nombre: 'Código', | 
| 306 | filtro: { | 311 | filtro: { | 
| 307 | nombre: 'rellenarDigitos', | 312 | nombre: 'rellenarDigitos', | 
| 308 | parametro: 3 | 313 | parametro: 3 | 
| 309 | } | 314 | } | 
| 310 | }, | 315 | }, | 
| 311 | { | 316 | { | 
| 312 | propiedad: 'NomVen', | 317 | propiedad: 'NomVen', | 
| 313 | nombre: 'Nombre' | 318 | nombre: 'Nombre' | 
| 314 | } | 319 | } | 
| 315 | ], | 320 | ], | 
| 316 | size: 'md' | 321 | size: 'md' | 
| 317 | }; | 322 | }; | 
| 318 | focaModalService.modal(parametrosModal).then( | 323 | focaModalService.modal(parametrosModal).then( | 
| 319 | function (vendedor) { | 324 | function (vendedor) { | 
| 320 | 325 | ||
| 321 | indicarPassword(vendedor) | 326 | indicarPassword(vendedor) | 
| 322 | .then(function () { | 327 | .then(function () { | 
| 323 | validarPlanillaVendedor(vendedor) | 328 | validarPlanillaVendedor(vendedor) | 
| 324 | .then(function () { | 329 | .then(function () { | 
| 325 | 330 | ||
| 326 | $filter('filter')($scope.botonera, { | 331 | $filter('filter')($scope.botonera, { | 
| 327 | label: 'Vendedor' | 332 | label: 'Vendedor' | 
| 328 | })[0].checked = true; | 333 | })[0].checked = true; | 
| 329 | 334 | ||
| 330 | $scope.$broadcast('addCabecera', { | 335 | $scope.$broadcast('addCabecera', { | 
| 331 | label: 'Vendedor:', | 336 | label: 'Vendedor:', | 
| 332 | valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + | 337 | valor: $filter('rellenarDigitos')(vendedor.CodVen, 3) + | 
| 333 | ' - ' + | 338 | ' - ' + | 
| 334 | vendedor.NomVen | 339 | vendedor.NomVen | 
| 335 | }); | 340 | }); | 
| 336 | 341 | ||
| 337 | $scope.factura.vendedor = vendedor; | 342 | $scope.factura.vendedor = vendedor; | 
| 338 | 343 | ||
| 339 | getProductosByPlanilla(vendedor.NplVen); | 344 | getProductosByPlanilla(vendedor.NplVen); | 
| 340 | }) | 345 | }) | 
| 341 | .catch($scope.seleccionarVendedor); | 346 | .catch($scope.seleccionarVendedor); | 
| 342 | }) | 347 | }) | 
| 343 | .catch(function (err) { | 348 | .catch(function (err) { | 
| 344 | console.error(err); | 349 | console.error(err); | 
| 345 | }); | 350 | }); | 
| 346 | 351 | ||
| 347 | }, function () { } | 352 | }, function () { } | 
| 348 | ); | 353 | ); | 
| 349 | }; | 354 | }; | 
| 350 | 355 | ||
| 351 | $scope.seleccionarMoneda = function () { | 356 | $scope.seleccionarMoneda = function () { | 
| 352 | 357 | ||
| 353 | var parametrosModal = { | 358 | var parametrosModal = { | 
| 354 | titulo: 'Búsqueda de monedas', | 359 | titulo: 'Búsqueda de monedas', | 
| 355 | query: '/moneda', | 360 | query: '/moneda', | 
| 356 | columnas: [ | 361 | columnas: [ | 
| 357 | { | 362 | { | 
| 358 | propiedad: 'DETALLE', | 363 | propiedad: 'DETALLE', | 
| 359 | nombre: 'Nombre' | 364 | nombre: 'Nombre' | 
| 360 | }, | 365 | }, | 
| 361 | { | 366 | { | 
| 362 | propiedad: 'SIMBOLO', | 367 | propiedad: 'SIMBOLO', | 
| 363 | nombre: 'Símbolo' | 368 | nombre: 'Símbolo' | 
| 364 | } | 369 | } | 
| 365 | ], | 370 | ], | 
| 366 | size: 'md' | 371 | size: 'md' | 
| 367 | }; | 372 | }; | 
| 368 | focaModalService.modal(parametrosModal).then( | 373 | focaModalService.modal(parametrosModal).then( | 
| 369 | function (moneda) { | 374 | function (moneda) { | 
| 370 | 375 | ||
| 371 | if (moneda.ID !== 1) { | 376 | if (moneda.ID !== 1) { | 
| 372 | $scope.abrirModalCotizacion(moneda); | 377 | $scope.abrirModalCotizacion(moneda); | 
| 373 | return; | 378 | return; | 
| 374 | } | 379 | } | 
| 375 | 380 | ||
| 376 | crearRemitoService.getCotizacionByIdMoneda(1) | 381 | crearRemitoService.getCotizacionByIdMoneda(1) | 
| 377 | .then(function (res) { | 382 | .then(function (res) { | 
| 378 | 383 | ||
| 379 | var cotizacionPArgentino = res.data[0].cotizaciones[0]; | 384 | var cotizacionPArgentino = res.data[0].cotizaciones[0]; | 
| 380 | cotizacionPArgentino.moneda = moneda; | 385 | cotizacionPArgentino.moneda = moneda; | 
| 381 | 386 | ||
| 382 | actualizarCabeceraMoneda(cotizacionPArgentino); | 387 | actualizarCabeceraMoneda(cotizacionPArgentino); | 
| 383 | 388 | ||
| 384 | $scope.remito.cotizacion = cotizacionPArgentino; | 389 | $scope.remito.cotizacion = cotizacionPArgentino; | 
| 385 | }); | 390 | }); | 
| 386 | }, function () { | 391 | }, function () { | 
| 387 | 392 | ||
| 388 | } | 393 | } | 
| 389 | ); | 394 | ); | 
| 390 | }; | 395 | }; | 
| 391 | 396 | ||
| 392 | $scope.abrirModalCotizacion = function (moneda) { | 397 | $scope.abrirModalCotizacion = function (moneda) { | 
| 393 | var modalInstance = $uibModal.open( | 398 | var modalInstance = $uibModal.open( | 
| 394 | { | 399 | { | 
| 395 | ariaLabelledBy: 'Busqueda de Cotización', | 400 | ariaLabelledBy: 'Busqueda de Cotización', | 
| 396 | templateUrl: 'modal-cotizacion.html', | 401 | templateUrl: 'modal-cotizacion.html', | 
| 397 | controller: 'focaModalCotizacionController', | 402 | controller: 'focaModalCotizacionController', | 
| 398 | size: 'lg', | 403 | size: 'lg', | 
| 399 | resolve: { idMoneda: function () { return moneda.ID; } } | 404 | resolve: { idMoneda: function () { return moneda.ID; } } | 
| 400 | } | 405 | } | 
| 401 | ); | 406 | ); | 
| 402 | modalInstance.result.then( | 407 | modalInstance.result.then( | 
| 403 | function (cotizacion) { | 408 | function (cotizacion) { | 
| 404 | 409 | ||
| 405 | cotizacion.moneda = moneda; | 410 | cotizacion.moneda = moneda; | 
| 406 | actualizarCabeceraMoneda(cotizacion); | 411 | actualizarCabeceraMoneda(cotizacion); | 
| 407 | $scope.factura.cotizacion = cotizacion; | 412 | $scope.factura.cotizacion = cotizacion; | 
| 408 | 413 | ||
| 409 | }, function () { | 414 | }, function () { | 
| 410 | 415 | ||
| 411 | } | 416 | } | 
| 412 | ); | 417 | ); | 
| 413 | }; | 418 | }; | 
| 414 | 419 | ||
| 415 | $scope.seleccionarObservaciones = function () { | 420 | $scope.seleccionarObservaciones = function () { | 
| 416 | var observacion = { | 421 | var observacion = { | 
| 417 | titulo: 'Ingrese Observaciones', | 422 | titulo: 'Ingrese Observaciones', | 
| 418 | value: $scope.factura.observaciones, | 423 | value: $scope.factura.observaciones, | 
| 419 | maxlength: 155, | 424 | maxlength: 155, | 
| 420 | textarea: true | 425 | textarea: true | 
| 421 | }; | 426 | }; | 
| 422 | 427 | ||
| 423 | focaModalService | 428 | focaModalService | 
| 424 | .prompt(observacion) | 429 | .prompt(observacion) | 
| 425 | .then(function (observaciones) { | 430 | .then(function (observaciones) { | 
| 426 | $scope.factura.observaciones = observaciones; | 431 | $scope.factura.observaciones = observaciones; | 
| 427 | }); | 432 | }); | 
| 428 | }; | 433 | }; | 
| 429 | 434 | ||
| 430 | $scope.articulosFiltro = function () { | 435 | $scope.articulosFiltro = function () { | 
| 431 | return $scope.factura.articulosFactura.filter(function (articulo) { | 436 | return $scope.factura.articulosFactura.filter(function (articulo) { | 
| 432 | return !articulo.desactivado; | 437 | return !articulo.desactivado; | 
| 433 | }); | 438 | }); | 
| 434 | }; | 439 | }; | 
| 435 | 440 | ||
| 436 | $scope.getTotal = function () { | 441 | $scope.getTotal = function () { | 
| 437 | 442 | ||
| 438 | var total = 0; | 443 | var total = 0; | 
| 439 | 444 | ||
| 440 | $scope.articulosFiltro().forEach(function (articulo) { | 445 | $scope.articulosFiltro().forEach(function (articulo) { | 
| 441 | total += articulo.PUN * articulo.CAN; | 446 | total += articulo.PUN * articulo.CAN; | 
| 442 | }); | 447 | }); | 
| 443 | 448 | ||
| 444 | return parseFloat(total.toFixed(2)); | 449 | return parseFloat(total.toFixed(2)); | 
| 445 | }; | 450 | }; | 
| 446 | 451 | ||
| 447 | $scope.quitarDespacho = function (articulo, index) { | 452 | $scope.quitarDespacho = function (articulo, index) { | 
| 448 | 453 | ||
| 449 | if (articulo.SUR == 0) { | 454 | if (articulo.SUR == 0) { | 
| 450 | articulo.desactivado = true; | 455 | articulo.desactivado = true; | 
| 451 | return; | 456 | return; | 
| 452 | } | 457 | } | 
| 453 | 458 | ||
| 454 | crearFacturaService | 459 | crearFacturaService | 
| 455 | .setearDespachoDesocupado({ | 460 | .setearDespachoDesocupado({ | 
| 456 | surtidor: $scope.factura.despachos[index].SUR, | 461 | surtidor: $scope.factura.despachos[index].SUR, | 
| 457 | producto: $scope.factura.despachos[index].PRO, | 462 | producto: $scope.factura.despachos[index].PRO, | 
| 458 | carga: $scope.factura.despachos[index].CAR, | 463 | carga: $scope.factura.despachos[index].CAR, | 
| 459 | planilla: $scope.factura.despachos[index].PLA | 464 | planilla: $scope.factura.despachos[index].PLA | 
| 460 | }) | 465 | }) | 
| 461 | .then(function () { | 466 | .then(function () { | 
| 462 | articulo.desactivado = true; | 467 | articulo.desactivado = true; | 
| 463 | $scope.factura.despachos.splice(index, 1); | 468 | $scope.factura.despachos.splice(index, 1); | 
| 464 | }) | 469 | }) | 
| 465 | .catch(function () { | 470 | .catch(function () { | 
| 466 | focaModalService.alert('Hubo un error al desasociar este despacho'); | 471 | focaModalService.alert('Hubo un error al desasociar este despacho'); | 
| 467 | }); | 472 | }); | 
| 468 | }; | 473 | }; | 
| 469 | 474 | ||
| 470 | //Recibe aviso si el teclado está en uso | 475 | //Recibe aviso si el teclado está en uso | 
| 471 | $rootScope.$on('usarTeclado', function (event, data) { | 476 | $rootScope.$on('usarTeclado', function (event, data) { | 
| 472 | if (data) { | 477 | if (data) { | 
| 473 | $scope.mostrarTeclado = true; | 478 | $scope.mostrarTeclado = true; | 
| 474 | return; | 479 | return; | 
| 475 | } | 480 | } | 
| 476 | $scope.mostrarTeclado = false; | 481 | $scope.mostrarTeclado = false; | 
| 477 | }); | 482 | }); | 
| 478 | 483 | ||
| 479 | $scope.selectFocus = function ($event) { | 484 | $scope.selectFocus = function ($event) { | 
| 480 | // Si el teclado esta en uso no selecciona el valor | 485 | // Si el teclado esta en uso no selecciona el valor | 
| 481 | if ($scope.mostrarTeclado) { | 486 | if ($scope.mostrarTeclado) { | 
| 482 | return; | 487 | return; | 
| 483 | } | 488 | } | 
| 484 | $event.target.select(); | 489 | $event.target.select(); | 
| 485 | }; | 490 | }; | 
| 486 | 491 | ||
| 487 | 492 | ||
| 488 | function getProductosByPlanilla(numeroPlanilla) { | 493 | function getProductosByPlanilla(numeroPlanilla) { | 
| 489 | 494 | ||
| 490 | crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function (res) { | 495 | crearFacturaService.getProductosByPlanilla(numeroPlanilla).then(function (res) { | 
| 491 | 496 | ||
| 492 | if (!res.data.length) { | 497 | if (!res.data.length) { | 
| 493 | 498 | ||
| 494 | focaModalService.alert('No hay despachos disponibles por el momento'); | 499 | focaModalService.alert('No hay despachos disponibles por el momento'); | 
| 495 | return; | 500 | return; | 
| 496 | } | 501 | } | 
| 497 | 502 | ||
| 498 | $scope.botoneraProductos.length = 0; | 503 | $scope.botoneraProductos.length = 0; | 
| 499 | res.data.forEach(function (producto) { | 504 | res.data.forEach(function (producto) { | 
| 500 | 505 | ||
| 501 | $scope.botoneraProductos.push({ | 506 | $scope.botoneraProductos.push({ | 
| 502 | label: producto.DetArt, | 507 | label: producto.DetArt, | 
| 503 | image: producto.nombreImagen, | 508 | image: producto.nombreImagen, | 
| 504 | imageDefault: 'productoDefault.png' | 509 | imageDefault: 'productoDefault.png' | 
| 505 | }); | 510 | }); | 
| 506 | 511 | ||
| 507 | crearFuncionesProductos(producto); | 512 | crearFuncionesProductos(producto); | 
| 508 | }); | 513 | }); | 
| 509 | }); | 514 | }); | 
| 510 | } | 515 | } | 
| 511 | 516 | ||
| 512 | $scope.seleccionarBusquedaProductos = function () { | 517 | $scope.seleccionarBusquedaProductos = function () { | 
| 513 | 518 | ||
| 514 | if (angular.equals({}, $scope.factura.vendedor)) { | 519 | if (angular.equals({}, $scope.factura.vendedor)) { | 
| 515 | 520 | ||
| 516 | focaModalService.alert('Seleccione Vendedor'); | 521 | focaModalService.alert('Seleccione Vendedor'); | 
| 517 | return false; | 522 | return false; | 
| 518 | } | 523 | } | 
| 519 | 524 | ||
| 520 | var modalInstance = $uibModal.open( | 525 | var modalInstance = $uibModal.open( | 
| 521 | { | 526 | { | 
| 522 | ariaLabelledBy: 'Busqueda de Productos', | 527 | ariaLabelledBy: 'Busqueda de Productos', | 
| 523 | templateUrl: 'modal-busqueda-productos.html', | 528 | templateUrl: 'modal-busqueda-productos.html', | 
| 524 | controller: 'modalBusquedaProductosCtrl', | 529 | controller: 'modalBusquedaProductosCtrl', | 
| 525 | resolve: { | 530 | resolve: { | 
| 526 | parametroProducto: { | 531 | parametroProducto: { | 
| 527 | idLista: null, | 532 | idLista: null, | 
| 528 | cotizacion: $scope.factura.cotizacion.VENDEDOR, | 533 | cotizacion: $scope.factura.cotizacion.VENDEDOR, | 
| 529 | simbolo: $scope.factura.cotizacion.moneda.SIMBOLO, | 534 | simbolo: $scope.factura.cotizacion.moneda.SIMBOLO, | 
| 530 | buscarTodos: true | 535 | buscarTodos: true | 
| 531 | } | 536 | } | 
| 532 | }, | 537 | }, | 
| 533 | size: 'lg' | 538 | size: 'lg' | 
| 534 | } | 539 | } | 
| 535 | ); | 540 | ); | 
| 536 | 541 | ||
| 537 | modalInstance.result | 542 | modalInstance.result | 
| 538 | .then(function (producto) { | 543 | .then(function (producto) { | 
| 539 | 544 | ||
| 540 | var articulo = { | 545 | var articulo = { | 
| 541 | TIP: $scope.factura.cliente.tipoFactura, | 546 | TIP: $scope.factura.cliente.tipoFactura, | 
| 542 | TCO: 'FT', | 547 | TCO: 'FT', | 
| 543 | SUC: parseInt($scope.puntoVenta), | 548 | SUC: parseInt($scope.puntoVenta), | 
| 544 | ORD: $scope.articulosFiltro().length + 1, | 549 | ORD: $scope.articulosFiltro().length + 1, | 
| 545 | SEC: producto.sector, | 550 | SEC: producto.sector, | 
| 546 | ART: producto.codigo, | 551 | ART: producto.codigo, | 
| 547 | RUB: producto.CodRub, | 552 | RUB: producto.CodRub, | 
| 548 | DES: producto.descripcionLarga, | 553 | DES: producto.descripcionLarga, | 
| 549 | PUN: producto.precio, | 554 | PUN: producto.precio, | 
| 550 | IVA: producto.IMPIVA, | 555 | IVA: producto.IMPIVA, | 
| 551 | NET: producto.IvaCO != 0 ? parseFloat(producto.neto) : 0, | 556 | NET: producto.IvaCO != 0 ? parseFloat(producto.neto) : 0, | 
| 552 | NEX: producto.IvaCO == 0 ? parseFloat(producto.neto) : 0, | 557 | NEX: producto.IvaCO == 0 ? parseFloat(producto.neto) : 0, | 
| 553 | IMI: producto.ImpInt, | 558 | IMI: producto.ImpInt, | 
| 554 | IMI2: producto.ImpInt2, | 559 | IMI2: producto.ImpInt2, | 
| 555 | IMI3: producto.ImpInt3, | 560 | IMI3: producto.ImpInt3, | 
| 556 | PUT: producto.precio, | 561 | PUT: producto.precio, | 
| 557 | SUR: 0, | 562 | SUR: 0, | 
| 558 | PLA: $scope.factura.vendedor.NplVen, | 563 | PLA: $scope.factura.vendedor.NplVen, | 
| 559 | LUG: $scope.factura.vendedor.LugVen, | 564 | LUG: $scope.factura.vendedor.LugVen, | 
| 560 | LEG: $scope.factura.vendedor.CodVen, | 565 | LEG: $scope.factura.vendedor.CodVen, | 
| 561 | TUR: $scope.factura.vendedor.TurVen, | 566 | TUR: $scope.factura.vendedor.TurVen, | 
| 562 | ORDEN_PRECOMPRA: '', | 567 | ORDEN_PRECOMPRA: '', | 
| 563 | ESC: producto.tipoFactura === 'L' ? 1 : 0, | 568 | ESC: producto.tipoFactura === 'L' ? 1 : 0, | 
| 564 | CMF: 0, | 569 | CMF: 0, | 
| 565 | PTA: 0, | 570 | PTA: 0, | 
| 566 | IVS: 0, | 571 | IVS: 0, | 
| 567 | TIVA: 0, | 572 | TIVA: 0, | 
| 568 | CON: 0, | 573 | CON: 0, | 
| 569 | SINO: '', | 574 | SINO: '', | 
| 570 | ORD_TRA: 0, | 575 | ORD_TRA: 0, | 
| 571 | IMP_DESP: 0, | 576 | IMP_DESP: 0, | 
| 572 | PCD: 0, | 577 | PCD: 0, | 
| 573 | RTO: '', | 578 | RTO: '', | 
| 574 | }; | 579 | }; | 
| 575 | 580 | ||
| 576 | $scope.factura.articulosFactura.push(articulo); | 581 | $scope.factura.articulosFactura.push(articulo); | 
| 577 | $scope.cambioEdit(articulo, 'cantidad'); | 582 | $scope.cambioEdit(articulo, 'cantidad'); | 
| 578 | 583 | ||
| 579 | }) | 584 | }) | 
| 580 | .catch(function (e) { console.error(e); }); | 585 | .catch(function (e) { console.error(e); }); | 
| 581 | }; | 586 | }; | 
| 582 | 587 | ||
| 583 | function crearFuncionesProductos(producto) { | 588 | function crearFuncionesProductos(producto) { | 
| 584 | 589 | ||
| 585 | $scope[nombreFuncion(producto.DetArt)] = function () { | 590 | $scope[nombreFuncion(producto.DetArt)] = function () { | 
| 586 | 591 | ||
| 587 | if (angular.equals($scope.factura.cliente, {})) { | 592 | if (angular.equals($scope.factura.cliente, {})) { | 
| 588 | focaModalService.alert('Seleccione cliente'); | 593 | focaModalService.alert('Seleccione cliente'); | 
| 589 | return; | 594 | return; | 
| 590 | } | 595 | } | 
| 591 | 596 | ||
| 592 | var modalInstance = $uibModal.open( | 597 | var modalInstance = $uibModal.open( | 
| 593 | { | 598 | { | 
| 594 | templateUrl: 'modal-combustibles.html', | 599 | templateUrl: 'modal-combustibles.html', | 
| 595 | controller: 'focaModalCombustiblesController', | 600 | controller: 'focaModalCombustiblesController', | 
| 596 | resolve: { | 601 | resolve: { | 
| 597 | parametros: function () { | 602 | parametros: function () { | 
| 598 | return { | 603 | return { | 
| 599 | despachos: producto.despachos, | 604 | despachos: producto.despachos, | 
| 600 | nombreProducto: producto.DetArt | 605 | nombreProducto: producto.DetArt | 
| 601 | }; | 606 | }; | 
| 602 | } | 607 | } | 
| 603 | }, | 608 | }, | 
| 604 | size: 'md' | 609 | size: 'md' | 
| 605 | } | 610 | } | 
| 606 | ); | 611 | ); | 
| 607 | 612 | ||
| 608 | modalInstance.result.then(function (despacho) { | 613 | modalInstance.result.then(function (despacho) { | 
| 609 | 614 | ||
| 610 | var articulo = { | 615 | var articulo = { | 
| 611 | TIP: $scope.factura.cliente.tipoFactura, | 616 | TIP: $scope.factura.cliente.tipoFactura, | 
| 612 | TCO: 'FT', | 617 | TCO: 'FT', | 
| 613 | SUC: parseInt($scope.puntoVenta), | 618 | SUC: parseInt($scope.puntoVenta), | 
| 614 | ORD: $scope.articulosFiltro().length + 1, | 619 | ORD: $scope.articulosFiltro().length + 1, | 
| 615 | SEC: despacho.SEC, | 620 | SEC: despacho.SEC, | 
| 616 | ART: despacho.PRO, | 621 | ART: despacho.PRO, | 
| 617 | RUB: producto.CodRub, | 622 | RUB: producto.CodRub, | 
| 618 | DES: producto.DetArt, | 623 | DES: producto.DetArt, | 
| 619 | CAN: despacho.LTS, | 624 | CAN: despacho.LTS, | 
| 620 | PUN: producto.PreVen, | 625 | PUN: producto.PreVen, | 
| 621 | IVA: producto.IMPIVA, | 626 | IVA: producto.IMPIVA, | 
| 622 | NET: producto.IvaCO != 0 ? producto.PreNet : 0, | 627 | NET: producto.IvaCO != 0 ? producto.PreNet : 0, | 
| 623 | NEX: producto.IvaCO == 0 ? producto.PreNet : 0, | 628 | NEX: producto.IvaCO == 0 ? producto.PreNet : 0, | 
| 624 | IMI: producto.ImpInt, | 629 | IMI: producto.ImpInt, | 
| 625 | IMI2: producto.ImpInt2, | 630 | IMI2: producto.ImpInt2, | 
| 626 | IMI3: producto.ImpInt3, | 631 | IMI3: producto.ImpInt3, | 
| 627 | PUT: producto.PreVen, | 632 | PUT: producto.PreVen, | 
| 628 | SUR: despacho.SUR, | 633 | SUR: despacho.SUR, | 
| 629 | PLA: despacho.PLA, | 634 | PLA: despacho.PLA, | 
| 630 | LUG: despacho.LUG, | 635 | LUG: despacho.LUG, | 
| 631 | LEG: $scope.factura.vendedor.CodVen, | 636 | LEG: $scope.factura.vendedor.CodVen, | 
| 632 | TUR: $scope.factura.vendedor.TurVen, | 637 | TUR: $scope.factura.vendedor.TurVen, | 
| 633 | ORDEN_PRECOMPRA: '', | 638 | ORDEN_PRECOMPRA: '', | 
| 634 | ESC: producto.tipoFactura === 'L' ? 1 : 0, | 639 | ESC: producto.tipoFactura === 'L' ? 1 : 0, | 
| 635 | CMF: 0, | 640 | CMF: 0, | 
| 636 | PTA: 0, | 641 | PTA: 0, | 
| 637 | IVS: 0, | 642 | IVS: 0, | 
| 638 | TIVA: 21, // TODO traer POR de la tabla ACODIVA where ID = IvaCO | 643 | TIVA: 21, // TODO traer POR de la tabla ACODIVA where ID = IvaCO | 
| 639 | CON: 0, | 644 | CON: 0, | 
| 640 | SINO: '', | 645 | SINO: '', | 
| 641 | ORD_TRA: 0, | 646 | ORD_TRA: 0, | 
| 642 | IMP_DESP: 0, | 647 | IMP_DESP: 0, | 
| 643 | PCD: 0, | 648 | PCD: 0, | 
| 644 | RTO: '', | 649 | RTO: '', | 
| 645 | }; | 650 | }; | 
| 646 | 651 | ||
| 647 | crearFacturaService.setearDespachoOcupado({ | 652 | crearFacturaService.setearDespachoOcupado({ | 
| 648 | surtidor: despacho.SUR, | 653 | surtidor: despacho.SUR, | 
| 649 | producto: despacho.PRO, | 654 | producto: despacho.PRO, | 
| 650 | carga: despacho.CAR | 655 | carga: despacho.CAR | 
| 651 | }) | 656 | }) | 
| 652 | .then(function () { | 657 | .then(function () { | 
| 653 | $scope.factura.articulosFactura.push(articulo); | 658 | $scope.factura.articulosFactura.push(articulo); | 
| 654 | $scope.factura.despachos.push(despacho); | 659 | $scope.factura.despachos.push(despacho); | 
| 655 | }) | 660 | }) | 
| 656 | .catch(function (err) { | 661 | .catch(function (err) { | 
| 657 | 662 | ||
| 658 | console.error(err); | 663 | console.error(err); | 
| 659 | focaModalService.alert('El despacho esta en uso'); | 664 | focaModalService.alert('El despacho esta en uso'); | 
| 660 | }); | 665 | }); | 
| 661 | 666 | ||
| 662 | }) | 667 | }) | 
| 663 | .catch(function (err) { | 668 | .catch(function (err) { | 
| 664 | console.error(err); | 669 | console.error(err); | 
| 665 | }); | 670 | }); | 
| 666 | 671 | ||
| 667 | }; | 672 | }; | 
| 668 | } | 673 | } | 
| 669 | 674 | ||
| 670 | function nombreFuncion(string) { | 675 | function nombreFuncion(string) { | 
| 671 | var texto = 'seleccionar'; | 676 | var texto = 'seleccionar'; | 
| 672 | var arr = string.split(' '); | 677 | var arr = string.split(' '); | 
| 673 | arr.forEach(function (palabra) { | 678 | arr.forEach(function (palabra) { | 
| 674 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); | 679 | palabra = palabra.charAt(0).toUpperCase() + palabra.slice(1); | 
| 675 | texto += palabra; | 680 | texto += palabra; | 
| 676 | }); | 681 | }); | 
| 677 | return texto; | 682 | return texto; | 
| 678 | } | 683 | } | 
| 679 | 684 | ||
| 680 | function indicarPassword(vendedor) { | 685 | function indicarPassword(vendedor) { | 
| 681 | 686 | ||
| 682 | return new Promise(function (resolve, reject) { | 687 | return new Promise(function (resolve, reject) { | 
| 683 | 688 | ||
| 684 | function openPrompt() { | 689 | function openPrompt() { | 
| 685 | return focaModalService | 690 | return focaModalService | 
| 686 | .prompt({ | 691 | .prompt({ | 
| 687 | titulo: 'Indique Contraseña', | 692 | titulo: 'Indique Contraseña', | 
| 688 | value: '', | 693 | value: '', | 
| 689 | tipo: 'password' | 694 | tipo: 'password' | 
| 690 | }) | 695 | }) | 
| 691 | .then(function (contraseña) { | 696 | .then(function (contraseña) { | 
| 692 | 697 | ||
| 693 | if (contraseña !== vendedor.ClaVen.trim()) { | 698 | if (contraseña !== vendedor.ClaVen.trim()) { | 
| 694 | 699 | ||
| 695 | focaModalService.alert('Clave incorrecta').then(function () { | 700 | focaModalService.alert('Clave incorrecta').then(function () { | 
| 696 | openPrompt(vendedor); | 701 | openPrompt(vendedor); | 
| 697 | }); | 702 | }); | 
| 698 | } else { | 703 | } else { | 
| 699 | resolve(); | 704 | resolve(); | 
| 700 | } | 705 | } | 
| 701 | }) | 706 | }) | 
| 702 | .catch(reject); | 707 | .catch(reject); | 
| 703 | } | 708 | } | 
| 704 | 709 | ||
| 705 | openPrompt(); | 710 | openPrompt(); | 
| 706 | }); | 711 | }); | 
| 707 | } | 712 | } | 
| 708 | 713 | ||
| 709 | function validarPlanillaVendedor(vendedor) { | 714 | function validarPlanillaVendedor(vendedor) { | 
| 710 | 715 | ||
| 711 | return new Promise(function (resolve, reject) { | 716 | return new Promise(function (resolve, reject) { | 
| 712 | 717 | ||
| 713 | crearFacturaService | 718 | crearFacturaService | 
| 714 | .validarPlanillaVendedor(vendedor.CodVen.toString().trim()) | 719 | .validarPlanillaVendedor(vendedor.CodVen.toString().trim()) | 
| 715 | .then(function (res) { | 720 | .then(function (res) { | 
| 716 | 721 | ||
| 717 | if (!res.data.length) { | 722 | if (!res.data.length) { | 
| 718 | 723 | ||
| 719 | focaModalService | 724 | focaModalService | 
| 720 | .alert('No se encontró planilla abierta para el vendedor') | 725 | .alert('No se encontró planilla abierta para el vendedor') | 
| 721 | .then(reject); | 726 | .then(reject); | 
| 722 | 727 | ||
| 723 | } else { | 728 | } else { | 
| 724 | resolve(); | 729 | resolve(); | 
| 725 | } | 730 | } | 
| 726 | 731 | ||
| 727 | }) | 732 | }) | 
| 728 | .catch(function (err) { | 733 | .catch(function (err) { | 
| 729 | console.log(err) | 734 | console.log(err) | 
| 730 | reject(); | 735 | reject(); | 
| 731 | }); | 736 | }); | 
| 732 | }); | 737 | }); | 
| 733 | } | 738 | } | 
| 734 | 739 | ||
| 735 | function rellenar(relleno, longitud) { | 740 | function rellenar(relleno, longitud) { | 
| 736 | relleno = '' + relleno; | 741 | relleno = '' + relleno; | 
| 737 | while (relleno.length < longitud) { | 742 | while (relleno.length < longitud) { | 
| 738 | relleno = '0' + relleno; | 743 | relleno = '0' + relleno; | 
| 739 | } | 744 | } | 
| 740 | return relleno; | 745 | return relleno; | 
| 741 | } | 746 | } | 
| 742 | 747 | ||
| 743 | $scope.salir = function () { | 748 | $scope.salir = function () { | 
| 744 | var confirmacion = false; | 749 | var confirmacion = false; | 
| 745 | 750 | ||
| 746 | if (!angular.equals($scope.factura, $scope.inicial)) { | 751 | if (!angular.equals($scope.factura, $scope.inicial)) { | 
| 747 | confirmacion = true; | 752 | confirmacion = true; | 
| 748 | } | 753 | } | 
| 749 | 754 | ||
| 750 | if (confirmacion) { | 755 | if (confirmacion) { | 
| 751 | focaModalService.confirm( | 756 | focaModalService.confirm( | 
| 752 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 757 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 
| 753 | ).then(function (data) { | 758 | ).then(function (data) { | 
| 754 | if (data) { | 759 | if (data) { | 
| 755 | $location.path('/'); | 760 | $location.path('/'); | 
| 756 | } | 761 | } | 
| 757 | }); | 762 | }); | 
| 758 | } else { | 763 | } else { | 
| 759 | $location.path('/'); | 764 | $location.path('/'); | 
| 760 | } | 765 | } | 
| 761 | } | 766 | } | 
| 762 | 767 | ||
| 763 | function setearFactura(factura) { | 768 | function setearFactura(factura) { | 
| 764 | 769 | ||
| 765 | $scope.$broadcast('cleanCabecera'); | 770 | $scope.$broadcast('cleanCabecera'); | 
| 766 | 771 | ||
| 767 | $scope.cabeceras = []; | 772 | $scope.cabeceras = []; | 
| 768 | 773 | ||
| 769 | if (factura.cotizacion && factura.cotizacion.moneda.CODIGO_AFIP !== 'PES') { | 774 | if (factura.cotizacion && factura.cotizacion.moneda.CODIGO_AFIP !== 'PES') { | 
| 770 | $scope.cabeceras.push({ | 775 | $scope.cabeceras.push({ | 
| 771 | label: 'Moneda:', | 776 | label: 'Moneda:', | 
| 772 | valor: factura.cotizacion.moneda.DETALLE | 777 | valor: factura.cotizacion.moneda.DETALLE | 
| 773 | }); | 778 | }); | 
| 774 | $scope.cabeceras.push({ | 779 | $scope.cabeceras.push({ | 
| 775 | label: 'Fecha cotizacion:', | 780 | label: 'Fecha cotizacion:', | 
| 776 | valor: $filter('date')(factura.cotizacion.FECHA, | 781 | valor: $filter('date')(factura.cotizacion.FECHA, | 
| 777 | 'dd/MM/yyyy') | 782 | 'dd/MM/yyyy') | 
| 778 | }); | 783 | }); | 
| 779 | $scope.cabeceras.push({ | 784 | $scope.cabeceras.push({ | 
| 780 | label: 'Cotizacion:', | 785 | label: 'Cotizacion:', | 
| 781 | valor: $filter('number')(factura.cotizacion.VENDEDOR, | 786 | valor: $filter('number')(factura.cotizacion.VENDEDOR, | 
| 782 | '2') | 787 | '2') | 
| 783 | }); | 788 | }); | 
| 784 | } | 789 | } | 
| 785 | 790 | ||
| 786 | if (factura.cotizacion && factura.cotizacion.moneda) { | 791 | if (factura.cotizacion && factura.cotizacion.moneda) { | 
| 787 | // $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; | 792 | // $filter('filter')($scope.botonera, { label: 'Moneda' })[0].checked = true; | 
| 788 | } | 793 | } | 
| 789 | 794 | ||
| 790 | if (factura.cliente && factura.cliente.cod) { | 795 | if (factura.cliente && factura.cliente.cod) { | 
| 791 | $scope.cabeceras.push({ | 796 | $scope.cabeceras.push({ | 
| 792 | label: 'Cliente:', | 797 | label: 'Cliente:', | 
| 793 | valor: $filter('rellenarDigitos')(factura.cliente.cod, 3) + ' - ' + | 798 | valor: $filter('rellenarDigitos')(factura.cliente.cod, 3) + ' - ' + | 
| 794 | factura.cliente.nom | 799 | factura.cliente.nom | 
| 795 | }); | 800 | }); | 
| 796 | 801 | ||
| 797 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; | 802 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; | 
| 798 | } | 803 | } | 
| 799 | 804 | ||
| 800 | $scope.puntoVenta = rellenar(factura.sucursal, 4); | 805 | $scope.puntoVenta = rellenar(factura.sucursal, 4); | 
| 801 | $scope.comprobante = rellenar(factura.numerofactura, 8); | 806 | $scope.comprobante = rellenar(factura.numerofactura, 8); | 
| 802 | $scope.factura = factura; | 807 | $scope.factura = factura; | 
| 803 | 808 | ||
| 804 | addArrayCabecera($scope.cabeceras); | 809 | addArrayCabecera($scope.cabeceras); | 
| 805 | } | 810 | } | 
| 806 | 811 | ||
| 807 | function getLSFactura() { | 812 | function getLSFactura() { | 
| 808 | var factura = JSON.parse($localStorage.factura || null); | 813 | var factura = JSON.parse($localStorage.factura || null); | 
| 809 | if (factura) { | 814 | if (factura) { | 
| 810 | setearFactura(factura); | 815 | setearFactura(factura); | 
| 811 | delete $localStorage.factura; | 816 | delete $localStorage.factura; | 
| 812 | } | 817 | } | 
| 813 | } | 818 | } | 
| 814 | 819 | ||
| 815 | function addArrayCabecera(array) { | 820 | function addArrayCabecera(array) { | 
| 816 | for (var i = 0; i < array.length; i++) { | 821 | for (var i = 0; i < array.length; i++) { | 
| 817 | $scope.$broadcast('addCabecera', { | 822 | $scope.$broadcast('addCabecera', { | 
| 818 | label: array[i].label, | 823 | label: array[i].label, | 
| 819 | valor: array[i].valor | 824 | valor: array[i].valor | 
| 820 | }); | 825 | }); | 
| 821 | } | 826 | } | 
| 822 | } | 827 | } | 
| 823 | 828 | ||
| 824 | $scope.cambioEdit = function (articulo, propiedad) { | 829 | $scope.cambioEdit = function (articulo, propiedad) { | 
| 825 | if (propiedad === 'cantidad' && articulo.SUR == 0) { | 830 | if (propiedad === 'cantidad' && articulo.SUR == 0) { | 
| 826 | articulo.editCantidad = true; | 831 | articulo.editCantidad = true; | 
| 827 | } | 832 | } | 
| 828 | }; | 833 | }; | 
| 829 | 834 | ||
| 830 | $scope.editarArticulo = function (key, articulo, tmpCantidad) { | 835 | $scope.editarArticulo = function (key, articulo, tmpCantidad) { | 
| 831 | if (key === 13) { | 836 | if (key === 13) { | 
| 832 | if (!articulo.cantidad && tmpCantidad.length === 0) { | 837 | if (!articulo.cantidad && tmpCantidad.length === 0) { | 
| 833 | focaModalService.alert('Los valores deben ser al menos 1'); | 838 | focaModalService.alert('Los valores deben ser al menos 1'); | 
| 834 | return; | 839 | return; | 
| 835 | } else if (tmpCantidad === '0') { | 840 | } else if (tmpCantidad === '0') { | 
| 836 | focaModalService.alert('Esta ingresando un producto con valor 0'); | 841 | focaModalService.alert('Esta ingresando un producto con valor 0'); | 
| 837 | return; | 842 | return; | 
| 838 | } else if (parseInt(tmpCantidad) < 0) { | 843 | } else if (parseInt(tmpCantidad) < 0) { | 
| 839 | focaModalService.alert('Los valores no pueden ser negativos'); | 844 | focaModalService.alert('Los valores no pueden ser negativos'); | 
| 840 | return; | 845 | return; | 
| 841 | } | 846 | } | 
| 842 | articulo.CAN = parseInt(tmpCantidad); | 847 | articulo.CAN = parseInt(tmpCantidad); | 
| 843 | $scope.getTotal(); | 848 | $scope.getTotal(); | 
| 844 | articulo.editCantidad = false; | 849 | articulo.editCantidad = false; | 
| 845 | } | 850 | } | 
| 846 | }; | 851 | }; | 
| 847 | 852 | ||
| 848 | $scope.cancelarEditar = function (articulo) { | 853 | $scope.cancelarEditar = function (articulo) { | 
| 849 | $scope.tmpCantidad = articulo.CAN; | 854 | $scope.tmpCantidad = articulo.CAN; | 
| 850 | articulo.editCantidad = false; | 855 | articulo.editCantidad = false; | 
| 851 | }; | 856 | }; | 
| 852 | 857 | ||
| 853 | function actualizarCabeceraMoneda(cotizacion) { | 858 | function actualizarCabeceraMoneda(cotizacion) { | 
| 854 | 859 | ||
| 855 | $scope.factura.articulosFactura.forEach(function (art) { | 860 | $scope.factura.articulosFactura.forEach(function (art) { | 
| 856 | art.PUN = (art.PUN * $scope.factura.cotizacion.VENDEDOR).toFixed(4); | 861 | art.PUN = (art.PUN * $scope.factura.cotizacion.VENDEDOR).toFixed(4); | 
| 857 | art.PUN = (art.PUN / cotizacion.VENDEDOR).toFixed(4); | 862 | art.PUN = (art.PUN / cotizacion.VENDEDOR).toFixed(4); | 
| 858 | }); | 863 | }); | 
| 859 | 864 | ||
| 860 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { | 865 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { | 
| 861 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 866 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 
| 862 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 867 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 
| 863 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 868 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 
| 864 | } else { | 869 | } else { | 
| 865 | $scope.$broadcast('addCabecera', { | 870 | $scope.$broadcast('addCabecera', { | 
| 866 | label: 'Moneda:', | 871 | label: 'Moneda:', | 
| 867 | valor: cotizacion.moneda.DETALLE | 872 | valor: cotizacion.moneda.DETALLE | 
| 868 | }); | 873 | }); | 
| 869 | $scope.$broadcast('addCabecera', { | 874 | $scope.$broadcast('addCabecera', { | 
| 870 | label: 'Fecha cotizacion:', | 875 | label: 'Fecha cotizacion:', | 
| 871 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 876 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 
| 872 | }); | 877 | }); | 
| 873 | $scope.$broadcast('addCabecera', { | 878 | $scope.$broadcast('addCabecera', { | 
| 874 | label: 'Cotizacion:', | 879 | label: 'Cotizacion:', | 
| 875 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 880 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 
| 876 | }); | 881 | }); | 
| 877 | } | 882 | } | 
| 878 | } | 883 | } | 
| 879 | 884 | ||
| 880 | function validarGuardar() { | 885 | function validarGuardar() { | 
| 881 | 886 | ||
| 882 | if (angular.equals({}, $scope.factura.vendedor)) { | 887 | if (angular.equals({}, $scope.factura.vendedor)) { | 
| 883 | 888 | ||
| 884 | focaModalService.alert('Seleccione Vendedor'); | 889 | focaModalService.alert('Seleccione Vendedor'); | 
| 885 | return false; | 890 | return false; | 
| 886 | } else if (angular.equals({}, $scope.factura.cliente)) { | 891 | } else if (angular.equals({}, $scope.factura.cliente)) { | 
| 887 | 892 | ||
| 888 | focaModalService.alert('Seleccione Cliente'); | 893 | focaModalService.alert('Seleccione Cliente'); | 
| 889 | return false; | 894 | return false; | 
| 890 | } else if (!$scope.articulosFiltro().length) { | 895 | } else if (!$scope.articulosFiltro().length) { | 
| 891 | 896 | ||
| 892 | focaModalService.alert('Seleccione al menos un Articulo'); | 897 | focaModalService.alert('Seleccione al menos un Articulo'); | 
| 893 | return false; | 898 | return false; | 
| 894 | } | 899 | } | 
| 895 | 900 | ||
| 896 | return true; | 901 | return true; | 
| 897 | } | 902 | } | 
| 898 | 903 | ||
| 899 | //recibo la propiedad por la cual quiero obtener el valor | 904 | //recibo la propiedad por la cual quiero obtener el valor | 
| 900 | function getImporte(propiedad) { | 905 | function getImporte(propiedad) { | 
| 901 | var importe = 0; | 906 | var importe = 0; | 
| 902 | 907 | ||
| 903 | $scope.articulosFiltro().forEach(function (articulo) { | 908 | $scope.articulosFiltro().forEach(function (articulo) { | 
| 904 | 909 | ||
| 905 | if (articulo[propiedad]) { | 910 | if (articulo[propiedad]) { | 
| 906 | importe += articulo[propiedad] * articulo.CAN; | 911 | importe += articulo[propiedad] * articulo.CAN; | 
| 907 | } | 912 | } | 
| 908 | return; | 913 | return; | 
| 909 | 914 | ||
| 910 | }); | 915 | }); | 
| 911 | 916 | ||
| 912 | return importe; | 917 | return importe; | 
| 913 | } | 918 | } | 
| 914 | } | 919 | } | 
| 915 | ]); | 920 | ]); | 
| 916 | 921 | 
src/js/controllerEstadoCuenta.js
| 1 | angular.module('focaCrearFactura') | 1 | angular.module('focaCrearFactura') | 
| 2 | .controller('focaModalEstadoCuentaController', [ | 2 | .controller('focaModalEstadoCuentaController', [ | 
| 3 | '$scope', '$uibModalInstance', 'crearFacturaService', 'parametros', | 3 | '$scope', '$uibModalInstance', 'crearFacturaService', 'parametros', | 
| 4 | function ($scope, $uibModalInstance, crearFacturaService, parametros) { | 4 | function ($scope, $uibModalInstance, crearFacturaService, parametros) { | 
| 5 | 5 | ||
| 6 | $scope.estadoCuenta = { | 6 | $scope.estadoCuenta = { | 
| 7 | autorizado: 0.0, | 7 | autorizado: 0.0, | 
| 8 | extracciones: 0.0, | 8 | extracciones: 0.0, | 
| 9 | saldo: 0.0, | 9 | saldo: 0.0, | 
| 10 | situacion: false, | 10 | situacion: false, | 
| 11 | facturasVencidas: 0.0 | 11 | facturasVencidas: 0.0 | 
| 12 | }; | 12 | }; | 
| 13 | 13 | ||
| 14 | $scope.cliente = parametros; | ||
| 15 | |||
| 14 | init(); | 16 | init(); | 
| 15 | 17 | ||
| 16 | function init() { | 18 | function init() { | 
| 17 | crearFacturaService.getResumenCuenta(parametros.idCliente) | 19 | crearFacturaService.getResumenCuenta(parametros.idCliente) | 
| 18 | .then(function (res) { | 20 | .then(function (res) { | 
| 19 | $scope.estadoCuenta = res.data; | 21 | $scope.estadoCuenta = res.data; | 
| 20 | }) | 22 | }) | 
| 21 | .catch(function (e) { console.error(e); }); | 23 | .catch(function (e) { console.error(e); }); | 
| 22 | } | 24 | } | 
| 23 | 25 | ||
| 24 | $scope.elegirTipoDePago = function (tipoDePago) { | 26 | $scope.elegirTipoDePago = function (tipoDePago) { | 
| 25 | $uibModalInstance.close(tipoDePago); | 27 | $uibModalInstance.close(tipoDePago); | 
| 26 | }; | 28 | }; | 
| 27 | 29 | ||
| 28 | $scope.cancel = function () { | 30 | $scope.cancel = function () { | 
| 29 | $uibModalInstance.dismiss('cancel'); | 31 | $uibModalInstance.dismiss('cancel'); | 
| 30 | }; | 32 | }; | 
| 31 | } | 33 | } | 
| 32 | ]); | 34 | ]); | 
| 33 | 35 | 
src/views/modal-estado-cuenta.html
| 1 | <div class="modal-header py-1"> | 1 | <div class="modal-header py-1"> | 
| 2 | <div class="row w-100"> | 2 | <div class="row w-100"> | 
| 3 | <div class="col-lg-6"> | 3 | <div class="col-lg-6"> | 
| 4 | <h5 class="modal-title text-center my-1">Estado cuenta corriente</h5> | 4 | <h5 class="modal-title text-center my-1">Estado cuenta corriente</h5> | 
| 5 | </div> | 5 | </div> | 
| 6 | </div> | 6 | </div> | 
| 7 | </div> | 7 | </div> | 
| 8 | <div class="modal-body" id="modal-body"> | 8 | <div class="modal-body" id="modal-body"> | 
| 9 | <div class="row m-3"> | 9 | <div class="row m-3"> | 
| 10 | <div class="col"> | 10 | <div class="col"> | 
| 11 | <!-- <div class="row mb-2"> | 11 | <!-- <div class="row mb-2"> | 
| 12 | <div class="col text-center"> | 12 | <div class="col text-center"> | 
| 13 | <p class="m-0">Autorizado</p> | 13 | <p class="m-0">Autorizado</p> | 
| 14 | <p class="h5 m-0" ng-bind="estadoCuenta.autorizado | currency"></p> | 14 | <p class="h5 m-0" ng-bind="estadoCuenta.autorizado | currency"></p> | 
| 15 | </div> | 15 | </div> | 
| 16 | </div> | ||
| 17 | <div class="row border-top mb-2"> | ||
| 18 | <div class="col text-center"> | ||
| 19 | <p class="m-0">Extracciones</p> | ||
| 20 | <p class="h5 m-0" ng-bind="estadoCuenta.extracciones | currency"></p> | ||
| 21 | </div> | ||
| 22 | </div> --> | 16 | </div> --> | 
| 23 | <div class="row mb-2"> | 17 | <div class="row mb-2"> | 
| 24 | <div class="col text-center"> | 18 | <div class="col text-center"> | 
| 19 | <p class="m-0">Cliente</p> | ||
| 20 | <label class="h5" ng-bind="cliente.idCliente"></label> | ||
| 21 | <label class="h5"> -  </label> | ||
| 22 | <label class="h5" ng-bind="cliente.nombreCliente"></label> | ||
| 23 | </div> | ||
| 24 | </div> | ||
| 25 | <div class="row border-top mb-2"> | ||
| 26 | <div class="col text-center"> | ||
| 25 | <p class="m-0">Saldo</p> | 27 | <p class="m-0">Saldo</p> | 
| 26 | <p class="h5 m-0" ng-bind="estadoCuenta.saldo | currency"></p> | 28 | <p class="h5 m-0" ng-bind="estadoCuenta.saldo | currency"></p> | 
| 27 | </div> | 29 | </div> | 
| 28 | </div> | 30 | </div> | 
| 29 | <!-- <div class="row border-top"> | 31 | <!-- <div class="row border-top"> | 
| 30 | <div class="col text-center"> | 32 | <div class="col text-center"> | 
| 31 | <p class="m-0">Situacion</p> | 33 | <p class="m-0">Situacion</p> | 
| 32 | <h4> | 34 | <h4> | 
| 33 | <p | 35 | <p | 
| 34 | ng-show="estadoCuenta.situacion" | 36 | ng-show="estadoCuenta.situacion" | 
| 35 | class="badge badge-success m-0 px-3">Permitido | 37 | class="badge badge-success m-0 px-3">Permitido | 
| 36 | </p> | 38 | </p> | 
| 37 | <p | 39 | <p | 
| 38 | ng-show="!estadoCuenta.situacion" | 40 | ng-show="!estadoCuenta.situacion" | 
| 39 | class="badge badge-danger m-0 px-3">No permitido | 41 | class="badge badge-danger m-0 px-3">No permitido | 
| 40 | </p> | 42 | </p> | 
| 41 | </h4> | 43 | </h4> | 
| 42 | </div> | 44 | </div> | 
| 43 | </div> | 45 | </div> | 
| 44 | <div class="row border-top mb-2"> | 46 | <div class="row border-top mb-2"> | 
| 45 | <div class="col text-center"> | 47 | <div class="col text-center"> | 
| 46 | <p class="m-0">Facturas Vencidas</p> | 48 | <p class="m-0">Facturas Vencidas</p> | 
| 47 | <p class="h5 m-0" ng-bind="estadoCuenta.facturasVencidas | currency"></p> | 49 | <p class="h5 m-0" ng-bind="estadoCuenta.facturasVencidas | currency"></p> | 
| 48 | </div> | 50 | </div> | 
| 49 | </div> --> | 51 | </div> --> | 
| 50 | </div> | 52 | </div> | 
| 51 | </div> | 53 | </div> | 
| 52 | <div class="row h-25 align-items-center mx-0 botonera-secundaria"> | 54 | <div class="row h-25 align-items-center mx-0 botonera-secundaria"> | 
| 53 | <div class="col-6 col-sm-4 offset-sm-2"> | 55 | <div class="col-6 col-sm-4 offset-sm-2"> | 
| 54 | <button | 56 | <button | 
| 55 | type="button" | 57 | type="button" | 
| 56 | class="btn btn-sm btn-block btn-tarjeta rounded border p-1" | 58 | class="btn btn-sm btn-block btn-tarjeta rounded border p-1" | 
| 57 | ng-disabled="!estadoCuenta.situacion" | 59 | ng-disabled="!estadoCuenta.situacion" | 
| 58 | ng-click="elegirTipoDePago({tipo: 'Contado', formaDePago: 1})" | 60 | ng-click="elegirTipoDePago({tipo: 'Contado', formaDePago: 1})" | 
| 59 | > | 61 | > | 
| 60 | <img ng-src="./img/contado.png" alt=""> | 62 | <img ng-src="./img/contado.png" alt=""> | 
| 61 | <p class="m-0">Contado</p> | 63 | <p class="m-0">Contado</p> | 
| 62 | </button> | 64 | </button> | 
| 63 | </div> | 65 | </div> | 
| 64 | <div class="col-6 col-sm-4"> | 66 | <div class="col-6 col-sm-4"> | 
| 65 | <button | 67 | <button | 
| 66 | type="button" | 68 | type="button" | 
| 67 | class="btn btn-sm btn-block btn-tarjeta rounded border p-1" | 69 | class="btn btn-sm btn-block btn-tarjeta rounded border p-1" | 
| 68 | ng-disabled="!estadoCuenta.situacion" | 70 | ng-disabled="!estadoCuenta.situacion" | 
| 69 | foca-focus="true" | 71 | foca-focus="true" | 
| 70 | ng-click="elegirTipoDePago({tipo: 'Cuenta Corriente', formaDePago: 2})" | 72 | ng-click="elegirTipoDePago({tipo: 'Cuenta Corriente', formaDePago: 2})" | 
| 71 | > | 73 | > | 
| 72 | <img ng-src="./img/cuentaCorriente.png" alt=""> | 74 | <img ng-src="./img/cuentaCorriente.png" alt=""> | 
| 73 | <p class="m-0">Cta. Corriente</p> | 75 | <p class="m-0">Cta. Corriente</p> | 
| 74 | </button> | 76 | </button> | 
| 75 | </div> | 77 | </div> |