From fdc60f1cc4eec3cc6b51e07481d5752ede9c5847 Mon Sep 17 00:00:00 2001 From: Pablo Marco del Pont Date: Thu, 8 Nov 2018 11:20:49 -0300 Subject: [PATCH] =?UTF-8?q?Versi=C3=B3n=20que=20no=20funciona.=20Subido=20?= =?UTF-8?q?a=20pedido=20de=20Nicol=C3=A1s.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 6 + .jshintrc | 64 +++ gulpfile.js | 95 ++++ index.html | 46 ++ package.json | 68 +++ src/etc/develop.js.ejemplo | 4 + src/js/app.js | 18 + src/js/businessService.js | 27 ++ src/js/controller.js | 621 +++++++++++++++++++++++++ src/js/route.js | 7 + src/js/service.js | 56 +++ src/views/foca-crear-remito-ficha-cliente.html | 78 ++++ src/views/remito-lista.html | 25 + src/views/remito.html | 474 +++++++++++++++++++ vendor/cordovaGeolocationModule.min.js | 1 + 15 files changed, 1590 insertions(+) create mode 100644 .gitignore create mode 100644 .jshintrc create mode 100644 gulpfile.js create mode 100644 index.html create mode 100644 package.json create mode 100644 src/etc/develop.js.ejemplo create mode 100644 src/js/app.js create mode 100644 src/js/businessService.js create mode 100644 src/js/controller.js create mode 100644 src/js/route.js create mode 100644 src/js/service.js create mode 100644 src/views/foca-crear-remito-ficha-cliente.html create mode 100644 src/views/remito-lista.html create mode 100644 src/views/remito.html create mode 100644 vendor/cordovaGeolocationModule.min.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..76a3502 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/dist +package-lock\.json +/src/etc/develop.js + +tmp/ diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..d8cbb07 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,64 @@ +{ + /* + * ENVIRONMENTS + * ================= + */ + + // Define globals exposed by modern browsers. + "browser": true, + + // Define globals exposed by jQuery. + "jquery": true, + + // Define globals exposed by Node.js. + "node": true, + + // Allow ES6. + "esversion": 6, + + /* + * ENFORCING OPTIONS + * ================= + */ + + // Force all variable names to use either camelCase style or UPPER_CASE + // with underscores. + "camelcase": true, + + // Prohibit use of == and != in favor of === and !==. + "eqeqeq": true, + + // Enforce tab width of 2 spaces. + "indent": 4, + + // Prohibit use of a variable before it is defined. + "latedef": false, + + // Enforce line length to 100 characters + "maxlen": 100, + + // Require capitalized names for constructor functions. + "newcap": true, + + // Enforce use of single quotation marks for strings. + "quotmark": "single", + + // Enforce placing 'use strict' at the top function scope + "strict": false, + + // Prohibit use of explicitly undeclared variables. + "undef": true, + + // Warn when variables are defined but never used. + "unused": true, + + // Para que funcione en angular + "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], + /* + * RELAXING OPTIONS + * ================= + */ + + // Suppress warnings about == null comparisons. + "eqnull": true +} diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..43da736 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,95 @@ +const templateCache = require('gulp-angular-templatecache'); +const clean = require('gulp-clean'); +const concat = require('gulp-concat'); +const htmlmin = require('gulp-htmlmin'); +const rename = require('gulp-rename'); +const uglify = require('gulp-uglify'); +const gulp = require('gulp'); +const pump = require('pump'); +const jshint = require('gulp-jshint'); +const replace = require('gulp-replace'); +const connect = require('gulp-connect'); + +var paths = { + srcJS: 'src/js/*.js', + srcViews: 'src/views/*.html', + tmp: 'tmp', + dist: 'dist/' +}; + +gulp.task('templates', ['clean'], function() { + return pump( + [ + gulp.src(paths.srcViews), + htmlmin(), + templateCache('views.js', { + module: 'focaCrearRemito', + root: '' + }), + gulp.dest(paths.tmp) + ] + ); +}); + +gulp.task('uglify', ['templates'], function() { + return pump( + [ + gulp.src([ + paths.srcJS, + 'tmp/views.js' + ]), + concat('foca-crear-remito.js'), + replace('src/views/', ''), + gulp.dest(paths.tmp), + rename('foca-crear-remito.min.js'), + uglify(), + replace('"ngRoute","ui.bootstrap","focaModalVendedores","focaBusquedaProductos",'+ + '"focaModalProveedor","focaBusquedaCliente","focaModalPrecioCondicion",'+ + '"focaModalFlete","focaDirectivas","focaModal","focaModalDomicilio",'+ + '"focaModalMoneda","focaModalCotizacion","focaSeguimiento","angular-ladda",'+ + '"cordovaGeolocationModule"', ''), + gulp.dest(paths.dist) + ] + ); +}); + +gulp.task('clean', function(){ + return gulp.src(['tmp', 'dist'], {read: false}) + .pipe(clean()); +}); + +gulp.task('pre-commit', function() { + return pump( + [ + gulp.src(paths.srcJS), + jshint('.jshintrc'), + jshint.reporter('default'), + jshint.reporter('fail') + ] + ); + + gulp.start('uglify'); +}); + +gulp.task('webserver', function() { + pump [ + connect.server({port: 3300, host: '0.0.0.0'}) + ] +}); + +gulp.task('clean-post-install', function() { + return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', + 'index.html'], {read: false}) + .pipe(clean()); +}); + +gulp.task('default', ['webserver']); + +gulp.task('watch', function() { + gulp.watch([paths.srcJS, paths.srcViews], ['copy']); +}); + +gulp.task('copy', ['uglify'], function(){ + return gulp.src('dist/*.js') + .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-crear-remito/dist')); +}); diff --git a/index.html b/index.html new file mode 100644 index 0000000..aa71710 --- /dev/null +++ b/index.html @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + diff --git a/package.json b/package.json new file mode 100644 index 0000000..b5496d1 --- /dev/null +++ b/package.json @@ -0,0 +1,68 @@ +{ + "name": "foca-crear-remito", + "version": "0.0.1", + "description": "Listado y ABM nota de remitos", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "compile": "gulp uglify", + "gulp-pre-commit": "gulp pre-commit", + "postinstall": "npm run compile && gulp clean-post-install", + "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route 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 git+https://debo.suite.repo/modulos-npm/foca-directivas.git git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git git+https://debo.suite.repo/modulos-npm/foca-modal-flete git+https://debo.suite.repo/modulos-npm/foca-modal.git git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git" + }, + "pre-commit": [ + "gulp-pre-commit" + ], + "repository": { + "type": "git", + "url": "https://debo.suite.repo/modulos-npm/foca-crear-remito.git" + }, + "author": "Foca Software", + "license": "ISC", + "peerDependencies": { + "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", + "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", + "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", + "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", + "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", + "foca-seguimiento": "git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git" + }, + "devDependencies": { + "angular": "^1.7.5", + "angular-ladda": "^0.4.3", + "angular-route": "^1.7.5", + "bootstrap": "^4.1.3", + "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", + "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", + "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", + "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", + "foca-modal-cotizacion": "git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git", + "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", + "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete", + "foca-modal-moneda": "git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git", + "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", + "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", + "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", + "foca-seguimiento": "git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git", + "font-awesome": "^4.7.0", + "gulp": "^3.9.1", + "gulp-angular-templatecache": "^2.2.2", + "gulp-clean": "^0.4.0", + "gulp-concat": "^2.6.1", + "gulp-connect": "^5.6.1", + "gulp-htmlmin": "^5.0.1", + "gulp-jshint": "^2.1.0", + "gulp-rename": "^1.4.0", + "gulp-replace": "^1.0.0", + "gulp-sequence": "^1.0.0", + "gulp-uglify": "^3.0.1", + "gulp-uglify-es": "^1.0.4", + "jasmine-core": "^3.3.0", + "jquery": "^3.3.1", + "jshint": "^2.9.6", + "ladda": "1.0.6", + "pre-commit": "^1.2.2", + "pump": "^3.0.0", + "ui-bootstrap4": "^3.0.5" + } +} diff --git a/src/etc/develop.js.ejemplo b/src/etc/develop.js.ejemplo new file mode 100644 index 0000000..eea69a7 --- /dev/null +++ b/src/etc/develop.js.ejemplo @@ -0,0 +1,4 @@ +angular.module('focaCrearRemito') + .constant("API_ENDPOINT", { + 'URL': '//127.0.0.1:9000' + }); diff --git a/src/js/app.js b/src/js/app.js new file mode 100644 index 0000000..341fe24 --- /dev/null +++ b/src/js/app.js @@ -0,0 +1,18 @@ +angular.module('focaCrearRemito', [ + 'ngRoute', + 'ui.bootstrap', + 'focaModalVendedores', + 'focaBusquedaProductos', + 'focaModalProveedor', + 'focaBusquedaCliente', + 'focaModalPrecioCondicion', + 'focaModalFlete', + 'focaDirectivas', + 'focaModal', + 'focaModalDomicilio', + 'focaModalMoneda', + 'focaModalCotizacion', + 'focaSeguimiento', + 'angular-ladda', + 'cordovaGeolocationModule' +]); diff --git a/src/js/businessService.js b/src/js/businessService.js new file mode 100644 index 0000000..bd3d19e --- /dev/null +++ b/src/js/businessService.js @@ -0,0 +1,27 @@ +angular.module('focaCrearRemito') + .factory('remitoBusinessService', [ + 'crearRemitoService', + function(crearRemitoService) { + return { + addArticulos: function(articulosRemito, idRemito, cotizacion) { + for(var i = 0; i < articulosRemito.length; i++) { + delete articulosRemito[i].editCantidad; + delete articulosRemito[i].editPrecio; + articulosRemito[i].idRemito = idRemito; + articulosRemito[i].precio = articulosRemito[i].precio * cotizacion; + crearRemitoService.crearArticulosParaRemito(articulosRemito[i]); + } + }, + addEstado: function(idRemito, idVendedor) { + var date = new Date(); + var estado = { + idRemito: idRemito, + fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) + .toISOString().slice(0, 19).replace('T', ' '), + estado: 0, + idVendedor: idVendedor + }; + crearRemitoService.crearEstadoParaRemito(estado); + } + }; + }]); diff --git a/src/js/controller.js b/src/js/controller.js new file mode 100644 index 0000000..96368e2 --- /dev/null +++ b/src/js/controller.js @@ -0,0 +1,621 @@ +angular.module('focaCrearRemito') .controller('remitoController', + [ + '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', + 'focaModalService', 'focaSeguimientoService', 'remitoBusinessService', + function( + $scope, $uibModal, $location, $filter, crearRemitoService, focaModalService, + focaSeguimientoService, remitoBusinessService + ) { + $scope.botonera = [ + {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, + {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, + {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, + {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, + { + texto: 'Precios y condiciones', + accion: function() {$scope.abrirModalListaPrecio();}}, + {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, + {texto: '', accion: function() {}}, + {texto: '', accion: function() {}} + ]; + $scope.datepickerAbierto = false; + + $scope.show = false; + $scope.cargando = true; + $scope.dateOptions = { + maxDate: new Date(), + minDate: new Date(2010, 0, 1) + }; + + $scope.remito = { + vendedor: {}, + cliente: {}, + proveedor: {}, + domicilio: {dom: ''}, + moneda: {}, + cotizacion: {} + }; + var monedaPorDefecto; + //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' + crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { + monedaPorDefecto = { + id: res.data[0].ID, + detalle: res.data[0].DETALLE, + simbolo: res.data[0].SIMBOLO, + cotizaciones: res.data[0].cotizaciones + }; + addCabecera('Moneda:', monedaPorDefecto.detalle); + addCabecera('Fecha cotizacion:', + new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); + addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); + $scope.remito.moneda = monedaPorDefecto; + $scope.remito.cotizacion = monedaPorDefecto.cotizaciones[0]; + }); + + $scope.cabecera = []; + $scope.showCabecera = true; + + $scope.now = new Date(); + $scope.puntoVenta = Math.round(Math.random() * 10000); + $scope.comprobante = Math.round(Math.random() * 1000000); + + $scope.articulosTabla = []; + $scope.idLista = undefined; + //La pantalla solo se usa para cargar remitos + //var remitoTemp = crearRemitoService.getRemito(); + + crearRemitoService.getPrecioCondicion().then( + function(res) { + $scope.precioCondiciones = res.data; + } + ); + //La pantalla solo se usa para cargar remitos + // if (remitoTemp !== undefined) { + // remitoTemp.fechaCarga = new Date(remitoTemp.fechaCarga); + // $scope.remito = remitoTemp; + // $scope.remito.flete = ($scope.remito.flete).toString(); + // $scope.remito.bomba = ($scope.remito.bomba).toString(); + // $scope.idLista = $scope.remito.precioCondicion; + // crearRemitoService + // .getArticulosByIdRemito($scope.remito.id).then( + // function(res) { + // $scope.articulosTabla = res.data; + // } + // ); + //TODO DOMICILIOS QUE SE CARGAN AL EDITAR REMITO + //(NO REQUERIDO EN ESTA VERSION) + // crearRemitoService.getDomiciliosByIdRemito($scope.remito.id).then( + // function(res) { + // $scope.remito.domicilio = res.data; + // } + // ); + // } else { + // $scope.remito.fechaCarga = new Date(); + // $scope.remito.bomba = '0'; + // $scope.remito.flete = '0'; + // $scope.idLista = undefined; + // } + //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO + // $scope.addNewDom = function() { + // $scope.remito.domicilio.push({ 'id': 0 }); + // }; + // $scope.removeNewChoice = function(choice) { + // if ($scope.remito.domicilio.length > 1) { + // $scope.remito.domicilio.splice($scope.remito.domicilio.findIndex( + // function(c) { + // return c.$$hashKey === choice.$$hashKey; + // } + // ), 1); + // } + // }; + + $scope.crearRemito = function() { + if(!$scope.remito.vendedor.codigo) { + focaModalService.alert('Ingrese Vendedor'); + return; + } else if(!$scope.remito.cliente.cod) { + focaModalService.alert('Ingrese Cliente'); + return; + } else if(!$scope.remito.proveedor.codigo) { + focaModalService.alert('Ingrese Proveedor'); + return; + } else if(!$scope.remito.moneda.id) { + focaModalService.alert('Ingrese Moneda'); + return; + } else if(!$scope.remito.cotizacion.ID) { + focaModalService.alert('Ingrese Cotización'); + return; + } else if(!$scope.plazosPagos) { + focaModalService.alert('Ingrese Precios y Condiciones'); + return; + } else if( + $scope.remito.flete === undefined || $scope.remito.flete === null) + { + focaModalService.alert('Ingrese Flete'); + return; + } else if(!$scope.remito.domicilio.id) { + focaModalService.alert('Ingrese Domicilio'); + return; + } else if($scope.articulosTabla.length === 0) { + focaModalService.alert('Debe cargar al menos un articulo'); + return; + } + var date = new Date(); + var remito = { + id: 0, + fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) + .toISOString().slice(0, 19).replace('T', ' '), + idVendedor: $scope.remito.vendedor.codigo, + idCliente: $scope.remito.cliente.cod, + nombreCliente: $scope.remito.cliente.nom, + cuitCliente: $scope.remito.cliente.cuit, + idProveedor: $scope.remito.proveedor.codigo, + idDomicilio: $scope.remito.domicilio.id, + idCotizacion: $scope.remito.cotizacion.ID, + cotizacion: $scope.remito.cotizacion.COTIZACION, + flete: $scope.remito.flete, + fob: $scope.remito.fob, + bomba: $scope.remito.bomba, + kilometros: $scope.remito.kilometros, + estado: 0, + total: $scope.getTotal() + }; + crearRemitoService.crearRemito(remito).then( + function(data) { + remitoBusinessService.addArticulos($scope.articulosTabla, + data.data.id, $scope.remito.cotizacion.COTIZACION); + focaSeguimientoService.guardarPosicion('crear nota remito', ''); + var plazos = $scope.plazosPagos; + for(var j = 0; j < plazos.length; j++) { + var json = { + idRemito: data.data.id, + dias: plazos[j].dias + }; + crearRemitoService.crearPlazosParaRemito(json); + } + remitoBusinessService.addEstado(data.data.id, + $scope.remito.vendedor.codigo); + + focaModalService.alert('Nota remito creada'); + $scope.cabecera = []; + addCabecera('Moneda:', $scope.remito.moneda.detalle); + addCabecera( + 'Fecha cotizacion:', + $filter('date')($scope.remito.cotizacion.FECHA, 'dd/MM/yyyy') + ); + addCabecera('Cotizacion:', $scope.remito.cotizacion.COTIZACION); + $scope.remito.vendedor = {}; + $scope.remito.cliente = {}; + $scope.remito.proveedor = {}; + $scope.remito.domicilio = {}; + $scope.remito.flete = null; + $scope.remito.fob = null; + $scope.remito.bomba = null; + $scope.remito.kilometros = null; + $scope.articulosTabla = []; + } + ); + }; + + $scope.seleccionarArticulo = function() { + if ($scope.idLista === undefined) { + focaModalService.alert( + 'Primero seleccione una lista de precio y condicion'); + return; + } + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Productos', + templateUrl: 'modal-busqueda-productos.html', + controller: 'modalBusquedaProductosCtrl', + resolve: { + parametroProducto: { + idLista: $scope.idLista, + cotizacion: $scope.remito.cotizacion.COTIZACION, + simbolo: $scope.remito.moneda.simbolo + } + }, + size: 'lg' + } + ); + modalInstance.result.then( + function(producto) { + var newArt = + { + id: 0, + codigo: producto.codigo, + sector: producto.sector, + sectorCodigo: producto.sector + '-' + producto.codigo, + descripcion: producto.descripcion, + item: $scope.articulosTabla.length + 1, + nombre: producto.descripcion, + precio: parseFloat(producto.precio.toFixed(4)), + costoUnitario: producto.costo, + editCantidad: false, + editPrecio: false + }; + $scope.articuloACargar = newArt; + $scope.cargando = false; + }, function() { + // funcion ejecutada cuando se cancela el modal + } + ); + }; + + $scope.seleccionarVendedor = function() { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Vendedores', + templateUrl: 'modal-vendedores.html', + controller: 'modalVendedoresCtrl', + size: 'lg' + } + ); + modalInstance.result.then( + function(vendedor) { + addCabecera('Vendedor:', vendedor.NomVen); + $scope.remito.vendedor.codigo = vendedor.CodVen; + }, function() { + + } + ); + }; + + $scope.seleccionarProveedor = function() { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Proveedor', + templateUrl: 'modal-proveedor.html', + controller: 'focaModalProveedorCtrl', + size: 'lg' + } + ); + modalInstance.result.then( + function(proveedor) { + $scope.remito.proveedor.codigo = proveedor.COD; + addCabecera('Proveedor:', proveedor.NOM); + }, function() { + + } + ); + }; + + $scope.seleccionarCliente = function() { + + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Cliente', + templateUrl: 'foca-busqueda-cliente-modal.html', + controller: 'focaBusquedaClienteModalController', + size: 'lg' + } + ); + modalInstance.result.then( + function(cliente) { + $scope.abrirModalDomicilios(cliente); + }, function() { + + } + ); + }; + + $scope.abrirModalDomicilios = function(cliente) { + var modalInstanceDomicilio = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Domicilios', + templateUrl: 'modal-domicilio.html', + controller: 'focaModalDomicilioController', + resolve: { idCliente: function() { return cliente.cod; }}, + size: 'lg', + } + ); + modalInstanceDomicilio.result.then( + function(domicilio) { + $scope.remito.domicilio.id = domicilio.nivel2; + $scope.remito.cliente = cliente; + + addCabecera('Cliente:', cliente.nom); + addCabecera('Domicilio:', domicilio.dom); + }, function() { + $scope.seleccionarCliente(); + return; + } + ); + }; + + $scope.mostrarFichaCliente = function() { + $uibModal.open( + { + ariaLabelledBy: 'Datos del Cliente', + templateUrl: 'foca-crear-remito-ficha-cliente.html', + controller: 'focaCrearRemitoFichaClienteController', + size: 'lg' + } + ); + }; + + $scope.getTotal = function() { + var total = 0; + var arrayTempArticulos = $scope.articulosTabla; + for (var i = 0; i < arrayTempArticulos.length; i++) { + total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; + } + return parseFloat(total.toFixed(2)); + }; + + $scope.getSubTotal = function() { + if($scope.articuloACargar) { + return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; + } + }; + + $scope.abrirModalListaPrecio = function() { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Precio Condición', + templateUrl: 'modal-precio-condicion.html', + controller: 'focaModalPrecioCondicionController', + size: 'lg' + } + ); + modalInstance.result.then( + function(precioCondicion) { + var cabecera = ''; + var plazosConcat = ''; + if(!Array.isArray(precioCondicion)) { + $scope.plazosPagos = precioCondicion.plazoPago; + $scope.idLista = precioCondicion.idListaPrecio; + for(var i = 0; i < precioCondicion.plazoPago.length; i++) { + plazosConcat += precioCondicion.plazoPago[i].dias + ' '; + } + cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); + } else { //Cuando se ingresan los plazos manualmente + $scope.idLista = -1; //-1, el modal productos busca todos los productos + $scope.plazosPagos = precioCondicion; + for(var j = 0; j < precioCondicion.length; j++) { + plazosConcat += precioCondicion[j].dias + ' '; + } + cabecera = 'Ingreso manual ' + plazosConcat.trim(); + } + $scope.articulosTabla = []; + addCabecera('Precios y condiciones:', cabecera); + }, function() { + + } + ); + }; + + $scope.abrirModalFlete = function() { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Flete', + templateUrl: 'modal-flete.html', + controller: 'focaModalFleteController', + size: 'lg', + resolve: { + parametrosFlete: + function() { + return { + flete: $scope.remito.flete ? '1' : + ($scope.remito.fob ? 'FOB' : + ($scope.remito.flete === undefined ? null : '0')), + bomba: $scope.remito.bomba ? '1' : + ($scope.remito.bomba === undefined ? null : '0'), + kilometros: $scope.remito.kilometros + }; + } + } + } + ); + modalInstance.result.then( + function(datos) { + $scope.remito.flete = datos.flete; + $scope.remito.fob = datos.FOB; + $scope.remito.bomba = datos.bomba; + $scope.remito.kilometros = datos.kilometros; + + addCabecera('Flete:', datos.flete ? 'Si' : + ($scope.remito.fob ? 'FOB' : 'No')); + if(datos.flete) { + addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); + addCabecera('Kilometros:', datos.kilometros); + } else { + removeCabecera('Bomba:'); + removeCabecera('Kilometros:'); + $scope.remito.fob = false; + $scope.remito.bomba = false; + $scope.remito.kilometros = null; + } + }, function() { + + } + ); + }; + + $scope.abrirModalMoneda = function() { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Moneda', + templateUrl: 'modal-moneda.html', + controller: 'focaModalMonedaController', + size: 'lg' + } + ); + modalInstance.result.then( + function(moneda) { + $scope.abrirModalCotizacion(moneda); + }, function() { + + } + ); + }; + + $scope.abrirModalCotizacion = function(moneda) { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Cotización', + templateUrl: 'modal-cotizacion.html', + controller: 'focaModalCotizacionController', + size: 'lg', + resolve: {idMoneda: function() {return moneda.ID;}} + } + ); + modalInstance.result.then( + function(cotizacion) { + var articulosTablaTemp = $scope.articulosTabla; + for(var i = 0; i < articulosTablaTemp.length; i++) { + articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * + $scope.remito.cotizacion.COTIZACION; + articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / + cotizacion.COTIZACION; + } + $scope.articulosTabla = articulosTablaTemp; + $scope.remito.moneda = { + id: moneda.ID, + detalle: moneda.DETALLE, + simbolo: moneda.SIMBOLO + }; + $scope.remito.cotizacion = { + ID: cotizacion.ID, + COTIZACION: cotizacion.COTIZACION, + FECHA: cotizacion.FECHA + }; + addCabecera('Moneda:', moneda.DETALLE); + addCabecera( + 'Fecha cotizacion:', + $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') + ); + addCabecera('Cotizacion:', cotizacion.COTIZACION); + }, function() { + + } + ); + }; + + $scope.agregarATabla = function(key) { + if(key === 13) { + if($scope.articuloACargar.cantidad === undefined || + $scope.articuloACargar.cantidad === 0 || + $scope.articuloACargar.cantidad === null ){ + focaModalService.alert('El valor debe ser al menos 1'); + return; + } + delete $scope.articuloACargar.sectorCodigo; + $scope.articulosTabla.push($scope.articuloACargar); + $scope.cargando = true; + } + }; + + $scope.quitarArticulo = function(key) { + $scope.articulosTabla.splice(key, 1); + }; + + $scope.editarArticulo = function(key, articulo) { + if(key === 13) { + if(articulo.cantidad === null || articulo.cantidad === 0 || + articulo.cantidad === undefined){ + focaModalService.alert('El valor debe ser al menos 1'); + return; + } + articulo.editCantidad = false; + articulo.editPrecio = false; + } + }; + + $scope.cambioEdit = function(articulo, propiedad) { + if(propiedad === 'cantidad') { + articulo.editCantidad = true; + } else if(propiedad === 'precio') { + articulo.editPrecio = true; + } + }; + + $scope.limpiarFlete = function() { + $scope.remito.fleteNombre = ''; + $scope.remito.chofer = ''; + $scope.remito.vehiculo = ''; + $scope.remito.kilometros = ''; + $scope.remito.costoUnitarioKmFlete = ''; + $scope.choferes = ''; + $scope.vehiculos = ''; + }; + + $scope.limpiarPantalla = function() { + $scope.limpiarFlete(); + $scope.remito.flete = '0'; + $scope.remito.bomba = '0'; + $scope.remito.precioCondicion = ''; + $scope.articulosTabla = []; + $scope.remito.vendedor.nombre = ''; + $scope.remito.cliente = {nombre: ''}; + $scope.remito.domicilio = {dom: ''}; + $scope.domiciliosCliente = []; + }; + + $scope.resetFilter = function() { + $scope.articuloACargar = {}; + $scope.cargando = true; + }; + + $scope.selectFocus = function($event) { + $event.target.select(); + }; + + $scope.salir = function() { + $location.path('/'); + }; + + function addCabecera(label, valor) { + var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); + if(propiedad.length === 1) { + propiedad[0].valor = valor; + } else { + $scope.cabecera.push({label: label, valor: valor}); + } + } + + function removeCabecera(label) { + var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); + if(propiedad.length === 1){ + $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); + } + } + } + ] +) +.controller('remitoListaCtrl', [ + '$scope', + 'crearRemitoService', + '$location', + function($scope, crearRemitoService, $location) { + crearRemitoService.obtenerRemito().then(function(datos) { + $scope.remitos = datos.data; + }); + $scope.editar = function(remito) { + crearRemitoService.setRemito(remito); + $location.path('/venta-nota-remito/abm/'); + }; + $scope.crearRemito = function() { + crearRemitoService.clearRemito(); + $location.path('/venta-nota-remito/abm/'); + }; + } +]) +.controller('focaCrearRemitoFichaClienteController', [ + '$scope', + 'crearRemitoService', + '$location', + function($scope, crearRemitoService, $location) { + crearRemitoService.obtenerRemito().then(function(datos) { + $scope.remitos = datos.data; + }); + $scope.editar = function(remito) { + crearRemitoService.setRemito(remito); + $location.path('/venta-nota-remito/abm/'); + }; + $scope.crearRemito = function() { + crearRemitoService.clearRemito(); + $location.path('/venta-nota-remito/abm/'); + }; + } +]); diff --git a/src/js/route.js b/src/js/route.js new file mode 100644 index 0000000..870a87f --- /dev/null +++ b/src/js/route.js @@ -0,0 +1,7 @@ +angular.module('focaCrearRemito') + .config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/venta-nota-remito/crear', { + controller: 'remitoController', + templateUrl: 'src/views/nota-remito.html' + }); + }]); diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..d821bd9 --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,56 @@ +angular.module('focaCrearRemito') + .service('crearRemitoService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { + var route = API_ENDPOINT.URL; + return { + crearRemito: function(remito) { + return $http.post(route + '/nota-remito', {remito: remito}); + }, + obtenerRemito: function() { + return $http.get(route +'/nota-remito'); + }, + setRemito: function(remito) { + this.remito = remito; + }, + clearRemito: function() { + this.remito = undefined; + }, + getRemito: function() { + return this.remito; + }, + getArticulosByIdRemito: function(id) { + return $http.get(route+'/articulos/nota-remito/'+id); + }, + crearArticulosParaRemito: function(articuloRemito) { + return $http.post(route + '/articulos/nota-remito', + {articuloRemito: articuloRemito}); + }, + getDomiciliosByIdRemito: function(id) { + return $http.get(route +'/nota-remito/'+id+'/domicilios'); + }, + getDomiciliosByIdCliente: function(id) { + var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) + return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); + }, + getPrecioCondicion: function() { + return $http.get(route + '/precio-condicion'); + }, + getPrecioCondicionById: function(id) { + return $http.get(route + '/precio-condicion/' + id); + }, + getPlazoPagoByPrecioCondicion: function(id) { + return $http.get(route + '/plazo-pago/precio-condicion/'+ id); + }, + crearFlete: function(flete) { + return $http.post(route + '/flete', {flete : flete}); + }, + crearPlazosParaRemito: function(plazos) { + return $http.post(route + '/plazo-pago/nota-remito', plazos); + }, + getCotizacionByIdMoneda: function(id) { + return $http.get(route + '/moneda/' + id); + }, + crearEstadoParaRemito: function(estado) { + return $http.post(route + '/estado', {estado: estado}); + } + }; + }]); diff --git a/src/views/foca-crear-remito-ficha-cliente.html b/src/views/foca-crear-remito-ficha-cliente.html new file mode 100644 index 0000000..b6b831a --- /dev/null +++ b/src/views/foca-crear-remito-ficha-cliente.html @@ -0,0 +1,78 @@ + + + diff --git a/src/views/remito-lista.html b/src/views/remito-lista.html new file mode 100644 index 0000000..905bb2e --- /dev/null +++ b/src/views/remito-lista.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + +
CódigoVendedorClienteProveedorTotal
+ + +
diff --git a/src/views/remito.html b/src/views/remito.html new file mode 100644 index 0000000..c64dca8 --- /dev/null +++ b/src/views/remito.html @@ -0,0 +1,474 @@ +
+
+
+
+
+
+
+
+
REMITO
+
+
Nº {{puntoVenta}}-{{comprobante}} +
+
+ Fecha: + + + +
+
+
+
+ + +
+ + + + +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#CódigoDescripciónCantidadPrecio UnitarioSubTotal + +
+ + + + + + + + + + +
+ + + + + + + + + + + +
+ +
+ Items: + + +

Total:

+
+

{{getTotal() | currency: remito.moneda.simbolo}}

+
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
# +
+
Código
+
Descripción
+
+
+
Cantidad
+
P. Uni.
+
Subtotal
+
+
+   +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ + +
+
+
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ + +
+
+
+ +
+ +
+ +
+ Cantidad Items: + + +

Total:

+
+

{{getTotal() | currency: remito.moneda.simbolo}}

+
+
+
+
+
+
+ + +
+
+
+
+
+
+ Salir + Guardar +
+
+
diff --git a/vendor/cordovaGeolocationModule.min.js b/vendor/cordovaGeolocationModule.min.js new file mode 100644 index 0000000..4a78dd7 --- /dev/null +++ b/vendor/cordovaGeolocationModule.min.js @@ -0,0 +1 @@ +var cordovaGeolocationModule=angular.module("cordovaGeolocationModule",[]);cordovaGeolocationModule.constant("cordovaGeolocationConstants",{apiVersion:"1.0.0",cordovaVersion:">=3.4.0"});cordovaGeolocationModule.factory("cordovaGeolocationService",["$rootScope","$log","cordovaGeolocationConstants",function(e,t,n){return{apiVersion:function(){t.debug("cordovaGeolocationService.apiVersion.");return n.apiVersion},cordovaVersion:function(){t.debug("cordovaGeolocationService.cordovaVersion.");return n.cordovaVersion},checkGeolocationAvailability:function(){t.debug("cordovaGeolocationService.checkGeolocationAvailability.");if(!navigator.geolocation){t.warn("Geolocation API is not available.");return false}return true},getCurrentPosition:function(n,r,i){t.debug("cordovaGeolocationService.getCurrentPosition.");if(!this.checkGeolocationAvailability()){return}navigator.geolocation.getCurrentPosition(function(t){e.$apply(n(t))},function(t){e.$apply(r(t))},i)},watchPosition:function(n,r,i){t.debug("cordovaGeolocationService.watchPosition.");if(!this.checkGeolocationAvailability()){return}return navigator.geolocation.watchPosition(function(t){e.$apply(n(t))},function(t){e.$apply(r(t))},i)},clearWatch:function(e){t.debug("cordovaGeolocationService.clearWatch.");if(!this.checkGeolocationAvailability()){return}navigator.geolocation.clearWatch(e)}}}]) \ No newline at end of file -- 1.9.1