Commit 60727f1f8dd99bc5e1ad1bb90ba95d86fe6171d9

Authored by Eric Fernandez
Exists in master

Merge branch 'master' of https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido

# Conflicts:
#	src/js/controller.js
1 const templateCache = require('gulp-angular-templatecache'); 1 const templateCache = require('gulp-angular-templatecache');
2 const clean = require('gulp-clean'); 2 const clean = require('gulp-clean');
3 const concat = require('gulp-concat'); 3 const concat = require('gulp-concat');
4 const htmlmin = require('gulp-htmlmin'); 4 const htmlmin = require('gulp-htmlmin');
5 const rename = require('gulp-rename'); 5 const rename = require('gulp-rename');
6 const uglify = require('gulp-uglify'); 6 const uglify = require('gulp-uglify');
7 const gulp = require('gulp'); 7 const gulp = require('gulp');
8 const pump = require('pump'); 8 const pump = require('pump');
9 const jshint = require('gulp-jshint'); 9 const jshint = require('gulp-jshint');
10 const replace = require('gulp-replace'); 10 const replace = require('gulp-replace');
11 const connect = require('gulp-connect'); 11 const connect = require('gulp-connect');
12 12
13 var paths = { 13 var paths = {
14 srcJS: 'src/js/*.js', 14 srcJS: 'src/js/*.js',
15 srcViews: 'src/views/*.html', 15 srcViews: 'src/views/*.html',
16 tmp: 'tmp', 16 tmp: 'tmp',
17 dist: 'dist/' 17 dist: 'dist/'
18 }; 18 };
19 19
20 gulp.task('templates', ['clean'], function() { 20 gulp.task('templates', ['clean'], function() {
21 return pump( 21 return pump(
22 [ 22 [
23 gulp.src(paths.srcViews), 23 gulp.src(paths.srcViews),
24 htmlmin(), 24 htmlmin(),
25 templateCache('views.js', { 25 templateCache('views.js', {
26 module: 'focaCrearNotaPedido', 26 module: 'focaCrearNotaPedido',
27 root: '' 27 root: ''
28 }), 28 }),
29 gulp.dest(paths.tmp) 29 gulp.dest(paths.tmp)
30 ] 30 ]
31 ); 31 );
32 }); 32 });
33 33
34 gulp.task('uglify', ['templates'], function() { 34 gulp.task('uglify', ['templates'], function() {
35 return pump( 35 return pump(
36 [ 36 [
37 gulp.src([ 37 gulp.src([
38 paths.srcJS, 38 paths.srcJS,
39 'tmp/views.js' 39 'tmp/views.js'
40 ]), 40 ]),
41 concat('foca-crear-nota-pedido.js'), 41 concat('foca-crear-nota-pedido.js'),
42 replace('src/views/', ''), 42 replace('src/views/', ''),
43 gulp.dest(paths.tmp), 43 gulp.dest(paths.tmp),
44 rename('foca-crear-nota-pedido.min.js'), 44 rename('foca-crear-nota-pedido.min.js'),
45 uglify(), 45 uglify(),
46 replace('"ngRoute","ui.bootstrap","focaModalVendedores","focaBusquedaProductos",'+ 46 replace('"ngRoute","ui.bootstrap","focaModalVendedores","focaBusquedaProductos",'+
47 '"focaModalProveedor","focaBusquedaCliente","focaModalPrecioCondicion",'+ 47 '"focaModalProveedor","focaBusquedaCliente","focaModalPrecioCondicion",'+
48 '"focaModalFlete","focaDirectivas","focaModal","focaModalDomicilio",'+ 48 '"focaModalFlete","focaDirectivas","focaModal","focaModalDomicilio",'+
49 '"angular-ladda","focaModalMoneda","focaModalCotizacion"', ''), 49 '"angular-ladda","focaModalMoneda","focaModalCotizacion"', ''),
50 gulp.dest(paths.dist) 50 gulp.dest(paths.dist)
51 ] 51 ]
52 ); 52 );
53 }); 53 });
54 54
55 gulp.task('clean', function(){ 55 gulp.task('clean', function(){
56 return gulp.src(['tmp', 'dist'], {read: false}) 56 return gulp.src(['tmp', 'dist'], {read: false})
57 .pipe(clean()); 57 .pipe(clean());
58 }); 58 });
59 59
60 gulp.task('pre-commit', function() { 60 gulp.task('pre-commit', function() {
61 return pump( 61 return pump(
62 [ 62 [
63 gulp.src(paths.srcJS), 63 gulp.src(paths.srcJS),
64 jshint('.jshintrc'), 64 jshint('.jshintrc'),
65 jshint.reporter('default'), 65 jshint.reporter('default'),
66 jshint.reporter('fail') 66 jshint.reporter('fail')
67 ] 67 ]
68 ); 68 );
69 69
70 gulp.start('uglify'); 70 gulp.start('uglify');
71 }); 71 });
72 72
73 gulp.task('webserver', function() { 73 gulp.task('webserver', function() {
74 pump [ 74 pump [
75 connect.server({port: 3300, host: '0.0.0.0'}) 75 connect.server({port: 3300, host: '0.0.0.0'})
76 ] 76 ]
77 }); 77 });
78 78
79 gulp.task('clean-post-install', function() { 79 gulp.task('clean-post-install', function() {
80 return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', 80 return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js',
81 'index.html'], {read: false}) 81 'index.html'], {read: false})
82 .pipe(clean()); 82 .pipe(clean());
83 }); 83 });
84 84
85 gulp.task('default', ['webserver']); 85 gulp.task('default', ['webserver']);
86 86
87 gulp.task('watch', function() { 87 gulp.task('watch', function() {
88 gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); 88 gulp.watch([paths.srcJS, paths.srcViews], ['uglify']);
89 }); 89 });
90 90
1 <html ng-app="focaCrearNotaPedido"> 1 <html ng-app="focaCrearNotaPedido">
2 <head> 2 <head>
3 <meta charset="UTF-8"/> 3 <meta charset="UTF-8"/>
4 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 4 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
5 5
6 <!--CSS--> 6 <!--CSS-->
7 <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> 7 <link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/>
8 <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/> 8 <link href="node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
9 <link href="node_modules/ladda/dist/ladda-themeless.min.css" rel="stylesheet"> 9 <link href="node_modules/ladda/dist/ladda-themeless.min.css" rel="stylesheet">
10 10
11 <!--VENDOR JS--> 11 <!--VENDOR JS-->
12 <script src="node_modules/jquery/dist/jquery.min.js"></script> 12 <script src="node_modules/jquery/dist/jquery.min.js"></script>
13 <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> 13 <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
14 <script src="node_modules/angular/angular.min.js"></script> 14 <script src="node_modules/angular/angular.min.js"></script>
15 <script src="node_modules/angular-route/angular-route.min.js"></script> 15 <script src="node_modules/angular-route/angular-route.min.js"></script>
16 <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> 16 <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script>
17 <script src="node_modules/ladda/dist/spin.min.js"></script> 17 <script src="node_modules/ladda/dist/spin.min.js"></script>
18 <script src="node_modules/ladda/dist/ladda.min.js"></script> 18 <script src="node_modules/ladda/dist/ladda.min.js"></script>
19 <script src="node_modules/angular-ladda/dist/angular-ladda.min.js"></script> 19 <script src="node_modules/angular-ladda/dist/angular-ladda.min.js"></script>
20 20
21 <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> 21 <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script>
22 <script src="node_modules/foca-modal-vendedores/dist/foca-modal-vendedores.min.js"></script> 22 <script src="node_modules/foca-modal-vendedores/dist/foca-modal-vendedores.min.js"></script>
23 <script src="node_modules/foca-modal-busqueda-productos/dist/foca-busqueda-productos.min.js"></script> 23 <script src="node_modules/foca-modal-busqueda-productos/dist/foca-busqueda-productos.min.js"></script>
24 <script src="node_modules/foca-modal-proveedor/dist/foca-modal-proveedor.min.js"></script> 24 <script src="node_modules/foca-modal-proveedor/dist/foca-modal-proveedor.min.js"></script>
25 <script src="node_modules/foca-busqueda-cliente/dist/foca-busqueda-cliente.min.js"></script> 25 <script src="node_modules/foca-busqueda-cliente/dist/foca-busqueda-cliente.min.js"></script>
26 <script src="node_modules/foca-modal-precio-condiciones/dist/foca-modal-precio-condiciones.min.js"></script> 26 <script src="node_modules/foca-modal-precio-condiciones/dist/foca-modal-precio-condiciones.min.js"></script>
27 <script src="node_modules/foca-modal-flete/dist/foca-modal-flete.min.js"></script> 27 <script src="node_modules/foca-modal-flete/dist/foca-modal-flete.min.js"></script>
28 <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> 28 <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script>
29 <script src="node_modules/foca-modal-domicilio/dist/foca-modal-domicilios.min.js"></script> 29 <script src="node_modules/foca-modal-domicilio/dist/foca-modal-domicilios.min.js"></script>
30 <script src="node_modules/foca-modal-moneda/dist/foca-modal-moneda.min.js"></script> 30 <script src="node_modules/foca-modal-moneda/dist/foca-modal-moneda.min.js"></script>
31 <script src="node_modules/foca-modal-cotizacion/dist/foca-modal-cotizacion.min.js"></script> 31 <script src="node_modules/foca-modal-cotizacion/dist/foca-modal-cotizacion.min.js"></script>
32
32 33 <script src="src/js/app.js"></script>
33 <script src="src/js/app.js"></script> 34 <script src="src/js/controller.js"></script>
34 <script src="src/js/controller.js"></script> 35 <script src="src/js/service.js"></script>
35 <script src="src/js/service.js"></script> 36 <script src="src/js/route.js"></script>
36 <script src="src/js/route.js"></script> 37
37 38 <script src="src/etc/develop.js"></script>
38 <script src="src/etc/develop.js"></script> 39 </head>
39 </head> 40 <body>
40 <body> 41 <div ng-view class="container-fluid"></div>
41 <div ng-view class="container-fluid"></div> 42 </body>
42 </body> 43 </html>
43 </html> 44
1 { 1 {
2 "name": "foca-crear-nota-pedido", 2 "name": "foca-crear-nota-pedido",
3 "version": "0.0.1", 3 "version": "0.0.1",
4 "description": "Listado y ABM nota de pedidos", 4 "description": "Listado y ABM nota de pedidos",
5 "main": "index.js", 5 "main": "index.js",
6 "scripts": { 6 "scripts": {
7 "test": "echo \"Error: no test specified\" && exit 1", 7 "test": "echo \"Error: no test specified\" && exit 1",
8 "compile": "gulp uglify", 8 "compile": "gulp uglify",
9 "gulp-pre-commit": "gulp pre-commit", 9 "gulp-pre-commit": "gulp pre-commit",
10 "postinstall": "npm run compile && gulp clean-post-install", 10 "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 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-modal-moneda.git git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git" 11 "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-modal-moneda.git git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git"
12 }, 12 },
13 "pre-commit": [ 13 "pre-commit": [
14 "gulp-pre-commit" 14 "gulp-pre-commit"
15 ], 15 ],
16 "repository": { 16 "repository": {
17 "type": "git", 17 "type": "git",
18 "url": "https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido.git" 18 "url": "https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido.git"
19 }, 19 },
20 "author": "Foca Software", 20 "author": "Foca Software",
21 "license": "ISC", 21 "license": "ISC",
22 "peerDependencies": { 22 "peerDependencies": {
23 "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", 23 "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git",
24 "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", 24 "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git",
25 "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", 25 "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos",
26 "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", 26 "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git",
27 "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git" 27 "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git"
28 },
28 }, 29 "devDependencies": {
29 "devDependencies": { 30 "angular": "^1.7.5",
30 "angular": "^1.7.5", 31 "angular-ladda": "^0.4.3",
31 "angular-ladda": "^0.4.3", 32 "angular-route": "^1.7.5",
32 "angular-route": "^1.7.5", 33 "bootstrap": "^4.1.3",
33 "bootstrap": "^4.1.3", 34 "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git",
34 "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", 35 "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git",
35 "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", 36 "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git",
36 "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", 37 "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos",
37 "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", 38 "foca-modal-cotizacion": "git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git",
38 "foca-modal-cotizacion": "git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git", 39 "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git",
39 "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", 40 "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete",
40 "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete", 41 "foca-modal-moneda": "git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git",
41 "foca-modal-moneda": "git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git", 42 "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git",
42 "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", 43 "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git",
43 "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", 44 "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git",
44 "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", 45 "font-awesome": "^4.7.0",
46 "gulp": "^3.9.1",
45 "font-awesome": "^4.7.0", 47 "gulp-angular-templatecache": "^2.2.2",
46 "gulp": "^3.9.1", 48 "gulp-clean": "^0.4.0",
47 "gulp-angular-templatecache": "^2.2.2", 49 "gulp-concat": "^2.6.1",
48 "gulp-clean": "^0.4.0", 50 "gulp-connect": "^5.6.1",
49 "gulp-concat": "^2.6.1", 51 "gulp-htmlmin": "^5.0.1",
50 "gulp-connect": "^5.6.1", 52 "gulp-jshint": "^2.1.0",
51 "gulp-htmlmin": "^5.0.1", 53 "gulp-rename": "^1.4.0",
52 "gulp-jshint": "^2.1.0", 54 "gulp-replace": "^1.0.0",
53 "gulp-rename": "^1.4.0", 55 "gulp-sequence": "^1.0.0",
54 "gulp-replace": "^1.0.0", 56 "gulp-uglify": "^3.0.1",
55 "gulp-sequence": "^1.0.0", 57 "gulp-uglify-es": "^1.0.4",
56 "gulp-uglify": "^3.0.1", 58 "jasmine-core": "^3.3.0",
57 "gulp-uglify-es": "^1.0.4", 59 "jquery": "^3.3.1",
58 "jasmine-core": "^3.3.0", 60 "jshint": "^2.9.6",
59 "jquery": "^3.3.1", 61 "ladda": "1.0.6",
60 "jshint": "^2.9.6", 62 "pre-commit": "^1.2.2",
61 "ladda": "1.0.6", 63 "pump": "^3.0.0",
62 "pre-commit": "^1.2.2", 64 "ui-bootstrap4": "^3.0.5"
63 "pump": "^3.0.0", 65 }
64 "ui-bootstrap4": "^3.0.5" 66 }
65 } 67
1 angular.module('focaCrearNotaPedido', [ 1 angular.module('focaCrearNotaPedido', [
2 'ngRoute', 2 'ngRoute',
3 'ui.bootstrap', 3 'ui.bootstrap',
4 'focaModalVendedores', 4 'focaModalVendedores',
5 'focaBusquedaProductos', 5 'focaBusquedaProductos',
6 'focaModalProveedor', 6 'focaModalProveedor',
7 'focaBusquedaCliente', 7 'focaBusquedaCliente',
8 'focaModalPrecioCondicion', 8 'focaModalPrecioCondicion',
9 'focaModalFlete', 9 'focaModalFlete',
10 'focaDirectivas', 10 'focaDirectivas',
11 'focaModal', 11 'focaModal',
12 'focaModalDomicilio', 12 'focaModalDomicilio',
13 'angular-ladda',
14 'focaModalMoneda', 13 'angular-ladda',
15 'focaModalCotizacion' 14 'focaModalMoneda',
15 'focaModalCotizacion'
16 ]);
src/js/controller.js
1 angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', 1 angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
2 [ 2 [
3 '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', 3 '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService',
4 'focaModalService', 4 'focaModalService',
5 function( 5 function(
6 $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService 6 $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService
7 ) {
7 ) { 8 $scope.botonera = [
8 $scope.botonera = [ 9 {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}},
9 {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, 10 {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}},
10 {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, 11 {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}},
11 {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, 12 {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}},
12 {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, 13 {
13 { 14 texto: 'Precios y condiciones',
14 texto: 'Precios y condiciones', 15 accion: function() {$scope.abrirModalListaPrecio();}},
15 accion: function() {$scope.abrirModalListaPrecio();}}, 16 {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}},
16 {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, 17 {texto: '', accion: function() {}},
17 {texto: '', accion: function() {}}, 18 {texto: '', accion: function() {}}
18 {texto: '', accion: function() {}} 19 ];
19 ]; 20 $scope.datepickerAbierto = false;
20 $scope.datepickerAbierto = false; 21
21 22 $scope.show = false;
22 $scope.show = false; 23 $scope.cargando = true;
23 $scope.cargando = true; 24 $scope.dateOptions = {
24 $scope.dateOptions = { 25 maxDate: new Date(),
25 maxDate: new Date(), 26 minDate: new Date(2010, 0, 1)
26 minDate: new Date(2010, 0, 1) 27 };
27 }; 28
28 29 $scope.notaPedido = {
29 $scope.notaPedido = { 30 vendedor: {},
30 vendedor: {}, 31 cliente: {},
31 cliente: {}, 32 proveedor: {},
32 proveedor: {}, 33 domicilio: {dom: ''},
33 domicilio: {dom: ''}, 34 moneda: {},
34 moneda: {}, 35 cotizacion: {}
35 cotizacion: {} 36 };
36 }; 37 var monedaPorDefecto;
37 var monedaPorDefecto; 38 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
38 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' 39 crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) {
39 crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { 40 monedaPorDefecto = {
40 monedaPorDefecto = { 41 id: res.data[0].ID,
41 id: res.data[0].ID, 42 detalle: res.data[0].DETALLE,
42 detalle: res.data[0].DETALLE, 43 simbolo: res.data[0].SIMBOLO,
43 simbolo: res.data[0].SIMBOLO, 44 cotizaciones: res.data[0].cotizaciones
44 cotizaciones: res.data[0].cotizaciones 45 };
45 }; 46 addCabecera('Moneda:', monedaPorDefecto.detalle);
46 addCabecera('Moneda:', monedaPorDefecto.detalle); 47 addCabecera('Fecha cotizacion:',
47 addCabecera('Fecha cotizacion:', 48 new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString());
48 new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); 49 addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION);
49 addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); 50 $scope.notaPedido.moneda = monedaPorDefecto;
50 $scope.notaPedido.moneda = monedaPorDefecto; 51 $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0];
51 $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; 52 });
52 }); 53
53 54 $scope.cabecera = [];
54 $scope.cabecera = []; 55 $scope.showCabecera = true;
55 $scope.showCabecera = true; 56
56 57 $scope.now = new Date();
57 $scope.now = new Date(); 58 $scope.puntoVenta = Math.round(Math.random() * 10000);
58 $scope.puntoVenta = Math.round(Math.random() * 10000); 59 $scope.comprobante = Math.round(Math.random() * 1000000);
59 $scope.comprobante = Math.round(Math.random() * 1000000); 60
60 61 $scope.articulosTabla = [];
61 $scope.articulosTabla = []; 62 $scope.idLista = undefined;
62 $scope.idLista = undefined; 63 //La pantalla solo se usa para cargar pedidos
63 //La pantalla solo se usa para cargar pedidos 64 //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido();
64 //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); 65
65 66 crearNotaPedidoService.getPrecioCondicion().then(
66 crearNotaPedidoService.getPrecioCondicion().then( 67 function(res) {
67 function(res) { 68 $scope.precioCondiciones = res.data;
68 $scope.precioCondiciones = res.data; 69 }
69 } 70 );
70 ); 71 //La pantalla solo se usa para cargar pedidos
71 //La pantalla solo se usa para cargar pedidos 72 // if (notaPedidoTemp !== undefined) {
72 // if (notaPedidoTemp !== undefined) { 73 // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga);
73 // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); 74 // $scope.notaPedido = notaPedidoTemp;
74 // $scope.notaPedido = notaPedidoTemp; 75 // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString();
75 // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); 76 // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString();
76 // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); 77 // $scope.idLista = $scope.notaPedido.precioCondicion;
77 // $scope.idLista = $scope.notaPedido.precioCondicion; 78 // crearNotaPedidoService
78 // crearNotaPedidoService 79 // .getArticulosByIdNotaPedido($scope.notaPedido.id).then(
79 // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( 80 // function(res) {
80 // function(res) { 81 // $scope.articulosTabla = res.data;
81 // $scope.articulosTabla = res.data; 82 // }
82 // } 83 // );
83 // ); 84 //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO
84 //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO 85 //(NO REQUERIDO EN ESTA VERSION)
85 //(NO REQUERIDO EN ESTA VERSION) 86 // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then(
86 // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( 87 // function(res) {
87 // function(res) { 88 // $scope.notaPedido.domicilio = res.data;
88 // $scope.notaPedido.domicilio = res.data; 89 // }
89 // } 90 // );
90 // ); 91 // } else {
91 // } else { 92 // $scope.notaPedido.fechaCarga = new Date();
92 // $scope.notaPedido.fechaCarga = new Date(); 93 // $scope.notaPedido.bomba = '0';
93 // $scope.notaPedido.bomba = '0'; 94 // $scope.notaPedido.flete = '0';
94 // $scope.notaPedido.flete = '0'; 95 // $scope.idLista = undefined;
95 // $scope.idLista = undefined; 96 // }
96 // } 97 //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO
97 //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO 98 // $scope.addNewDom = function() {
98 // $scope.addNewDom = function() { 99 // $scope.notaPedido.domicilio.push({ 'id': 0 });
99 // $scope.notaPedido.domicilio.push({ 'id': 0 }); 100 // };
100 // }; 101 // $scope.removeNewChoice = function(choice) {
101 // $scope.removeNewChoice = function(choice) { 102 // if ($scope.notaPedido.domicilio.length > 1) {
102 // if ($scope.notaPedido.domicilio.length > 1) { 103 // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex(
103 // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( 104 // function(c) {
104 // function(c) { 105 // return c.$$hashKey === choice.$$hashKey;
105 // return c.$$hashKey === choice.$$hashKey; 106 // }
106 // } 107 // ), 1);
107 // ), 1); 108 // }
108 // } 109 // };
109 // }; 110
110 111 $scope.crearNotaPedido = function() {
111 $scope.crearNotaPedido = function() { 112 if(!$scope.notaPedido.vendedor.codigo) {
112 if(!$scope.notaPedido.vendedor.codigo) { 113 focaModalService.alert('Ingrese Vendedor');
113 focaModalService.alert('Ingrese Vendedor'); 114 return;
114 return; 115 } else if(!$scope.notaPedido.cliente.id) {
115 } else if(!$scope.notaPedido.cliente.id) { 116 focaModalService.alert('Ingrese Cliente');
116 focaModalService.alert('Ingrese Cliente'); 117 return;
117 return; 118 } else if(!$scope.notaPedido.proveedor.codigo) {
118 } else if(!$scope.notaPedido.proveedor.codigo) { 119 focaModalService.alert('Ingrese Proveedor');
119 focaModalService.alert('Ingrese Proveedor'); 120 return;
120 return; 121 } else if(!$scope.notaPedido.moneda.id) {
121 } else if(!$scope.notaPedido.moneda.id) { 122 focaModalService.alert('Ingrese Moneda');
122 focaModalService.alert('Ingrese Moneda'); 123 return;
123 return; 124 } else if(!$scope.notaPedido.cotizacion.ID) {
124 } else if(!$scope.notaPedido.cotizacion.ID) { 125 focaModalService.alert('Ingrese Cotización');
125 focaModalService.alert('Ingrese Cotización'); 126 return;
126 return; 127 } else if(!$scope.plazosPagos) {
127 } else if(!$scope.plazosPagos) { 128 focaModalService.alert('Ingrese Precios y Condiciones');
128 focaModalService.alert('Ingrese Precios y Condiciones'); 129 return;
129 return; 130 } else if(!$scope.notaPedido.flete) {
130 } else if(!$scope.notaPedido.flete) { 131 focaModalService.alert('Ingrese Flete');
131 focaModalService.alert('Ingrese Flete'); 132 return;
132 return; 133 } else if(!$scope.notaPedido.domicilio.id) {
133 } else if(!$scope.notaPedido.domicilio.id) { 134 focaModalService.aler('Ingrese Domicilio');
134 focaModalService.aler('Ingrese Domicilio'); 135 return;
135 return; 136 } else if($scope.articulosTabla.length === 0) {
136 } else if($scope.articulosTabla.length === 0) { 137 focaModalService.alert('Debe cargar al menos un articulo');
137 focaModalService.alert('Debe cargar al menos un articulo'); 138 return;
138 return; 139 }
139 } 140 var date = new Date();
140 var date = new Date(); 141 var notaPedido = {
141 var notaPedido = { 142 id: 0,
142 id: 0, 143 fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000))
143 fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) 144 .toISOString().slice(0, 19).replace('T', ' '),
144 .toISOString().slice(0, 19).replace('T', ' '), 145 idVendedor: $scope.notaPedido.vendedor.codigo,
145 idVendedor: $scope.notaPedido.vendedor.codigo, 146 idCliente: $scope.notaPedido.cliente.id,
146 idCliente: $scope.notaPedido.cliente.id, 147 idProveedor: $scope.notaPedido.proveedor.codigo,
147 idProveedor: $scope.notaPedido.proveedor.codigo, 148 idDomicilio: $scope.notaPedido.domicilio.id,
148 idDomicilio: $scope.notaPedido.domicilio.id, 149 idCotizacion: $scope.notaPedido.cotizacion.ID,
149 idCotizacion: $scope.notaPedido.cotizacion.ID, 150 flete: $scope.notaPedido.flete,
150 flete: $scope.notaPedido.flete, 151 fob: $scope.notaPedido.fob,
151 fob: $scope.notaPedido.fob, 152 bomba: $scope.notaPedido.bomba,
152 bomba: $scope.notaPedido.bomba, 153 kilometros: $scope.notaPedido.kilometros,
153 kilometros: $scope.notaPedido.kilometros, 154 total: $scope.getTotal()
154 total: $scope.getTotal() 155 };
155 }; 156 crearNotaPedidoService.crearNotaPedido(notaPedido).then(
156 crearNotaPedidoService.crearNotaPedido(notaPedido).then( 157 function(data) {
157 function(data) { 158 crearNotaPedidoService.addArticulos($scope.articulosTabla,
158 crearNotaPedidoService.addArticulos($scope.articulosTabla, 159 data.data.id, $scope.notaPedido.cotizacion.COTIZACION);
159 data.data.id, $scope.notaPedido.cotizacion.COTIZACION); 160
160 161 var plazos = $scope.plazosPagos;
161 var plazos = $scope.plazosPagos; 162 for(var j = 0; j < plazos.length; j++) {
162 for(var j = 0; j < plazos.length; j++) { 163 var json = {
163 var json = { 164 idPedido: data.data.id,
164 idPedido: data.data.id, 165 dias: plazos[j].dias
165 dias: plazos[j].dias 166 };
166 }; 167 crearNotaPedidoService.crearPlazosParaNotaPedido(json);
167 crearNotaPedidoService.crearPlazosParaNotaPedido(json); 168 }
168 } 169 focaModalService.alert('Nota pedido creada');
169 focaModalService.alert('Nota pedido creada'); 170 $scope.cabecera = [];
170 $scope.cabecera = []; 171 addCabecera('Moneda:', $scope.notaPedido.moneda.detalle);
171 addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); 172 addCabecera(
172 addCabecera( 173 'Fecha cotizacion:',
173 'Fecha cotizacion:', 174 $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy')
174 $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') 175 );
175 ); 176 addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.COTIZACION);
176 addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.COTIZACION); 177 $scope.notaPedido.vendedor = {};
177 $scope.notaPedido.vendedor = {}; 178 $scope.notaPedido.cliente = {};
178 $scope.notaPedido.cliente = {}; 179 $scope.notaPedido.proveedor = {};
179 $scope.notaPedido.proveedor = {}; 180 $scope.notaPedido.domicilio = {};
180 $scope.notaPedido.domicilio = {}; 181 $scope.notaPedido.flete = null;
181 $scope.notaPedido.flete = null; 182 $scope.notaPedido.fob = null;
182 $scope.notaPedido.fob = null; 183 $scope.notaPedido.bomba = null;
183 $scope.notaPedido.bomba = null; 184 $scope.notaPedido.kilometros = null;
184 $scope.notaPedido.kilometros = null; 185 $scope.articulosTabla = [];
185 $scope.articulosTabla = []; 186 }
186 } 187 );
187 ); 188 };
188 }; 189
189 190 $scope.seleccionarArticulo = function() {
190 $scope.seleccionarArticulo = function() { 191 if ($scope.idLista === undefined) {
191 if ($scope.idLista === undefined) { 192 focaModalService.alert(
192 focaModalService.alert( 193 'Primero seleccione una lista de precio y condicion');
193 'Primero seleccione una lista de precio y condicion'); 194 return;
194 return; 195 }
195 } 196 var modalInstance = $uibModal.open(
196 var modalInstance = $uibModal.open( 197 {
197 { 198 ariaLabelledBy: 'Busqueda de Productos',
198 ariaLabelledBy: 'Busqueda de Productos', 199 templateUrl: 'modal-busqueda-productos.html',
199 templateUrl: 'modal-busqueda-productos.html', 200 controller: 'modalBusquedaProductosCtrl',
200 controller: 'modalBusquedaProductosCtrl', 201 resolve: {
201 resolve: { 202 parametroProducto: {
202 parametroProducto: { 203 idLista: $scope.idLista,
203 idLista: $scope.idLista, 204 cotizacion: $scope.notaPedido.cotizacion.COTIZACION,
204 cotizacion: $scope.notaPedido.cotizacion.COTIZACION, 205 simbolo: $scope.notaPedido.moneda.simbolo
205 simbolo: $scope.notaPedido.moneda.simbolo 206 }
206 } 207 },
207 }, 208 size: 'lg'
208 size: 'lg' 209 }
209 } 210 );
210 ); 211 modalInstance.result.then(
211 modalInstance.result.then( 212 function(producto) {
212 function(producto) { 213 var newArt =
213 var newArt = 214 {
214 { 215 id: 0,
215 id: 0, 216 codigo: producto.codigo,
216 codigo: producto.codigo, 217 sector: producto.sector,
217 sector: producto.sector, 218 sectorCodigo: producto.sector + '-' + producto.codigo,
218 sectorCodigo: producto.sector + '-' + producto.codigo, 219 descripcion: producto.descripcion,
219 descripcion: producto.descripcion, 220 item: $scope.articulosTabla.length + 1,
220 item: $scope.articulosTabla.length + 1, 221 nombre: producto.descripcion,
221 nombre: producto.descripcion, 222 precio: parseFloat(producto.precio.toFixed(4)),
222 precio: parseFloat(producto.precio.toFixed(4)), 223 costoUnitario: producto.costo,
223 costoUnitario: producto.costo, 224 editCantidad: false,
224 editCantidad: false, 225 editPrecio: false
225 editPrecio: false 226 };
226 }; 227 $scope.articuloACargar = newArt;
227 $scope.articuloACargar = newArt; 228 $scope.cargando = false;
228 $scope.cargando = false; 229 }, function() {
229 }, function() { 230 // funcion ejecutada cuando se cancela el modal
230 // funcion ejecutada cuando se cancela el modal 231 }
231 } 232 );
232 ); 233 };
233 }; 234
234 235 $scope.seleccionarVendedor = function() {
235 $scope.seleccionarVendedor = function() { 236 var modalInstance = $uibModal.open(
236 var modalInstance = $uibModal.open( 237 {
237 { 238 ariaLabelledBy: 'Busqueda de Vendedores',
238 ariaLabelledBy: 'Busqueda de Vendedores', 239 templateUrl: 'modal-vendedores.html',
239 templateUrl: 'modal-vendedores.html', 240 controller: 'modalVendedoresCtrl',
240 controller: 'modalVendedoresCtrl', 241 size: 'lg'
241 size: 'lg' 242 }
242 } 243 );
243 ); 244 modalInstance.result.then(
244 modalInstance.result.then( 245 function(vendedor) {
245 function(vendedor) { 246 addCabecera('Vendedor:', vendedor.NomVen);
246 addCabecera('Vendedor:', vendedor.NomVen); 247 $scope.notaPedido.vendedor.codigo = vendedor.CodVen;
247 $scope.notaPedido.vendedor.codigo = vendedor.CodVen; 248 }, function() {
248 }, function() { 249
249 250 }
250 } 251 );
251 ); 252 };
252 }; 253
253 254 $scope.seleccionarProveedor = function() {
254 $scope.seleccionarProveedor = function() { 255 var modalInstance = $uibModal.open(
255 var modalInstance = $uibModal.open( 256 {
256 { 257 ariaLabelledBy: 'Busqueda de Proveedor',
257 ariaLabelledBy: 'Busqueda de Proveedor', 258 templateUrl: 'modal-proveedor.html',
258 templateUrl: 'modal-proveedor.html', 259 controller: 'focaModalProveedorCtrl',
259 controller: 'focaModalProveedorCtrl', 260 size: 'lg'
260 size: 'lg' 261 }
261 } 262 );
262 ); 263 modalInstance.result.then(
263 modalInstance.result.then( 264 function(proveedor) {
264 function(proveedor) { 265 $scope.notaPedido.proveedor.codigo = proveedor.COD;
265 $scope.notaPedido.proveedor.codigo = proveedor.COD; 266 addCabecera('Proveedor:', proveedor.NOM);
266 addCabecera('Proveedor:', proveedor.NOM); 267 }, function() {
267 }, function() { 268
268 269 }
269 } 270 );
270 ); 271 };
271 }; 272
272 273 $scope.seleccionarCliente = function() {
273 $scope.seleccionarCliente = function() { 274
274 275 var modalInstance = $uibModal.open(
275 var modalInstance = $uibModal.open( 276 {
276 { 277 ariaLabelledBy: 'Busqueda de Cliente',
277 ariaLabelledBy: 'Busqueda de Cliente', 278 templateUrl: 'foca-busqueda-cliente-modal.html',
278 templateUrl: 'foca-busqueda-cliente-modal.html', 279 controller: 'focaBusquedaClienteModalController',
279 controller: 'focaBusquedaClienteModalController', 280 size: 'lg'
280 size: 'lg' 281 }
281 } 282 );
282 ); 283 modalInstance.result.then(
283 modalInstance.result.then( 284 function(cliente) {
284 function(cliente) { 285 crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then(
285 crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( 286 function(data) {
286 function(data) { 287 if(data.data.length === 0){
287 if(data.data.length === 0){ 288 focaModalService
288 focaModalService 289 .alert('El cliente no tienen domicilios de entrega')
289 .alert('El cliente no tienen domicilios de entrega') 290 .then(
290 .then( 291 function() {
291 function() { 292 $scope.seleccionarCliente();
292 $scope.seleccionarCliente(); 293 }
293 } 294 );
294 ); 295 return;
295 return; 296 }
296 } 297 $scope.abrirModalDomicilios(cliente);
297 $scope.abrirModalDomicilios(cliente); 298 }
298 } 299 );
299 ); 300 }, function() {
300 }, function() { 301
301 302 }
302 } 303 );
303 ); 304 };
304 }; 305
305 306 $scope.abrirModalDomicilios = function(cliente) {
306 $scope.abrirModalDomicilios = function(cliente) { 307 var modalInstanceDomicilio = $uibModal.open(
307 var modalInstanceDomicilio = $uibModal.open( 308 {
308 { 309 ariaLabelledBy: 'Busqueda de Domicilios',
309 ariaLabelledBy: 'Busqueda de Domicilios', 310 templateUrl: 'modal-domicilio.html',
310 templateUrl: 'modal-domicilio.html', 311 controller: 'focaModalDomicilioController',
311 controller: 'focaModalDomicilioController', 312 resolve: { idCliente: function() { return cliente.cod; }},
312 resolve: { idCliente: function() { return cliente.cod; }}, 313 size: 'lg',
313 size: 'lg', 314 }
314 } 315 );
315 ); 316 modalInstanceDomicilio.result.then(
316 modalInstanceDomicilio.result.then( 317 function(domicilio) {
317 function(domicilio) { 318 $scope.notaPedido.domicilio.id = domicilio.id;
318 $scope.notaPedido.domicilio.id = domicilio.id; 319 $scope.notaPedido.cliente.id = cliente.cod;
319 $scope.notaPedido.cliente.id = cliente.cod; 320 addCabecera('Cliente:', cliente.nom);
320 addCabecera('Cliente:', cliente.nom); 321 addCabecera('Domicilio:', domicilio.dom);
321 addCabecera('Domicilio:', domicilio.dom); 322 }, function() {
322 }, function() { 323 $scope.seleccionarCliente();
323 $scope.seleccionarCliente(); 324 return;
324 return; 325 }
325 } 326 );
326 ); 327 };
327 }; 328
328 329 $scope.mostrarFichaCliente = function() {
329 $scope.mostrarFichaCliente = function() { 330 $uibModal.open(
330 $uibModal.open( 331 {
331 { 332 ariaLabelledBy: 'Datos del Cliente',
332 ariaLabelledBy: 'Datos del Cliente', 333 templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html',
333 templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', 334 controller: 'focaCrearNotaPedidoFichaClienteController',
334 controller: 'focaCrearNotaPedidoFichaClienteController', 335 size: 'lg'
335 size: 'lg' 336 }
336 } 337 );
337 ); 338 };
338 }; 339
339 340 $scope.getTotal = function() {
340 $scope.getTotal = function() { 341 var total = 0;
341 var total = 0; 342 var arrayTempArticulos = $scope.articulosTabla;
342 var arrayTempArticulos = $scope.articulosTabla; 343 for (var i = 0; i < arrayTempArticulos.length; i++) {
343 for (var i = 0; i < arrayTempArticulos.length; i++) { 344 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
344 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 345 }
345 } 346 return parseFloat(total.toFixed(2));
346 return parseFloat(total.toFixed(2)); 347 };
347 }; 348
348 349 $scope.getSubTotal = function() {
349 $scope.getSubTotal = function() { 350 if($scope.articuloACargar) {
350 if($scope.articuloACargar) { 351 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
351 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 352 }
352 } 353 };
353 }; 354
354 355 $scope.abrirModalListaPrecio = function() {
355 $scope.abrirModalListaPrecio = function() { 356 var modalInstance = $uibModal.open(
356 var modalInstance = $uibModal.open( 357 {
357 { 358 ariaLabelledBy: 'Busqueda de Precio Condición',
358 ariaLabelledBy: 'Busqueda de Precio Condición', 359 templateUrl: 'modal-precio-condicion.html',
359 templateUrl: 'modal-precio-condicion.html', 360 controller: 'focaModalPrecioCondicionController',
360 controller: 'focaModalPrecioCondicionController', 361 size: 'lg'
361 size: 'lg' 362 }
362 } 363 );
363 ); 364 modalInstance.result.then(
364 modalInstance.result.then( 365 function(precioCondicion) {
365 function(precioCondicion) { 366 var cabecera = '';
366 var cabecera = ''; 367 var plazosConcat = '';
367 var plazosConcat = ''; 368 if(!Array.isArray(precioCondicion)) {
368 if(!Array.isArray(precioCondicion)) { 369 $scope.plazosPagos = precioCondicion.plazoPago;
369 $scope.plazosPagos = precioCondicion.plazoPago; 370 $scope.idLista = precioCondicion.idListaPrecio;
370 $scope.idLista = precioCondicion.idListaPrecio; 371 for(var i = 0; i < precioCondicion.plazoPago.length; i++) {
371 for(var i = 0; i < precioCondicion.plazoPago.length; i++) { 372 plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
372 plazosConcat += precioCondicion.plazoPago[i].dias + ' '; 373 }
373 } 374 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim();
374 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); 375 } else { //Cuando se ingresan los plazos manualmente
375 } else { //Cuando se ingresan los plazos manualmente 376 $scope.idLista = -1; //-1, el modal productos busca todos los productos
376 $scope.idLista = -1; //-1, el modal productos busca todos los productos 377 $scope.plazosPagos = precioCondicion;
377 $scope.plazosPagos = precioCondicion; 378 for(var j = 0; j < precioCondicion.length; j++) {
378 for(var j = 0; j < precioCondicion.length; j++) { 379 plazosConcat += precioCondicion[j].dias + ' ';
379 plazosConcat += precioCondicion[j].dias + ' '; 380 }
380 } 381 cabecera = 'Ingreso manual ' + plazosConcat.trim();
381 cabecera = 'Ingreso manual ' + plazosConcat.trim(); 382 }
382 } 383 $scope.articulosTabla = [];
383 $scope.articulosTabla = []; 384 addCabecera('Precios y condiciones:', cabecera);
384 addCabecera('Precios y condiciones:', cabecera); 385 }, function() {
385 }, function() { 386
386 387 }
387 } 388 );
388 ); 389 };
389 }; 390
390 391 $scope.abrirModalFlete = function() {
391 $scope.abrirModalFlete = function() { 392 var modalInstance = $uibModal.open(
392 var modalInstance = $uibModal.open( 393 {
393 { 394 ariaLabelledBy: 'Busqueda de Flete',
394 ariaLabelledBy: 'Busqueda de Flete', 395 templateUrl: 'modal-flete.html',
395 templateUrl: 'modal-flete.html', 396 controller: 'focaModalFleteController',
396 controller: 'focaModalFleteController', 397 size: 'lg',
397 size: 'lg', 398 resolve: {
398 resolve: { 399 parametrosFlete:
399 parametrosFlete: 400 function() {
400 function() { 401 return {
401 return { 402 flete: $scope.notaPedido.flete ? '1' :
402 flete: $scope.notaPedido.flete ? '1' : 403 ($scope.notaPedido.fob ? 'FOB' :
403 ($scope.notaPedido.fob ? 'FOB' : 404 ($scope.notaPedido.flete === undefined ? null : '0')),
404 ($scope.notaPedido.flete === undefined ? null : '0')), 405 bomba: $scope.notaPedido.bomba ? '1' :
405 bomba: $scope.notaPedido.bomba ? '1' : 406 ($scope.notaPedido.bomba === undefined ? null : '0'),
406 ($scope.notaPedido.bomba === undefined ? null : '0'), 407 kilometros: $scope.notaPedido.kilometros
407 kilometros: $scope.notaPedido.kilometros 408 };
408 }; 409 }
409 } 410 }
410 } 411 }
411 } 412 );
412 ); 413 modalInstance.result.then(
413 modalInstance.result.then( 414 function(datos) {
414 function(datos) { 415 $scope.notaPedido.flete = datos.flete;
415 $scope.notaPedido.flete = datos.flete; 416 $scope.notaPedido.fob = datos.FOB;
416 $scope.notaPedido.fob = datos.FOB; 417 $scope.notaPedido.bomba = datos.bomba;
417 $scope.notaPedido.bomba = datos.bomba; 418 $scope.notaPedido.kilometros = datos.kilometros;
418 $scope.notaPedido.kilometros = datos.kilometros; 419
419 420 addCabecera('Flete:', datos.flete ? 'Si' :
420 addCabecera('Flete:', datos.flete ? 'Si' : 421 ($scope.notaPedido.fob ? 'FOB' : 'No'));
421 ($scope.notaPedido.fob ? 'FOB' : 'No')); 422 if(datos.flete) {
422 if(datos.flete) { 423 addCabecera('Bomba:', datos.bomba ? 'Si' : 'No');
423 addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); 424 addCabecera('Kilometros:', datos.kilometros);
424 addCabecera('Kilometros:', datos.kilometros); 425 } else {
425 } else { 426 removeCabecera('Bomba:');
426 removeCabecera('Bomba:'); 427 removeCabecera('Kilometros:');
427 removeCabecera('Kilometros:'); 428 $scope.notaPedido.fob = false;
428 $scope.notaPedido.fob = false; 429 $scope.notaPedido.bomba = false;
429 $scope.notaPedido.bomba = false; 430 $scope.notaPedido.kilometros = null;
430 $scope.notaPedido.kilometros = null; 431 }
431 } 432 }, function() {
432 }, function() { 433
433 434 }
434 } 435 );
435 ); 436 };
436 }; 437
437 438 $scope.abrirModalMoneda = function() {
438 $scope.abrirModalMoneda = function() { 439 var modalInstance = $uibModal.open(
439 var modalInstance = $uibModal.open( 440 {
440 { 441 ariaLabelledBy: 'Busqueda de Moneda',
441 ariaLabelledBy: 'Busqueda de Moneda', 442 templateUrl: 'modal-moneda.html',
442 templateUrl: 'modal-moneda.html', 443 controller: 'focaModalMonedaController',
443 controller: 'focaModalMonedaController', 444 size: 'lg'
444 size: 'lg' 445 }
445 } 446 );
446 ); 447 modalInstance.result.then(
447 modalInstance.result.then( 448 function(moneda) {
448 function(moneda) { 449 $scope.abrirModalCotizacion(moneda);
449 $scope.abrirModalCotizacion(moneda); 450 }, function() {
450 }, function() { 451
451 452 }
452 } 453 );
453 ); 454 };
454 }; 455
455 456 $scope.abrirModalCotizacion = function(moneda) {
456 $scope.abrirModalCotizacion = function(moneda) { 457 var modalInstance = $uibModal.open(
457 var modalInstance = $uibModal.open( 458 {
458 { 459 ariaLabelledBy: 'Busqueda de Cotización',
459 ariaLabelledBy: 'Busqueda de Cotización', 460 templateUrl: 'modal-cotizacion.html',
460 templateUrl: 'modal-cotizacion.html', 461 controller: 'focaModalCotizacionController',
461 controller: 'focaModalCotizacionController', 462 size: 'lg',
462 size: 'lg', 463 resolve: {idMoneda: function() {return moneda.ID;}}
463 resolve: {idMoneda: function() {return moneda.ID;}} 464 }
464 } 465 );
465 ); 466 modalInstance.result.then(
466 modalInstance.result.then( 467 function(cotizacion) {
467 function(cotizacion) { 468 var articulosTablaTemp = $scope.articulosTabla;
468 var articulosTablaTemp = $scope.articulosTabla; 469 for(var i = 0; i < articulosTablaTemp.length; i++) {
469 for(var i = 0; i < articulosTablaTemp.length; i++) { 470 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
470 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * 471 $scope.notaPedido.cotizacion.COTIZACION;
471 $scope.notaPedido.cotizacion.COTIZACION; 472 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio /
472 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / 473 cotizacion.COTIZACION;
473 cotizacion.COTIZACION; 474 }
474 } 475 $scope.articulosTabla = articulosTablaTemp;
475 $scope.articulosTabla = articulosTablaTemp; 476 $scope.notaPedido.moneda = {
476 $scope.notaPedido.moneda = { 477 id: moneda.ID,
477 id: moneda.ID, 478 detalle: moneda.DETALLE,
478 detalle: moneda.DETALLE, 479 simbolo: moneda.SIMBOLO
479 simbolo: moneda.SIMBOLO 480 };
480 }; 481 $scope.notaPedido.cotizacion = {
481 $scope.notaPedido.cotizacion = { 482 ID: cotizacion.ID,
482 ID: cotizacion.ID, 483 COTIZACION: cotizacion.COTIZACION,
483 COTIZACION: cotizacion.COTIZACION, 484 FECHA: cotizacion.FECHA
484 FECHA: cotizacion.FECHA 485 };
485 }; 486 addCabecera('Moneda:', moneda.DETALLE);
486 addCabecera('Moneda:', moneda.DETALLE); 487 addCabecera(
487 addCabecera( 488 'Fecha cotizacion:',
488 'Fecha cotizacion:', 489 $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
489 $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 490 );
490 ); 491 addCabecera('Cotizacion:', cotizacion.COTIZACION);
491 addCabecera('Cotizacion:', cotizacion.COTIZACION); 492 }, function() {
492 }, function() { 493
493 494 }
494 } 495 );
495 ); 496 };
496 }; 497
497 498 $scope.agregarATabla = function(key) {
498 $scope.agregarATabla = function(key) { 499 if(key === 13) {
499 if(key === 13) { 500 if($scope.articuloACargar.cantidad === undefined ||
500 if($scope.articuloACargar.cantidad === undefined || 501 $scope.articuloACargar.cantidad === 0 ||
501 $scope.articuloACargar.cantidad === 0 || 502 $scope.articuloACargar.cantidad === null ){
502 $scope.articuloACargar.cantidad === null ){ 503 focaModalService.alert('El valor debe ser al menos 1');
503 focaModalService.alert('El valor debe ser al menos 1'); 504 return;
504 return; 505 }
505 } 506 delete $scope.articuloACargar.sectorCodigo;
506 delete $scope.articuloACargar.sectorCodigo; 507 $scope.articulosTabla.push($scope.articuloACargar);
507 $scope.articulosTabla.push($scope.articuloACargar); 508 $scope.cargando = true;
508 $scope.cargando = true; 509 }
509 } 510 };
510 }; 511
511 512 $scope.quitarArticulo = function(key) {
512 $scope.quitarArticulo = function(key) { 513 $scope.articulosTabla.splice(key, 1);
513 $scope.articulosTabla.splice(key, 1); 514 };
514 }; 515
515 516 $scope.editarArticulo = function(key, articulo) {
516 $scope.editarArticulo = function(key, articulo) { 517 if(key === 13) {
517 if(key === 13) { 518 if(articulo.cantidad === null || articulo.cantidad === 0 ||
518 if(articulo.cantidad === null || articulo.cantidad === 0 || 519 articulo.cantidad === undefined){
519 articulo.cantidad === undefined){ 520 focaModalService.alert('El valor debe ser al menos 1');
520 focaModalService.alert('El valor debe ser al menos 1'); 521 return;
521 return; 522 }
522 } 523 articulo.editCantidad = false;
523 articulo.editCantidad = false; 524 articulo.editPrecio = false;
524 articulo.editPrecio = false; 525 }
525 } 526 };
526 }; 527
527 528 $scope.cambioEdit = function(articulo, propiedad) {
528 $scope.cambioEdit = function(articulo, propiedad) { 529 if(propiedad === 'cantidad') {
529 if(propiedad === 'cantidad') { 530 articulo.editCantidad = true;
530 articulo.editCantidad = true; 531 } else if(propiedad === 'precio') {
531 } else if(propiedad === 'precio') { 532 articulo.editPrecio = true;
532 articulo.editPrecio = true; 533 }
533 } 534 };
534 }; 535
535 536 $scope.limpiarFlete = function() {
536 $scope.limpiarFlete = function() { 537 $scope.notaPedido.fleteNombre = '';
537 $scope.notaPedido.fleteNombre = ''; 538 $scope.notaPedido.chofer = '';
538 $scope.notaPedido.chofer = ''; 539 $scope.notaPedido.vehiculo = '';
539 $scope.notaPedido.vehiculo = ''; 540 $scope.notaPedido.kilometros = '';
540 $scope.notaPedido.kilometros = ''; 541 $scope.notaPedido.costoUnitarioKmFlete = '';
541 $scope.notaPedido.costoUnitarioKmFlete = ''; 542 $scope.choferes = '';
542 $scope.choferes = ''; 543 $scope.vehiculos = '';
543 $scope.vehiculos = ''; 544 };
544 }; 545
545 546 $scope.limpiarPantalla = function() {
546 $scope.limpiarPantalla = function() { 547 $scope.limpiarFlete();
547 $scope.limpiarFlete(); 548 $scope.notaPedido.flete = '0';
548 $scope.notaPedido.flete = '0'; 549 $scope.notaPedido.bomba = '0';
549 $scope.notaPedido.bomba = '0'; 550 $scope.notaPedido.precioCondicion = '';
550 $scope.notaPedido.precioCondicion = ''; 551 $scope.articulosTabla = [];
551 $scope.articulosTabla = []; 552 $scope.notaPedido.vendedor.nombre = '';
552 $scope.notaPedido.vendedor.nombre = ''; 553 $scope.notaPedido.cliente = {nombre: ''};
553 $scope.notaPedido.cliente = {nombre: ''}; 554 $scope.notaPedido.domicilio = {dom: ''};
554 $scope.notaPedido.domicilio = {dom: ''}; 555 $scope.domiciliosCliente = [];
555 $scope.domiciliosCliente = []; 556 };
556 }; 557
557 558 $scope.resetFilter = function() {
558 $scope.resetFilter = function() { 559 $scope.articuloACargar = {};
559 $scope.articuloACargar = {}; 560 $scope.cargando = true;
560 $scope.cargando = true; 561 };
561 }; 562
562 563 $scope.selectFocus = function($event) {
563 $scope.selectFocus = function($event) { 564 $event.target.select();
564 $event.target.select(); 565 };
565 }; 566
566 567 $scope.salir = function() {
567 $scope.salir = function() { 568 $location.path('/');
568 $location.path('/'); 569 };
569 }; 570
570 571 function addCabecera(label, valor) {
571 function addCabecera(label, valor) { 572 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
572 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 573 if(propiedad.length === 1) {
573 if(propiedad.length === 1) { 574 propiedad[0].valor = valor;
574 propiedad[0].valor = valor; 575 } else {
575 } else { 576 $scope.cabecera.push({label: label, valor: valor});
576 $scope.cabecera.push({label: label, valor: valor}); 577 }
577 } 578 }
578 } 579
579 580 function removeCabecera(label) {
580 function removeCabecera(label) { 581 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
581 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 582 if(propiedad.length === 1){
582 if(propiedad.length === 1){ 583 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
583 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 584 }
584 } 585 }
585 } 586 }
586 } 587 ]
587 ] 588 )
588 ) 589 .controller('notaPedidoListaCtrl', [
589 .controller('notaPedidoListaCtrl', [ 590 '$scope',
590 '$scope', 591 'crearNotaPedidoService',
591 'crearNotaPedidoService', 592 '$location',
592 '$location', 593 function($scope, crearNotaPedidoService, $location) {
593 function($scope, crearNotaPedidoService, $location) { 594 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) {
594 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { 595 $scope.notaPedidos = datos.data;
595 $scope.notaPedidos = datos.data; 596 });
596 }); 597 $scope.editar = function(notaPedido) {
597 $scope.editar = function(notaPedido) { 598 crearNotaPedidoService.setNotaPedido(notaPedido);
598 crearNotaPedidoService.setNotaPedido(notaPedido); 599 $location.path('/venta-nota-pedido/abm/');
599 $location.path('/venta-nota-pedido/abm/'); 600 };
600 }; 601 $scope.crearPedido = function() {
601 $scope.crearPedido = function() { 602 crearNotaPedidoService.clearNotaPedido();
602 crearNotaPedidoService.clearNotaPedido(); 603 $location.path('/venta-nota-pedido/abm/');
603 $location.path('/venta-nota-pedido/abm/'); 604 };
604 }; 605 }
605 } 606 ])
606 ]) 607 .controller('focaCrearNotaPedidoFichaClienteController', [
607 .controller('focaCrearNotaPedidoFichaClienteController', [ 608 '$scope',
608 '$scope', 609 'crearNotaPedidoService',
609 'crearNotaPedidoService', 610 '$location',
610 '$location', 611 function($scope, crearNotaPedidoService, $location) {
611 function($scope, crearNotaPedidoService, $location) { 612 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) {
612 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { 613 $scope.notaPedidos = datos.data;
613 $scope.notaPedidos = datos.data; 614 });
614 }); 615 $scope.editar = function(notaPedido) {
615 $scope.editar = function(notaPedido) { 616 crearNotaPedidoService.setNotaPedido(notaPedido);
616 crearNotaPedidoService.setNotaPedido(notaPedido); 617 $location.path('/venta-nota-pedido/abm/');
617 $location.path('/venta-nota-pedido/abm/'); 618 };
618 }; 619 $scope.crearPedido = function() {
619 $scope.crearPedido = function() { 620 crearNotaPedidoService.clearNotaPedido();
620 crearNotaPedidoService.clearNotaPedido(); 621 $location.path('/venta-nota-pedido/abm/');
621 $location.path('/venta-nota-pedido/abm/'); 622 };
622 }; 623 }
623 } 624 ]);
624 ]); 625