Commit 6215e17d29b828c52107f690a574001703556fef
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master See merge request !49
Showing
7 changed files
Show diff stats
.gitignore
1 | /node_modules | 1 | /node_modules |
2 | /dist | 2 | /dist |
3 | package-lock\.json | 3 | package-lock\.json |
4 | /src/etc/develop.js | 4 | /src/etc/develop.js |
5 | 5 | ||
6 | tmp/ | 6 | tmp/ |
7 | debug.log | ||
7 | 8 |
gulpfile.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 | const header = require('gulp-header'); | 12 | const header = require('gulp-header'); |
13 | const footer = require('gulp-footer'); | 13 | const footer = require('gulp-footer'); |
14 | const gulpSequence = require('gulp-sequence'); | ||
14 | 15 | ||
15 | var paths = { | 16 | var paths = { |
16 | srcJS: 'src/js/*.js', | 17 | srcJS: 'src/js/*.js', |
17 | srcViews: 'src/views/*.html', | 18 | srcViews: 'src/views/*.html', |
18 | specs: 'spec/*.js', | 19 | specs: 'spec/*.js', |
19 | tmp: 'tmp', | 20 | tmp: 'tmp', |
20 | dist: 'dist/' | 21 | dist: 'dist/' |
21 | }; | 22 | }; |
22 | 23 | ||
23 | gulp.task('templates', ['clean'], function() { | 24 | gulp.task('uglify', gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')); |
25 | |||
26 | gulp.task('templates', function() { | ||
24 | return pump( | 27 | return pump( |
25 | [ | 28 | [ |
26 | gulp.src(paths.srcViews), | 29 | gulp.src(paths.srcViews), |
27 | htmlmin(), | 30 | htmlmin(), |
28 | templateCache('views.js', { | 31 | templateCache('views.js', { |
29 | module: 'focaCrearNotaPedido', | 32 | module: 'focaCrearNotaPedido', |
30 | root: '' | 33 | root: '' |
31 | }), | 34 | }), |
32 | gulp.dest(paths.tmp) | 35 | gulp.dest(paths.tmp) |
33 | ] | 36 | ] |
34 | ); | 37 | ); |
35 | }); | 38 | }); |
36 | 39 | ||
37 | gulp.task('uglify', ['templates', 'uglify-spec'], function() { | 40 | gulp.task('uglify-app', function() { |
38 | return pump( | 41 | return pump( |
39 | [ | 42 | [ |
40 | gulp.src([ | 43 | gulp.src([ |
41 | paths.srcJS, | 44 | paths.srcJS, |
42 | 'tmp/views.js' | 45 | 'tmp/views.js' |
43 | ]), | 46 | ]), |
44 | concat('foca-crear-nota-pedido.js'), | 47 | concat('foca-crear-nota-pedido.js'), |
45 | replace('src/views/', ''), | 48 | replace('src/views/', ''), |
46 | gulp.dest(paths.tmp), | 49 | gulp.dest(paths.tmp), |
47 | rename('foca-crear-nota-pedido.min.js'), | 50 | rename('foca-crear-nota-pedido.min.js'), |
48 | uglify(), | 51 | uglify(), |
49 | gulp.dest(paths.dist) | 52 | gulp.dest(paths.dist) |
50 | ] | 53 | ] |
51 | ); | 54 | ); |
52 | }); | 55 | }); |
53 | 56 | ||
54 | gulp.task('uglify-spec', function() { | 57 | gulp.task('uglify-spec', function() { |
55 | return pump([ | 58 | return pump([ |
56 | gulp.src(paths.specs), | 59 | gulp.src(paths.specs), |
57 | concat('foca-crear-nota-pedido.spec.js'), | 60 | concat('foca-crear-nota-pedido.spec.js'), |
58 | replace("src/views/", ''), | 61 | replace("src/views/", ''), |
59 | header("describe('Módulo foca-crear-nota-pedido', function() { \n"), | 62 | header("describe('Módulo foca-crear-nota-pedido', function() { \n"), |
60 | footer("});"), | 63 | footer("});"), |
61 | gulp.dest(paths.dist) | 64 | gulp.dest(paths.dist) |
62 | ]); | 65 | ]); |
63 | }); | 66 | }); |
64 | 67 | ||
65 | gulp.task('clean', function() { | 68 | gulp.task('clean', function() { |
66 | return gulp.src(['tmp', 'dist'], {read: false}) | 69 | return gulp.src(['tmp', 'dist'], {read: false}) |
67 | .pipe(clean()); | 70 | .pipe(clean()); |
68 | }); | 71 | }); |
69 | 72 | ||
70 | gulp.task('pre-commit', function() { | 73 | gulp.task('pre-commit', function() { |
71 | return pump( | 74 | return pump( |
72 | [ | 75 | [ |
73 | gulp.src([paths.srcJS, paths.specs]), | 76 | gulp.src([paths.srcJS, paths.specs]), |
74 | jshint('.jshintrc'), | 77 | jshint('.jshintrc'), |
75 | jshint.reporter('default'), | 78 | jshint.reporter('default'), |
76 | jshint.reporter('fail') | 79 | jshint.reporter('fail') |
77 | ] | 80 | ] |
78 | ); | 81 | ); |
79 | 82 | ||
80 | gulp.start('uglify'); | 83 | gulp.start('uglify'); |
81 | }); | 84 | }); |
82 | 85 | ||
83 | gulp.task('webserver', function() { | 86 | gulp.task('webserver', function() { |
84 | pump [ | 87 | pump [ |
85 | connect.server({port: 3300, host: '0.0.0.0'}) | 88 | connect.server({port: 3300, host: '0.0.0.0'}) |
86 | ] | 89 | ] |
87 | }); | 90 | }); |
88 | 91 | ||
89 | gulp.task('clean-post-install', function() { | 92 | gulp.task('clean-post-install', function() { |
90 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 93 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
91 | 'index.html', 'test.html', 'spec'], {read: false}) | 94 | 'index.html', 'test.html', 'spec'], {read: false}) |
92 | .pipe(clean()); | 95 | .pipe(clean()); |
93 | }); | 96 | }); |
94 | 97 | ||
95 | gulp.task('default', ['webserver']); | 98 | gulp.task('default', ['webserver']); |
96 | 99 | ||
97 | gulp.task('watch', function() { | 100 | gulp.task('watch', function() { |
98 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | 101 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); |
99 | }); | 102 | }); |
100 | 103 | ||
101 | gulp.task('copy', ['uglify'], function() { | 104 | gulp.task('copy', ['uglify'], function() { |
102 | return gulp.src('dist/*.js') | 105 | return gulp.src('dist/*.js') |
103 | .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-crear-nota-pedido/dist/')); | 106 | .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-crear-nota-pedido/dist/')); |
104 | }); | 107 | }); |
105 | 108 | ||
106 | gulp.task('watchAndCopy', function() { | 109 | gulp.task('watchAndCopy', function() { |
107 | return gulp.watch([paths.srcJS], ['copy']); | 110 | return gulp.watch([paths.srcJS], ['copy']); |
108 | }); | 111 | }); |
109 | 112 |
package.json
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": "test.html", | 7 | "test": "test.html", |
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+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-vendedores.git git+http://git.focasoftware.com/npm/foca-modal-proveedor.git git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git git+http://git.focasoftware.com/npm/foca-modal-flete.git git+http://git.focasoftware.com/npm/foca-modal.git git+http://git.focasoftware.com/npm/foca-modal-domicilio.git git+http://git.focasoftware.com/npm/foca-seguimiento.git git+http://git.focasoftware.com/npm/foca-modal-moneda.git git+http://git.focasoftware.com/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+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-vendedores.git git+http://git.focasoftware.com/npm/foca-modal-proveedor.git git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git git+http://git.focasoftware.com/npm/foca-modal-flete.git git+http://git.focasoftware.com/npm/foca-modal.git git+http://git.focasoftware.com/npm/foca-modal-domicilio.git git+http://git.focasoftware.com/npm/foca-seguimiento.git git+http://git.focasoftware.com/npm/foca-modal-moneda.git git+http://git.focasoftware.com/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-botonera-facturador": "git+http://git.focasoftware.com/npm/foca-botonera-facturador.git", | 23 | "foca-botonera-facturador": "git+http://git.focasoftware.com/npm/foca-botonera-facturador.git", |
24 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", | 24 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", |
25 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | 25 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
26 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", | 26 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", |
27 | "foca-modal-busqueda-productos": "git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git", | 27 | "foca-modal-busqueda-productos": "git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git", |
28 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", | 28 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", |
29 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", | 29 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", |
30 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", | 30 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", |
31 | "foca-modal-moneda": "git+http://git.focasoftware.com/npm/foca-modal-moneda.git", | 31 | "foca-modal-moneda": "git+http://git.focasoftware.com/npm/foca-modal-moneda.git", |
32 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", | 32 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", |
33 | "foca-modal-proveedor": "git+http://git.focasoftware.com/npm/foca-modal-proveedor.git", | 33 | "foca-modal-proveedor": "git+http://git.focasoftware.com/npm/foca-modal-proveedor.git", |
34 | "foca-modal-vendedores": "git+http://git.focasoftware.com/npm/foca-modal-vendedores.git", | 34 | "foca-modal-vendedores": "git+http://git.focasoftware.com/npm/foca-modal-vendedores.git", |
35 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git" | 35 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git" |
36 | }, | 36 | }, |
37 | "devDependencies": { | 37 | "devDependencies": { |
38 | "angular": "^1.7.5", | 38 | "angular": "^1.7.5", |
39 | "angular-ladda": "^0.4.3", | 39 | "angular-ladda": "^0.4.3", |
40 | "angular-mocks": "^1.7.7", | 40 | "angular-mocks": "^1.7.7", |
41 | "angular-route": "^1.7.5", | 41 | "angular-route": "^1.7.5", |
42 | "bootstrap": "^4.1.3", | 42 | "bootstrap": "^4.1.3", |
43 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", | 43 | "foca-busqueda-cliente": "git+http://git.focasoftware.com/npm/foca-busqueda-cliente.git", |
44 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | 44 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
45 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", | 45 | "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", |
46 | "foca-modal-busqueda-productos": "git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git", | 46 | "foca-modal-busqueda-productos": "git+http://git.focasoftware.com/npm/foca-modal-busqueda-productos.git", |
47 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", | 47 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", |
48 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", | 48 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", |
49 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", | 49 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", |
50 | "foca-modal-moneda": "git+http://git.focasoftware.com/npm/foca-modal-moneda.git", | 50 | "foca-modal-moneda": "git+http://git.focasoftware.com/npm/foca-modal-moneda.git", |
51 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", | 51 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", |
52 | "foca-modal-proveedor": "git+http://git.focasoftware.com/npm/foca-modal-proveedor.git", | 52 | "foca-modal-proveedor": "git+http://git.focasoftware.com/npm/foca-modal-proveedor.git", |
53 | "foca-modal-vendedores": "git+http://git.focasoftware.com/npm/foca-modal-vendedores.git", | 53 | "foca-modal-vendedores": "git+http://git.focasoftware.com/npm/foca-modal-vendedores.git", |
54 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git", | 54 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git", |
55 | "font-awesome": "^4.7.0", | 55 | "font-awesome": "^4.7.0", |
56 | "gulp": "^3.9.1", | 56 | "gulp": "^3.9.1", |
57 | "gulp-angular-templatecache": "^2.2.5", | 57 | "gulp-angular-templatecache": "^2.2.5", |
58 | "gulp-clean": "^0.4.0", | 58 | "gulp-clean": "^0.4.0", |
59 | "gulp-concat": "^2.6.1", | 59 | "gulp-concat": "^2.6.1", |
60 | "gulp-connect": "^5.6.1", | 60 | "gulp-connect": "^5.6.1", |
61 | "gulp-htmlmin": "^5.0.1", | 61 | "gulp-htmlmin": "^5.0.1", |
62 | "gulp-jshint": "^2.1.0", | 62 | "gulp-jshint": "^2.1.0", |
63 | "gulp-rename": "^1.4.0", | 63 | "gulp-rename": "^1.4.0", |
64 | "gulp-replace": "^1.0.0", | 64 | "gulp-replace": "^1.0.0", |
65 | "gulp-sequence": "^1.0.0", | 65 | "gulp-sequence": "^1.0.0", |
66 | "gulp-uglify": "^3.0.1", | 66 | "gulp-uglify": "^3.0.1", |
67 | "gulp-uglify-es": "^1.0.4", | 67 | "gulp-uglify-es": "^1.0.4", |
68 | "jasmine-core": "^3.3.0", | 68 | "jasmine-core": "^3.3.0", |
69 | "jquery": "^3.3.1", | 69 | "jquery": "^3.3.1", |
70 | "jshint": "^2.9.6", | 70 | "jshint": "^2.9.6", |
71 | "ladda": "1.0.6", | 71 | "ladda": "1.0.6", |
72 | "ngstorage": "^0.3.11", | ||
72 | "pre-commit": "^1.2.2", | 73 | "pre-commit": "^1.2.2", |
73 | "pump": "^3.0.0", | 74 | "pump": "^3.0.0", |
74 | "ui-bootstrap4": "^3.0.5" | 75 | "ui-bootstrap4": "^3.0.5" |
75 | } | 76 | } |
76 | } | 77 | } |
77 | 78 |
spec/controllerSpec.js
1 | describe('Controladores módulo crear nota de pedido', function() { | 1 | describe('Controladores módulo crear nota de pedido', function() { |
2 | 2 | ||
3 | var $controler; | 3 | var $controler; |
4 | 4 | ||
5 | beforeEach(function() { | 5 | beforeEach(function() { |
6 | module('focaCrearNotaPedido'); | 6 | module('focaCrearNotaPedido'); |
7 | inject(function(_$controller_) { | 7 | inject(function(_$controller_) { |
8 | $controler = _$controller_; | 8 | $controler = _$controller_; |
9 | }); | 9 | }); |
10 | }); | 10 | }); |
11 | 11 | ||
12 | describe('Controlador notaPedidoCtrl', function() { | 12 | describe('Controlador notaPedidoCtrl', function() { |
13 | 13 | ||
14 | var filter = function() { | 14 | var filter = function() { |
15 | return function() { }; | 15 | return function() { }; |
16 | }; | 16 | }; |
17 | var timeout; | 17 | var timeout; |
18 | 18 | ||
19 | beforeEach(function() { | 19 | beforeEach(function() { |
20 | 20 | ||
21 | inject(function($timeout) { | 21 | inject(function($timeout) { |
22 | timeout = $timeout; | 22 | timeout = $timeout; |
23 | }); | 23 | }); |
24 | }); | 24 | }); |
25 | 25 | ||
26 | it('La función seleccionarNotaPedido levanta modal', function() { | 26 | it('La función seleccionarNotaPedido levanta modal', function() { |
27 | //arrange | 27 | //arrange |
28 | var scope = {}; | 28 | var scope = { |
29 | $watch: function() { }, | ||
30 | $broadcast: function() { } | ||
31 | }; | ||
29 | var uibModal = { | 32 | var uibModal = { |
30 | open: function() { } | 33 | open: function() { } |
31 | }; | 34 | }; |
32 | 35 | ||
33 | $controler('notaPedidoCtrl', { | 36 | $controler('notaPedidoCtrl', { |
34 | $scope: scope, | 37 | $scope: scope, |
35 | $uibModal: uibModal, | 38 | $uibModal: uibModal, |
36 | $location: {}, | 39 | $location: {}, |
37 | $filter: filter, | 40 | $filter: filter, |
38 | $timeout: timeout, | 41 | $timeout: timeout, |
39 | crearNotaPedidoService: { | 42 | crearNotaPedidoService: { |
43 | getNumeroNotaPedido: function() { | ||
44 | return { | ||
45 | then: function() { } | ||
46 | }; | ||
47 | }, | ||
40 | getBotonera: function() { }, | 48 | getBotonera: function() { }, |
41 | getCotizacionByIdMoneda: function() { | 49 | getCotizacionByIdMoneda: function() { |
42 | return { | 50 | return { |
43 | then: function() { } | 51 | then: function() { } |
44 | }; | 52 | }; |
45 | } | 53 | } |
46 | }, | 54 | }, |
47 | focaBotoneraLateralService: {}, | 55 | focaBotoneraLateralService: {}, |
48 | focaModalService: {}, | 56 | focaModalService: {}, |
49 | notaPedidoBusinessService: {}, | 57 | notaPedidoBusinessService: {}, |
50 | $rootScope: { | 58 | $rootScope: { |
51 | $on: function() { } | 59 | $on: function() { } |
52 | }, | 60 | }, |
53 | focaSeguimientoService: {}, | 61 | focaSeguimientoService: {}, |
54 | APP: {}, | 62 | APP: {}, |
55 | focaLoginService: {} | 63 | focaLoginService: {}, |
64 | $localStorage: {} | ||
56 | }); | 65 | }); |
57 | var respuesta = { result: { then: function() { } } }; | 66 | var respuesta = { result: { then: function() { } } }; |
58 | 67 | ||
59 | //act | 68 | //act |
60 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 69 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
61 | scope.seleccionarNotaPedido(); | 70 | scope.seleccionarNotaPedido(); |
62 | 71 | ||
63 | //assert | 72 | //assert |
64 | expect(uibModal.open).toHaveBeenCalled(); | 73 | expect(uibModal.open).toHaveBeenCalled(); |
65 | }); | 74 | }); |
66 | 75 | ||
67 | it('La función seleccionarNotaPedido llama a broadCast en promesa', function(done) { | 76 | it('La función seleccionarNotaPedido llama a broadCast en promesa', function(done) { |
68 | //arrange | 77 | //arrange |
69 | var scope = {}; | 78 | var scope = { |
79 | $watch: function() { }, | ||
80 | $broadcast: function() { } | ||
81 | }; | ||
70 | var uibModal = { | 82 | var uibModal = { |
71 | open: function() { } | 83 | open: function() { } |
72 | }; | 84 | }; |
73 | 85 | ||
74 | $controler('notaPedidoCtrl', { | 86 | $controler('notaPedidoCtrl', { |
75 | $scope: scope, | 87 | $scope: scope, |
76 | $uibModal: uibModal, | 88 | $uibModal: uibModal, |
77 | $location: {}, | 89 | $location: {}, |
78 | $filter: filter, | 90 | $filter: filter, |
79 | $timeout: timeout, | 91 | $timeout: timeout, |
80 | crearNotaPedidoService: { | 92 | crearNotaPedidoService: { |
93 | getNumeroNotaPedido: function() { | ||
94 | return { | ||
95 | then: function() { } | ||
96 | }; | ||
97 | }, | ||
81 | getBotonera: function() { }, | 98 | getBotonera: function() { }, |
82 | getCotizacionByIdMoneda: function() { | 99 | getCotizacionByIdMoneda: function() { |
83 | return { | 100 | return { |
84 | then: function() { } | 101 | then: function() { } |
85 | }; | 102 | }; |
86 | } | 103 | } |
87 | }, | 104 | }, |
88 | focaBotoneraLateralService: {}, | 105 | focaBotoneraLateralService: {}, |
89 | focaModalService: {}, | 106 | focaModalService: {}, |
90 | notaPedidoBusinessService: { | 107 | notaPedidoBusinessService: { |
91 | plazoToString: function() { }, | 108 | plazoToString: function() { }, |
92 | calcularArticulos: function() { } | 109 | calcularArticulos: function() { } |
93 | }, | 110 | }, |
94 | $rootScope: { | 111 | $rootScope: { |
95 | $on: function() { } | 112 | $on: function() { } |
96 | }, | 113 | }, |
97 | focaSeguimientoService: {}, | 114 | focaSeguimientoService: {}, |
98 | APP: {}, | 115 | APP: {}, |
99 | focaLoginService: {} | 116 | focaLoginService: {}, |
117 | $localStorage: {} | ||
100 | }); | 118 | }); |
101 | var notaPedido = { | 119 | var notaPedido = { |
102 | cotizacion: { | 120 | cotizacion: { |
103 | moneda: {} | 121 | moneda: {} |
104 | }, | 122 | }, |
105 | cliente: {}, | 123 | cliente: {}, |
106 | vendedor: {}, | 124 | vendedor: {}, |
107 | proveedor: {}, | 125 | proveedor: {}, |
108 | notaPedidoPlazo: {}, | 126 | notaPedidoPlazo: [], |
109 | notaPedidoPuntoDescarga: [] | 127 | notaPedidoPuntoDescarga: [] |
110 | }; | 128 | }; |
111 | var respuesta = { result: Promise.resolve(notaPedido) }; | 129 | var respuesta = { result: Promise.resolve(notaPedido) }; |
112 | 130 | ||
113 | //act | 131 | //act |
114 | scope.notaPedido = {}; | 132 | scope.notaPedido = {}; |
115 | scope.$broadcast = function() { }; | 133 | scope.$broadcast = function() { }; |
116 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 134 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
117 | spyOn(scope, '$broadcast'); | 135 | spyOn(scope, '$broadcast'); |
118 | scope.seleccionarNotaPedido(); | 136 | scope.seleccionarNotaPedido(); |
119 | 137 | ||
120 | //assert | 138 | //assert |
121 | respuesta.result.then(function() { | 139 | respuesta.result.then(function() { |
122 | expect(scope.$broadcast).toHaveBeenCalledWith('removeCabecera', 'Bomba:'); | 140 | expect(scope.$broadcast).toHaveBeenCalledWith('removeCabecera', 'Bomba:'); |
123 | expect(scope.$broadcast).toHaveBeenCalledWith('removeCabecera', 'Kilometros:'); | 141 | expect(scope.$broadcast).toHaveBeenCalledWith('removeCabecera', 'Kilometros:'); |
124 | done(); | 142 | done(); |
125 | }); | 143 | }); |
126 | }); | 144 | }); |
127 | 145 | ||
128 | it('función seleccionarProductos muestra alerta cuando idLista undefined', function() { | 146 | it('función seleccionarProductos muestra alerta cuando idLista undefined', function() { |
129 | //arrange | 147 | //arrange |
130 | var scope = {}; | 148 | var scope = { |
149 | $watch: function() { }, | ||
150 | $broadcast: function() { } | ||
151 | }; | ||
131 | var focaModalService = { | 152 | var focaModalService = { |
132 | alert: function() { } | 153 | alert: function() { } |
133 | }; | 154 | }; |
134 | 155 | ||
135 | $controler('notaPedidoCtrl', { | 156 | $controler('notaPedidoCtrl', { |
136 | $scope: scope, | 157 | $scope: scope, |
137 | $uibModal: {}, | 158 | $uibModal: {}, |
138 | $location: {}, | 159 | $location: {}, |
139 | $filter: filter, | 160 | $filter: filter, |
140 | $timeout: timeout, | 161 | $timeout: timeout, |
141 | crearNotaPedidoService: { | 162 | crearNotaPedidoService: { |
163 | getNumeroNotaPedido: function() { | ||
164 | return { | ||
165 | then: function() { } | ||
166 | }; | ||
167 | }, | ||
142 | getBotonera: function() { }, | 168 | getBotonera: function() { }, |
143 | getCotizacionByIdMoneda: function() { | 169 | getCotizacionByIdMoneda: function() { |
144 | return { | 170 | return { |
145 | then: function() { } | 171 | then: function() { } |
146 | }; | 172 | }; |
147 | } | 173 | } |
148 | }, | 174 | }, |
149 | focaBotoneraLateralService: {}, | 175 | focaBotoneraLateralService: {}, |
150 | focaModalService: focaModalService, | 176 | focaModalService: focaModalService, |
151 | notaPedidoBusinessService: {}, | 177 | notaPedidoBusinessService: {}, |
152 | $rootScope: { | 178 | $rootScope: { |
153 | $on: function() { } | 179 | $on: function() { } |
154 | }, | 180 | }, |
155 | focaSeguimientoService: {}, | 181 | focaSeguimientoService: {}, |
156 | APP: {}, | 182 | APP: {}, |
157 | focaLoginService: {} | 183 | focaLoginService: {}, |
184 | $localStorage: {} | ||
158 | }); | 185 | }); |
159 | 186 | ||
160 | //act | 187 | //act |
161 | spyOn(focaModalService, 'alert'); | 188 | spyOn(focaModalService, 'alert'); |
162 | scope.idLista = undefined; | 189 | scope.idLista = undefined; |
163 | scope.seleccionarProductos(); | 190 | scope.seleccionarProductos(); |
164 | 191 | ||
165 | //assert | 192 | //assert |
166 | expect(focaModalService.alert) | 193 | expect(focaModalService.alert) |
167 | .toHaveBeenCalledWith('Primero seleccione una lista de precio y condicion'); | 194 | .toHaveBeenCalledWith('Primero seleccione una lista de precio y condicion'); |
168 | }); | 195 | }); |
169 | 196 | ||
170 | it('función seleccionarProductos abre modal', function() { | 197 | it('función seleccionarProductos abre modal', function() { |
171 | //arrange | 198 | //arrange |
172 | var scope = {}; | 199 | var scope = { |
200 | $watch: function() { }, | ||
201 | $broadcast: function() { } | ||
202 | }; | ||
173 | var uibModal = { | 203 | var uibModal = { |
174 | open: function() { } | 204 | open: function() { } |
175 | }; | 205 | }; |
176 | 206 | ||
177 | $controler('notaPedidoCtrl', { | 207 | $controler('notaPedidoCtrl', { |
178 | $scope: scope, | 208 | $scope: scope, |
179 | $uibModal: uibModal, | 209 | $uibModal: uibModal, |
180 | $location: {}, | 210 | $location: {}, |
181 | $filter: filter, | 211 | $filter: filter, |
182 | $timeout: timeout, | 212 | $timeout: timeout, |
183 | crearNotaPedidoService: { | 213 | crearNotaPedidoService: { |
214 | getNumeroNotaPedido: function() { | ||
215 | return { | ||
216 | then: function() { } | ||
217 | }; | ||
218 | }, | ||
184 | getBotonera: function() { }, | 219 | getBotonera: function() { }, |
185 | getCotizacionByIdMoneda: function() { | 220 | getCotizacionByIdMoneda: function() { |
186 | return { | 221 | return { |
187 | then: function() { } | 222 | then: function() { } |
188 | }; | 223 | }; |
189 | } | 224 | } |
190 | }, | 225 | }, |
191 | focaBotoneraLateralService: {}, | 226 | focaBotoneraLateralService: {}, |
192 | focaModalService: {}, | 227 | focaModalService: {}, |
193 | notaPedidoBusinessService: {}, | 228 | notaPedidoBusinessService: {}, |
194 | $rootScope: { | 229 | $rootScope: { |
195 | $on: function() { } | 230 | $on: function() { } |
196 | }, | 231 | }, |
197 | focaSeguimientoService: {}, | 232 | focaSeguimientoService: {}, |
198 | APP: {}, | 233 | APP: {}, |
199 | focaLoginService: {} | 234 | focaLoginService: {}, |
235 | $localStorage: {} | ||
200 | }); | 236 | }); |
201 | scope.idLista = true; | 237 | scope.idLista = true; |
202 | scope.notaPedido = { | 238 | scope.notaPedido = { |
203 | cotizacion: {}, | 239 | cotizacion: { |
204 | moneda: {} | 240 | moneda: {} |
241 | }, | ||
242 | |||
205 | }; | 243 | }; |
206 | var respuesta = { result: {then: function() { } } }; | 244 | var respuesta = { result: {then: function() { } } }; |
207 | 245 | ||
208 | //act | 246 | //act |
209 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 247 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
210 | scope.seleccionarProductos(); | 248 | scope.seleccionarProductos(); |
211 | 249 | ||
212 | //assert | 250 | //assert |
213 | expect(uibModal.open).toHaveBeenCalled(); | 251 | expect(uibModal.open).toHaveBeenCalled(); |
214 | }); | 252 | }); |
215 | 253 | ||
216 | it('función seleccionarPuntosDeDescarga muestra alerta cuando cliente y domicilio son' + | 254 | it('función seleccionarPuntosDeDescarga muestra alerta cuando cliente y domicilio son' + |
217 | 'undefined', function() | 255 | 'undefined', function() |
218 | { | 256 | { |
219 | //arrange | 257 | //arrange |
220 | var scope = {}; | 258 | var scope = { |
259 | $watch: function() { }, | ||
260 | $broadcast: function() { } | ||
261 | }; | ||
221 | var focaModalService = { | 262 | var focaModalService = { |
222 | alert: function() { } | 263 | alert: function() { } |
223 | }; | 264 | }; |
224 | 265 | ||
225 | $controler('notaPedidoCtrl', { | 266 | $controler('notaPedidoCtrl', { |
226 | $scope: scope, | 267 | $scope: scope, |
227 | $uibModal: {}, | 268 | $uibModal: {}, |
228 | $location: {}, | 269 | $location: {}, |
229 | $filter: filter, | 270 | $filter: filter, |
230 | $timeout: timeout, | 271 | $timeout: timeout, |
231 | crearNotaPedidoService: { | 272 | crearNotaPedidoService: { |
273 | getNumeroNotaPedido: function() { | ||
274 | return { | ||
275 | then: function() { } | ||
276 | }; | ||
277 | }, | ||
232 | getBotonera: function() { }, | 278 | getBotonera: function() { }, |
233 | getCotizacionByIdMoneda: function() { | 279 | getCotizacionByIdMoneda: function() { |
234 | return { | 280 | return { |
235 | then: function() { } | 281 | then: function() { } |
236 | }; | 282 | }; |
237 | } | 283 | } |
238 | }, | 284 | }, |
239 | focaBotoneraLateralService: {}, | 285 | focaBotoneraLateralService: {}, |
240 | focaModalService: focaModalService, | 286 | focaModalService: focaModalService, |
241 | notaPedidoBusinessService: {}, | 287 | notaPedidoBusinessService: {}, |
242 | $rootScope: { | 288 | $rootScope: { |
243 | $on: function() { } | 289 | $on: function() { } |
244 | }, | 290 | }, |
245 | focaSeguimientoService: {}, | 291 | focaSeguimientoService: {}, |
246 | APP: {}, | 292 | APP: {}, |
247 | focaLoginService: {} | 293 | focaLoginService: {}, |
294 | $localStorage: {} | ||
248 | }); | 295 | }); |
249 | scope.idLista = true; | 296 | scope.idLista = true; |
250 | scope.notaPedido = { | 297 | scope.notaPedido = { |
251 | cliente: { COD: false }, | 298 | cliente: { COD: false }, |
252 | domicilio: { id: false} | 299 | domicilio: { id: false} |
253 | }; | 300 | }; |
254 | 301 | ||
255 | //act | 302 | //act |
256 | spyOn(focaModalService, 'alert'); | 303 | spyOn(focaModalService, 'alert'); |
257 | scope.seleccionarPuntosDeDescarga(); | 304 | scope.seleccionarPuntosDeDescarga(); |
258 | 305 | ||
259 | //assert | 306 | //assert |
260 | expect(focaModalService.alert).toHaveBeenCalled(); | 307 | expect(focaModalService.alert).toHaveBeenCalled(); |
261 | }); | 308 | }); |
262 | 309 | ||
263 | it('función seleccionarPuntosDeDescarga abre modal', function() { | 310 | it('función seleccionarPuntosDeDescarga abre modal', function() { |
264 | //arrange | 311 | //arrange |
265 | var scope = {}; | 312 | var scope = { |
313 | $watch: function() { }, | ||
314 | $broadcast: function() { } | ||
315 | }; | ||
266 | var uibModal = { | 316 | var uibModal = { |
267 | open: function() { } | 317 | open: function() { } |
268 | }; | 318 | }; |
269 | 319 | ||
270 | $controler('notaPedidoCtrl', { | 320 | $controler('notaPedidoCtrl', { |
271 | $scope: scope, | 321 | $scope: scope, |
272 | $uibModal: uibModal, | 322 | $uibModal: uibModal, |
273 | $location: {}, | 323 | $location: {}, |
274 | $filter: filter, | 324 | $filter: filter, |
275 | $timeout: timeout, | 325 | $timeout: timeout, |
276 | crearNotaPedidoService: { | 326 | crearNotaPedidoService: { |
327 | getNumeroNotaPedido: function() { | ||
328 | return { | ||
329 | then: function() { } | ||
330 | }; | ||
331 | }, | ||
277 | getBotonera: function() { }, | 332 | getBotonera: function() { }, |
278 | getCotizacionByIdMoneda: function() { | 333 | getCotizacionByIdMoneda: function() { |
279 | return { | 334 | return { |
280 | then: function() { } | 335 | then: function() { } |
281 | }; | 336 | }; |
282 | } | 337 | } |
283 | }, | 338 | }, |
284 | focaBotoneraLateralService: {}, | 339 | focaBotoneraLateralService: {}, |
285 | focaModalService: {}, | 340 | focaModalService: {}, |
286 | notaPedidoBusinessService: {}, | 341 | notaPedidoBusinessService: {}, |
287 | $rootScope: { | 342 | $rootScope: { |
288 | $on: function() { } | 343 | $on: function() { } |
289 | }, | 344 | }, |
290 | focaSeguimientoService: {}, | 345 | focaSeguimientoService: {}, |
291 | APP: {}, | 346 | APP: {}, |
292 | focaLoginService: {} | 347 | focaLoginService: {}, |
348 | $localStorage: {} | ||
293 | }); | 349 | }); |
294 | scope.idLista = true; | 350 | scope.idLista = true; |
295 | scope.notaPedido = { | 351 | scope.notaPedido = { |
296 | cliente: { COD: true }, | 352 | cliente: { COD: true }, |
297 | domicilio: { id: true } | 353 | domicilio: { id: true } |
298 | }; | 354 | }; |
299 | var respuesta = { result: { then: function() { } } }; | 355 | var respuesta = { result: { then: function() { } } }; |
300 | 356 | ||
301 | //act | 357 | //act |
302 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 358 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
303 | scope.seleccionarPuntosDeDescarga(); | 359 | scope.seleccionarPuntosDeDescarga(); |
304 | 360 | ||
305 | //assert | 361 | //assert |
306 | expect(uibModal.open).toHaveBeenCalled(); | 362 | expect(uibModal.open).toHaveBeenCalled(); |
307 | }); | 363 | }); |
308 | 364 | ||
309 | it('función seleccionarPuntosDeDescarga setea punto elegido', function(done) { | 365 | it('función seleccionarPuntosDeDescarga setea punto elegido', function(done) { |
310 | //arrange | 366 | //arrange |
311 | var scope = {}; | 367 | var scope = { |
368 | $watch: function() { }, | ||
369 | $broadcast: function() { } | ||
370 | }; | ||
312 | var uibModal = { | 371 | var uibModal = { |
313 | open: function() { } | 372 | open: function() { } |
314 | }; | 373 | }; |
315 | 374 | ||
316 | $controler('notaPedidoCtrl', { | 375 | $controler('notaPedidoCtrl', { |
317 | $scope: scope, | 376 | $scope: scope, |
318 | $uibModal: uibModal, | 377 | $uibModal: uibModal, |
319 | $location: {}, | 378 | $location: {}, |
320 | $filter: filter, | 379 | $filter: filter, |
321 | $timeout: timeout, | 380 | $timeout: timeout, |
322 | crearNotaPedidoService: { | 381 | crearNotaPedidoService: { |
382 | getNumeroNotaPedido: function() { | ||
383 | return { | ||
384 | then: function() { } | ||
385 | }; | ||
386 | }, | ||
323 | getBotonera: function() { }, | 387 | getBotonera: function() { }, |
324 | getCotizacionByIdMoneda: function() { | 388 | getCotizacionByIdMoneda: function() { |
325 | return { | 389 | return { |
326 | then: function() { } | 390 | then: function() { } |
327 | }; | 391 | }; |
328 | } | 392 | } |
329 | }, | 393 | }, |
330 | focaBotoneraLateralService: {}, | 394 | focaBotoneraLateralService: {}, |
331 | focaModalService: {}, | 395 | focaModalService: {}, |
332 | notaPedidoBusinessService: {}, | 396 | notaPedidoBusinessService: {}, |
333 | $rootScope: { | 397 | $rootScope: { |
334 | $on: function() { } | 398 | $on: function() { } |
335 | }, | 399 | }, |
336 | focaSeguimientoService: {}, | 400 | focaSeguimientoService: {}, |
337 | APP: {}, | 401 | APP: {}, |
338 | focaLoginService: {} | 402 | focaLoginService: {}, |
403 | $localStorage: {} | ||
339 | }); | 404 | }); |
340 | scope.idLista = true; | 405 | scope.idLista = true; |
341 | scope.notaPedido = { | 406 | scope.notaPedido = { |
342 | cliente: { COD: true }, | 407 | cliente: { COD: true }, |
343 | domicilio: { id: true } | 408 | domicilio: { id: true }, |
409 | puntosDescarga: [] | ||
344 | }; | 410 | }; |
345 | var respuesta = []; | 411 | var respuesta = []; |
346 | var promiseRespuesta = { result: Promise.resolve(respuesta) }; | 412 | var promiseRespuesta = { result: Promise.resolve(respuesta) }; |
347 | scope.$broadcast = function() { }; | 413 | scope.$broadcast = function() { }; |
348 | 414 | ||
349 | //act | 415 | //act |
350 | spyOn(uibModal, 'open').and.returnValue(promiseRespuesta); | 416 | spyOn(uibModal, 'open').and.returnValue(promiseRespuesta); |
351 | scope.seleccionarPuntosDeDescarga(); | 417 | scope.seleccionarPuntosDeDescarga(); |
352 | 418 | ||
353 | //assert | 419 | //assert |
354 | promiseRespuesta.result.then(function() { | 420 | promiseRespuesta.result.then(function() { |
355 | expect(scope.notaPedido.puntosDescarga).toEqual(respuesta); | 421 | expect(scope.notaPedido.puntosDescarga).toEqual(respuesta); |
356 | done(); | 422 | done(); |
357 | }); | 423 | }); |
358 | }); | 424 | }); |
359 | 425 | ||
360 | it('función seleccionarVendedor abre modal', function() { | 426 | it('función seleccionarVendedor abre modal', function() { |
361 | //arrange | 427 | //arrange |
362 | var scope = {}; | 428 | var scope = { |
429 | $watch: function() { }, | ||
430 | $broadcast: function() { } | ||
431 | }; | ||
363 | var focaModalService = { | 432 | var focaModalService = { |
364 | modal: function() { } | 433 | modal: function() { } |
365 | }; | 434 | }; |
366 | 435 | ||
367 | $controler('notaPedidoCtrl', { | 436 | $controler('notaPedidoCtrl', { |
368 | $scope: scope, | 437 | $scope: scope, |
369 | $uibModal: {}, | 438 | $uibModal: {}, |
370 | $location: {}, | 439 | $location: {}, |
371 | $filter: filter, | 440 | $filter: filter, |
372 | $timeout: timeout, | 441 | $timeout: timeout, |
373 | crearNotaPedidoService: { | 442 | crearNotaPedidoService: { |
443 | getNumeroNotaPedido: function() { | ||
444 | return { | ||
445 | then: function() { } | ||
446 | }; | ||
447 | }, | ||
374 | getBotonera: function() { }, | 448 | getBotonera: function() { }, |
375 | getCotizacionByIdMoneda: function() { | 449 | getCotizacionByIdMoneda: function() { |
376 | return { | 450 | return { |
377 | then: function() { } | 451 | then: function() { } |
378 | }; | 452 | }; |
379 | } | 453 | } |
380 | }, | 454 | }, |
381 | focaBotoneraLateralService: {}, | 455 | focaBotoneraLateralService: {}, |
382 | focaModalService: focaModalService, | 456 | focaModalService: focaModalService, |
383 | notaPedidoBusinessService: {}, | 457 | notaPedidoBusinessService: {}, |
384 | $rootScope: { | 458 | $rootScope: { |
385 | $on: function() { } | 459 | $on: function() { } |
386 | }, | 460 | }, |
387 | focaSeguimientoService: {}, | 461 | focaSeguimientoService: {}, |
388 | APP: {}, | 462 | APP: {}, |
389 | focaLoginService: {} | 463 | focaLoginService: {}, |
464 | $localStorage: {} | ||
390 | }); | 465 | }); |
391 | scope.idLista = true; | 466 | scope.idLista = true; |
392 | scope.notaPedido = { | 467 | scope.notaPedido = { |
393 | cliente: { COD: true }, | 468 | cliente: { COD: true }, |
394 | domicilio: { id: true } | 469 | domicilio: { id: true } |
395 | }; | 470 | }; |
396 | 471 | ||
397 | var respuesta = { then: function() { } }; | 472 | var respuesta = { then: function() { } }; |
398 | 473 | ||
399 | //act | 474 | //act |
400 | spyOn(focaModalService, 'modal').and.returnValue(respuesta); | 475 | spyOn(focaModalService, 'modal').and.returnValue(respuesta); |
401 | scope.seleccionarVendedor(); | 476 | scope.seleccionarVendedor(); |
402 | 477 | ||
403 | //assert | 478 | //assert |
404 | expect(focaModalService.modal).toHaveBeenCalled(); | 479 | expect(focaModalService.modal).toHaveBeenCalled(); |
405 | }); | 480 | }); |
406 | 481 | ||
407 | it('función seleccionarVendedor setea vendedor y cabecera', function(done) { | 482 | it('función seleccionarVendedor setea vendedor y cabecera', function(done) { |
408 | //arrange | 483 | //arrange |
409 | var scope = {}; | 484 | var scope = { |
485 | $watch: function() { }, | ||
486 | $broadcast: function() { } | ||
487 | }; | ||
410 | var focaModalService = { | 488 | var focaModalService = { |
411 | modal: function() { } | 489 | modal: function() { } |
412 | }; | 490 | }; |
413 | 491 | ||
414 | $controler('notaPedidoCtrl', { | 492 | $controler('notaPedidoCtrl', { |
415 | $scope: scope, | 493 | $scope: scope, |
416 | $uibModal: {}, | 494 | $uibModal: {}, |
417 | $location: {}, | 495 | $location: {}, |
418 | $filter: filter, | 496 | $filter: filter, |
419 | $timeout: timeout, | 497 | $timeout: timeout, |
420 | crearNotaPedidoService: { | 498 | crearNotaPedidoService: { |
499 | getNumeroNotaPedido: function() { | ||
500 | return { | ||
501 | then: function() { } | ||
502 | }; | ||
503 | }, | ||
421 | getBotonera: function() { }, | 504 | getBotonera: function() { }, |
422 | getCotizacionByIdMoneda: function() { | 505 | getCotizacionByIdMoneda: function() { |
423 | return { | 506 | return { |
424 | then: function() { } | 507 | then: function() { } |
425 | }; | 508 | }; |
426 | } | 509 | } |
427 | }, | 510 | }, |
428 | focaBotoneraLateralService: {}, | 511 | focaBotoneraLateralService: {}, |
429 | focaModalService: focaModalService, | 512 | focaModalService: focaModalService, |
430 | notaPedidoBusinessService: {}, | 513 | notaPedidoBusinessService: {}, |
431 | $rootScope: { | 514 | $rootScope: { |
432 | $on: function() { } | 515 | $on: function() { } |
433 | }, | 516 | }, |
434 | focaSeguimientoService: {}, | 517 | focaSeguimientoService: {}, |
435 | APP: {}, | 518 | APP: {}, |
436 | focaLoginService: {} | 519 | focaLoginService: {}, |
520 | $localStorage: {} | ||
437 | }); | 521 | }); |
438 | scope.idLista = true; | 522 | scope.idLista = true; |
439 | scope.notaPedido = { | 523 | scope.notaPedido = { |
440 | cliente: { COD: true }, | 524 | cliente: { COD: true }, |
441 | domicilio: { id: true } | 525 | domicilio: { id: true } |
442 | }; | 526 | }; |
443 | var respuesta = {}; | 527 | var respuesta = {}; |
444 | var promesaRespuesta = Promise.resolve(respuesta); | 528 | var promesaRespuesta = Promise.resolve(respuesta); |
445 | scope.$broadcast = function() { }; | 529 | scope.$broadcast = function() { }; |
446 | 530 | ||
447 | //act | 531 | //act |
448 | spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); | 532 | spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); |
449 | spyOn(scope, '$broadcast'); | 533 | spyOn(scope, '$broadcast'); |
450 | scope.seleccionarVendedor(); | 534 | scope.seleccionarVendedor(); |
451 | 535 | ||
452 | //assert | 536 | //assert |
453 | promesaRespuesta.then(function() { | 537 | promesaRespuesta.then(function() { |
454 | expect(scope.notaPedido.vendedor).toEqual(respuesta); | 538 | expect(scope.notaPedido.vendedor).toEqual(respuesta); |
455 | expect(scope.$broadcast).toHaveBeenCalled(); | 539 | expect(scope.$broadcast).toHaveBeenCalled(); |
456 | done(); | 540 | done(); |
457 | }); | 541 | }); |
458 | }); | 542 | }); |
459 | 543 | ||
460 | it('función seleccionarProveedor abre modal', function() { | 544 | it('función seleccionarProveedor abre modal', function() { |
461 | //arrange | 545 | //arrange |
462 | var scope = {}; | 546 | var scope = { |
547 | $watch: function() { }, | ||
548 | $broadcast: function() { } | ||
549 | }; | ||
463 | var focaModalService = { | 550 | var focaModalService = { |
464 | modal: function() { } | 551 | modal: function() { } |
465 | }; | 552 | }; |
466 | 553 | ||
467 | $controler('notaPedidoCtrl', { | 554 | $controler('notaPedidoCtrl', { |
468 | $scope: scope, | 555 | $scope: scope, |
469 | $uibModal: {}, | 556 | $uibModal: {}, |
470 | $location: {}, | 557 | $location: {}, |
471 | $filter: filter, | 558 | $filter: filter, |
472 | $timeout: timeout, | 559 | $timeout: timeout, |
473 | crearNotaPedidoService: { | 560 | crearNotaPedidoService: { |
561 | getNumeroNotaPedido: function() { | ||
562 | return { | ||
563 | then: function() { } | ||
564 | }; | ||
565 | }, | ||
474 | getBotonera: function() { }, | 566 | getBotonera: function() { }, |
475 | getCotizacionByIdMoneda: function() { | 567 | getCotizacionByIdMoneda: function() { |
476 | return { | 568 | return { |
477 | then: function() { } | 569 | then: function() { } |
478 | }; | 570 | }; |
479 | } | 571 | } |
480 | }, | 572 | }, |
481 | focaBotoneraLateralService: {}, | 573 | focaBotoneraLateralService: {}, |
482 | focaModalService: focaModalService, | 574 | focaModalService: focaModalService, |
483 | notaPedidoBusinessService: {}, | 575 | notaPedidoBusinessService: {}, |
484 | $rootScope: { | 576 | $rootScope: { |
485 | $on: function() { } | 577 | $on: function() { } |
486 | }, | 578 | }, |
487 | focaSeguimientoService: {}, | 579 | focaSeguimientoService: {}, |
488 | APP: {}, | 580 | APP: {}, |
489 | focaLoginService: {} | 581 | focaLoginService: {}, |
582 | $localStorage: {} | ||
490 | }); | 583 | }); |
491 | scope.notaPedido = {}; | 584 | scope.notaPedido = {}; |
492 | 585 | ||
493 | var respuesta = { then: function() { } }; | 586 | var respuesta = { then: function() { } }; |
494 | 587 | ||
495 | //act | 588 | //act |
496 | spyOn(focaModalService, 'modal').and.returnValue(respuesta); | 589 | spyOn(focaModalService, 'modal').and.returnValue(respuesta); |
497 | scope.seleccionarProveedor(); | 590 | scope.seleccionarProveedor(); |
498 | 591 | ||
499 | //assert | 592 | //assert |
500 | expect(focaModalService.modal).toHaveBeenCalled(); | 593 | expect(focaModalService.modal).toHaveBeenCalled(); |
501 | }); | 594 | }); |
502 | 595 | ||
503 | it('función seleccionarProveedor setea vendedor y cabecera', function(done) { | 596 | it('función seleccionarProveedor setea vendedor y cabecera', function(done) { |
504 | //arrange | 597 | //arrange |
505 | var scope = {}; | 598 | var scope = { |
599 | $watch: function() { }, | ||
600 | $broadcast: function() { } | ||
601 | }; | ||
506 | var focaModalService = { | 602 | var focaModalService = { |
507 | modal: function() { } | 603 | modal: function() { } |
508 | }; | 604 | }; |
509 | 605 | ||
510 | $controler('notaPedidoCtrl', { | 606 | $controler('notaPedidoCtrl', { |
511 | $scope: scope, | 607 | $scope: scope, |
512 | $uibModal: {}, | 608 | $uibModal: {}, |
513 | $location: {}, | 609 | $location: {}, |
514 | $filter: filter, | 610 | $filter: filter, |
515 | $timeout: timeout, | 611 | $timeout: timeout, |
516 | crearNotaPedidoService: { | 612 | crearNotaPedidoService: { |
613 | getNumeroNotaPedido: function() { | ||
614 | return { | ||
615 | then: function() { } | ||
616 | }; | ||
617 | }, | ||
517 | getBotonera: function() { }, | 618 | getBotonera: function() { }, |
518 | getCotizacionByIdMoneda: function() { | 619 | getCotizacionByIdMoneda: function() { |
519 | return { | 620 | return { |
520 | then: function() { } | 621 | then: function() { } |
521 | }; | 622 | }; |
522 | } | 623 | } |
523 | }, | 624 | }, |
524 | focaBotoneraLateralService: {}, | 625 | focaBotoneraLateralService: {}, |
525 | focaModalService: focaModalService, | 626 | focaModalService: focaModalService, |
526 | notaPedidoBusinessService: {}, | 627 | notaPedidoBusinessService: {}, |
527 | $rootScope: { | 628 | $rootScope: { |
528 | $on: function() { } | 629 | $on: function() { } |
529 | }, | 630 | }, |
530 | focaSeguimientoService: {}, | 631 | focaSeguimientoService: {}, |
531 | APP: {}, | 632 | APP: {}, |
532 | focaLoginService: {} | 633 | focaLoginService: {}, |
634 | $localStorage: {} | ||
533 | }); | 635 | }); |
534 | 636 | ||
535 | scope.notaPedido = {}; | 637 | scope.notaPedido = {}; |
536 | var respuesta = {}; | 638 | var respuesta = {}; |
537 | var promesaRespuesta = Promise.resolve(respuesta); | 639 | var promesaRespuesta = Promise.resolve(respuesta); |
538 | scope.$broadcast = function() { }; | 640 | scope.$broadcast = function() { }; |
539 | 641 | ||
540 | //act | 642 | //act |
541 | spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); | 643 | spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); |
542 | spyOn(scope, '$broadcast'); | 644 | spyOn(scope, '$broadcast'); |
543 | scope.seleccionarProveedor(); | 645 | scope.seleccionarProveedor(); |
544 | 646 | ||
545 | //assert | 647 | //assert |
546 | promesaRespuesta.then(function() { | 648 | promesaRespuesta.then(function() { |
547 | expect(scope.notaPedido.proveedor).toEqual(respuesta); | 649 | expect(scope.notaPedido.proveedor).toEqual(respuesta); |
548 | expect(scope.$broadcast).toHaveBeenCalled(); | 650 | expect(scope.$broadcast).toHaveBeenCalled(); |
549 | done(); | 651 | done(); |
550 | }); | 652 | }); |
551 | }); | 653 | }); |
552 | 654 | ||
553 | it('función seleccionarCliente abre alerta cuando no se elije vendedor', function() { | 655 | it('función seleccionarCliente abre alerta cuando no se elije vendedor', function() { |
554 | //arrange | 656 | //arrange |
555 | var scope = {}; | 657 | var scope = { |
658 | $watch: function() { }, | ||
659 | $broadcast: function() { } | ||
660 | }; | ||
556 | var focaModalService = { | 661 | var focaModalService = { |
557 | alert: function() { } | 662 | alert: function() { } |
558 | }; | 663 | }; |
559 | 664 | ||
560 | $controler('notaPedidoCtrl', { | 665 | $controler('notaPedidoCtrl', { |
561 | $scope: scope, | 666 | $scope: scope, |
562 | $uibModal: {}, | 667 | $uibModal: {}, |
563 | $location: {}, | 668 | $location: {}, |
564 | $filter: filter, | 669 | $filter: filter, |
565 | $timeout: timeout, | 670 | $timeout: timeout, |
566 | crearNotaPedidoService: { | 671 | crearNotaPedidoService: { |
672 | getNumeroNotaPedido: function() { | ||
673 | return { | ||
674 | then: function() { } | ||
675 | }; | ||
676 | }, | ||
567 | getBotonera: function() { }, | 677 | getBotonera: function() { }, |
568 | getCotizacionByIdMoneda: function() { | 678 | getCotizacionByIdMoneda: function() { |
569 | return { | 679 | return { |
570 | then: function() { } | 680 | then: function() { } |
571 | }; | 681 | }; |
572 | } | 682 | } |
573 | }, | 683 | }, |
574 | focaBotoneraLateralService: {}, | 684 | focaBotoneraLateralService: {}, |
575 | focaModalService: focaModalService, | 685 | focaModalService: focaModalService, |
576 | notaPedidoBusinessService: {}, | 686 | notaPedidoBusinessService: {}, |
577 | $rootScope: { | 687 | $rootScope: { |
578 | $on: function() { } | 688 | $on: function() { } |
579 | }, | 689 | }, |
580 | focaSeguimientoService: {}, | 690 | focaSeguimientoService: {}, |
581 | APP: {}, | 691 | APP: {}, |
582 | focaLoginService: {} | 692 | focaLoginService: {}, |
693 | $localStorage: {} | ||
583 | }); | 694 | }); |
584 | scope.notaPedido = { | 695 | scope.notaPedido = { |
585 | vendedor: { NUM: false } | 696 | vendedor: { NUM: false } |
586 | }; | 697 | }; |
587 | 698 | ||
588 | //act | 699 | //act |
589 | spyOn(focaModalService, 'alert'); | 700 | spyOn(focaModalService, 'alert'); |
590 | scope.seleccionarCliente(); | 701 | scope.seleccionarCliente(); |
591 | 702 | ||
592 | //assert | 703 | //assert |
593 | expect(focaModalService.alert).toHaveBeenCalledWith('Primero seleccione un vendedor'); | 704 | expect(focaModalService.alert).toHaveBeenCalledWith('Primero seleccione un vendedor'); |
594 | }); | 705 | }); |
595 | 706 | ||
596 | it('función seleccionarCliente abre modal', function() { | 707 | it('función seleccionarCliente abre modal', function() { |
597 | //arrange | 708 | //arrange |
598 | var scope = {}; | 709 | var scope = { |
710 | $watch: function() { }, | ||
711 | $broadcast: function() { } | ||
712 | }; | ||
599 | var uibModal = { | 713 | var uibModal = { |
600 | open: function() { } | 714 | open: function() { } |
601 | }; | 715 | }; |
602 | 716 | ||
603 | $controler('notaPedidoCtrl', { | 717 | $controler('notaPedidoCtrl', { |
604 | $scope: scope, | 718 | $scope: scope, |
605 | $uibModal: uibModal, | 719 | $uibModal: uibModal, |
606 | $location: {}, | 720 | $location: {}, |
607 | $filter: filter, | 721 | $filter: filter, |
608 | $timeout: timeout, | 722 | $timeout: timeout, |
609 | crearNotaPedidoService: { | 723 | crearNotaPedidoService: { |
724 | getNumeroNotaPedido: function() { | ||
725 | return { | ||
726 | then: function() { } | ||
727 | }; | ||
728 | }, | ||
610 | getBotonera: function() { }, | 729 | getBotonera: function() { }, |
611 | getCotizacionByIdMoneda: function() { | 730 | getCotizacionByIdMoneda: function() { |
612 | return { | 731 | return { |
613 | then: function() { } | 732 | then: function() { } |
614 | }; | 733 | }; |
615 | } | 734 | } |
616 | }, | 735 | }, |
617 | focaBotoneraLateralService: {}, | 736 | focaBotoneraLateralService: {}, |
618 | focaModalService: {}, | 737 | focaModalService: {}, |
619 | notaPedidoBusinessService: {}, | 738 | notaPedidoBusinessService: {}, |
620 | $rootScope: { | 739 | $rootScope: { |
621 | $on: function() { } | 740 | $on: function() { } |
622 | }, | 741 | }, |
623 | focaSeguimientoService: {}, | 742 | focaSeguimientoService: {}, |
624 | APP: {}, | 743 | APP: {}, |
625 | focaLoginService: {} | 744 | focaLoginService: {}, |
745 | $localStorage: {} | ||
626 | }); | 746 | }); |
627 | scope.notaPedido = { | 747 | scope.notaPedido = { |
628 | vendedor: { NUM: true } | 748 | vendedor: { NUM: true } |
629 | }; | 749 | }; |
630 | 750 | ||
631 | var respuesta = { result: {then: function() { } } }; | 751 | var respuesta = { result: {then: function() { } } }; |
632 | 752 | ||
633 | //act | 753 | //act |
634 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 754 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
635 | scope.seleccionarCliente(); | 755 | scope.seleccionarCliente(); |
636 | 756 | ||
637 | //assert | 757 | //assert |
638 | expect(uibModal.open).toHaveBeenCalled(); | 758 | expect(uibModal.open).toHaveBeenCalled(); |
639 | }); | 759 | }); |
640 | 760 | ||
641 | it('función seleccionarCliente setea vendedor y llama a domicilios', function(done) { | 761 | it('función seleccionarCliente setea vendedor y llama a domicilios', function(done) { |
642 | 762 | ||
643 | //arrange | 763 | //arrange |
644 | var scope = {}; | 764 | var scope = { |
765 | $watch: function() { }, | ||
766 | $broadcast: function() { } | ||
767 | }; | ||
645 | var uibModal = { | 768 | var uibModal = { |
646 | open: function() { } | 769 | open: function() { } |
647 | }; | 770 | }; |
648 | 771 | ||
649 | $controler('notaPedidoCtrl', { | 772 | $controler('notaPedidoCtrl', { |
650 | $scope: scope, | 773 | $scope: scope, |
651 | $uibModal: uibModal, | 774 | $uibModal: uibModal, |
652 | $location: {}, | 775 | $location: {}, |
653 | $filter: filter, | 776 | $filter: filter, |
654 | $timeout: timeout, | 777 | $timeout: timeout, |
655 | crearNotaPedidoService: { | 778 | crearNotaPedidoService: { |
779 | getNumeroNotaPedido: function() { | ||
780 | return { | ||
781 | then: function() { } | ||
782 | }; | ||
783 | }, | ||
656 | getBotonera: function() { }, | 784 | getBotonera: function() { }, |
657 | getCotizacionByIdMoneda: function() { | 785 | getCotizacionByIdMoneda: function() { |
658 | return { | 786 | return { |
659 | then: function() { } | 787 | then: function() { } |
660 | }; | 788 | }; |
661 | } | 789 | } |
662 | }, | 790 | }, |
663 | focaBotoneraLateralService: {}, | 791 | focaBotoneraLateralService: {}, |
664 | focaModalService: {}, | 792 | focaModalService: {}, |
665 | notaPedidoBusinessService: {}, | 793 | notaPedidoBusinessService: {}, |
666 | $rootScope: { | 794 | $rootScope: { |
667 | $on: function() { } | 795 | $on: function() { } |
668 | }, | 796 | }, |
669 | focaSeguimientoService: {}, | 797 | focaSeguimientoService: {}, |
670 | APP: {}, | 798 | APP: {}, |
671 | focaLoginService: {} | 799 | focaLoginService: {}, |
800 | $localStorage: {} | ||
672 | }); | 801 | }); |
673 | scope.idLista = true; | 802 | scope.idLista = true; |
674 | scope.notaPedido = { | 803 | scope.notaPedido = { |
675 | vendedor: { NUM: true } | 804 | vendedor: { NUM: true } |
676 | }; | 805 | }; |
677 | var respuesta = {}; | 806 | var respuesta = {}; |
678 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; | 807 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; |
679 | 808 | ||
680 | //act | 809 | //act |
681 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); | 810 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); |
682 | spyOn(scope, 'abrirModalDomicilios'); | 811 | spyOn(scope, 'abrirModalDomicilios'); |
683 | scope.seleccionarCliente(); | 812 | scope.seleccionarCliente(); |
684 | 813 | ||
685 | //assert | 814 | //assert |
686 | promesaRespuesta.result.then(function() { | 815 | promesaRespuesta.result.then(function() { |
687 | expect(scope.cliente).toEqual(respuesta); | 816 | expect(scope.cliente).toEqual(respuesta); |
688 | expect(scope.abrirModalDomicilios).toHaveBeenCalled(); | 817 | expect(scope.abrirModalDomicilios).toHaveBeenCalled(); |
689 | done(); | 818 | done(); |
690 | }); | 819 | }); |
691 | }); | 820 | }); |
692 | 821 | ||
693 | it('función abrirModalDomicilios abre modal', function() { | 822 | it('función abrirModalDomicilios abre modal', function() { |
694 | //arrange | 823 | //arrange |
695 | var scope = {}; | 824 | var scope = { |
825 | $watch: function() { }, | ||
826 | $broadcast: function() { } | ||
827 | }; | ||
696 | var uibModal = { | 828 | var uibModal = { |
697 | open: function() { } | 829 | open: function() { } |
698 | }; | 830 | }; |
699 | 831 | ||
700 | $controler('notaPedidoCtrl', { | 832 | $controler('notaPedidoCtrl', { |
701 | $scope: scope, | 833 | $scope: scope, |
702 | $uibModal: uibModal, | 834 | $uibModal: uibModal, |
703 | $location: {}, | 835 | $location: {}, |
704 | $filter: filter, | 836 | $filter: filter, |
705 | $timeout: timeout, | 837 | $timeout: timeout, |
706 | crearNotaPedidoService: { | 838 | crearNotaPedidoService: { |
839 | getNumeroNotaPedido: function() { | ||
840 | return { | ||
841 | then: function() { } | ||
842 | }; | ||
843 | }, | ||
707 | getBotonera: function() { }, | 844 | getBotonera: function() { }, |
708 | getCotizacionByIdMoneda: function() { | 845 | getCotizacionByIdMoneda: function() { |
709 | return { | 846 | return { |
710 | then: function() { } | 847 | then: function() { } |
711 | }; | 848 | }; |
712 | } | 849 | } |
713 | }, | 850 | }, |
714 | focaBotoneraLateralService: {}, | 851 | focaBotoneraLateralService: {}, |
715 | focaModalService: {}, | 852 | focaModalService: {}, |
716 | notaPedidoBusinessService: {}, | 853 | notaPedidoBusinessService: {}, |
717 | $rootScope: { | 854 | $rootScope: { |
718 | $on: function() { } | 855 | $on: function() { } |
719 | }, | 856 | }, |
720 | focaSeguimientoService: {}, | 857 | focaSeguimientoService: {}, |
721 | APP: {}, | 858 | APP: {}, |
722 | focaLoginService: {} | 859 | focaLoginService: {}, |
860 | $localStorage: {} | ||
723 | }); | 861 | }); |
724 | 862 | ||
725 | var respuesta = { result: {then: function() { } } }; | 863 | var respuesta = { result: {then: function() { } } }; |
726 | 864 | ||
727 | //act | 865 | //act |
728 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 866 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
729 | scope.abrirModalDomicilios(); | 867 | scope.abrirModalDomicilios(); |
730 | 868 | ||
731 | //assert | 869 | //assert |
732 | expect(uibModal.open).toHaveBeenCalled(); | 870 | expect(uibModal.open).toHaveBeenCalled(); |
733 | }); | 871 | }); |
734 | 872 | ||
735 | it('función abrirModalDomicilios setea domicilio, cliente y cabeceras', function(done) { | 873 | it('función abrirModalDomicilios setea domicilio, cliente y cabeceras', function(done) { |
736 | 874 | ||
737 | //arrange | 875 | //arrange |
738 | var scope = {}; | 876 | var scope = { |
877 | $watch: function() { }, | ||
878 | $broadcast: function() { } | ||
879 | }; | ||
739 | var uibModal = { | 880 | var uibModal = { |
740 | open: function() { } | 881 | open: function() { } |
741 | }; | 882 | }; |
742 | 883 | ||
743 | $controler('notaPedidoCtrl', { | 884 | $controler('notaPedidoCtrl', { |
744 | $scope: scope, | 885 | $scope: scope, |
745 | $uibModal: uibModal, | 886 | $uibModal: uibModal, |
746 | $location: {}, | 887 | $location: {}, |
747 | $filter: filter, | 888 | $filter: filter, |
748 | $timeout: timeout, | 889 | $timeout: timeout, |
749 | crearNotaPedidoService: { | 890 | crearNotaPedidoService: { |
891 | getNumeroNotaPedido: function() { | ||
892 | return { | ||
893 | then: function() { } | ||
894 | }; | ||
895 | }, | ||
750 | getBotonera: function() { }, | 896 | getBotonera: function() { }, |
751 | getCotizacionByIdMoneda: function() { | 897 | getCotizacionByIdMoneda: function() { |
752 | return { | 898 | return { |
753 | then: function() { } | 899 | then: function() { } |
754 | }; | 900 | }; |
755 | }, | 901 | }, |
756 | getPuntosDescargaByClienDom: function() { | 902 | getPuntosDescargaByClienDom: function() { |
757 | return { | 903 | return { |
758 | then: function() { } | 904 | then: function() { } |
759 | }; | 905 | }; |
760 | } | 906 | } |
761 | }, | 907 | }, |
762 | focaBotoneraLateralService: {}, | 908 | focaBotoneraLateralService: {}, |
763 | focaModalService: {}, | 909 | focaModalService: {}, |
764 | notaPedidoBusinessService: {}, | 910 | notaPedidoBusinessService: {}, |
765 | $rootScope: { | 911 | $rootScope: { |
766 | $on: function() { } | 912 | $on: function() { } |
767 | }, | 913 | }, |
768 | focaSeguimientoService: {}, | 914 | focaSeguimientoService: {}, |
769 | APP: {}, | 915 | APP: {}, |
770 | focaLoginService: {} | 916 | focaLoginService: {}, |
917 | $localStorage: {} | ||
771 | }); | 918 | }); |
772 | scope.idLista = true; | 919 | scope.idLista = true; |
773 | scope.notaPedido = { | 920 | scope.notaPedido = { |
774 | vendedor: { NUM: true } | 921 | vendedor: { NUM: true } |
775 | }; | 922 | }; |
776 | var respuesta = {}; | 923 | var respuesta = {}; |
777 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; | 924 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; |
778 | scope.$broadcast = function() { }; | 925 | scope.$broadcast = function() { }; |
779 | var cliente = { | 926 | var cliente = { |
780 | COD: undefined, | 927 | COD: undefined, |
781 | CUIT: undefined, | 928 | CUIT: undefined, |
782 | NOM: undefined | 929 | NOM: undefined |
783 | }; | 930 | }; |
784 | 931 | ||
785 | //act | 932 | //act |
786 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); | 933 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); |
787 | spyOn(scope, '$broadcast'); | 934 | spyOn(scope, '$broadcast'); |
788 | scope.abrirModalDomicilios({ }); | 935 | scope.abrirModalDomicilios({ }); |
789 | 936 | ||
790 | //assert | 937 | //assert |
791 | promesaRespuesta.result.then(function() { | 938 | promesaRespuesta.result.then(function() { |
792 | expect(scope.notaPedido.domicilio).toEqual(respuesta); | 939 | expect(scope.notaPedido.domicilio).toEqual(respuesta); |
793 | expect(scope.notaPedido.cliente).toEqual(cliente); | 940 | expect(scope.notaPedido.cliente).toEqual(cliente); |
794 | expect(scope.$broadcast).toHaveBeenCalled(); | 941 | expect(scope.$broadcast).toHaveBeenCalled(); |
795 | done(); | 942 | done(); |
796 | }); | 943 | }); |
797 | }); | 944 | }); |
798 | 945 | ||
799 | it('función getTotal devulve correctamente', function() { | 946 | it('función getTotal devulve correctamente', function() { |
800 | 947 | ||
801 | //arrange | 948 | //arrange |
802 | var scope = {}; | 949 | var scope = { |
950 | $watch: function() { }, | ||
951 | $broadcast: function() { } | ||
952 | }; | ||
803 | 953 | ||
804 | $controler('notaPedidoCtrl', { | 954 | $controler('notaPedidoCtrl', { |
805 | $scope: scope, | 955 | $scope: scope, |
806 | $uibModal: {}, | 956 | $uibModal: {}, |
807 | $location: {}, | 957 | $location: {}, |
808 | $filter: filter, | 958 | $filter: filter, |
809 | $timeout: timeout, | 959 | $timeout: timeout, |
810 | crearNotaPedidoService: { | 960 | crearNotaPedidoService: { |
961 | getNumeroNotaPedido: function() { | ||
962 | return { | ||
963 | then: function() { } | ||
964 | }; | ||
965 | }, | ||
811 | getBotonera: function() { }, | 966 | getBotonera: function() { }, |
812 | getCotizacionByIdMoneda: function() { | 967 | getCotizacionByIdMoneda: function() { |
813 | return { | 968 | return { |
814 | then: function() { } | 969 | then: function() { } |
815 | }; | 970 | }; |
816 | } | 971 | } |
817 | }, | 972 | }, |
818 | focaBotoneraLateralService: {}, | 973 | focaBotoneraLateralService: {}, |
819 | focaModalService: {}, | 974 | focaModalService: {}, |
820 | notaPedidoBusinessService: {}, | 975 | notaPedidoBusinessService: {}, |
821 | $rootScope: { | 976 | $rootScope: { |
822 | $on: function() { } | 977 | $on: function() { } |
823 | }, | 978 | }, |
824 | focaSeguimientoService: {}, | 979 | focaSeguimientoService: {}, |
825 | APP: {}, | 980 | APP: {}, |
826 | focaLoginService: {} | 981 | focaLoginService: {}, |
982 | $localStorage: {} | ||
827 | }); | 983 | }); |
828 | scope.idLista = true; | 984 | scope.idLista = true; |
829 | scope.notaPedido = { | 985 | scope.notaPedido = { |
830 | vendedor: { NUM: true } | 986 | vendedor: { NUM: true } |
831 | }; | 987 | }; |
832 | 988 | ||
833 | //act | 989 | //act |
834 | scope.articulosTabla = [{ precio: 2, cantidad: 1}]; | 990 | scope.notaPedido.articulosNotaPedido = [{ precio: 2, cantidad: 1}]; |
835 | var esperado = 2; | 991 | var esperado = 2; |
836 | var resultado = scope.getTotal(); | 992 | var resultado = scope.getTotal(); |
837 | 993 | ||
838 | //assert | 994 | //assert |
839 | expect(resultado).toEqual(esperado); | 995 | expect(resultado).toEqual(esperado); |
840 | }); | 996 | }); |
841 | 997 | ||
842 | it('función getSubTotal devulve correctamente', function() { | 998 | it('función getSubTotal devulve correctamente', function() { |
843 | 999 | ||
844 | //arrange | 1000 | //arrange |
845 | var scope = {}; | 1001 | var scope = { |
1002 | $watch: function() { }, | ||
1003 | $broadcast: function() { } | ||
1004 | }; | ||
846 | 1005 | ||
847 | $controler('notaPedidoCtrl', { | 1006 | $controler('notaPedidoCtrl', { |
848 | $scope: scope, | 1007 | $scope: scope, |
849 | $uibModal: {}, | 1008 | $uibModal: {}, |
850 | $location: {}, | 1009 | $location: {}, |
851 | $filter: filter, | 1010 | $filter: filter, |
852 | $timeout: timeout, | 1011 | $timeout: timeout, |
853 | crearNotaPedidoService: { | 1012 | crearNotaPedidoService: { |
1013 | getNumeroNotaPedido: function() { | ||
1014 | return { | ||
1015 | then: function() { } | ||
1016 | }; | ||
1017 | }, | ||
854 | getBotonera: function() { }, | 1018 | getBotonera: function() { }, |
855 | getCotizacionByIdMoneda: function() { | 1019 | getCotizacionByIdMoneda: function() { |
856 | return { | 1020 | return { |
857 | then: function() { } | 1021 | then: function() { } |
858 | }; | 1022 | }; |
859 | } | 1023 | } |
860 | }, | 1024 | }, |
861 | focaBotoneraLateralService: {}, | 1025 | focaBotoneraLateralService: {}, |
862 | focaModalService: {}, | 1026 | focaModalService: {}, |
863 | notaPedidoBusinessService: {}, | 1027 | notaPedidoBusinessService: {}, |
864 | $rootScope: { | 1028 | $rootScope: { |
865 | $on: function() { } | 1029 | $on: function() { } |
866 | }, | 1030 | }, |
867 | focaSeguimientoService: {}, | 1031 | focaSeguimientoService: {}, |
868 | APP: {}, | 1032 | APP: {}, |
869 | focaLoginService: {} | 1033 | focaLoginService: {}, |
1034 | $localStorage: {} | ||
870 | }); | 1035 | }); |
871 | scope.idLista = true; | 1036 | scope.idLista = true; |
872 | scope.notaPedido = { | 1037 | scope.notaPedido = { |
873 | vendedor: { NUM: true } | 1038 | vendedor: { NUM: true } |
874 | }; | 1039 | }; |
875 | 1040 | ||
876 | //act | 1041 | //act |
877 | scope.articuloACargar = { precio: 2, cantidad: 1}; | 1042 | scope.articuloACargar = { precio: 2, cantidad: 1}; |
878 | var esperado = 2; | 1043 | var esperado = 2; |
879 | var resultado = scope.getSubTotal(); | 1044 | var resultado = scope.getSubTotal(); |
880 | 1045 | ||
881 | //assert | 1046 | //assert |
882 | expect(resultado).toEqual(esperado); | 1047 | expect(resultado).toEqual(esperado); |
883 | }); | 1048 | }); |
884 | 1049 | ||
885 | it('función seleccionarPreciosYCondiciones abre modal', function() { | 1050 | it('función seleccionarPreciosYCondiciones abre modal', function() { |
886 | 1051 | ||
887 | //arrange | 1052 | //arrange |
888 | var scope = {}; | 1053 | var scope = { |
1054 | $watch: function() { }, | ||
1055 | $broadcast: function() { } | ||
1056 | }; | ||
889 | var uibModal = { | 1057 | var uibModal = { |
890 | open: function() { } | 1058 | open: function() { } |
891 | }; | 1059 | }; |
892 | 1060 | ||
893 | $controler('notaPedidoCtrl', { | 1061 | $controler('notaPedidoCtrl', { |
894 | $scope: scope, | 1062 | $scope: scope, |
895 | $uibModal: uibModal, | 1063 | $uibModal: uibModal, |
896 | $location: {}, | 1064 | $location: {}, |
897 | $filter: filter, | 1065 | $filter: filter, |
898 | $timeout: timeout, | 1066 | $timeout: timeout, |
899 | crearNotaPedidoService: { | 1067 | crearNotaPedidoService: { |
1068 | getNumeroNotaPedido: function() { | ||
1069 | return { | ||
1070 | then: function() { } | ||
1071 | }; | ||
1072 | }, | ||
900 | getBotonera: function() { }, | 1073 | getBotonera: function() { }, |
901 | getCotizacionByIdMoneda: function() { | 1074 | getCotizacionByIdMoneda: function() { |
902 | return { | 1075 | return { |
903 | then: function() { } | 1076 | then: function() { } |
904 | }; | 1077 | }; |
905 | } | 1078 | } |
906 | }, | 1079 | }, |
907 | focaBotoneraLateralService: {}, | 1080 | focaBotoneraLateralService: {}, |
908 | focaModalService: {}, | 1081 | focaModalService: {}, |
909 | notaPedidoBusinessService: {}, | 1082 | notaPedidoBusinessService: {}, |
910 | $rootScope: { | 1083 | $rootScope: { |
911 | $on: function() { } | 1084 | $on: function() { } |
912 | }, | 1085 | }, |
913 | focaSeguimientoService: {}, | 1086 | focaSeguimientoService: {}, |
914 | APP: {}, | 1087 | APP: {}, |
915 | focaLoginService: {} | 1088 | focaLoginService: {}, |
1089 | $localStorage: {} | ||
916 | }); | 1090 | }); |
917 | 1091 | ||
918 | scope.notaPedido = {}; | 1092 | scope.notaPedido = {}; |
919 | 1093 | ||
920 | var respuesta = { result: {then: function() { } } }; | 1094 | var respuesta = { result: {then: function() { } } }; |
921 | 1095 | ||
922 | //act | 1096 | //act |
923 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 1097 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
924 | scope.seleccionarPreciosYCondiciones(); | 1098 | scope.seleccionarPreciosYCondiciones(); |
925 | 1099 | ||
926 | //assert | 1100 | //assert |
927 | expect(uibModal.open).toHaveBeenCalled(); | 1101 | expect(uibModal.open).toHaveBeenCalled(); |
928 | }); | 1102 | }); |
929 | 1103 | ||
930 | it('función seleccionarPreciosYCondiciones setea articulos y cabecera', function(done) { | 1104 | it('función seleccionarPreciosYCondiciones setea articulos y cabecera', function(done) { |
931 | 1105 | ||
932 | //arrange | 1106 | //arrange |
933 | var scope = {}; | 1107 | var scope = { |
1108 | $watch: function() { }, | ||
1109 | $broadcast: function() { } | ||
1110 | }; | ||
934 | var uibModal = { | 1111 | var uibModal = { |
935 | open: function() { } | 1112 | open: function() { } |
936 | }; | 1113 | }; |
937 | 1114 | ||
938 | $controler('notaPedidoCtrl', { | 1115 | $controler('notaPedidoCtrl', { |
939 | $scope: scope, | 1116 | $scope: scope, |
940 | $uibModal: uibModal, | 1117 | $uibModal: uibModal, |
941 | $location: {}, | 1118 | $location: {}, |
942 | $filter: filter, | 1119 | $filter: filter, |
943 | $timeout: timeout, | 1120 | $timeout: timeout, |
944 | crearNotaPedidoService: { | 1121 | crearNotaPedidoService: { |
1122 | getNumeroNotaPedido: function() { | ||
1123 | return { | ||
1124 | then: function() { } | ||
1125 | }; | ||
1126 | }, | ||
945 | getBotonera: function() { }, | 1127 | getBotonera: function() { }, |
946 | getCotizacionByIdMoneda: function() { | 1128 | getCotizacionByIdMoneda: function() { |
947 | return { | 1129 | return { |
948 | then: function() { } | 1130 | then: function() { } |
949 | }; | 1131 | }; |
950 | } | 1132 | } |
951 | }, | 1133 | }, |
952 | focaBotoneraLateralService: {}, | 1134 | focaBotoneraLateralService: {}, |
953 | focaModalService: {}, | 1135 | focaModalService: {}, |
954 | notaPedidoBusinessService: {}, | 1136 | notaPedidoBusinessService: {}, |
955 | $rootScope: { | 1137 | $rootScope: { |
956 | $on: function() { } | 1138 | $on: function() { } |
957 | }, | 1139 | }, |
958 | focaSeguimientoService: {}, | 1140 | focaSeguimientoService: {}, |
959 | APP: {}, | 1141 | APP: {}, |
960 | focaLoginService: {} | 1142 | focaLoginService: {}, |
1143 | $localStorage: {} | ||
961 | }); | 1144 | }); |
962 | scope.idLista = true; | 1145 | scope.idLista = true; |
963 | scope.notaPedido = { | 1146 | scope.notaPedido = { |
964 | vendedor: { NUM: true } | 1147 | vendedor: { NUM: true } |
965 | }; | 1148 | }; |
966 | var respuesta = { plazoPago: { } }; | 1149 | var respuesta = { plazoPago: { } }; |
967 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; | 1150 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; |
968 | scope.$broadcast = function() { }; | 1151 | scope.$broadcast = function() { }; |
969 | 1152 | ||
970 | //act | 1153 | //act |
971 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); | 1154 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); |
972 | spyOn(scope, '$broadcast'); | 1155 | spyOn(scope, '$broadcast'); |
973 | scope.seleccionarPreciosYCondiciones(); | 1156 | scope.seleccionarPreciosYCondiciones(); |
974 | 1157 | ||
975 | //assert | 1158 | //assert |
976 | promesaRespuesta.result.then(function() { | 1159 | promesaRespuesta.result.then(function() { |
977 | expect(scope.articulosTabla.length).toEqual(0); | 1160 | expect(scope.notaPedido.articulosNotaPedido.length).toEqual(0); |
978 | expect(scope.$broadcast).toHaveBeenCalled(); | 1161 | expect(scope.$broadcast).toHaveBeenCalled(); |
979 | done(); | 1162 | done(); |
980 | }); | 1163 | }); |
981 | }); | 1164 | }); |
982 | 1165 | ||
983 | it('función seleccionarFlete abre modal', function() { | 1166 | it('función seleccionarFlete abre modal', function() { |
984 | 1167 | ||
985 | //arrange | 1168 | //arrange |
986 | var scope = {}; | 1169 | var scope = { |
1170 | $watch: function() { }, | ||
1171 | $broadcast: function() { } | ||
1172 | }; | ||
987 | var uibModal = { | 1173 | var uibModal = { |
988 | open: function() { } | 1174 | open: function() { } |
989 | }; | 1175 | }; |
990 | 1176 | ||
991 | $controler('notaPedidoCtrl', { | 1177 | $controler('notaPedidoCtrl', { |
992 | $scope: scope, | 1178 | $scope: scope, |
993 | $uibModal: uibModal, | 1179 | $uibModal: uibModal, |
994 | $location: {}, | 1180 | $location: {}, |
995 | $filter: filter, | 1181 | $filter: filter, |
996 | $timeout: timeout, | 1182 | $timeout: timeout, |
997 | crearNotaPedidoService: { | 1183 | crearNotaPedidoService: { |
1184 | getNumeroNotaPedido: function() { | ||
1185 | return { | ||
1186 | then: function() { } | ||
1187 | }; | ||
1188 | }, | ||
998 | getBotonera: function() { }, | 1189 | getBotonera: function() { }, |
999 | getCotizacionByIdMoneda: function() { | 1190 | getCotizacionByIdMoneda: function() { |
1000 | return { | 1191 | return { |
1001 | then: function() { } | 1192 | then: function() { } |
1002 | }; | 1193 | }; |
1003 | } | 1194 | } |
1004 | }, | 1195 | }, |
1005 | focaBotoneraLateralService: {}, | 1196 | focaBotoneraLateralService: {}, |
1006 | focaModalService: {}, | 1197 | focaModalService: {}, |
1007 | notaPedidoBusinessService: {}, | 1198 | notaPedidoBusinessService: {}, |
1008 | $rootScope: { | 1199 | $rootScope: { |
1009 | $on: function() { } | 1200 | $on: function() { } |
1010 | }, | 1201 | }, |
1011 | focaSeguimientoService: {}, | 1202 | focaSeguimientoService: {}, |
1012 | APP: {}, | 1203 | APP: {}, |
1013 | focaLoginService: {} | 1204 | focaLoginService: {}, |
1205 | $localStorage: {} | ||
1014 | }); | 1206 | }); |
1015 | 1207 | ||
1016 | scope.notaPedido = {}; | 1208 | scope.notaPedido = {}; |
1017 | 1209 | ||
1018 | var respuesta = { result: {then: function() { } } }; | 1210 | var respuesta = { result: {then: function() { } } }; |
1019 | 1211 | ||
1020 | //act | 1212 | //act |
1021 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 1213 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
1022 | scope.seleccionarFlete(); | 1214 | scope.seleccionarFlete(); |
1023 | 1215 | ||
1024 | //assert | 1216 | //assert |
1025 | expect(uibModal.open).toHaveBeenCalled(); | 1217 | expect(uibModal.open).toHaveBeenCalled(); |
1026 | }); | 1218 | }); |
1027 | 1219 | ||
1028 | it('función seleccionarFlete setea flete y cabecera', function(done) { | 1220 | it('función seleccionarFlete setea flete y cabecera', function(done) { |
1029 | 1221 | ||
1030 | //arrange | 1222 | //arrange |
1031 | var scope = {}; | 1223 | var scope = { |
1224 | $watch: function() { }, | ||
1225 | $broadcast: function() { } | ||
1226 | }; | ||
1032 | var uibModal = { | 1227 | var uibModal = { |
1033 | open: function() { } | 1228 | open: function() { } |
1034 | }; | 1229 | }; |
1035 | 1230 | ||
1036 | $controler('notaPedidoCtrl', { | 1231 | $controler('notaPedidoCtrl', { |
1037 | $scope: scope, | 1232 | $scope: scope, |
1038 | $uibModal: uibModal, | 1233 | $uibModal: uibModal, |
1039 | $location: {}, | 1234 | $location: {}, |
1040 | $filter: filter, | 1235 | $filter: filter, |
1041 | $timeout: timeout, | 1236 | $timeout: timeout, |
1042 | crearNotaPedidoService: { | 1237 | crearNotaPedidoService: { |
1238 | getNumeroNotaPedido: function() { | ||
1239 | return { | ||
1240 | then: function() { } | ||
1241 | }; | ||
1242 | }, | ||
1043 | getBotonera: function() { }, | 1243 | getBotonera: function() { }, |
1044 | getCotizacionByIdMoneda: function() { | 1244 | getCotizacionByIdMoneda: function() { |
1045 | return { | 1245 | return { |
1046 | then: function() { } | 1246 | then: function() { } |
1047 | }; | 1247 | }; |
1048 | } | 1248 | } |
1049 | }, | 1249 | }, |
1050 | focaBotoneraLateralService: {}, | 1250 | focaBotoneraLateralService: {}, |
1051 | focaModalService: {}, | 1251 | focaModalService: {}, |
1052 | notaPedidoBusinessService: {}, | 1252 | notaPedidoBusinessService: {}, |
1053 | $rootScope: { | 1253 | $rootScope: { |
1054 | $on: function() { } | 1254 | $on: function() { } |
1055 | }, | 1255 | }, |
1056 | focaSeguimientoService: {}, | 1256 | focaSeguimientoService: {}, |
1057 | APP: {}, | 1257 | APP: {}, |
1058 | focaLoginService: {} | 1258 | focaLoginService: {}, |
1259 | $localStorage: {} | ||
1059 | }); | 1260 | }); |
1060 | scope.idLista = true; | 1261 | scope.idLista = true; |
1061 | scope.notaPedido = { | 1262 | scope.notaPedido = { |
1062 | vendedor: { NUM: true } | 1263 | vendedor: { NUM: true } |
1063 | }; | 1264 | }; |
1064 | var respuesta = { flete: 1, FOB: 2, bomba: 3, kilometros: 4 }; | 1265 | var respuesta = { flete: 1, FOB: 2, bomba: 3, kilometros: 4 }; |
1065 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; | 1266 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; |
1066 | scope.$broadcast = function() { }; | 1267 | scope.$broadcast = function() { }; |
1067 | 1268 | ||
1068 | //act | 1269 | //act |
1069 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); | 1270 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); |
1070 | spyOn(scope, '$broadcast'); | 1271 | spyOn(scope, '$broadcast'); |
1071 | scope.seleccionarFlete(); | 1272 | scope.seleccionarFlete(); |
1072 | 1273 | ||
1073 | //assert | 1274 | //assert |
1074 | 1275 | ||
1075 | promesaRespuesta.result.then(function() { | 1276 | promesaRespuesta.result.then(function() { |
1076 | expect(scope.notaPedido.flete).toEqual(respuesta.flete); | 1277 | expect(scope.notaPedido.flete).toEqual(respuesta.flete); |
1077 | expect(scope.notaPedido.fob).toEqual(respuesta.FOB); | 1278 | expect(scope.notaPedido.fob).toEqual(respuesta.FOB); |
1078 | expect(scope.notaPedido.bomba).toEqual(respuesta.bomba); | 1279 | expect(scope.notaPedido.bomba).toEqual(respuesta.bomba); |
1079 | expect(scope.notaPedido.kilometros).toEqual(respuesta.kilometros); | 1280 | expect(scope.notaPedido.kilometros).toEqual(respuesta.kilometros); |
1080 | expect(scope.$broadcast).toHaveBeenCalled(); | 1281 | expect(scope.$broadcast).toHaveBeenCalled(); |
1081 | done(); | 1282 | done(); |
1082 | }); | 1283 | }); |
1083 | }); | 1284 | }); |
1084 | 1285 | ||
1085 | it('función seleccionarMoneda abre modal', function() { | 1286 | it('función seleccionarMoneda abre modal', function() { |
1086 | //arrange | 1287 | //arrange |
1087 | var scope = {}; | 1288 | var scope = { |
1289 | $watch: function() { }, | ||
1290 | $broadcast: function() { } | ||
1291 | }; | ||
1088 | var focaModalService = { | 1292 | var focaModalService = { |
1089 | modal: function() { } | 1293 | modal: function() { } |
1090 | }; | 1294 | }; |
1091 | 1295 | ||
1092 | $controler('notaPedidoCtrl', { | 1296 | $controler('notaPedidoCtrl', { |
1093 | $scope: scope, | 1297 | $scope: scope, |
1094 | $uibModal: {}, | 1298 | $uibModal: {}, |
1095 | $location: {}, | 1299 | $location: {}, |
1096 | $filter: filter, | 1300 | $filter: filter, |
1097 | $timeout: timeout, | 1301 | $timeout: timeout, |
1098 | crearNotaPedidoService: { | 1302 | crearNotaPedidoService: { |
1303 | getNumeroNotaPedido: function() { | ||
1304 | return { | ||
1305 | then: function() { } | ||
1306 | }; | ||
1307 | }, | ||
1099 | getBotonera: function() { }, | 1308 | getBotonera: function() { }, |
1100 | getCotizacionByIdMoneda: function() { | 1309 | getCotizacionByIdMoneda: function() { |
1101 | return { | 1310 | return { |
1102 | then: function() { } | 1311 | then: function() { } |
1103 | }; | 1312 | }; |
1104 | } | 1313 | } |
1105 | }, | 1314 | }, |
1106 | focaBotoneraLateralService: {}, | 1315 | focaBotoneraLateralService: {}, |
1107 | focaModalService: focaModalService, | 1316 | focaModalService: focaModalService, |
1108 | notaPedidoBusinessService: {}, | 1317 | notaPedidoBusinessService: {}, |
1109 | $rootScope: { | 1318 | $rootScope: { |
1110 | $on: function() { } | 1319 | $on: function() { } |
1111 | }, | 1320 | }, |
1112 | focaSeguimientoService: {}, | 1321 | focaSeguimientoService: {}, |
1113 | APP: {}, | 1322 | APP: {}, |
1114 | focaLoginService: {} | 1323 | focaLoginService: {}, |
1324 | $localStorage: {} | ||
1115 | }); | 1325 | }); |
1116 | scope.notaPedido = {}; | 1326 | scope.notaPedido = {}; |
1117 | 1327 | ||
1118 | var respuesta = { then: function() { } }; | 1328 | var respuesta = { then: function() { } }; |
1119 | 1329 | ||
1120 | //act | 1330 | //act |
1121 | spyOn(focaModalService, 'modal').and.returnValue(respuesta); | 1331 | spyOn(focaModalService, 'modal').and.returnValue(respuesta); |
1122 | scope.seleccionarMoneda(); | 1332 | scope.seleccionarMoneda(); |
1123 | 1333 | ||
1124 | //assert | 1334 | //assert |
1125 | expect(focaModalService.modal).toHaveBeenCalled(); | 1335 | expect(focaModalService.modal).toHaveBeenCalled(); |
1126 | }); | 1336 | }); |
1127 | 1337 | ||
1128 | it('función seleccionarMoneda llama Modal Cotizacion', function(done) { | 1338 | it('función seleccionarMoneda llama Modal Cotizacion', function(done) { |
1129 | //arrange | 1339 | //arrange |
1130 | var scope = {}; | 1340 | var scope = { |
1341 | $watch: function() { }, | ||
1342 | $broadcast: function() { } | ||
1343 | }; | ||
1131 | var focaModalService = { | 1344 | var focaModalService = { |
1132 | modal: function() { } | 1345 | modal: function() { } |
1133 | }; | 1346 | }; |
1134 | 1347 | ||
1135 | $controler('notaPedidoCtrl', { | 1348 | $controler('notaPedidoCtrl', { |
1136 | $scope: scope, | 1349 | $scope: scope, |
1137 | $uibModal: {}, | 1350 | $uibModal: {}, |
1138 | $location: {}, | 1351 | $location: {}, |
1139 | $filter: filter, | 1352 | $filter: filter, |
1140 | $timeout: timeout, | 1353 | $timeout: timeout, |
1141 | crearNotaPedidoService: { | 1354 | crearNotaPedidoService: { |
1355 | getNumeroNotaPedido: function() { | ||
1356 | return { | ||
1357 | then: function() { } | ||
1358 | }; | ||
1359 | }, | ||
1142 | getBotonera: function() { }, | 1360 | getBotonera: function() { }, |
1143 | getCotizacionByIdMoneda: function() { | 1361 | getCotizacionByIdMoneda: function() { |
1144 | return { | 1362 | return { |
1145 | then: function() { } | 1363 | then: function() { } |
1146 | }; | 1364 | }; |
1147 | } | 1365 | } |
1148 | }, | 1366 | }, |
1149 | focaBotoneraLateralService: {}, | 1367 | focaBotoneraLateralService: {}, |
1150 | focaModalService: focaModalService, | 1368 | focaModalService: focaModalService, |
1151 | notaPedidoBusinessService: {}, | 1369 | notaPedidoBusinessService: {}, |
1152 | $rootScope: { | 1370 | $rootScope: { |
1153 | $on: function() { } | 1371 | $on: function() { } |
1154 | }, | 1372 | }, |
1155 | focaSeguimientoService: {}, | 1373 | focaSeguimientoService: {}, |
1156 | APP: {}, | 1374 | APP: {}, |
1157 | focaLoginService: {} | 1375 | focaLoginService: {}, |
1376 | $localStorage: {} | ||
1158 | }); | 1377 | }); |
1159 | 1378 | ||
1160 | scope.notaPedido = {}; | 1379 | scope.notaPedido = {}; |
1161 | var respuesta = 'test'; | 1380 | var respuesta = 'test'; |
1162 | var promesaRespuesta = Promise.resolve(respuesta); | 1381 | var promesaRespuesta = Promise.resolve(respuesta); |
1163 | 1382 | ||
1164 | //act | 1383 | //act |
1165 | spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); | 1384 | spyOn(focaModalService, 'modal').and.returnValue(promesaRespuesta); |
1166 | spyOn(scope, 'abrirModalCotizacion'); | 1385 | spyOn(scope, 'abrirModalCotizacion'); |
1167 | scope.seleccionarMoneda(); | 1386 | scope.seleccionarMoneda(); |
1168 | 1387 | ||
1169 | //assert | 1388 | //assert |
1170 | promesaRespuesta.then(function() { | 1389 | promesaRespuesta.then(function() { |
1171 | expect(scope.abrirModalCotizacion).toHaveBeenCalledWith('test'); | 1390 | expect(scope.abrirModalCotizacion).toHaveBeenCalledWith('test'); |
1172 | done(); | 1391 | done(); |
1173 | }); | 1392 | }); |
1174 | }); | 1393 | }); |
1175 | 1394 | ||
1176 | it('función seleccionarObservaciones llama a prompt', function() { | 1395 | it('función seleccionarObservaciones llama a prompt', function() { |
1177 | 1396 | ||
1178 | //arrange | 1397 | //arrange |
1179 | var scope = {}; | 1398 | var scope = { |
1399 | $watch: function() { }, | ||
1400 | $broadcast: function() { } | ||
1401 | }; | ||
1180 | var focaModalService = { | 1402 | var focaModalService = { |
1181 | prompt: function() { } | 1403 | prompt: function() { } |
1182 | }; | 1404 | }; |
1183 | 1405 | ||
1184 | $controler('notaPedidoCtrl', { | 1406 | $controler('notaPedidoCtrl', { |
1185 | $scope: scope, | 1407 | $scope: scope, |
1186 | $uibModal: {}, | 1408 | $uibModal: {}, |
1187 | $location: {}, | 1409 | $location: {}, |
1188 | $filter: filter, | 1410 | $filter: filter, |
1189 | $timeout: timeout, | 1411 | $timeout: timeout, |
1190 | crearNotaPedidoService: { | 1412 | crearNotaPedidoService: { |
1413 | getNumeroNotaPedido: function() { | ||
1414 | return { | ||
1415 | then: function() { } | ||
1416 | }; | ||
1417 | }, | ||
1191 | getBotonera: function() { }, | 1418 | getBotonera: function() { }, |
1192 | getCotizacionByIdMoneda: function() { | 1419 | getCotizacionByIdMoneda: function() { |
1193 | return { | 1420 | return { |
1194 | then: function() { } | 1421 | then: function() { } |
1195 | }; | 1422 | }; |
1196 | } | 1423 | } |
1197 | }, | 1424 | }, |
1198 | focaBotoneraLateralService: {}, | 1425 | focaBotoneraLateralService: {}, |
1199 | focaModalService: focaModalService, | 1426 | focaModalService: focaModalService, |
1200 | notaPedidoBusinessService: {}, | 1427 | notaPedidoBusinessService: {}, |
1201 | $rootScope: { | 1428 | $rootScope: { |
1202 | $on: function() { } | 1429 | $on: function() { } |
1203 | }, | 1430 | }, |
1204 | focaSeguimientoService: {}, | 1431 | focaSeguimientoService: {}, |
1205 | APP: {}, | 1432 | APP: {}, |
1206 | focaLoginService: {} | 1433 | focaLoginService: {}, |
1434 | $localStorage: {} | ||
1207 | }); | 1435 | }); |
1208 | var respuesta = { then: function() { } }; | 1436 | var respuesta = { then: function() { } }; |
1209 | scope.notaPedido = {}; | 1437 | scope.notaPedido = {}; |
1210 | 1438 | ||
1211 | //act | 1439 | //act |
1212 | spyOn(focaModalService, 'prompt').and.returnValue(respuesta); | 1440 | spyOn(focaModalService, 'prompt').and.returnValue(respuesta); |
1213 | scope.seleccionarObservaciones(); | 1441 | scope.seleccionarObservaciones(); |
1214 | 1442 | ||
1215 | //assert | 1443 | //assert |
1216 | expect(focaModalService.prompt).toHaveBeenCalled(); | 1444 | expect(focaModalService.prompt).toHaveBeenCalled(); |
1217 | }); | 1445 | }); |
1218 | 1446 | ||
1219 | it('función seleccionarObservaciones setea observaciones', function(done) { | 1447 | it('función seleccionarObservaciones setea observaciones', function(done) { |
1220 | 1448 | ||
1221 | //arrange | 1449 | //arrange |
1222 | var scope = {}; | 1450 | var scope = { |
1451 | $watch: function() { }, | ||
1452 | $broadcast: function() { } | ||
1453 | }; | ||
1223 | var focaModalService = { | 1454 | var focaModalService = { |
1224 | prompt: function() { } | 1455 | prompt: function() { } |
1225 | }; | 1456 | }; |
1226 | 1457 | ||
1227 | $controler('notaPedidoCtrl', { | 1458 | $controler('notaPedidoCtrl', { |
1228 | $scope: scope, | 1459 | $scope: scope, |
1229 | $uibModal: {}, | 1460 | $uibModal: {}, |
1230 | $location: {}, | 1461 | $location: {}, |
1231 | $filter: filter, | 1462 | $filter: filter, |
1232 | $timeout: timeout, | 1463 | $timeout: timeout, |
1233 | crearNotaPedidoService: { | 1464 | crearNotaPedidoService: { |
1465 | getNumeroNotaPedido: function() { | ||
1466 | return { | ||
1467 | then: function() { } | ||
1468 | }; | ||
1469 | }, | ||
1234 | getBotonera: function() { }, | 1470 | getBotonera: function() { }, |
1235 | getCotizacionByIdMoneda: function() { | 1471 | getCotizacionByIdMoneda: function() { |
1236 | return { | 1472 | return { |
1237 | then: function() { } | 1473 | then: function() { } |
1238 | }; | 1474 | }; |
1239 | } | 1475 | } |
1240 | }, | 1476 | }, |
1241 | focaBotoneraLateralService: {}, | 1477 | focaBotoneraLateralService: {}, |
1242 | focaModalService: focaModalService, | 1478 | focaModalService: focaModalService, |
1243 | notaPedidoBusinessService: {}, | 1479 | notaPedidoBusinessService: {}, |
1244 | $rootScope: { | 1480 | $rootScope: { |
1245 | $on: function() { } | 1481 | $on: function() { } |
1246 | }, | 1482 | }, |
1247 | focaSeguimientoService: {}, | 1483 | focaSeguimientoService: {}, |
1248 | APP: {}, | 1484 | APP: {}, |
1249 | focaLoginService: {} | 1485 | focaLoginService: {}, |
1486 | $localStorage: {} | ||
1250 | }); | 1487 | }); |
1251 | var respuesta = 'unit test'; | 1488 | var respuesta = 'unit test'; |
1252 | var promesa = Promise.resolve(respuesta); | 1489 | var promesa = Promise.resolve(respuesta); |
1253 | scope.notaPedido = {}; | 1490 | scope.notaPedido = {}; |
1254 | 1491 | ||
1255 | //act | 1492 | //act |
1256 | spyOn(focaModalService, 'prompt').and.returnValue(promesa); | 1493 | spyOn(focaModalService, 'prompt').and.returnValue(promesa); |
1257 | scope.seleccionarObservaciones(); | 1494 | scope.seleccionarObservaciones(); |
1258 | 1495 | ||
1259 | //assert | 1496 | //assert |
1260 | promesa.then(function() { | 1497 | promesa.then(function() { |
1261 | expect(scope.notaPedido.observaciones).toEqual(respuesta); | 1498 | expect(scope.notaPedido.observaciones).toEqual(respuesta); |
1262 | done(); | 1499 | done(); |
1263 | }); | 1500 | }); |
1264 | }); | 1501 | }); |
1265 | 1502 | ||
1266 | it('función abrirModalCotizacion abre modal', function() { | 1503 | it('función abrirModalCotizacion abre modal', function() { |
1267 | 1504 | ||
1268 | //arrange | 1505 | //arrange |
1269 | var scope = {}; | 1506 | var scope = { |
1507 | $watch: function() { }, | ||
1508 | $broadcast: function() { } | ||
1509 | }; | ||
1270 | var uibModal = { | 1510 | var uibModal = { |
1271 | open: function() { } | 1511 | open: function() { } |
1272 | }; | 1512 | }; |
1273 | 1513 | ||
1274 | $controler('notaPedidoCtrl', { | 1514 | $controler('notaPedidoCtrl', { |
1275 | $scope: scope, | 1515 | $scope: scope, |
1276 | $uibModal: uibModal, | 1516 | $uibModal: uibModal, |
1277 | $location: {}, | 1517 | $location: {}, |
1278 | $filter: filter, | 1518 | $filter: filter, |
1279 | $timeout: timeout, | 1519 | $timeout: timeout, |
1280 | crearNotaPedidoService: { | 1520 | crearNotaPedidoService: { |
1521 | getNumeroNotaPedido: function() { | ||
1522 | return { | ||
1523 | then: function() { } | ||
1524 | }; | ||
1525 | }, | ||
1281 | getBotonera: function() { }, | 1526 | getBotonera: function() { }, |
1282 | getCotizacionByIdMoneda: function() { | 1527 | getCotizacionByIdMoneda: function() { |
1283 | return { | 1528 | return { |
1284 | then: function() { } | 1529 | then: function() { } |
1285 | }; | 1530 | }; |
1286 | } | 1531 | } |
1287 | }, | 1532 | }, |
1288 | focaBotoneraLateralService: {}, | 1533 | focaBotoneraLateralService: {}, |
1289 | focaModalService: {}, | 1534 | focaModalService: {}, |
1290 | notaPedidoBusinessService: {}, | 1535 | notaPedidoBusinessService: {}, |
1291 | $rootScope: { | 1536 | $rootScope: { |
1292 | $on: function() { } | 1537 | $on: function() { } |
1293 | }, | 1538 | }, |
1294 | focaSeguimientoService: {}, | 1539 | focaSeguimientoService: {}, |
1295 | APP: {}, | 1540 | APP: {}, |
1296 | focaLoginService: {} | 1541 | focaLoginService: {}, |
1542 | $localStorage: {} | ||
1297 | }); | 1543 | }); |
1298 | 1544 | ||
1299 | scope.notaPedido = {}; | 1545 | scope.notaPedido = {}; |
1300 | 1546 | ||
1301 | var respuesta = { result: {then: function() { } } }; | 1547 | var respuesta = { result: {then: function() { } } }; |
1302 | 1548 | ||
1303 | //act | 1549 | //act |
1304 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 1550 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
1305 | scope.abrirModalCotizacion(); | 1551 | scope.abrirModalCotizacion(); |
1306 | 1552 | ||
1307 | //assert | 1553 | //assert |
1308 | expect(uibModal.open).toHaveBeenCalled(); | 1554 | expect(uibModal.open).toHaveBeenCalled(); |
1309 | }); | 1555 | }); |
1310 | 1556 | ||
1311 | it('función abrirModalCotizacion setea datos y cabecera', function(done) { | 1557 | it('función abrirModalCotizacion setea datos y cabecera', function(done) { |
1312 | //arrange | 1558 | //arrange |
1313 | var scope = {}; | 1559 | var scope = { |
1560 | $watch: function() { }, | ||
1561 | $broadcast: function() { } | ||
1562 | }; | ||
1314 | var uibModal = { | 1563 | var uibModal = { |
1315 | open: function() { } | 1564 | open: function() { } |
1316 | }; | 1565 | }; |
1317 | 1566 | ||
1318 | $controler('notaPedidoCtrl', { | 1567 | $controler('notaPedidoCtrl', { |
1319 | $scope: scope, | 1568 | $scope: scope, |
1320 | $uibModal: uibModal, | 1569 | $uibModal: uibModal, |
1321 | $location: {}, | 1570 | $location: {}, |
1322 | $filter: filter, | 1571 | $filter: filter, |
1323 | $timeout: timeout, | 1572 | $timeout: timeout, |
1324 | crearNotaPedidoService: { | 1573 | crearNotaPedidoService: { |
1574 | getNumeroNotaPedido: function() { | ||
1575 | return { | ||
1576 | then: function() { } | ||
1577 | }; | ||
1578 | }, | ||
1325 | getBotonera: function() { }, | 1579 | getBotonera: function() { }, |
1326 | getCotizacionByIdMoneda: function() { | 1580 | getCotizacionByIdMoneda: function() { |
1327 | return { | 1581 | return { |
1328 | then: function() { } | 1582 | then: function() { } |
1329 | }; | 1583 | }; |
1330 | } | 1584 | } |
1331 | }, | 1585 | }, |
1332 | focaBotoneraLateralService: {}, | 1586 | focaBotoneraLateralService: {}, |
1333 | focaModalService: {}, | 1587 | focaModalService: {}, |
1334 | notaPedidoBusinessService: {}, | 1588 | notaPedidoBusinessService: {}, |
1335 | $rootScope: { | 1589 | $rootScope: { |
1336 | $on: function() { } | 1590 | $on: function() { } |
1337 | }, | 1591 | }, |
1338 | focaSeguimientoService: {}, | 1592 | focaSeguimientoService: {}, |
1339 | APP: {}, | 1593 | APP: {}, |
1340 | focaLoginService: {} | 1594 | focaLoginService: {}, |
1595 | $localStorage: {}, | ||
1596 | articulosNotaPedido: [] | ||
1341 | }); | 1597 | }); |
1342 | 1598 | ||
1343 | scope.notaPedido = {}; | 1599 | scope.notaPedido = {}; |
1344 | scope.articulosTabla = []; | 1600 | scope.articulosTabla = []; |
1345 | scope.$broadcast = function() { }; | 1601 | scope.$broadcast = function() { }; |
1346 | var moneda = 'moneda'; | 1602 | var moneda = 'moneda'; |
1347 | var cotizacion = 'test'; | 1603 | var cotizacion = 'test'; |
1348 | var promesaRespuesta = { result: Promise.resolve(cotizacion) }; | 1604 | var promesaRespuesta = { result: Promise.resolve(cotizacion) }; |
1349 | 1605 | ||
1350 | //act | 1606 | //act |
1351 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); | 1607 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); |
1352 | spyOn(scope, '$broadcast'); | 1608 | spyOn(scope, '$broadcast'); |
1353 | scope.abrirModalCotizacion(moneda); | 1609 | scope.abrirModalCotizacion(moneda); |
1354 | 1610 | ||
1355 | //assert | 1611 | //assert |
1356 | promesaRespuesta.result.then(function() { | 1612 | promesaRespuesta.result.then(function() { |
1357 | 1613 | ||
1358 | expect(scope.$broadcast).toHaveBeenCalled(); | 1614 | expect(scope.$broadcast).toHaveBeenCalled(); |
1359 | expect(scope.notaPedido.moneda).toEqual(moneda); | ||
1360 | expect(scope.monedaDefecto).toEqual(moneda); | ||
1361 | expect(scope.cotizacionDefecto).toEqual(cotizacion); | ||
1362 | expect(scope.notaPedido.cotizacion).toEqual(cotizacion); | 1615 | expect(scope.notaPedido.cotizacion).toEqual(cotizacion); |
1363 | done(); | 1616 | done(); |
1364 | }); | 1617 | }); |
1365 | }); | 1618 | }); |
1366 | 1619 | ||
1367 | it('función agregarATabla muestra alerta cuando a cargar undefined', function() { | 1620 | it('función agregarATabla muestra alerta cuando a cargar undefined', function() { |
1368 | 1621 | ||
1369 | //arrange | 1622 | //arrange |
1370 | var scope = {}; | 1623 | var scope = { |
1624 | $watch: function() { }, | ||
1625 | $broadcast: function() { } | ||
1626 | }; | ||
1371 | var focaModalService = { | 1627 | var focaModalService = { |
1372 | alert: function() { } | 1628 | alert: function() { } |
1373 | }; | 1629 | }; |
1374 | 1630 | ||
1375 | $controler('notaPedidoCtrl', { | 1631 | $controler('notaPedidoCtrl', { |
1376 | $scope: scope, | 1632 | $scope: scope, |
1377 | $uibModal: {}, | 1633 | $uibModal: {}, |
1378 | $location: {}, | 1634 | $location: {}, |
1379 | $filter: filter, | 1635 | $filter: filter, |
1380 | $timeout: timeout, | 1636 | $timeout: timeout, |
1381 | crearNotaPedidoService: { | 1637 | crearNotaPedidoService: { |
1638 | getNumeroNotaPedido: function() { | ||
1639 | return { | ||
1640 | then: function() { } | ||
1641 | }; | ||
1642 | }, | ||
1382 | getBotonera: function() { }, | 1643 | getBotonera: function() { }, |
1383 | getCotizacionByIdMoneda: function() { | 1644 | getCotizacionByIdMoneda: function() { |
1384 | return { | 1645 | return { |
1385 | then: function() { } | 1646 | then: function() { } |
1386 | }; | 1647 | }; |
1387 | } | 1648 | } |
1388 | }, | 1649 | }, |
1389 | focaBotoneraLateralService: {}, | 1650 | focaBotoneraLateralService: {}, |
1390 | focaModalService: focaModalService, | 1651 | focaModalService: focaModalService, |
1391 | notaPedidoBusinessService: {}, | 1652 | notaPedidoBusinessService: {}, |
1392 | $rootScope: { | 1653 | $rootScope: { |
1393 | $on: function() { } | 1654 | $on: function() { } |
1394 | }, | 1655 | }, |
1395 | focaSeguimientoService: {}, | 1656 | focaSeguimientoService: {}, |
1396 | APP: {}, | 1657 | APP: {}, |
1397 | focaLoginService: {} | 1658 | focaLoginService: {}, |
1659 | $localStorage: {} | ||
1398 | }); | 1660 | }); |
1399 | scope.articuloACargar = {}; | 1661 | scope.articuloACargar = {}; |
1400 | 1662 | ||
1401 | //act | 1663 | //act |
1402 | spyOn(focaModalService, 'alert'); | 1664 | spyOn(focaModalService, 'alert'); |
1403 | scope.agregarATabla(13); | 1665 | scope.agregarATabla(13); |
1404 | 1666 | ||
1405 | //assert | 1667 | //assert |
1406 | expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1'); | 1668 | expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1'); |
1407 | }); | 1669 | }); |
1408 | 1670 | ||
1409 | it('función editarArticulo muestra alerta cuando a cargar es undefined', function() { | 1671 | it('función editarArticulo muestra alerta cuando a cargar es undefined', function() { |
1410 | 1672 | ||
1411 | //arrange | 1673 | //arrange |
1412 | var scope = {}; | 1674 | var scope = { |
1675 | $watch: function() { }, | ||
1676 | $broadcast: function() { } | ||
1677 | }; | ||
1413 | var focaModalService = { | 1678 | var focaModalService = { |
1414 | alert: function() { } | 1679 | alert: function() { } |
1415 | }; | 1680 | }; |
1416 | 1681 | ||
1417 | $controler('notaPedidoCtrl', { | 1682 | $controler('notaPedidoCtrl', { |
1418 | $scope: scope, | 1683 | $scope: scope, |
1419 | $uibModal: {}, | 1684 | $uibModal: {}, |
1420 | $location: {}, | 1685 | $location: {}, |
1421 | $filter: filter, | 1686 | $filter: filter, |
1422 | $timeout: timeout, | 1687 | $timeout: timeout, |
1423 | crearNotaPedidoService: { | 1688 | crearNotaPedidoService: { |
1689 | getNumeroNotaPedido: function() { | ||
1690 | return { | ||
1691 | then: function() { } | ||
1692 | }; | ||
1693 | }, | ||
1424 | getBotonera: function() { }, | 1694 | getBotonera: function() { }, |
1425 | getCotizacionByIdMoneda: function() { | 1695 | getCotizacionByIdMoneda: function() { |
1426 | return { | 1696 | return { |
1427 | then: function() { } | 1697 | then: function() { } |
1428 | }; | 1698 | }; |
1429 | } | 1699 | } |
1430 | }, | 1700 | }, |
1431 | focaBotoneraLateralService: {}, | 1701 | focaBotoneraLateralService: {}, |
1432 | focaModalService: focaModalService, | 1702 | focaModalService: focaModalService, |
1433 | notaPedidoBusinessService: {}, | 1703 | notaPedidoBusinessService: {}, |
1434 | $rootScope: { | 1704 | $rootScope: { |
1435 | $on: function() { } | 1705 | $on: function() { } |
1436 | }, | 1706 | }, |
1437 | focaSeguimientoService: {}, | 1707 | focaSeguimientoService: {}, |
1438 | APP: {}, | 1708 | APP: {}, |
1439 | focaLoginService: {} | 1709 | focaLoginService: {}, |
1710 | $localStorage: {} | ||
1440 | }); | 1711 | }); |
1441 | scope.articuloACargar = {}; | 1712 | scope.articuloACargar = {}; |
1442 | 1713 | ||
1443 | //act | 1714 | //act |
1444 | spyOn(focaModalService, 'alert'); | 1715 | spyOn(focaModalService, 'alert'); |
1445 | scope.agregarATabla(13); | 1716 | scope.agregarATabla(13); |
1446 | 1717 | ||
1447 | //assert | 1718 | //assert |
1448 | expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1'); | 1719 | expect(focaModalService.alert).toHaveBeenCalledWith('El valor debe ser al menos 1'); |
1449 | }); | 1720 | }); |
1450 | 1721 | ||
1451 | it('función salir lleva a ruta correcta', function() { | 1722 | it('función salir lleva a ruta correcta', function() { |
1452 | 1723 | ||
1453 | inject(function($location) { | 1724 | inject(function($location) { |
1454 | 1725 | ||
1455 | //arrange | 1726 | //arrange |
1456 | var scope = {}; | 1727 | var scope = { |
1728 | $watch: function() { }, | ||
1729 | $broadcast: function() { } | ||
1730 | }; | ||
1457 | 1731 | ||
1458 | $controler('notaPedidoCtrl', { | 1732 | $controler('notaPedidoCtrl', { |
1459 | $scope: scope, | 1733 | $scope: scope, |
1460 | $uibModal: {}, | 1734 | $uibModal: {}, |
1461 | $location: $location, | 1735 | $location: $location, |
1462 | $filter: filter, | 1736 | $filter: filter, |
1463 | $timeout: timeout, | 1737 | $timeout: timeout, |
1464 | crearNotaPedidoService: { | 1738 | crearNotaPedidoService: { |
1739 | getNumeroNotaPedido: function() { | ||
1740 | return { | ||
1741 | then: function() { } | ||
1742 | }; | ||
1743 | }, | ||
1465 | getBotonera: function() { }, | 1744 | getBotonera: function() { }, |
1466 | getCotizacionByIdMoneda: function() { | 1745 | getCotizacionByIdMoneda: function() { |
1467 | return { | 1746 | return { |
1468 | then: function() { } | 1747 | then: function() { } |
1469 | }; | 1748 | }; |
1470 | } | 1749 | } |
1471 | }, | 1750 | }, |
1472 | focaBotoneraLateralService: {}, | 1751 | focaBotoneraLateralService: {}, |
1473 | focaModalService: {}, | 1752 | focaModalService: {}, |
1474 | notaPedidoBusinessService: {}, | 1753 | notaPedidoBusinessService: {}, |
1475 | $rootScope: { | 1754 | $rootScope: { |
1476 | $on: function() { } | 1755 | $on: function() { } |
1477 | }, | 1756 | }, |
1478 | focaSeguimientoService: {}, | 1757 | focaSeguimientoService: {}, |
1479 | APP: {}, | 1758 | APP: {}, |
1480 | focaLoginService: {} | 1759 | focaLoginService: {}, |
1760 | $localStorage: {}, | ||
1481 | }); | 1761 | }); |
1482 | 1762 | ||
1483 | //act | 1763 | //act |
1484 | scope.salir(); | 1764 | scope.salir(); |
1485 | 1765 | ||
1486 | //assert | 1766 | //assert |
1487 | expect($location.url()).toEqual('/'); | 1767 | expect($location.url()).toEqual('/'); |
1488 | }); | 1768 | }); |
1489 | }); | 1769 | }); |
spec/controllerSpecCrearPedido.js
1 | describe('Controladores módulo crear nota de pedido', function() { | 1 | describe('Controladores módulo crear nota de pedido', function() { |
2 | 2 | ||
3 | var $controler; | 3 | var $controler; |
4 | 4 | ||
5 | beforeEach(function() { | 5 | beforeEach(function() { |
6 | module('focaCrearNotaPedido'); | 6 | module('focaCrearNotaPedido'); |
7 | inject(function(_$controller_) { | 7 | inject(function(_$controller_) { |
8 | $controler = _$controller_; | 8 | $controler = _$controller_; |
9 | }); | 9 | }); |
10 | }); | 10 | }); |
11 | 11 | ||
12 | describe('Controlador notaPedidoCtrl crear nota de pedido', function() { | 12 | describe('Controlador notaPedidoCtrl crear nota de pedido', function() { |
13 | 13 | ||
14 | var filter = function() { | 14 | var filter = function() { |
15 | return function() { }; | 15 | return function() { }; |
16 | }; | 16 | }; |
17 | var timeout; | 17 | var timeout; |
18 | 18 | ||
19 | beforeEach(function() { | 19 | beforeEach(function() { |
20 | 20 | ||
21 | inject(function($timeout) { | 21 | inject(function($timeout) { |
22 | timeout = $timeout; | 22 | timeout = $timeout; |
23 | }); | 23 | }); |
24 | }); | 24 | }); |
25 | 25 | ||
26 | it('Existe el controlador notaPedidoCtrl', function() { | 26 | it('Existe el controlador notaPedidoCtrl', function() { |
27 | 27 | ||
28 | //act | 28 | //act |
29 | var controlador = $controler('notaPedidoCtrl', { | 29 | var controlador = $controler('notaPedidoCtrl', { |
30 | $scope: {}, | 30 | $scope: { |
31 | $watch: function() { }, | ||
32 | $broadcast: function() {} | ||
33 | }, | ||
31 | $uibModal: {}, | 34 | $uibModal: {}, |
32 | $location: {}, | 35 | $location: {}, |
33 | $filter: filter, | 36 | $filter: filter, |
34 | $timeout: timeout, | 37 | $timeout: timeout, |
35 | crearNotaPedidoService: { | 38 | crearNotaPedidoService: { |
39 | getNumeroNotaPedido: function() { | ||
40 | return { | ||
41 | then: function() { } | ||
42 | }; | ||
43 | }, | ||
36 | getBotonera: function() { }, | 44 | getBotonera: function() { }, |
37 | getCotizacionByIdMoneda: function() { | 45 | getCotizacionByIdMoneda: function() { |
38 | return { | 46 | return { |
39 | then: function() {} | 47 | then: function() {} |
40 | }; | 48 | }; |
41 | } | 49 | } |
42 | }, | 50 | }, |
43 | focaBotoneraLateralService: {}, | 51 | focaBotoneraLateralService: {}, |
44 | focaModalService: {}, | 52 | focaModalService: {}, |
45 | notaPedidoBusinessService: {}, | 53 | notaPedidoBusinessService: {}, |
46 | $rootScope: { | 54 | $rootScope: { |
47 | $on: function() { } | 55 | $on: function() { } |
48 | }, | 56 | }, |
49 | focaSeguimientoService: {}, | 57 | focaSeguimientoService: {}, |
50 | APP: {}, | 58 | APP: {}, |
51 | focaLoginService: {} | 59 | focaLoginService: {}, |
60 | $localStorage: {} | ||
52 | }); | 61 | }); |
53 | 62 | ||
54 | //expect | 63 | //expect |
55 | expect(typeof controlador).toEqual('object'); | 64 | expect(typeof controlador).toEqual('object'); |
56 | }); | 65 | }); |
57 | 66 | ||
58 | it('la funcion $scope.crearNotaPedido muestra alerta cuando vendedor es null', function() { | 67 | it('la funcion $scope.crearNotaPedido muestra alerta cuando vendedor es null', function() { |
59 | 68 | ||
60 | //arrange | 69 | //arrange |
61 | var scope = {}; | 70 | var scope = { |
71 | $watch: function() { }, | ||
72 | $broadcast: function() {} | ||
73 | }; | ||
62 | var focaModalService = { | 74 | var focaModalService = { |
63 | alert: function() { } | 75 | alert: function() { } |
64 | }; | 76 | }; |
65 | 77 | ||
66 | $controler('notaPedidoCtrl', { | 78 | $controler('notaPedidoCtrl', { |
67 | $scope: scope, | 79 | $scope: scope, |
68 | $uibModal: {}, | 80 | $uibModal: {}, |
69 | $location: {}, | 81 | $location: {}, |
70 | $filter: filter, | 82 | $filter: filter, |
71 | $timeout: timeout, | 83 | $timeout: timeout, |
72 | crearNotaPedidoService: { | 84 | crearNotaPedidoService: { |
85 | getNumeroNotaPedido: function() { | ||
86 | return { | ||
87 | then: function() { } | ||
88 | }; | ||
89 | }, | ||
73 | getBotonera: function() { }, | 90 | getBotonera: function() { }, |
74 | getCotizacionByIdMoneda: function() { | 91 | getCotizacionByIdMoneda: function() { |
75 | return { | 92 | return { |
76 | then: function() {} | 93 | then: function() {} |
77 | }; | 94 | }; |
78 | } | 95 | } |
79 | }, | 96 | }, |
80 | focaBotoneraLateralService: {}, | 97 | focaBotoneraLateralService: {}, |
81 | focaModalService: focaModalService, | 98 | focaModalService: focaModalService, |
82 | notaPedidoBusinessService: {}, | 99 | notaPedidoBusinessService: {}, |
83 | $rootScope: { | 100 | $rootScope: { |
84 | $on: function() { } | 101 | $on: function() { } |
85 | }, | 102 | }, |
86 | focaSeguimientoService: {}, | 103 | focaSeguimientoService: {}, |
87 | APP: {}, | 104 | APP: {}, |
88 | focaLoginService: {} | 105 | focaLoginService: {}, |
106 | $localStorage: {}, | ||
107 | $watch: function() { }, | ||
108 | $broadcast: function() {} | ||
89 | }); | 109 | }); |
90 | 110 | ||
91 | //act | 111 | //act |
92 | scope.notaPedido = { | 112 | scope.notaPedido = { |
93 | vendedor: { | 113 | vendedor: { |
94 | id: null | 114 | id: null |
95 | } | 115 | } |
96 | }; | 116 | }; |
97 | spyOn(focaModalService, 'alert'); | 117 | spyOn(focaModalService, 'alert'); |
98 | scope.crearNotaPedido(); | 118 | scope.crearNotaPedido(); |
99 | 119 | ||
100 | //expect | 120 | //expect |
101 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Vendedor'); | 121 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Vendedor'); |
102 | }); | 122 | }); |
103 | 123 | ||
104 | it('la funcion $scope.crearNotaPedido muestra alerta cuando cliente es null', function() { | 124 | it('la funcion $scope.crearNotaPedido muestra alerta cuando cliente es null', function() { |
105 | 125 | ||
106 | //arrange | 126 | //arrange |
107 | var scope = {}; | 127 | var scope = { |
128 | $watch: function() { }, | ||
129 | $broadcast: function() {} | ||
130 | }; | ||
108 | var focaModalService = { | 131 | var focaModalService = { |
109 | alert: function() { } | 132 | alert: function() { } |
110 | }; | 133 | }; |
111 | 134 | ||
112 | $controler('notaPedidoCtrl', { | 135 | $controler('notaPedidoCtrl', { |
113 | $scope: scope, | 136 | $scope: scope, |
114 | $uibModal: {}, | 137 | $uibModal: {}, |
115 | $location: {}, | 138 | $location: {}, |
116 | $filter: filter, | 139 | $filter: filter, |
117 | $timeout: timeout, | 140 | $timeout: timeout, |
118 | crearNotaPedidoService: { | 141 | crearNotaPedidoService: { |
142 | getNumeroNotaPedido: function() { | ||
143 | return { | ||
144 | then: function() { } | ||
145 | }; | ||
146 | }, | ||
119 | getBotonera: function() { }, | 147 | getBotonera: function() { }, |
120 | getCotizacionByIdMoneda: function() { | 148 | getCotizacionByIdMoneda: function() { |
121 | return { | 149 | return { |
122 | then: function() {} | 150 | then: function() {} |
123 | }; | 151 | }; |
124 | } | 152 | } |
125 | }, | 153 | }, |
126 | focaBotoneraLateralService: {}, | 154 | focaBotoneraLateralService: {}, |
127 | focaModalService: focaModalService, | 155 | focaModalService: focaModalService, |
128 | notaPedidoBusinessService: {}, | 156 | notaPedidoBusinessService: {}, |
129 | $rootScope: { | 157 | $rootScope: { |
130 | $on: function() { } | 158 | $on: function() { } |
131 | }, | 159 | }, |
132 | focaSeguimientoService: {}, | 160 | focaSeguimientoService: {}, |
133 | APP: {}, | 161 | APP: {}, |
134 | focaLoginService: {} | 162 | focaLoginService: {}, |
163 | $localStorage: {}, | ||
164 | $watch: function() { }, | ||
165 | $broadcast: function() {} | ||
135 | }); | 166 | }); |
136 | 167 | ||
137 | scope.notaPedido = { | 168 | scope.notaPedido = { |
138 | vendedor: { | 169 | vendedor: { |
139 | id: true | 170 | id: true |
140 | }, | 171 | }, |
141 | cliente:{ | 172 | cliente:{ |
142 | COD: false | 173 | COD: false |
143 | } | 174 | } |
144 | }; | 175 | }; |
145 | 176 | ||
146 | //act | 177 | //act |
147 | spyOn(focaModalService, 'alert'); | 178 | spyOn(focaModalService, 'alert'); |
148 | scope.crearNotaPedido(); | 179 | scope.crearNotaPedido(); |
149 | 180 | ||
150 | //expect | 181 | //expect |
151 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cliente'); | 182 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cliente'); |
152 | }); | 183 | }); |
153 | 184 | ||
154 | it('funcion $scope.crearNotaPedido muestra alerta cuando proveedor es null', function() { | 185 | it('funcion $scope.crearNotaPedido muestra alerta cuando proveedor es null', function() { |
155 | 186 | ||
156 | //arrange | 187 | //arrange |
157 | var scope = {}; | 188 | var scope = { |
189 | $watch: function() { }, | ||
190 | $broadcast: function() {} | ||
191 | }; | ||
158 | var focaModalService = { | 192 | var focaModalService = { |
159 | alert: function() { } | 193 | alert: function() { } |
160 | }; | 194 | }; |
161 | 195 | ||
162 | $controler('notaPedidoCtrl', { | 196 | $controler('notaPedidoCtrl', { |
163 | $scope: scope, | 197 | $scope: scope, |
164 | $uibModal: {}, | 198 | $uibModal: {}, |
165 | $location: {}, | 199 | $location: {}, |
166 | $filter: filter, | 200 | $filter: filter, |
167 | $timeout: timeout, | 201 | $timeout: timeout, |
168 | crearNotaPedidoService: { | 202 | crearNotaPedidoService: { |
203 | getNumeroNotaPedido: function() { | ||
204 | return { | ||
205 | then: function() { } | ||
206 | }; | ||
207 | }, | ||
169 | getBotonera: function() { }, | 208 | getBotonera: function() { }, |
170 | getCotizacionByIdMoneda: function() { | 209 | getCotizacionByIdMoneda: function() { |
171 | return { | 210 | return { |
172 | then: function() {} | 211 | then: function() {} |
173 | }; | 212 | }; |
174 | } | 213 | } |
175 | }, | 214 | }, |
176 | focaBotoneraLateralService: {}, | 215 | focaBotoneraLateralService: {}, |
177 | focaModalService: focaModalService, | 216 | focaModalService: focaModalService, |
178 | notaPedidoBusinessService: {}, | 217 | notaPedidoBusinessService: {}, |
179 | $rootScope: { | 218 | $rootScope: { |
180 | $on: function() { } | 219 | $on: function() { } |
181 | }, | 220 | }, |
182 | focaSeguimientoService: {}, | 221 | focaSeguimientoService: {}, |
183 | APP: {}, | 222 | APP: {}, |
184 | focaLoginService: {} | 223 | focaLoginService: {}, |
224 | $localStorage: {}, | ||
225 | $watch: function() { }, | ||
226 | $broadcast: function() {} | ||
185 | }); | 227 | }); |
186 | 228 | ||
187 | scope.notaPedido = { | 229 | scope.notaPedido = { |
188 | vendedor: { | 230 | vendedor: { |
189 | id: true | 231 | id: true |
190 | }, | 232 | }, |
191 | cliente:{ | 233 | cliente:{ |
192 | COD: true | 234 | COD: true |
193 | }, | 235 | }, |
194 | proveedor:{ | 236 | proveedor:{ |
195 | COD: null | 237 | COD: null |
196 | } | 238 | } |
197 | }; | 239 | }; |
198 | 240 | ||
199 | //act | 241 | //act |
200 | spyOn(focaModalService, 'alert'); | 242 | spyOn(focaModalService, 'alert'); |
201 | scope.crearNotaPedido(); | 243 | scope.crearNotaPedido(); |
202 | 244 | ||
203 | //expect | 245 | //expect |
204 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Proveedor'); | 246 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Proveedor'); |
205 | }); | 247 | }); |
206 | 248 | ||
207 | it('funcion $scope.crearNotaPedido muestra alerta cuando Moneda es null', function() { | 249 | it('funcion $scope.crearNotaPedido muestra alerta cuando Moneda es null', function() { |
208 | 250 | ||
209 | //arrange | 251 | //arrange |
210 | var scope = {}; | 252 | var scope = { |
253 | $watch: function() { }, | ||
254 | $broadcast: function() {} | ||
255 | }; | ||
211 | var focaModalService = { | 256 | var focaModalService = { |
212 | alert: function() { } | 257 | alert: function() { } |
213 | }; | 258 | }; |
214 | 259 | ||
215 | $controler('notaPedidoCtrl', { | 260 | $controler('notaPedidoCtrl', { |
216 | $scope: scope, | 261 | $scope: scope, |
217 | $uibModal: {}, | 262 | $uibModal: {}, |
218 | $location: {}, | 263 | $location: {}, |
219 | $filter: filter, | 264 | $filter: filter, |
220 | $timeout: timeout, | 265 | $timeout: timeout, |
221 | crearNotaPedidoService: { | 266 | crearNotaPedidoService: { |
267 | getNumeroNotaPedido: function() { | ||
268 | return { | ||
269 | then: function() { } | ||
270 | }; | ||
271 | }, | ||
222 | getBotonera: function() { }, | 272 | getBotonera: function() { }, |
223 | getCotizacionByIdMoneda: function() { | 273 | getCotizacionByIdMoneda: function() { |
224 | return { | 274 | return { |
225 | then: function() {} | 275 | then: function() {} |
226 | }; | 276 | }; |
227 | } | 277 | } |
228 | }, | 278 | }, |
229 | focaBotoneraLateralService: {}, | 279 | focaBotoneraLateralService: {}, |
230 | focaModalService: focaModalService, | 280 | focaModalService: focaModalService, |
231 | notaPedidoBusinessService: {}, | 281 | notaPedidoBusinessService: {}, |
232 | $rootScope: { | 282 | $rootScope: { |
233 | $on: function() { } | 283 | $on: function() { } |
234 | }, | 284 | }, |
235 | focaSeguimientoService: {}, | 285 | focaSeguimientoService: {}, |
236 | APP: {}, | 286 | APP: {}, |
237 | focaLoginService: {} | 287 | focaLoginService: {}, |
288 | $localStorage: {}, | ||
289 | $watch: function() { }, | ||
290 | $broadcast: function() {} | ||
238 | }); | 291 | }); |
239 | 292 | ||
240 | scope.notaPedido = { | 293 | scope.notaPedido = { |
241 | vendedor: { | 294 | vendedor: { |
242 | id: true | 295 | id: true |
243 | }, | 296 | }, |
244 | cliente:{ | 297 | cliente:{ |
245 | COD: true | 298 | COD: true |
246 | }, | 299 | }, |
247 | proveedor:{ | 300 | proveedor:{ |
248 | COD: true | 301 | COD: true |
249 | }, | 302 | }, |
250 | moneda:{ | 303 | cotizacion: { |
251 | ID: null | 304 | ID: true, |
305 | moneda:{ | ||
306 | ID: null | ||
307 | } | ||
252 | } | 308 | } |
253 | }; | 309 | }; |
254 | 310 | ||
255 | //act | 311 | //act |
256 | spyOn(focaModalService, 'alert'); | 312 | spyOn(focaModalService, 'alert'); |
257 | scope.crearNotaPedido(); | 313 | scope.crearNotaPedido(); |
258 | 314 | ||
259 | //expect | 315 | //expect |
260 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Moneda'); | 316 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Moneda'); |
261 | }); | 317 | }); |
262 | 318 | ||
263 | it('funcion $scope.crearNotaPedido muestra alerta cuando cotizacion es null', function() { | 319 | it('funcion $scope.crearNotaPedido muestra alerta cuando cotizacion es null', function() { |
264 | 320 | ||
265 | //arrange | 321 | //arrange |
266 | var scope = {}; | 322 | var scope = { |
323 | $watch: function() { }, | ||
324 | $broadcast: function() {} | ||
325 | }; | ||
267 | var focaModalService = { | 326 | var focaModalService = { |
268 | alert: function() { } | 327 | alert: function() { } |
269 | }; | 328 | }; |
270 | 329 | ||
271 | $controler('notaPedidoCtrl', { | 330 | $controler('notaPedidoCtrl', { |
272 | $scope: scope, | 331 | $scope: scope, |
273 | $uibModal: {}, | 332 | $uibModal: {}, |
274 | $location: {}, | 333 | $location: {}, |
275 | $filter: filter, | 334 | $filter: filter, |
276 | $timeout: timeout, | 335 | $timeout: timeout, |
277 | crearNotaPedidoService: { | 336 | crearNotaPedidoService: { |
337 | getNumeroNotaPedido: function() { | ||
338 | return { | ||
339 | then: function() { } | ||
340 | }; | ||
341 | }, | ||
278 | getBotonera: function() { }, | 342 | getBotonera: function() { }, |
279 | getCotizacionByIdMoneda: function() { | 343 | getCotizacionByIdMoneda: function() { |
280 | return { | 344 | return { |
281 | then: function() {} | 345 | then: function() {} |
282 | }; | 346 | }; |
283 | } | 347 | } |
284 | }, | 348 | }, |
285 | focaBotoneraLateralService: {}, | 349 | focaBotoneraLateralService: {}, |
286 | focaModalService: focaModalService, | 350 | focaModalService: focaModalService, |
287 | notaPedidoBusinessService: {}, | 351 | notaPedidoBusinessService: {}, |
288 | $rootScope: { | 352 | $rootScope: { |
289 | $on: function() { } | 353 | $on: function() { } |
290 | }, | 354 | }, |
291 | focaSeguimientoService: {}, | 355 | focaSeguimientoService: {}, |
292 | APP: {}, | 356 | APP: {}, |
293 | focaLoginService: {} | 357 | focaLoginService: {}, |
358 | $localStorage: {}, | ||
359 | $watch: function() { }, | ||
360 | $broadcast: function() {} | ||
294 | }); | 361 | }); |
295 | 362 | ||
296 | scope.notaPedido = { | 363 | scope.notaPedido = { |
297 | vendedor: { | 364 | vendedor: { |
298 | id: true | 365 | id: true |
299 | }, | 366 | }, |
300 | cliente:{ | 367 | cliente:{ |
301 | COD: true | 368 | COD: true |
302 | }, | 369 | }, |
303 | proveedor:{ | 370 | proveedor:{ |
304 | COD: true | 371 | COD: true |
305 | }, | 372 | }, |
306 | moneda:{ | ||
307 | ID: true | ||
308 | }, | ||
309 | cotizacion:{ | 373 | cotizacion:{ |
310 | ID: null | 374 | ID: null, |
375 | moneda: { | ||
376 | ID: true | ||
377 | } | ||
311 | } | 378 | } |
312 | }; | 379 | }; |
313 | 380 | ||
314 | //act | 381 | //act |
315 | spyOn(focaModalService, 'alert'); | 382 | spyOn(focaModalService, 'alert'); |
316 | scope.crearNotaPedido(); | 383 | scope.crearNotaPedido(); |
317 | 384 | ||
318 | //expect | 385 | //expect |
319 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cotización'); | 386 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cotización'); |
320 | }); | 387 | }); |
321 | 388 | ||
322 | it('funcion $scope.crearNotaPedido muestra alerta cuando plazos es null', function() { | 389 | it('funcion $scope.crearNotaPedido muestra alerta cuando plazos es null', function() { |
323 | 390 | ||
324 | //arrange | 391 | //arrange |
325 | var scope = {}; | 392 | var scope = { |
393 | $watch: function() { }, | ||
394 | $broadcast: function() {} | ||
395 | }; | ||
326 | var focaModalService = { | 396 | var focaModalService = { |
327 | alert: function() { } | 397 | alert: function() { } |
328 | }; | 398 | }; |
329 | 399 | ||
330 | $controler('notaPedidoCtrl', { | 400 | $controler('notaPedidoCtrl', { |
331 | $scope: scope, | 401 | $scope: scope, |
332 | $uibModal: {}, | 402 | $uibModal: {}, |
333 | $location: {}, | 403 | $location: {}, |
334 | $filter: filter, | 404 | $filter: filter, |
335 | $timeout: timeout, | 405 | $timeout: timeout, |
336 | crearNotaPedidoService: { | 406 | crearNotaPedidoService: { |
407 | getNumeroNotaPedido: function() { | ||
408 | return { | ||
409 | then: function() { } | ||
410 | }; | ||
411 | }, | ||
337 | getBotonera: function() { }, | 412 | getBotonera: function() { }, |
338 | getCotizacionByIdMoneda: function() { | 413 | getCotizacionByIdMoneda: function() { |
339 | return { | 414 | return { |
340 | then: function() {} | 415 | then: function() {} |
341 | }; | 416 | }; |
342 | } | 417 | } |
343 | }, | 418 | }, |
344 | focaBotoneraLateralService: {}, | 419 | focaBotoneraLateralService: {}, |
345 | focaModalService: focaModalService, | 420 | focaModalService: focaModalService, |
346 | notaPedidoBusinessService: {}, | 421 | notaPedidoBusinessService: {}, |
347 | $rootScope: { | 422 | $rootScope: { |
348 | $on: function() { } | 423 | $on: function() { } |
349 | }, | 424 | }, |
350 | focaSeguimientoService: {}, | 425 | focaSeguimientoService: {}, |
351 | APP: {}, | 426 | APP: {}, |
352 | focaLoginService: {} | 427 | focaLoginService: {}, |
428 | $localStorage: {}, | ||
429 | $watch: function() { }, | ||
430 | $broadcast: function() {} | ||
353 | }); | 431 | }); |
354 | 432 | ||
355 | scope.notaPedido = { | 433 | scope.notaPedido = { |
356 | vendedor: { | 434 | vendedor: { |
357 | id: true | 435 | id: true |
358 | }, | 436 | }, |
359 | cliente:{ | 437 | cliente:{ |
360 | COD: true | 438 | COD: true |
361 | }, | 439 | }, |
362 | proveedor:{ | 440 | proveedor:{ |
363 | COD: true | 441 | COD: true |
364 | }, | 442 | }, |
365 | moneda:{ | ||
366 | ID: true | ||
367 | }, | ||
368 | cotizacion:{ | 443 | cotizacion:{ |
369 | ID: true | 444 | ID: true, |
445 | moneda:{ | ||
446 | ID: true | ||
447 | } | ||
370 | } | 448 | } |
371 | }; | 449 | }; |
372 | 450 | ||
373 | scope.plazosPagos = null; | 451 | scope.plazosPagos = null; |
374 | 452 | ||
375 | //act | 453 | //act |
376 | spyOn(focaModalService, 'alert'); | 454 | spyOn(focaModalService, 'alert'); |
377 | scope.crearNotaPedido(); | 455 | scope.crearNotaPedido(); |
378 | 456 | ||
379 | //expect | 457 | //expect |
380 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Precios y Condiciones'); | 458 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Precios y Condiciones'); |
381 | }); | 459 | }); |
382 | 460 | ||
383 | it('funcion $scope.crearNotaPedido muestra alerta cuando flete es null', function() { | 461 | it('funcion $scope.crearNotaPedido muestra alerta cuando flete es null', function() { |
384 | 462 | ||
385 | //arrange | 463 | //arrange |
386 | var scope = {}; | 464 | var scope = { |
465 | $watch: function() { }, | ||
466 | $broadcast: function() {} | ||
467 | }; | ||
387 | var focaModalService = { | 468 | var focaModalService = { |
388 | alert: function() { } | 469 | alert: function() { } |
389 | }; | 470 | }; |
390 | 471 | ||
391 | $controler('notaPedidoCtrl', { | 472 | $controler('notaPedidoCtrl', { |
392 | $scope: scope, | 473 | $scope: scope, |
393 | $uibModal: {}, | 474 | $uibModal: {}, |
394 | $location: {}, | 475 | $location: {}, |
395 | $filter: filter, | 476 | $filter: filter, |
396 | $timeout: timeout, | 477 | $timeout: timeout, |
397 | crearNotaPedidoService: { | 478 | crearNotaPedidoService: { |
479 | getNumeroNotaPedido: function() { | ||
480 | return { | ||
481 | then: function() { } | ||
482 | }; | ||
483 | }, | ||
398 | getBotonera: function() { }, | 484 | getBotonera: function() { }, |
399 | getCotizacionByIdMoneda: function() { | 485 | getCotizacionByIdMoneda: function() { |
400 | return { | 486 | return { |
401 | then: function() {} | 487 | then: function() {} |
402 | }; | 488 | }; |
403 | } | 489 | } |
404 | }, | 490 | }, |
405 | focaBotoneraLateralService: {}, | 491 | focaBotoneraLateralService: {}, |
406 | focaModalService: focaModalService, | 492 | focaModalService: focaModalService, |
407 | notaPedidoBusinessService: {}, | 493 | notaPedidoBusinessService: {}, |
408 | $rootScope: { | 494 | $rootScope: { |
409 | $on: function() { } | 495 | $on: function() { } |
410 | }, | 496 | }, |
411 | focaSeguimientoService: {}, | 497 | focaSeguimientoService: {}, |
412 | APP: {}, | 498 | APP: {}, |
413 | focaLoginService: {} | 499 | focaLoginService: {}, |
500 | $localStorage: {}, | ||
501 | $watch: function() { }, | ||
502 | $broadcast: function() {} | ||
414 | }); | 503 | }); |
415 | 504 | ||
416 | scope.notaPedido = { | 505 | scope.notaPedido = { |
417 | vendedor: { | 506 | vendedor: { |
418 | id: true | 507 | id: true |
419 | }, | 508 | }, |
420 | cliente:{ | 509 | cliente:{ |
421 | COD: true | 510 | COD: true |
422 | }, | 511 | }, |
423 | proveedor:{ | 512 | proveedor:{ |
424 | COD: true | 513 | COD: true |
425 | }, | 514 | }, |
426 | moneda:{ | ||
427 | ID: true | ||
428 | }, | ||
429 | cotizacion:{ | 515 | cotizacion:{ |
430 | ID: true | 516 | ID: true, |
517 | moneda:{ | ||
518 | ID: true | ||
519 | } | ||
431 | }, | 520 | }, |
432 | flete: null | 521 | flete: null, |
522 | notaPedidoPlazo: [] | ||
433 | }; | 523 | }; |
434 | 524 | ||
435 | scope.plazosPagos = true; | 525 | scope.plazosPagos = true; |
436 | 526 | ||
437 | //act | 527 | //act |
438 | spyOn(focaModalService, 'alert'); | 528 | spyOn(focaModalService, 'alert'); |
439 | scope.crearNotaPedido(); | 529 | scope.crearNotaPedido(); |
440 | 530 | ||
441 | //expect | 531 | //expect |
442 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Flete'); | 532 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Flete'); |
443 | }); | 533 | }); |
444 | 534 | ||
445 | it('funcion $scope.crearNotaPedido muestra alerta cuando domicilio es null', function() { | 535 | it('funcion $scope.crearNotaPedido muestra alerta cuando domicilio es null', function() { |
446 | 536 | ||
447 | //arrange | 537 | //arrange |
448 | var scope = {}; | 538 | var scope = { |
539 | $watch: function() { }, | ||
540 | $broadcast: function() {} | ||
541 | }; | ||
449 | var focaModalService = { | 542 | var focaModalService = { |
450 | alert: function() { } | 543 | alert: function() { } |
451 | }; | 544 | }; |
452 | 545 | ||
453 | $controler('notaPedidoCtrl', { | 546 | $controler('notaPedidoCtrl', { |
454 | $scope: scope, | 547 | $scope: scope, |
455 | $uibModal: {}, | 548 | $uibModal: {}, |
456 | $location: {}, | 549 | $location: {}, |
457 | $filter: filter, | 550 | $filter: filter, |
458 | $timeout: timeout, | 551 | $timeout: timeout, |
459 | crearNotaPedidoService: { | 552 | crearNotaPedidoService: { |
553 | getNumeroNotaPedido: function() { | ||
554 | return { | ||
555 | then: function() { } | ||
556 | }; | ||
557 | }, | ||
460 | getBotonera: function() { }, | 558 | getBotonera: function() { }, |
461 | getCotizacionByIdMoneda: function() { | 559 | getCotizacionByIdMoneda: function() { |
462 | return { | 560 | return { |
463 | then: function() {} | 561 | then: function() {} |
464 | }; | 562 | }; |
465 | } | 563 | } |
466 | }, | 564 | }, |
467 | focaBotoneraLateralService: {}, | 565 | focaBotoneraLateralService: {}, |
468 | focaModalService: focaModalService, | 566 | focaModalService: focaModalService, |
469 | notaPedidoBusinessService: {}, | 567 | notaPedidoBusinessService: {}, |
470 | $rootScope: { | 568 | $rootScope: { |
471 | $on: function() { } | 569 | $on: function() { } |
472 | }, | 570 | }, |
473 | focaSeguimientoService: {}, | 571 | focaSeguimientoService: {}, |
474 | APP: {}, | 572 | APP: {}, |
475 | focaLoginService: {} | 573 | focaLoginService: {}, |
574 | $localStorage: {}, | ||
575 | $watch: function() { }, | ||
576 | $broadcast: function() {} | ||
476 | }); | 577 | }); |
477 | 578 | ||
478 | scope.notaPedido = { | 579 | scope.notaPedido = { |
479 | vendedor: { | 580 | vendedor: { |
480 | id: true | 581 | id: true |
481 | }, | 582 | }, |
482 | cliente:{ | 583 | cliente:{ |
483 | COD: true | 584 | COD: true |
484 | }, | 585 | }, |
485 | proveedor:{ | 586 | proveedor:{ |
486 | COD: true | 587 | COD: true |
487 | }, | 588 | }, |
488 | moneda:{ | ||
489 | ID: true | ||
490 | }, | ||
491 | cotizacion:{ | 589 | cotizacion:{ |
492 | ID: true | 590 | ID: true, |
591 | moneda:{ | ||
592 | ID: true | ||
593 | } | ||
493 | }, | 594 | }, |
494 | flete: true, | 595 | flete: true, |
495 | domicilioStamp: null | 596 | domicilioStamp: null, |
597 | notaPedidoPlazo: [] | ||
496 | }; | 598 | }; |
497 | 599 | ||
498 | scope.plazosPagos = true; | 600 | scope.plazosPagos = true; |
499 | 601 | ||
500 | //act | 602 | //act |
501 | spyOn(focaModalService, 'alert'); | 603 | spyOn(focaModalService, 'alert'); |
502 | scope.crearNotaPedido(); | 604 | scope.crearNotaPedido(); |
503 | 605 | ||
504 | //expect | 606 | //expect |
505 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Domicilio'); | 607 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Domicilio'); |
506 | }); | 608 | }); |
507 | 609 | ||
508 | it('funcion $scope.crearNotaPedido muestra alerta cuando no se cargaron articulos', | 610 | it('funcion $scope.crearNotaPedido muestra alerta cuando no se cargaron articulos', |
509 | function() | 611 | function() |
510 | { | 612 | { |
511 | 613 | ||
512 | //arrange | 614 | //arrange |
513 | var scope = {}; | 615 | var scope = { |
616 | $watch: function() { }, | ||
617 | $broadcast: function() {} | ||
618 | }; | ||
514 | var focaModalService = { | 619 | var focaModalService = { |
515 | alert: function() { } | 620 | alert: function() { } |
516 | }; | 621 | }; |
517 | 622 | ||
518 | $controler('notaPedidoCtrl', { | 623 | $controler('notaPedidoCtrl', { |
519 | $scope: scope, | 624 | $scope: scope, |
520 | $uibModal: {}, | 625 | $uibModal: {}, |
521 | $location: {}, | 626 | $location: {}, |
522 | $filter: filter, | 627 | $filter: filter, |
523 | $timeout: timeout, | 628 | $timeout: timeout, |
524 | crearNotaPedidoService: { | 629 | crearNotaPedidoService: { |
630 | getNumeroNotaPedido: function() { | ||
631 | return { | ||
632 | then: function() {} | ||
633 | }; | ||
634 | }, | ||
525 | getBotonera: function() { }, | 635 | getBotonera: function() { }, |
526 | getCotizacionByIdMoneda: function() { | 636 | getCotizacionByIdMoneda: function() { |
527 | return { | 637 | return { |
528 | then: function() {} | 638 | then: function() {} |
529 | }; | 639 | }; |
640 | }, | ||
641 | crearNotaPedido: function() { | ||
642 | return { | ||
643 | then: function() { } | ||
644 | }; | ||
530 | } | 645 | } |
531 | }, | 646 | }, |
532 | focaBotoneraLateralService: {}, | 647 | focaBotoneraLateralService: { |
648 | startGuardar: function() {} | ||
649 | }, | ||
533 | focaModalService: focaModalService, | 650 | focaModalService: focaModalService, |
534 | notaPedidoBusinessService: {}, | 651 | notaPedidoBusinessService: {}, |
535 | $rootScope: { | 652 | $rootScope: { |
536 | $on: function() { } | 653 | $on: function() { } |
537 | }, | 654 | }, |
538 | focaSeguimientoService: {}, | 655 | focaSeguimientoService: {}, |
539 | APP: {}, | 656 | APP: {}, |
540 | focaLoginService: {} | 657 | focaLoginService: {}, |
658 | $localStorage: {}, | ||
659 | $watch: function() { }, | ||
660 | $broadcast: function() {} | ||
541 | }); | 661 | }); |
542 | 662 | ||
543 | scope.notaPedido = { | 663 | scope.notaPedido = { |
544 | vendedor: { | 664 | vendedor: { |
545 | id: true | 665 | id: true |
546 | }, | 666 | }, |
547 | cliente:{ | 667 | cliente:{ |
548 | COD: true | 668 | COD: true |
549 | }, | 669 | }, |
550 | proveedor:{ | 670 | proveedor:{ |
551 | COD: true | 671 | COD: true |
552 | }, | 672 | }, |
553 | moneda:{ | ||
554 | ID: true | ||
555 | }, | ||
556 | cotizacion:{ | 673 | cotizacion:{ |
557 | ID: true | 674 | ID: true, |
675 | moneda:{ | ||
676 | ID: true | ||
677 | } | ||
678 | }, | ||
679 | precioCondicion: { | ||
680 | id: true | ||
681 | }, | ||
682 | domicilio: { | ||
683 | id: true | ||
558 | }, | 684 | }, |
559 | flete: true, | 685 | flete: true, |
560 | domicilioStamp: true, | 686 | domicilioStamp: true, |
687 | notaPedidoPlazo: [], | ||
688 | articulosNotaPedido: [], | ||
689 | fechaCarga: true | ||
561 | }; | 690 | }; |
562 | 691 | ||
563 | scope.plazosPagos = true; | ||
564 | scope.articulosTabla = []; | 692 | scope.articulosTabla = []; |
565 | 693 | ||
566 | //act | 694 | //act |
567 | spyOn(focaModalService, 'alert'); | 695 | spyOn(focaModalService, 'alert'); |
568 | scope.crearNotaPedido(); | 696 | scope.crearNotaPedido(); |
569 | 697 | ||
570 | //expect | 698 | //expect |
571 | expect(focaModalService.alert) | 699 | expect(focaModalService.alert) |
572 | .toHaveBeenCalledWith('Debe cargar al menos un articulo'); | 700 | .toHaveBeenCalledWith('Debe cargar al menos un articulo'); |
573 | }); | 701 | }); |
574 | 702 | ||
575 | it('funcion $scope.crearNotaPedido llama startGuardar', function() { | 703 | it('funcion $scope.crearNotaPedido llama startGuardar', function() { |
576 | 704 | ||
577 | //arrange | 705 | //arrange |
578 | var scope = {}; | 706 | var scope = { |
707 | $watch: function() { }, | ||
708 | $broadcast: function() {} | ||
709 | }; | ||
579 | var focaBotoneraLateralService = { | 710 | var focaBotoneraLateralService = { |
580 | startGuardar: function() { } | 711 | startGuardar: function() { } |
581 | }; | 712 | }; |
582 | 713 | ||
583 | $controler('notaPedidoCtrl', { | 714 | $controler('notaPedidoCtrl', { |
584 | $scope: scope, | 715 | $scope: scope, |
585 | $uibModal: {}, | 716 | $uibModal: {}, |
586 | $location: {}, | 717 | $location: {}, |
587 | $filter: filter, | 718 | $filter: filter, |
588 | $timeout: timeout, | 719 | $timeout: timeout, |
589 | crearNotaPedidoService: { | 720 | crearNotaPedidoService: { |
721 | getNumeroNotaPedido: function() { | ||
722 | return { | ||
723 | then: function() { } | ||
724 | }; | ||
725 | }, | ||
590 | getBotonera: function() { }, | 726 | getBotonera: function() { }, |
591 | getCotizacionByIdMoneda: function() { | 727 | getCotizacionByIdMoneda: function() { |
592 | return { | 728 | return { |
593 | then: function() {} | 729 | then: function() {} |
594 | }; | 730 | }; |
595 | }, | 731 | }, |
596 | crearNotaPedido: function() { | 732 | crearNotaPedido: function() { |
597 | return { | 733 | return { |
598 | then: function() { } | 734 | then: function() { } |
599 | }; | 735 | }; |
600 | } | 736 | } |
601 | }, | 737 | }, |
602 | focaBotoneraLateralService: focaBotoneraLateralService, | 738 | focaBotoneraLateralService: focaBotoneraLateralService, |
603 | focaModalService: {}, | 739 | focaModalService: { |
740 | alert: function() {} | ||
741 | }, | ||
604 | notaPedidoBusinessService: {}, | 742 | notaPedidoBusinessService: {}, |
605 | $rootScope: { | 743 | $rootScope: { |
606 | $on: function() { } | 744 | $on: function() { } |
607 | }, | 745 | }, |
608 | focaSeguimientoService: {}, | 746 | focaSeguimientoService: {}, |
609 | APP: {}, | 747 | APP: {}, |
610 | focaLoginService: {} | 748 | focaLoginService: {}, |
749 | $localStorage: {}, | ||
750 | $watch: function() { }, | ||
751 | $broadcast: function() {} | ||
611 | }); | 752 | }); |
612 | 753 | ||
613 | scope.notaPedido = { | 754 | scope.notaPedido = { |
614 | vendedor: { | 755 | vendedor: { |
615 | id: true | 756 | id: true |
616 | }, | 757 | }, |
617 | cliente:{ | 758 | cliente:{ |
618 | COD: true | 759 | COD: true |
619 | }, | 760 | }, |
620 | proveedor:{ | 761 | proveedor:{ |
621 | COD: true | 762 | COD: true |
622 | }, | 763 | }, |
623 | moneda:{ | ||
624 | ID: true | ||
625 | }, | ||
626 | cotizacion:{ | 764 | cotizacion:{ |
627 | ID: true | 765 | ID: true, |
766 | moneda:{ | ||
767 | ID: true | ||
768 | } | ||
628 | }, | 769 | }, |
629 | flete: true, | 770 | flete: true, |
630 | domicilioStamp: true, | 771 | domicilioStamp: true, |
631 | domicilio: { | 772 | domicilio: { |
632 | id: true | 773 | id: true |
633 | } | 774 | }, |
775 | notaPedidoPlazo: [], | ||
776 | articulosNotaPedido: true, | ||
777 | fechaCarga: true | ||
634 | }; | 778 | }; |
635 | 779 | ||
636 | scope.plazosPagos = true; | 780 | scope.plazosPagos = true; |
637 | scope.articulosTabla = [1]; | 781 | scope.articulosTabla = [1]; |
638 | 782 | ||
639 | //act | 783 | //act |
640 | spyOn(focaBotoneraLateralService, 'startGuardar'); | 784 | spyOn(focaBotoneraLateralService, 'startGuardar'); |
641 | scope.crearNotaPedido(); | 785 | scope.crearNotaPedido(scope.notaPedido); |
642 | 786 | ||
643 | //expect | 787 | //expect |
644 | expect(focaBotoneraLateralService.startGuardar).toHaveBeenCalled(); | 788 | expect(focaBotoneraLateralService.startGuardar).toHaveBeenCalled(); |
645 | }); | 789 | }); |
646 | 790 | ||
647 | it('funcion $scope.crearNotaPedido llama funciones al guardar', function(done) { | 791 | it('funcion $scope.crearNotaPedido llama funciones al guardar', function(done) { |
648 | 792 | ||
649 | //arrange | 793 | //arrange |
650 | var scope = {}; | 794 | var scope = { |
795 | $watch: function() { }, | ||
796 | $broadcast: function() {} | ||
797 | }; | ||
651 | var focaBotoneraLateralService = { | 798 | var focaBotoneraLateralService = { |
652 | startGuardar: function() { }, | 799 | startGuardar: function() { }, |
653 | endGuardar: function() { } | 800 | endGuardar: function() { } |
654 | }; | 801 | }; |
655 | var focaSeguimientoService = { | 802 | var focaSeguimientoService = { |
656 | guardarPosicion: function() { } | 803 | guardarPosicion: function() { } |
657 | }; | 804 | }; |
658 | var notaPedidoBusinessService = { | 805 | var notaPedidoBusinessService = { |
659 | addArticulos: function() { }, | 806 | addArticulos: function() { }, |
660 | addEstado: function() { } | 807 | addEstado: function() { } |
661 | }; | 808 | }; |
662 | var crearNotaPedidoService = { | 809 | var crearNotaPedidoService = { |
663 | getBotonera: function() { }, | 810 | getBotonera: function() { }, |
664 | getCotizacionByIdMoneda: function() { | 811 | getCotizacionByIdMoneda: function() { |
665 | return { | 812 | return { |
666 | then: function() {} | 813 | then: function() {} |
667 | }; | 814 | }; |
668 | }, | 815 | }, |
669 | crearNotaPedido: function() { }, | 816 | crearNotaPedido: function() { |
817 | return { | ||
818 | then: function() { } | ||
819 | }; | ||
820 | }, | ||
670 | getNumeroNotaPedido: function() { | 821 | getNumeroNotaPedido: function() { |
671 | return { | 822 | return { |
672 | then: function() { } | 823 | then: function() { } |
673 | }; | 824 | }; |
674 | } | 825 | } |
675 | }; | 826 | }; |
676 | 827 | ||
677 | $controler('notaPedidoCtrl', { | 828 | $controler('notaPedidoCtrl', { |
678 | $scope: scope, | 829 | $scope: scope, |
679 | $uibModal: {}, | 830 | $uibModal: {}, |
680 | $location: {}, | 831 | $location: {}, |
681 | $filter: filter, | 832 | $filter: filter, |
682 | $timeout: timeout, | 833 | $timeout: timeout, |
683 | crearNotaPedidoService: crearNotaPedidoService, | 834 | crearNotaPedidoService: crearNotaPedidoService, |
684 | focaBotoneraLateralService: focaBotoneraLateralService, | 835 | focaBotoneraLateralService: focaBotoneraLateralService, |
685 | focaModalService: {}, | 836 | focaModalService: { |
837 | alert: function() {} | ||
838 | }, | ||
686 | notaPedidoBusinessService: notaPedidoBusinessService, | 839 | notaPedidoBusinessService: notaPedidoBusinessService, |
687 | $rootScope: { | 840 | $rootScope: { |
688 | $on: function() { } | 841 | $on: function() { } |
689 | }, | 842 | }, |
690 | focaSeguimientoService: focaSeguimientoService, | 843 | focaSeguimientoService: focaSeguimientoService, |
691 | APP: {}, | 844 | APP: {}, |
692 | focaLoginService: {} | 845 | focaLoginService: {}, |
846 | $localStorage: {}, | ||
847 | $watch: function() { }, | ||
848 | $broadcast: function() {} | ||
693 | }); | 849 | }); |
694 | 850 | ||
695 | scope.notaPedido = { | 851 | scope.notaPedido = { |
696 | vendedor: { | 852 | vendedor: { |
697 | id: true | 853 | id: true |
698 | }, | 854 | }, |
699 | cliente:{ | 855 | cliente:{ |
700 | COD: true | 856 | COD: true |
701 | }, | 857 | }, |
702 | proveedor:{ | 858 | proveedor:{ |
703 | COD: true | 859 | COD: true |
704 | }, | 860 | }, |
705 | moneda:{ | ||
706 | ID: true | ||
707 | }, | ||
708 | cotizacion:{ | 861 | cotizacion:{ |
709 | ID: true | 862 | ID: true, |
863 | moneda:{ | ||
864 | ID: true | ||
865 | } | ||
710 | }, | 866 | }, |
711 | flete: true, | 867 | flete: true, |
712 | domicilioStamp: true, | 868 | domicilioStamp: true, |
713 | domicilio: { | 869 | domicilio: { |
714 | id: true | 870 | id: true |
715 | } | 871 | }, |
872 | notaPedidoPlazo: [], | ||
873 | articulosNotaPedido: [1], | ||
874 | fechaCarga: true | ||
716 | }; | 875 | }; |
717 | 876 | ||
718 | scope.plazosPagos = []; | 877 | scope.plazosPagos = []; |
src/js/controller.js
1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
2 | [ | 2 | [ |
3 | '$scope', | 3 | '$scope', |
4 | '$uibModal', | 4 | '$uibModal', |
5 | '$location', | 5 | '$location', |
6 | '$filter', | 6 | '$filter', |
7 | '$timeout', | 7 | '$timeout', |
8 | 'crearNotaPedidoService', | 8 | 'crearNotaPedidoService', |
9 | 'focaBotoneraLateralService', | 9 | 'focaBotoneraLateralService', |
10 | 'focaModalService', | 10 | 'focaModalService', |
11 | 'notaPedidoBusinessService', | 11 | 'notaPedidoBusinessService', |
12 | '$rootScope', | 12 | '$rootScope', |
13 | 'focaSeguimientoService', | 13 | 'focaSeguimientoService', |
14 | 'APP', | 14 | 'APP', |
15 | 'focaLoginService', | 15 | 'focaLoginService', |
16 | '$localStorage', | ||
16 | function( | 17 | function( |
17 | $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService, | 18 | $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService, |
18 | focaBotoneraLateralService, focaModalService, notaPedidoBusinessService, | 19 | focaBotoneraLateralService, focaModalService, notaPedidoBusinessService, |
19 | $rootScope, focaSeguimientoService, APP, focaLoginService) | 20 | $rootScope, focaSeguimientoService, APP, focaLoginService, $localStorage) |
20 | { | 21 | { |
21 | config(); | 22 | config(); |
22 | 23 | ||
23 | function config() { | 24 | function config() { |
24 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA | 25 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA |
26 | $scope.notaPedido = {}; | ||
25 | $scope.isNumber = angular.isNumber; | 27 | $scope.isNumber = angular.isNumber; |
26 | $scope.datepickerAbierto = false; | 28 | $scope.datepickerAbierto = false; |
27 | $scope.show = false; | 29 | $scope.show = false; |
28 | $scope.cargando = true; | 30 | $scope.cargando = true; |
29 | $scope.now = new Date(); | ||
30 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); | 31 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
31 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); | 32 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
32 | $scope.dateOptions = { | 33 | $scope.dateOptions = { |
33 | maxDate: new Date(), | 34 | maxDate: new Date(), |
34 | minDate: new Date(2010, 0, 1) | 35 | minDate: new Date(2010, 0, 1) |
35 | }; | 36 | }; |
36 | 37 | ||
37 | //SETEO BOTONERA LATERAL | 38 | //SETEO BOTONERA LATERAL |
38 | $timeout(function() { | 39 | $timeout(function() { |
39 | focaBotoneraLateralService.showSalir(false); | 40 | focaBotoneraLateralService.showSalir(false); |
40 | focaBotoneraLateralService.showPausar(true); | 41 | focaBotoneraLateralService.showPausar(true); |
41 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); | 42 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); |
42 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 43 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
43 | }); | 44 | }); |
44 | 45 | ||
45 | // SETEA BOTONERA DE FACTURADOR TENIENDO EN CUENTA SI ESTA SETEADO EL VENDEDOR | 46 | // SETEA BOTONERA DE FACTURADOR TENIENDO EN CUENTA SI ESTA SETEADO EL VENDEDOR |
46 | if (APP === 'distribuidor') { | 47 | if (APP === 'distribuidor') { |
47 | $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; | 48 | $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; |
48 | $scope.botonera = crearNotaPedidoService.getBotonera($scope.idVendedor); | 49 | $scope.botonera = crearNotaPedidoService.getBotonera($scope.idVendedor); |
49 | } else { | 50 | } else { |
50 | $scope.botonera = crearNotaPedidoService.getBotonera(); | 51 | $scope.botonera = crearNotaPedidoService.getBotonera(); |
51 | } | 52 | } |
52 | 53 | ||
53 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 54 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
54 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | 55 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { |
55 | $scope.monedaDefecto = res.data[0]; | 56 | var monedaPorDefecto = res.data[0]; |
56 | $scope.cotizacionDefecto = $scope.monedaDefecto.cotizaciones[0]; | ||
57 | 57 | ||
58 | init(); | 58 | $scope.notaPedido.cotizacion = Object.assign( |
59 | {moneda: monedaPorDefecto}, | ||
60 | monedaPorDefecto.cotizaciones[0] | ||
61 | ); | ||
62 | $scope.inicial.cotizacion = $scope.notaPedido.cotizacion; | ||
59 | }); | 63 | }); |
64 | |||
65 | init(); | ||
66 | $timeout(function() {getLSNotaPedido();}); | ||
60 | } | 67 | } |
61 | 68 | ||
62 | function init() { | 69 | function init() { |
63 | $scope.$broadcast('cleanCabecera'); | 70 | $scope.$broadcast('cleanCabecera'); |
64 | 71 | ||
65 | $scope.notaPedido = { | 72 | $scope.notaPedido = { |
66 | id: 0, | 73 | id: 0, |
67 | cliente: {}, | 74 | cliente: {}, |
68 | proveedor: {}, | 75 | proveedor: {}, |
69 | domicilio: {dom: ''}, | 76 | domicilio: {dom: ''}, |
70 | vendedor: {}, | 77 | vendedor: {}, |
71 | moneda: $scope.monedaDefecto, | 78 | fechaCarga: new Date(), |
72 | cotizacion: $scope.cotizacionDefecto | 79 | cotizacion: {}, |
80 | articulosNotaPedido: [], | ||
81 | notaPedidoPlazo: [] | ||
73 | }; | 82 | }; |
74 | |||
75 | $scope.articulosTabla = []; | ||
76 | $scope.idLista = undefined; | 83 | $scope.idLista = undefined; |
77 | 84 | ||
78 | crearNotaPedidoService.getNumeroNotaPedido().then( | 85 | crearNotaPedidoService.getNumeroNotaPedido().then( |
79 | function(res) { | 86 | function(res) { |
80 | $scope.puntoVenta = $filter('rellenarDigitos')( | 87 | $scope.puntoVenta = $filter('rellenarDigitos')( |
81 | res.data.sucursal, 4 | 88 | res.data.sucursal, 4 |
82 | ); | 89 | ); |
83 | 90 | ||
84 | $scope.comprobante = $filter('rellenarDigitos')( | 91 | $scope.comprobante = $filter('rellenarDigitos')( |
85 | res.data.numeroNotaPedido, 8 | 92 | res.data.numeroNotaPedido, 8 |
86 | ); | 93 | ); |
87 | }, | 94 | }, |
88 | function(err) { | 95 | function(err) { |
89 | focaModalService.alert('La terminal no esta configurada correctamente'); | 96 | focaModalService.alert('La terminal no esta configurada correctamente'); |
90 | console.info(err); | 97 | console.info(err); |
91 | } | 98 | } |
92 | ); | 99 | ); |
93 | 100 | ||
94 | if (APP === 'distribuidor') { | 101 | if (APP === 'distribuidor') { |
95 | crearNotaPedidoService.getVendedorById($scope.idVendedor).then( | 102 | crearNotaPedidoService.getVendedorById($scope.idVendedor).then( |
96 | function(res) { | 103 | function(res) { |
97 | var vendedor = res.data; | 104 | var vendedor = res.data; |
98 | $scope.$broadcast('addCabecera', { | 105 | $scope.$broadcast('addCabecera', { |
99 | label: 'Vendedor:', | 106 | label: 'Vendedor:', |
100 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 107 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
101 | vendedor.NOM | 108 | vendedor.NOM |
102 | }); | 109 | }); |
103 | 110 | ||
104 | $scope.notaPedido.vendedor = vendedor; | 111 | $scope.notaPedido.vendedor = vendedor; |
105 | $scope.inicial.notaPedido.vendedor =$scope.notaPedido.vendedor; | 112 | $scope.inicial.notaPedido.vendedor =$scope.notaPedido.vendedor; |
106 | } | 113 | } |
107 | ); | 114 | ); |
108 | } | 115 | } |
109 | 116 | ||
110 | $scope.inicial = { | 117 | $scope.inicial = angular.copy($scope.notaPedido); |
111 | notaPedido: angular.copy($scope.notaPedido), | ||
112 | articulosTabla: angular.copy($scope.articulosTabla), | ||
113 | idLista: angular.copy($scope.idLista) | ||
114 | }; | ||
115 | } | 118 | } |
116 | 119 | ||
120 | $scope.$watch('notaPedido', function(newValue, oldValue) { | ||
121 | focaBotoneraLateralService.setPausarData({ | ||
122 | label: 'notaPedido', | ||
123 | val: newValue | ||
124 | }); | ||
125 | }, true); | ||
126 | |||
117 | $scope.crearNotaPedido = function() { | 127 | $scope.crearNotaPedido = function() { |
118 | if(!$scope.notaPedido.vendedor.id) { | 128 | if (!$scope.notaPedido.vendedor.id) { |
119 | focaModalService.alert('Ingrese Vendedor'); | 129 | focaModalService.alert('Ingrese Vendedor'); |
120 | return; | 130 | return; |
121 | } else if(!$scope.notaPedido.cliente.COD) { | 131 | } else if (!$scope.notaPedido.cliente.COD) { |
122 | focaModalService.alert('Ingrese Cliente'); | 132 | focaModalService.alert('Ingrese Cliente'); |
123 | return; | 133 | return; |
124 | } else if(!$scope.notaPedido.proveedor.COD) { | 134 | } else if (!$scope.notaPedido.proveedor.COD) { |
125 | focaModalService.alert('Ingrese Proveedor'); | 135 | focaModalService.alert('Ingrese Proveedor'); |
126 | return; | 136 | return; |
127 | } else if(!$scope.notaPedido.moneda.ID) { | 137 | } else if (!$scope.notaPedido.cotizacion.ID) { |
128 | focaModalService.alert('Ingrese Moneda'); | ||
129 | return; | ||
130 | } else if(!$scope.notaPedido.cotizacion.ID) { | ||
131 | focaModalService.alert('Ingrese Cotización'); | 138 | focaModalService.alert('Ingrese Cotización'); |
132 | return; | 139 | return; |
133 | } else if(!$scope.plazosPagos) { | 140 | } else if (!$scope.notaPedido.cotizacion.moneda.ID) { |
141 | focaModalService.alert('Ingrese Moneda'); | ||
142 | return; | ||
143 | } else if (!$scope.notaPedido.notaPedidoPlazo) { | ||
134 | focaModalService.alert('Ingrese Precios y Condiciones'); | 144 | focaModalService.alert('Ingrese Precios y Condiciones'); |
135 | return; | 145 | return; |
136 | } else if( | 146 | } else if ( |
137 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) | 147 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) |
138 | { | 148 | { |
139 | focaModalService.alert('Ingrese Flete'); | 149 | focaModalService.alert('Ingrese Flete'); |
140 | return; | 150 | return; |
141 | } else if(!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto | 151 | } else if (!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto |
142 | focaModalService.alert('Ingrese Domicilio'); | 152 | focaModalService.alert('Ingrese Domicilio'); |
143 | return; | 153 | return; |
144 | } else if($scope.articulosTabla.length === 0) { | 154 | } else if ($scope.notaPedido.articulosNotaPedido.length === 0) { |
145 | focaModalService.alert('Debe cargar al menos un articulo'); | 155 | focaModalService.alert('Debe cargar al menos un articulo'); |
146 | return; | 156 | return; |
147 | } | 157 | } |
148 | focaBotoneraLateralService.startGuardar(); | 158 | focaBotoneraLateralService.startGuardar(); |
149 | $scope.saveLoading = true; | 159 | $scope.saveLoading = true; |
150 | var notaPedido = { | 160 | var notaPedido = { |
151 | id: $scope.notaPedido.id, | 161 | id: $scope.notaPedido.id, |
152 | fechaCarga: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | 162 | fechaCarga: new Date($scope.notaPedido.fechaCarga).toISOString().slice(0, 19).replace('T', ' '), |
153 | idVendedor: $scope.notaPedido.vendedor.id, | 163 | idVendedor: $scope.notaPedido.vendedor.id, |
154 | idCliente: $scope.notaPedido.cliente.COD, | 164 | idCliente: $scope.notaPedido.cliente.COD, |
155 | nombreCliente: $scope.notaPedido.cliente.NOM, | 165 | nombreCliente: $scope.notaPedido.cliente.NOM, |
156 | cuitCliente: $scope.notaPedido.cliente.CUIT, | 166 | cuitCliente: $scope.notaPedido.cliente.CUIT, |
157 | idProveedor: $scope.notaPedido.proveedor.COD, | 167 | idProveedor: $scope.notaPedido.proveedor.COD, |
158 | idDomicilio: $scope.notaPedido.domicilio.id, | 168 | idDomicilio: $scope.notaPedido.domicilio.id, |
159 | idCotizacion: $scope.notaPedido.cotizacion.ID, | 169 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
160 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, | 170 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, |
161 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 171 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
162 | flete: $scope.notaPedido.flete, | 172 | flete: $scope.notaPedido.flete, |
163 | fob: $scope.notaPedido.fob, | 173 | fob: $scope.notaPedido.fob, |
164 | bomba: $scope.notaPedido.bomba, | 174 | bomba: $scope.notaPedido.bomba, |
165 | kilometros: $scope.notaPedido.kilometros, | 175 | kilometros: $scope.notaPedido.kilometros, |
166 | domicilioStamp: $scope.notaPedido.domicilioStamp, | 176 | domicilioStamp: $scope.notaPedido.domicilioStamp, |
167 | observaciones: $scope.notaPedido.observaciones, | 177 | observaciones: $scope.notaPedido.observaciones, |
168 | estado: 0, | 178 | estado: 0, |
169 | total: $scope.getTotal() | 179 | total: $scope.getTotal() |
170 | }; | 180 | }; |
171 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 181 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
172 | function(data) { | 182 | function(data) { |
173 | // Al guardar los datos de la nota de pedido logueamos la | 183 | // Al guardar los datos de la nota de pedido logueamos la |
174 | // actividad para su seguimiento. | 184 | // actividad para su seguimiento. |
175 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? | 185 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? |
176 | focaSeguimientoService.guardarPosicion( | 186 | focaSeguimientoService.guardarPosicion( |
177 | 'Nota de pedido', | 187 | 'Nota de pedido', |
178 | data.data.id, | 188 | data.data.id, |
179 | '' | 189 | '' |
180 | ); | 190 | ); |
181 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, | 191 | notaPedidoBusinessService.addArticulos( |
192 | $scope.notaPedido.articulosNotaPedido, | ||
182 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); | 193 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); |
183 | 194 | ||
184 | if($scope.notaPedido.puntosDescarga) { | 195 | if ($scope.notaPedido.notaPedidoPuntoDescarga) { |
185 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, | 196 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, |
186 | $scope.notaPedido.puntosDescarga); | 197 | $scope.notaPedido.notaPedidoPuntoDescarga); |
187 | } | 198 | } |
188 | 199 | ||
189 | var plazos = $scope.plazosPagos; | 200 | var plazos = $scope.notaPedido.notaPedidoPlazo; |
190 | var plazosACrear = []; | 201 | var plazosACrear = []; |
191 | plazos.forEach(function(plazo) { | 202 | plazos.forEach(function(plazo) { |
192 | plazosACrear.push({ | 203 | plazosACrear.push({ |
193 | idNotaPedido: data.data.id, | 204 | idNotaPedido: data.data.id, |
194 | dias: plazo.dias | 205 | dias: plazo.dias |
195 | }); | 206 | }); |
196 | }); | 207 | }); |
197 | 208 | ||
198 | if (plazosACrear.length) { | 209 | if (plazosACrear.length) { |
199 | crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); | 210 | crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); |
200 | } | 211 | } |
201 | 212 | ||
202 | notaPedidoBusinessService.addEstado(data.data.id, | 213 | notaPedidoBusinessService.addEstado(data.data.id, |
203 | $scope.notaPedido.vendedor.id); | 214 | $scope.notaPedido.vendedor.id); |
204 | 215 | ||
205 | focaBotoneraLateralService.endGuardar(true); | 216 | focaBotoneraLateralService.endGuardar(true); |
206 | $scope.saveLoading = false; | 217 | $scope.saveLoading = false; |
207 | 218 | ||
208 | init(); | 219 | init(); |
209 | }, function(error) { | 220 | }, function(error) { |
210 | focaModalService.alert('Hubo un error al crear la nota de pedido'); | 221 | focaModalService.alert('Hubo un error al crear la nota de pedido'); |
211 | focaBotoneraLateralService.endGuardar(); | 222 | focaBotoneraLateralService.endGuardar(); |
212 | $scope.saveLoading = false; | 223 | $scope.saveLoading = false; |
213 | console.info(error); | 224 | console.info(error); |
214 | } | 225 | } |
215 | ); | 226 | ); |
216 | }; | 227 | }; |
217 | 228 | ||
218 | $scope.seleccionarNotaPedido = function() { | 229 | $scope.seleccionarNotaPedido = function() { |
219 | var modalInstance = $uibModal.open( | 230 | var modalInstance = $uibModal.open( |
220 | { | 231 | { |
221 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 232 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
222 | templateUrl: 'foca-modal-nota-pedido.html', | 233 | templateUrl: 'foca-modal-nota-pedido.html', |
223 | controller: 'focaModalNotaPedidoController', | 234 | controller: 'focaModalNotaPedidoController', |
224 | size: 'lg', | 235 | size: 'lg', |
225 | resolve: { | 236 | resolve: { |
226 | usadoPor: function() {return 'notaPedido';}, | 237 | usadoPor: function() {return 'notaPedido';}, |
227 | idVendedor: function() { | 238 | idVendedor: function() { |
228 | if(APP === 'distribuidor') | 239 | if(APP === 'distribuidor') |
229 | return $scope.notaPedido.vendedor.id; | 240 | return $scope.notaPedido.vendedor.id; |
230 | else | 241 | else |
231 | return null; | 242 | return null; |
232 | } | 243 | } |
233 | } | 244 | } |
234 | } | 245 | } |
235 | ); | 246 | ); |
236 | modalInstance.result.then( | 247 | modalInstance.result.then(setearNotaPedido); |
237 | function(notaPedido) { | ||
238 | $scope.now = new Date(notaPedido.fechaCarga); | ||
239 | //añado cabeceras | ||
240 | $scope.notaPedido.id = notaPedido.id; | ||
241 | $scope.$broadcast('removeCabecera', 'Bomba:'); | ||
242 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | ||
243 | var cabeceras = [ | ||
244 | { | ||
245 | label: 'Moneda:', | ||
246 | valor: notaPedido.cotizacion.moneda.DETALLE | ||
247 | }, | ||
248 | { | ||
249 | label: 'Fecha cotizacion:', | ||
250 | valor: $filter('date')(notaPedido.cotizacion.FECHA, | ||
251 | 'dd/MM/yyyy') | ||
252 | }, | ||
253 | { | ||
254 | label: 'Cotizacion:', | ||
255 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, | ||
256 | '2') | ||
257 | }, | ||
258 | { | ||
259 | label: 'Cliente:', | ||
260 | valor: notaPedido.cliente.NOM | ||
261 | }, | ||
262 | { | ||
263 | label: 'Domicilio:', | ||
264 | valor: notaPedido.domicilioStamp | ||
265 | }, | ||
266 | { | ||
267 | label: 'Vendedor:', | ||
268 | valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + | ||
269 | ' - ' + notaPedido.vendedor.NOM | ||
270 | }, | ||
271 | { | ||
272 | label: 'Proveedor:', | ||
273 | valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) + | ||
274 | ' - ' + notaPedido.proveedor.NOM | ||
275 | }, | ||
276 | { | ||
277 | label: 'Precios y condiciones:', | ||
278 | valor: valorPrecioCondicion() + ' ' + | ||
279 | notaPedidoBusinessService | ||
280 | .plazoToString(notaPedido.notaPedidoPlazo) | ||
281 | }, | ||
282 | { | ||
283 | label: 'Flete:', | ||
284 | valor: notaPedido.fob === 1 ? 'FOB' : ( | ||
285 | notaPedido.flete === 1 ? 'Si' : 'No') | ||
286 | } | ||
287 | ]; | ||
288 | |||
289 | function valorPrecioCondicion() { | ||
290 | if(notaPedido.idPrecioCondicion > 0) { | ||
291 | return notaPedido.precioCondicion.nombre; | ||
292 | } else { | ||
293 | return 'Ingreso Manual'; | ||
294 | } | ||
295 | } | ||
296 | |||
297 | if(notaPedido.flete === 1) { | ||
298 | var cabeceraBomba = { | ||
299 | label: 'Bomba:', | ||
300 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | ||
301 | }; | ||
302 | if(notaPedido.kilometros) { | ||
303 | var cabeceraKilometros = { | ||
304 | label: 'Kilometros:', | ||
305 | valor: notaPedido.kilometros | ||
306 | }; | ||
307 | cabeceras.push(cabeceraKilometros); | ||
308 | } | ||
309 | cabeceras.push(cabeceraBomba); | ||
310 | } | ||
311 | |||
312 | $scope.articulosTabla = notaPedido.articulosNotaPedido; | ||
313 | notaPedidoBusinessService.calcularArticulos($scope.articulosTabla, | ||
314 | notaPedido.cotizacion.VENDEDOR); | ||
315 | |||
316 | if(notaPedido.idPrecioCondicion > 0) { | ||
317 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | ||
318 | } else { | ||
319 | $scope.idLista = -1; | ||
320 | } | ||
321 | |||
322 | $scope.puntoVenta = $filter('rellenarDigitos')( | ||
323 | notaPedido.sucursal, 4 | ||
324 | ); | ||
325 | |||
326 | $scope.comprobante = $filter('rellenarDigitos')( | ||
327 | notaPedido.numeroNotaPedido, 8 | ||
328 | ); | ||
329 | |||
330 | $scope.notaPedido = notaPedido; | ||
331 | $scope.notaPedido.moneda = notaPedido.cotizacion.moneda; | ||
332 | $scope.plazosPagos = notaPedido.notaPedidoPlazo; | ||
333 | $scope.notaPedido.puntosDescarga = | ||
334 | formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga); | ||
335 | addArrayCabecera(cabeceras); | ||
336 | |||
337 | }, function() { | ||
338 | // funcion ejecutada cuando se cancela el modal | ||
339 | } | ||
340 | ); | ||
341 | }; | 248 | }; |
342 | 249 | ||
343 | $scope.seleccionarProductos = function() { | 250 | $scope.seleccionarProductos = function() { |
344 | if ($scope.idLista === undefined) { | 251 | if ($scope.idLista === undefined) { |
345 | focaModalService.alert( | 252 | focaModalService.alert( |
346 | 'Primero seleccione una lista de precio y condicion'); | 253 | 'Primero seleccione una lista de precio y condicion'); |
347 | return; | 254 | return; |
348 | } | 255 | } |
349 | var modalInstance = $uibModal.open( | 256 | var modalInstance = $uibModal.open( |
350 | { | 257 | { |
351 | ariaLabelledBy: 'Busqueda de Productos', | 258 | ariaLabelledBy: 'Busqueda de Productos', |
352 | templateUrl: 'modal-busqueda-productos.html', | 259 | templateUrl: 'modal-busqueda-productos.html', |
353 | controller: 'modalBusquedaProductosCtrl', | 260 | controller: 'modalBusquedaProductosCtrl', |
354 | resolve: { | 261 | resolve: { |
355 | parametroProducto: { | 262 | parametroProducto: { |
356 | idLista: $scope.idLista, | 263 | idLista: $scope.idLista, |
357 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 264 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
358 | simbolo: $scope.notaPedido.moneda.SIMBOLO | 265 | simbolo: $scope.notaPedido.cotizacion.moneda.SIMBOLO |
359 | } | 266 | } |
360 | }, | 267 | }, |
361 | size: 'lg' | 268 | size: 'lg' |
362 | } | 269 | } |
363 | ); | 270 | ); |
364 | modalInstance.result.then( | 271 | modalInstance.result.then( |
365 | function(producto) { | 272 | function(producto) { |
366 | var newArt = | 273 | var newArt = |
367 | { | 274 | { |
368 | id: 0, | 275 | id: 0, |
369 | codigo: producto.codigo, | 276 | codigo: producto.codigo, |
370 | sector: producto.sector, | 277 | sector: producto.sector, |
371 | sectorCodigo: producto.sector + '-' + producto.codigo, | 278 | sectorCodigo: producto.sector + '-' + producto.codigo, |
372 | descripcion: producto.descripcion, | 279 | descripcion: producto.descripcion, |
373 | item: $scope.articulosTabla.length + 1, | 280 | item: $scope.notaPedido.articulosNotaPedido.length + 1, |
374 | nombre: producto.descripcion, | 281 | nombre: producto.descripcion, |
375 | precio: parseFloat(producto.precio.toFixed(4)), | 282 | precio: parseFloat(producto.precio.toFixed(4)), |
376 | costoUnitario: producto.costo, | 283 | costoUnitario: producto.costo, |
377 | editCantidad: false, | 284 | editCantidad: false, |
378 | editPrecio: false, | 285 | editPrecio: false, |
379 | rubro: producto.CodRub, | 286 | rubro: producto.CodRub, |
380 | exentoUnitario: producto.precio, | 287 | exentoUnitario: producto.precio, |
381 | ivaUnitario: producto.IMPIVA, | 288 | ivaUnitario: producto.IMPIVA, |
382 | impuestoInternoUnitario: producto.ImpInt, | 289 | impuestoInternoUnitario: producto.ImpInt, |
383 | impuestoInterno1Unitario: producto.ImpInt2, | 290 | impuestoInterno1Unitario: producto.ImpInt2, |
384 | impuestoInterno2Unitario: producto.ImpInt3, | 291 | impuestoInterno2Unitario: producto.ImpInt3, |
385 | precioLista: producto.precio, | 292 | precioLista: producto.precio, |
386 | combustible: 1, | 293 | combustible: 1, |
387 | facturado: 0, | 294 | facturado: 0, |
388 | idArticulo: producto.id | 295 | idArticulo: producto.id |
389 | }; | 296 | }; |
390 | $scope.articuloACargar = newArt; | 297 | $scope.articuloACargar = newArt; |
391 | $scope.cargando = false; | 298 | $scope.cargando = false; |
392 | }, function() { | 299 | }, function() { |
393 | // funcion ejecutada cuando se cancela el modal | 300 | // funcion ejecutada cuando se cancela el modal |
394 | } | 301 | } |
395 | ); | 302 | ); |
396 | }; | 303 | }; |
397 | 304 | ||
398 | $scope.seleccionarPuntosDeDescarga = function() { | 305 | $scope.seleccionarPuntosDeDescarga = function() { |
399 | if(!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { | 306 | if(!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { |
400 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 307 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
401 | return; | 308 | return; |
402 | }else { | 309 | }else { |
403 | var modalInstance = $uibModal.open( | 310 | var modalInstance = $uibModal.open( |
404 | { | 311 | { |
405 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', | 312 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
406 | templateUrl: 'modal-punto-descarga.html', | 313 | templateUrl: 'modal-punto-descarga.html', |
407 | controller: 'focaModalPuntoDescargaController', | 314 | controller: 'focaModalPuntoDescargaController', |
408 | size: 'lg', | 315 | size: 'lg', |
409 | resolve: { | 316 | resolve: { |
410 | filters: { | 317 | filters: { |
411 | idDomicilio: $scope.notaPedido.domicilio.id, | 318 | idDomicilio: $scope.notaPedido.domicilio.id, |
412 | idCliente: $scope.notaPedido.cliente.COD, | 319 | idCliente: $scope.notaPedido.cliente.COD, |
413 | articulos: $scope.articulosTabla, | 320 | articulos: $scope.notaPedido.articulosNotaPedido, |
414 | puntosDescarga: $scope.notaPedido.puntosDescarga | 321 | puntosDescarga: $scope.notaPedido.notaPedidoPuntoDescarga |
415 | } | 322 | } |
416 | } | 323 | } |
417 | } | 324 | } |
418 | ); | 325 | ); |
419 | modalInstance.result.then( | 326 | modalInstance.result.then( |
420 | function(puntosDescarga) { | 327 | function(puntosDescarga) { |
421 | $scope.notaPedido.puntosDescarga = puntosDescarga; | 328 | $scope.notaPedido.notaPedidoPuntoDescarga = puntosDescarga; |
422 | 329 | ||
423 | //AGREGO PUNTOS DE DESCARGA A CABECERA | 330 | //AGREGO PUNTOS DE DESCARGA A CABECERA |
424 | var puntosStamp = ''; | 331 | var puntosStamp = ''; |
425 | puntosDescarga.forEach(function(punto, idx, arr) { | 332 | puntosDescarga.forEach(function(punto, idx, arr) { |
426 | puntosStamp += punto.descripcion; | 333 | puntosStamp += punto.descripcion; |
427 | if((idx + 1) !== arr.length) puntosStamp += ', '; | 334 | if((idx + 1) !== arr.length) puntosStamp += ', '; |
428 | }); | 335 | }); |
429 | 336 | ||
430 | $scope.$broadcast('addCabecera', { | 337 | $scope.$broadcast('addCabecera', { |
431 | label: 'Puntos de descarga:', | 338 | label: 'Puntos de descarga:', |
432 | valor: puntosStamp | 339 | valor: puntosStamp |
433 | }); | 340 | }); |
434 | }, function() { | 341 | }, function() { |
435 | $scope.abrirModalDomicilios($scope.cliente); | 342 | $scope.abrirModalDomicilios($scope.cliente); |
436 | } | 343 | } |
437 | ); | 344 | ); |
438 | } | 345 | } |
439 | }; | 346 | }; |
440 | 347 | ||
441 | $scope.seleccionarVendedor = function() { | 348 | $scope.seleccionarVendedor = function() { |
442 | if(validarNotaRemitada()) { | 349 | if(validarNotaRemitada()) { |
443 | var parametrosModal = { | 350 | var parametrosModal = { |
444 | titulo: 'Búsqueda vendedores', | 351 | titulo: 'Búsqueda vendedores', |
445 | query: '/vendedor', | 352 | query: '/vendedor', |
446 | columnas: [ | 353 | columnas: [ |
447 | { | 354 | { |
448 | propiedad: 'NUM', | 355 | propiedad: 'NUM', |
449 | nombre: 'Código', | 356 | nombre: 'Código', |
450 | filtro: { | 357 | filtro: { |
451 | nombre: 'rellenarDigitos', | 358 | nombre: 'rellenarDigitos', |
452 | parametro: 3 | 359 | parametro: 3 |
453 | } | 360 | } |
454 | }, | 361 | }, |
455 | { | 362 | { |
456 | propiedad: 'NOM', | 363 | propiedad: 'NOM', |
457 | nombre: 'Nombre' | 364 | nombre: 'Nombre' |
458 | } | 365 | } |
459 | ], | 366 | ], |
460 | size: 'md' | 367 | size: 'md' |
461 | }; | 368 | }; |
462 | focaModalService.modal(parametrosModal).then( | 369 | focaModalService.modal(parametrosModal).then( |
463 | function(vendedor) { | 370 | function(vendedor) { |
464 | $scope.$broadcast('addCabecera', { | 371 | $scope.$broadcast('addCabecera', { |
465 | label: 'Vendedor:', | 372 | label: 'Vendedor:', |
466 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 373 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
467 | vendedor.NOM | 374 | vendedor.NOM |
468 | }); | 375 | }); |
469 | $scope.notaPedido.vendedor = vendedor; | 376 | $scope.notaPedido.vendedor = vendedor; |
470 | }, function() { | 377 | }, function() { |
471 | 378 | ||
472 | } | 379 | } |
473 | ); | 380 | ); |
474 | } | 381 | } |
475 | }; | 382 | }; |
476 | 383 | ||
477 | $scope.seleccionarProveedor = function() { | 384 | $scope.seleccionarProveedor = function() { |
478 | if(validarNotaRemitada()) { | 385 | if(validarNotaRemitada()) { |
479 | var parametrosModal = { | 386 | var parametrosModal = { |
480 | titulo: 'Búsqueda de Proveedor', | 387 | titulo: 'Búsqueda de Proveedor', |
481 | query: '/proveedor', | 388 | query: '/proveedor', |
482 | columnas: [ | 389 | columnas: [ |
483 | { | 390 | { |
484 | nombre: 'Código', | 391 | nombre: 'Código', |
485 | propiedad: 'COD', | 392 | propiedad: 'COD', |
486 | filtro: { | 393 | filtro: { |
487 | nombre: 'rellenarDigitos', | 394 | nombre: 'rellenarDigitos', |
488 | parametro: 5 | 395 | parametro: 5 |
489 | } | 396 | } |
490 | }, | 397 | }, |
491 | { | 398 | { |
492 | nombre: 'Nombre', | 399 | nombre: 'Nombre', |
493 | propiedad: 'NOM' | 400 | propiedad: 'NOM' |
494 | }, | 401 | }, |
495 | { | 402 | { |
496 | nombre: 'CUIT', | 403 | nombre: 'CUIT', |
497 | propiedad: 'CUIT' | 404 | propiedad: 'CUIT' |
498 | } | 405 | } |
499 | ], | 406 | ], |
500 | tipo: 'POST', | 407 | tipo: 'POST', |
501 | json: {razonCuitCod: ''} | 408 | json: {razonCuitCod: ''} |
502 | }; | 409 | }; |
503 | focaModalService.modal(parametrosModal).then( | 410 | focaModalService.modal(parametrosModal).then( |
504 | function(proveedor) { | 411 | function(proveedor) { |
505 | $scope.notaPedido.proveedor = proveedor; | 412 | $scope.notaPedido.proveedor = proveedor; |
506 | $scope.$broadcast('addCabecera', { | 413 | $scope.$broadcast('addCabecera', { |
507 | label: 'Proveedor:', | 414 | label: 'Proveedor:', |
508 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 415 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
509 | proveedor.NOM | 416 | proveedor.NOM |
510 | }); | 417 | }); |
511 | }, function() { | 418 | }, function() { |
512 | 419 | ||
513 | } | 420 | } |
514 | ); | 421 | ); |
515 | } | 422 | } |
516 | }; | 423 | }; |
517 | 424 | ||
518 | $scope.seleccionarCliente = function() { | 425 | $scope.seleccionarCliente = function() { |
519 | if(!$scope.notaPedido.vendedor.NUM) { | 426 | if(!$scope.notaPedido.vendedor.NUM) { |
520 | focaModalService.alert('Primero seleccione un vendedor'); | 427 | focaModalService.alert('Primero seleccione un vendedor'); |
521 | return; | 428 | return; |
522 | } | 429 | } |
523 | if(validarNotaRemitada()) { | 430 | if(validarNotaRemitada()) { |
524 | var modalInstance = $uibModal.open( | 431 | var modalInstance = $uibModal.open( |
525 | { | 432 | { |
526 | ariaLabelledBy: 'Busqueda de Cliente', | 433 | ariaLabelledBy: 'Busqueda de Cliente', |
527 | templateUrl: 'foca-busqueda-cliente-modal.html', | 434 | templateUrl: 'foca-busqueda-cliente-modal.html', |
528 | controller: 'focaBusquedaClienteModalController', | 435 | controller: 'focaBusquedaClienteModalController', |
529 | resolve: { | 436 | resolve: { |
530 | vendedor: function() { return $scope.notaPedido.vendedor; } | 437 | vendedor: function() { return $scope.notaPedido.vendedor; } |
531 | }, | 438 | }, |
532 | size: 'lg' | 439 | size: 'lg' |
533 | } | 440 | } |
534 | ); | 441 | ); |
535 | modalInstance.result.then( | 442 | modalInstance.result.then( |
536 | function(cliente) { | 443 | function(cliente) { |
537 | $scope.abrirModalDomicilios(cliente); | 444 | $scope.abrirModalDomicilios(cliente); |
538 | $scope.cliente = cliente; | 445 | $scope.cliente = cliente; |
539 | }, function() {} | 446 | }, function() {} |
540 | ); | 447 | ); |
541 | } | 448 | } |
542 | }; | 449 | }; |
543 | 450 | ||
544 | $scope.abrirModalDomicilios = function(cliente) { | 451 | $scope.abrirModalDomicilios = function(cliente) { |
545 | var modalInstanceDomicilio = $uibModal.open( | 452 | var modalInstanceDomicilio = $uibModal.open( |
546 | { | 453 | { |
547 | ariaLabelledBy: 'Busqueda de Domicilios', | 454 | ariaLabelledBy: 'Busqueda de Domicilios', |
548 | templateUrl: 'modal-domicilio.html', | 455 | templateUrl: 'modal-domicilio.html', |
549 | controller: 'focaModalDomicilioController', | 456 | controller: 'focaModalDomicilioController', |
550 | resolve: { | 457 | resolve: { |
551 | idCliente: function() { return cliente.cod; }, | 458 | idCliente: function() { return cliente.cod; }, |
552 | esNuevo: function() { return cliente.esNuevo; } | 459 | esNuevo: function() { return cliente.esNuevo; } |
553 | }, | 460 | }, |
554 | size: 'lg', | 461 | size: 'lg', |
555 | } | 462 | } |
556 | ); | 463 | ); |
557 | modalInstanceDomicilio.result.then( | 464 | modalInstanceDomicilio.result.then( |
558 | function(domicilio) { | 465 | function(domicilio) { |
559 | $scope.notaPedido.domicilio = domicilio; | 466 | $scope.notaPedido.domicilio = domicilio; |
560 | $scope.notaPedido.cliente = { | 467 | $scope.notaPedido.cliente = { |
561 | COD: cliente.cod, | 468 | COD: cliente.cod, |
562 | CUIT: cliente.cuit, | 469 | CUIT: cliente.cuit, |
563 | NOM: cliente.nom | 470 | NOM: cliente.nom |
564 | }; | 471 | }; |
565 | var domicilioStamp = | 472 | var domicilioStamp = |
566 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 473 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
567 | domicilio.Localidad + ', ' + domicilio.Provincia; | 474 | domicilio.Localidad + ', ' + domicilio.Provincia; |
568 | $scope.notaPedido.domicilioStamp = domicilioStamp; | 475 | $scope.notaPedido.domicilioStamp = domicilioStamp; |
569 | 476 | ||
570 | $scope.notaPedido.puntosDescarga = domicilio.puntosDescarga; | 477 | $scope.notaPedido.notaPedidoPuntoDescarga = domicilio.puntosDescarga; |
571 | 478 | ||
572 | $scope.$broadcast('addCabecera', { | 479 | $scope.$broadcast('addCabecera', { |
573 | label: 'Cliente:', | 480 | label: 'Cliente:', |
574 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom | 481 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom |
575 | }); | 482 | }); |
576 | $scope.$broadcast('addCabecera', { | 483 | $scope.$broadcast('addCabecera', { |
577 | label: 'Domicilio:', | 484 | label: 'Domicilio:', |
578 | valor: domicilioStamp | 485 | valor: domicilioStamp |
579 | }); | 486 | }); |
580 | if(domicilio.verPuntos) { | 487 | if(domicilio.verPuntos) { |
581 | delete $scope.notaPedido.domicilio.verPuntos; | 488 | delete $scope.notaPedido.domicilio.verPuntos; |
582 | $scope.seleccionarPuntosDeDescarga(); | 489 | $scope.seleccionarPuntosDeDescarga(); |
583 | }else { | 490 | }else { |
584 | crearNotaPedidoService | 491 | crearNotaPedidoService |
585 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | 492 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
586 | .then(function(res) { | 493 | .then(function(res) { |
587 | if(res.data.length) $scope.seleccionarPuntosDeDescarga(); | 494 | if(res.data.length) $scope.seleccionarPuntosDeDescarga(); |
588 | }); | 495 | }); |
589 | } | 496 | } |
590 | }, function() { | 497 | }, function() { |
591 | $scope.seleccionarCliente(); | 498 | $scope.seleccionarCliente(); |
592 | return; | 499 | return; |
593 | } | 500 | } |
594 | ); | 501 | ); |
595 | }; | 502 | }; |
596 | 503 | ||
597 | $scope.getTotal = function() { | 504 | $scope.getTotal = function() { |
598 | var total = 0; | 505 | var total = 0; |
599 | 506 | if ($scope.notaPedido.articulosNotaPedido) { | |
600 | if ($scope.articulosTabla) { | 507 | var arrayTempArticulos = $scope.notaPedido.articulosNotaPedido; |
601 | var arrayTempArticulos = $scope.articulosTabla; | ||
602 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 508 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
603 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 509 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
604 | } | 510 | } |
605 | } | 511 | } |
606 | 512 | ||
607 | return parseFloat(total.toFixed(2)); | 513 | return parseFloat(total.toFixed(2)); |
608 | }; | 514 | }; |
609 | 515 | ||
610 | $scope.getSubTotal = function() { | 516 | $scope.getSubTotal = function() { |
611 | if($scope.articuloACargar) { | 517 | if($scope.articuloACargar) { |
612 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 518 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
613 | } | 519 | } |
614 | }; | 520 | }; |
615 | 521 | ||
616 | $scope.seleccionarPreciosYCondiciones = function() { | 522 | $scope.seleccionarPreciosYCondiciones = function() { |
617 | if(validarNotaRemitada()) { | 523 | if(validarNotaRemitada()) { |
618 | var modalInstance = $uibModal.open( | 524 | var modalInstance = $uibModal.open( |
619 | { | 525 | { |
620 | ariaLabelledBy: 'Busqueda de Precio Condición', | 526 | ariaLabelledBy: 'Busqueda de Precio Condición', |
621 | templateUrl: 'modal-precio-condicion.html', | 527 | templateUrl: 'modal-precio-condicion.html', |
622 | controller: 'focaModalPrecioCondicionController', | 528 | controller: 'focaModalPrecioCondicionController', |
623 | size: 'lg' | 529 | size: 'lg' |
624 | } | 530 | } |
625 | ); | 531 | ); |
626 | modalInstance.result.then( | 532 | modalInstance.result.then( |
627 | function(precioCondicion) { | 533 | function(precioCondicion) { |
628 | var cabecera = ''; | 534 | var cabecera = ''; |
629 | var plazosConcat = ''; | 535 | var plazosConcat = ''; |
630 | if(!Array.isArray(precioCondicion)) { | 536 | if(!Array.isArray(precioCondicion)) { |
537 | $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; | ||
538 | $scope.notaPedido.precioCondicion = precioCondicion; | ||
631 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; | 539 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; |
632 | $scope.plazosPagos = precioCondicion.plazoPago; | ||
633 | $scope.idLista = precioCondicion.idListaPrecio; | 540 | $scope.idLista = precioCondicion.idListaPrecio; |
634 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 541 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
635 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 542 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
636 | } | 543 | } |
637 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + | 544 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + |
638 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); | 545 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); |
639 | } else { //Cuando se ingresan los plazos manualmente | 546 | } else { //Cuando se ingresan los plazos manualmente |
640 | $scope.notaPedido.idPrecioCondicion = 0; | 547 | $scope.notaPedido.idPrecioCondicion = 0; |
641 | //-1, el modal productos busca todos los productos | 548 | //-1, el modal productos busca todos los productos |
642 | $scope.idLista = -1; | 549 | $scope.idLista = -1; |
643 | $scope.plazosPagos = precioCondicion; | 550 | $scope.notaPedido.notaPedidoPlazo = precioCondicion; |
644 | for(var j = 0; j < precioCondicion.length; j++) { | 551 | for(var j = 0; j < precioCondicion.length; j++) { |
645 | plazosConcat += precioCondicion[j].dias + ' '; | 552 | plazosConcat += precioCondicion[j].dias + ' '; |
646 | } | 553 | } |
647 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 554 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
648 | } | 555 | } |
649 | $scope.articulosTabla = []; | 556 | $scope.notaPedido.articulosNotaPedido = []; |
650 | $scope.$broadcast('addCabecera', { | 557 | $scope.$broadcast('addCabecera', { |
651 | label: 'Precios y condiciones:', | 558 | label: 'Precios y condiciones:', |
652 | valor: cabecera | 559 | valor: cabecera |
653 | }); | 560 | }); |
654 | }, function() { | 561 | }, function() { |
655 | 562 | ||
656 | } | 563 | } |
657 | ); | 564 | ); |
658 | } | 565 | } |
659 | }; | 566 | }; |
660 | 567 | ||
661 | $scope.seleccionarFlete = function() { | 568 | $scope.seleccionarFlete = function() { |
662 | if(validarNotaRemitada()) { | 569 | if(validarNotaRemitada()) { |
663 | var modalInstance = $uibModal.open( | 570 | var modalInstance = $uibModal.open( |
664 | { | 571 | { |
665 | ariaLabelledBy: 'Busqueda de Flete', | 572 | ariaLabelledBy: 'Busqueda de Flete', |
666 | templateUrl: 'modal-flete.html', | 573 | templateUrl: 'modal-flete.html', |
667 | controller: 'focaModalFleteController', | 574 | controller: 'focaModalFleteController', |
668 | size: 'lg', | 575 | size: 'lg', |
669 | resolve: { | 576 | resolve: { |
670 | parametrosFlete: | 577 | parametrosFlete: |
671 | function() { | 578 | function() { |
672 | return { | 579 | return { |
673 | flete: $scope.notaPedido.fob ? 'FOB' : | 580 | flete: $scope.notaPedido.fob ? 'FOB' : |
674 | ( $scope.notaPedido.flete ? '1' : | 581 | ( $scope.notaPedido.flete ? '1' : |
675 | ($scope.notaPedido.flete === undefined ? | 582 | ($scope.notaPedido.flete === undefined ? |
676 | null : '0')), | 583 | null : '0')), |
677 | bomba: $scope.notaPedido.bomba ? '1' : | 584 | bomba: $scope.notaPedido.bomba ? '1' : |
678 | ($scope.notaPedido.bomba === undefined ? | 585 | ($scope.notaPedido.bomba === undefined ? |
679 | null : '0'), | 586 | null : '0'), |
680 | kilometros: $scope.notaPedido.kilometros | 587 | kilometros: $scope.notaPedido.kilometros |
681 | }; | 588 | }; |
682 | } | 589 | } |
683 | } | 590 | } |
684 | } | 591 | } |
685 | ); | 592 | ); |
686 | modalInstance.result.then( | 593 | modalInstance.result.then( |
687 | function(datos) { | 594 | function(datos) { |
688 | $scope.notaPedido.flete = datos.flete; | 595 | $scope.notaPedido.flete = datos.flete; |
689 | $scope.notaPedido.fob = datos.FOB; | 596 | $scope.notaPedido.fob = datos.FOB; |
690 | $scope.notaPedido.bomba = datos.bomba; | 597 | $scope.notaPedido.bomba = datos.bomba; |
691 | $scope.notaPedido.kilometros = datos.kilometros; | 598 | $scope.notaPedido.kilometros = datos.kilometros; |
692 | $scope.$broadcast('addCabecera', { | 599 | $scope.$broadcast('addCabecera', { |
693 | label: 'Flete:', | 600 | label: 'Flete:', |
694 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') | 601 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') |
695 | }); | 602 | }); |
696 | if(datos.flete) { | 603 | if(datos.flete) { |
697 | $scope.$broadcast('addCabecera', { | 604 | $scope.$broadcast('addCabecera', { |
698 | label: 'Bomba:', | 605 | label: 'Bomba:', |
699 | valor: datos.bomba ? 'Si' : 'No' | 606 | valor: datos.bomba ? 'Si' : 'No' |
700 | }); | 607 | }); |
701 | $scope.$broadcast('addCabecera', { | 608 | $scope.$broadcast('addCabecera', { |
702 | label: 'Kilometros:', | 609 | label: 'Kilometros:', |
703 | valor: datos.kilometros | 610 | valor: datos.kilometros |
704 | }); | 611 | }); |
705 | } else { | 612 | } else { |
706 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 613 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
707 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 614 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
708 | $scope.notaPedido.bomba = false; | 615 | $scope.notaPedido.bomba = false; |
709 | $scope.notaPedido.kilometros = null; | 616 | $scope.notaPedido.kilometros = null; |
710 | } | 617 | } |
711 | }, function() { | 618 | }, function() { |
712 | 619 | ||
713 | } | 620 | } |
714 | ); | 621 | ); |
715 | } | 622 | } |
716 | }; | 623 | }; |
717 | 624 | ||
718 | $scope.seleccionarMoneda = function() { | 625 | $scope.seleccionarMoneda = function() { |
719 | if(validarNotaRemitada()) { | 626 | if(validarNotaRemitada()) { |
720 | var parametrosModal = { | 627 | var parametrosModal = { |
721 | titulo: 'Búsqueda de monedas', | 628 | titulo: 'Búsqueda de monedas', |
722 | query: '/moneda', | 629 | query: '/moneda', |
723 | columnas: [ | 630 | columnas: [ |
724 | { | 631 | { |
725 | propiedad: 'DETALLE', | 632 | propiedad: 'DETALLE', |
726 | nombre: 'Nombre' | 633 | nombre: 'Nombre' |
727 | }, | 634 | }, |
728 | { | 635 | { |
729 | propiedad: 'SIMBOLO', | 636 | propiedad: 'SIMBOLO', |
730 | nombre: 'Símbolo' | 637 | nombre: 'Símbolo' |
731 | } | 638 | } |
732 | ], | 639 | ], |
733 | size: 'md' | 640 | size: 'md' |
734 | }; | 641 | }; |
735 | focaModalService.modal(parametrosModal).then( | 642 | focaModalService.modal(parametrosModal).then( |
736 | function(moneda) { | 643 | function(moneda) { |
737 | $scope.abrirModalCotizacion(moneda); | 644 | $scope.abrirModalCotizacion(moneda); |
738 | }, function() { | 645 | }, function() { |
739 | 646 | ||
740 | } | 647 | } |
741 | ); | 648 | ); |
742 | } | 649 | } |
743 | }; | 650 | }; |
744 | 651 | ||
745 | $scope.seleccionarObservaciones = function() { | 652 | $scope.seleccionarObservaciones = function() { |
746 | focaModalService | 653 | focaModalService |
747 | .prompt('Ingrese observaciones', $scope.notaPedido.observaciones, true) | 654 | .prompt('Ingrese observaciones', $scope.notaPedido.observaciones, true) |
748 | .then(function(observaciones) { | 655 | .then(function(observaciones) { |
749 | $scope.notaPedido.observaciones = observaciones; | 656 | $scope.notaPedido.observaciones = observaciones; |
750 | }); | 657 | }); |
751 | }; | 658 | }; |
752 | 659 | ||
753 | $scope.abrirModalCotizacion = function(moneda) { | 660 | $scope.abrirModalCotizacion = function(moneda) { |
754 | var modalInstance = $uibModal.open( | 661 | var modalInstance = $uibModal.open( |
755 | { | 662 | { |
756 | ariaLabelledBy: 'Busqueda de Cotización', | 663 | ariaLabelledBy: 'Busqueda de Cotización', |
757 | templateUrl: 'modal-cotizacion.html', | 664 | templateUrl: 'modal-cotizacion.html', |
758 | controller: 'focaModalCotizacionController', | 665 | controller: 'focaModalCotizacionController', |
759 | size: 'lg', | 666 | size: 'lg', |
760 | resolve: { | 667 | resolve: { |
761 | idMoneda: function() { | 668 | idMoneda: function() { |
762 | return moneda.ID; | 669 | return moneda.ID; |
763 | } | 670 | } |
764 | } | 671 | } |
765 | } | 672 | } |
766 | ); | 673 | ); |
767 | modalInstance.result.then( | 674 | modalInstance.result.then( |
768 | function(cotizacion) { | 675 | function(cotizacion) { |
769 | var articulosTablaTemp = $scope.articulosTabla; | 676 | var articulosTablaTemp = $scope.notaPedido.articulosNotaPedido || []; |
770 | |||
771 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 677 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
772 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 678 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
773 | $scope.notaPedido.cotizacion.VENDEDOR; | 679 | $scope.notaPedido.cotizacion.VENDEDOR; |
774 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 680 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
775 | cotizacion.VENDEDOR; | 681 | cotizacion.VENDEDOR; |
776 | } | 682 | } |
777 | 683 | $scope.notaPedido.articulosNotaPedido = articulosTablaTemp; | |
778 | $scope.articulosTabla = articulosTablaTemp; | ||
779 | $scope.notaPedido.moneda = moneda; | ||
780 | $scope.monedaDefecto = moneda; | ||
781 | $scope.cotizacionDefecto = cotizacion; | ||
782 | $scope.notaPedido.cotizacion = cotizacion; | 684 | $scope.notaPedido.cotizacion = cotizacion; |
783 | 685 | $scope.notaPedido.cotizacion.moneda = moneda; | |
784 | if(moneda.DETALLE === 'PESOS ARGENTINOS') { | 686 | if(moneda.DETALLE === 'PESOS ARGENTINOS') { |
785 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 687 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
786 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 688 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
787 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 689 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
788 | } else { | 690 | } else { |
789 | $scope.$broadcast('addCabecera', { | 691 | $scope.$broadcast('addCabecera', { |
790 | label: 'Moneda:', | 692 | label: 'Moneda:', |
791 | valor: moneda.DETALLE | 693 | valor: moneda.DETALLE |
792 | }); | 694 | }); |
793 | $scope.$broadcast('addCabecera', { | 695 | $scope.$broadcast('addCabecera', { |
794 | label: 'Fecha cotizacion:', | 696 | label: 'Fecha cotizacion:', |
795 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 697 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
796 | }); | 698 | }); |
797 | $scope.$broadcast('addCabecera', { | 699 | $scope.$broadcast('addCabecera', { |
798 | label: 'Cotizacion:', | 700 | label: 'Cotizacion:', |
799 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 701 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
800 | }); | 702 | }); |
801 | } | 703 | } |
802 | }, function() { | 704 | }, function() { |
803 | 705 | ||
804 | } | 706 | } |
805 | ); | 707 | ); |
806 | }; | 708 | }; |
807 | 709 | ||
808 | $scope.agregarATabla = function(key) { | 710 | $scope.agregarATabla = function(key) { |
809 | if(key === 13) { | 711 | if(key === 13) { |
810 | if($scope.articuloACargar.cantidad === undefined || | 712 | if($scope.articuloACargar.cantidad === undefined || |
811 | $scope.articuloACargar.cantidad === 0 || | 713 | $scope.articuloACargar.cantidad === 0 || |
812 | $scope.articuloACargar.cantidad === null ) { | 714 | $scope.articuloACargar.cantidad === null ) { |
813 | focaModalService.alert('El valor debe ser al menos 1'); | 715 | focaModalService.alert('El valor debe ser al menos 1'); |
814 | return; | 716 | return; |
815 | } | 717 | } |
816 | delete $scope.articuloACargar.sectorCodigo; | 718 | delete $scope.articuloACargar.sectorCodigo; |
817 | $scope.articulosTabla.push($scope.articuloACargar); | 719 | $scope.notaPedido.articulosNotaPedido.push($scope.articuloACargar); |
818 | $scope.cargando = true; | 720 | $scope.cargando = true; |
819 | } | 721 | } |
820 | }; | 722 | }; |
821 | 723 | ||
822 | $scope.quitarArticulo = function(key) { | 724 | $scope.quitarArticulo = function(key) { |
823 | $scope.articulosTabla.splice(key, 1); | 725 | $scope.notaPedido.articulosNotaPedido.splice(key, 1); |
824 | }; | 726 | }; |
825 | 727 | ||
826 | $scope.editarArticulo = function(key, articulo) { | 728 | $scope.editarArticulo = function(key, articulo) { |
827 | if(key === 13) { | 729 | if(key === 13) { |
828 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 730 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
829 | articulo.cantidad === undefined) { | 731 | articulo.cantidad === undefined) { |
830 | focaModalService.alert('El valor debe ser al menos 1'); | 732 | focaModalService.alert('El valor debe ser al menos 1'); |
831 | return; | 733 | return; |
832 | } | 734 | } |
833 | articulo.editCantidad = false; | 735 | articulo.editCantidad = false; |
834 | articulo.editPrecio = false; | 736 | articulo.editPrecio = false; |
835 | } | 737 | } |
836 | }; | 738 | }; |
837 | 739 | ||
838 | $scope.cambioEdit = function(articulo, propiedad) { | 740 | $scope.cambioEdit = function(articulo, propiedad) { |
839 | if(propiedad === 'cantidad') { | 741 | if(propiedad === 'cantidad') { |
840 | articulo.editCantidad = true; | 742 | articulo.editCantidad = true; |
841 | } else if(propiedad === 'precio') { | 743 | } else if(propiedad === 'precio') { |
842 | articulo.editPrecio = true; | 744 | articulo.editPrecio = true; |
843 | } | 745 | } |
844 | }; | 746 | }; |
845 | 747 | ||
846 | $scope.resetFilter = function() { | 748 | $scope.resetFilter = function() { |
847 | $scope.articuloACargar = {}; | 749 | $scope.articuloACargar = {}; |
848 | $scope.cargando = true; | 750 | $scope.cargando = true; |
849 | }; | 751 | }; |
850 | //Recibe aviso si el teclado está en uso | 752 | //Recibe aviso si el teclado está en uso |
851 | $rootScope.$on('usarTeclado', function(event, data) { | 753 | $rootScope.$on('usarTeclado', function(event, data) { |
852 | if(data) { | 754 | if(data) { |
853 | $scope.mostrarTeclado = true; | 755 | $scope.mostrarTeclado = true; |
854 | return; | 756 | return; |
855 | } | 757 | } |
856 | $scope.mostrarTeclado = false; | 758 | $scope.mostrarTeclado = false; |
857 | }); | 759 | }); |
858 | 760 | ||
859 | $scope.selectFocus = function($event) { | 761 | $scope.selectFocus = function($event) { |
860 | // Si el teclado esta en uso no selecciona el valor | 762 | // Si el teclado esta en uso no selecciona el valor |
861 | if($scope.mostrarTeclado) { | 763 | if($scope.mostrarTeclado) { |
862 | return; | 764 | return; |
863 | } | 765 | } |
864 | $event.target.select(); | 766 | $event.target.select(); |
865 | }; | 767 | }; |
866 | 768 | ||
867 | $scope.salir = function() { | 769 | $scope.salir = function() { |
868 | $location.path('/'); | 770 | $location.path('/'); |
869 | }; | 771 | }; |
870 | 772 | ||
871 | $scope.parsearATexto = function(articulo) { | 773 | $scope.parsearATexto = function(articulo) { |
872 | articulo.cantidad = parseFloat(articulo.cantidad); | 774 | articulo.cantidad = parseFloat(articulo.cantidad); |
873 | articulo.precio = parseFloat(articulo.precio); | 775 | articulo.precio = parseFloat(articulo.precio); |
874 | }; | 776 | }; |
875 | 777 | ||
778 | function setearNotaPedido(notaPedido) { | ||
779 | //añado cabeceras | ||
780 | $scope.notaPedido = notaPedido; | ||
781 | $scope.$broadcast('removeCabecera', 'Bomba:'); | ||
782 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | ||
783 | |||
784 | var cabeceras = []; | ||
785 | |||
786 | if (notaPedido.cotizacion) { | ||
787 | cabeceras.push({ | ||
788 | label: 'Moneda:', | ||
789 | valor: notaPedido.cotizacion.moneda.DETALLE | ||
790 | }); | ||
791 | cabeceras.push({ | ||
792 | label: 'Fecha cotizacion:', | ||
793 | valor: $filter('date')(notaPedido.cotizacion.FECHA, | ||
794 | 'dd/MM/yyyy') | ||
795 | }); | ||
796 | cabeceras.push({ | ||
797 | label: 'Cotizacion:', | ||
798 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, | ||
799 | '2') | ||
800 | }); | ||
801 | } | ||
802 | if (notaPedido.cliente.COD) { | ||
803 | cabeceras.push({ | ||
804 | label: 'Cliente:', | ||
805 | valor: notaPedido.cliente.NOM | ||
806 | }); | ||
807 | cabeceras.push({ | ||
808 | label: 'Domicilio:', | ||
809 | valor: notaPedido.domicilioStamp | ||
810 | }); | ||
811 | } | ||
812 | if (notaPedido.vendedor.NUM) { | ||
813 | cabeceras.push({ | ||
814 | label: 'Vendedor:', | ||
815 | valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + | ||
816 | ' - ' + notaPedido.vendedor.NOM | ||
817 | }); | ||
818 | } | ||
819 | if (notaPedido.proveedor.COD) { | ||
820 | cabeceras.push({ | ||
821 | label: 'Proveedor:', | ||
822 | valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) + | ||
823 | ' - ' + notaPedido.proveedor.NOM | ||
824 | }); | ||
825 | } | ||
826 | if (notaPedido.notaPedidoPlazo.length) { | ||
827 | cabeceras.push({ | ||
828 | label: 'Precios y condiciones:', | ||
829 | valor: valorPrecioCondicion() + ' ' + | ||
830 | notaPedidoBusinessService | ||
831 | .plazoToString(notaPedido.notaPedidoPlazo) | ||
832 | }); | ||
833 | } | ||
834 | if (notaPedido.flete !== undefined) { | ||
835 | cabeceras.push({ | ||
836 | label: 'Flete:', | ||
837 | valor: notaPedido.fob === 1 ? 'FOB' : ( | ||
838 | notaPedido.flete === 1 ? 'Si' : 'No') | ||
839 | }); | ||
840 | } | ||
841 | |||
842 | |||
843 | function valorPrecioCondicion() { | ||
844 | if (notaPedido.idPrecioCondicion > 0) { | ||
845 | return notaPedido.precioCondicion.nombre; | ||
846 | } else { | ||
847 | return 'Ingreso Manual'; | ||
848 | } |
src/views/nota-pedido.html
1 | <div class="crear-nota-pedido foca-crear row"> | 1 | <div class="crear-nota-pedido foca-crear row"> |
2 | <foca-cabecera-facturador | 2 | <foca-cabecera-facturador |
3 | titulo="'Nota de pedido'" | 3 | titulo="'Nota de pedido'" |
4 | numero="puntoVenta + '-' + comprobante" | 4 | numero="puntoVenta + '-' + comprobante" |
5 | fecha="now" | 5 | fecha="notaPedido.fechaCarga" |
6 | class="mb-0 col-lg-12" | 6 | class="mb-0 col-lg-12" |
7 | busqueda="seleccionarNotaPedido" | 7 | busqueda="seleccionarNotaPedido" |
8 | ></foca-cabecera-facturador> | 8 | ></foca-cabecera-facturador> |
9 | <div class="col-lg-12"> | 9 | <div class="col-lg-12"> |
10 | <div class="row"> | 10 | <div class="row"> |
11 | <div class="col-12 col-md-10 col-lg-10 border border-light rounded"> | 11 | <div class="col-12 col-md-10 col-lg-10 border border-light rounded"> |
12 | <div class="row py-2 botonera-secundaria"> | 12 | <div class="row py-2 botonera-secundaria"> |
13 | <div class="col-12 foca-facturador-px"> | 13 | <div class="col-12 foca-facturador-px"> |
14 | <foca-botonera-facturador botones="botonera" extra="5" class="row"></foca-botonera-facturador> | 14 | <foca-botonera-facturador botones="botonera" extra="5" class="row"></foca-botonera-facturador> |
15 | </div> | 15 | </div> |
16 | </div> | 16 | </div> |
17 | <!-- PC --> | 17 | <!-- PC --> |
18 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> | 18 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> |
19 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> | 19 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> |
20 | <thead> | 20 | <thead> |
21 | <tr class="d-flex"> | 21 | <tr class="d-flex"> |
22 | <th valign="middle" class="">#</th> | 22 | <th valign="middle" class="">#</th> |
23 | <th valign="middle" class="col">Código</th> | 23 | <th valign="middle" class="col">Código</th> |
24 | <th valign="middle" class="col-4">Descripción</th> | 24 | <th valign="middle" class="col-4">Descripción</th> |
25 | <th valign="middle" class="col text-right">Cantidad</th> | 25 | <th valign="middle" class="col text-right">Cantidad</th> |
26 | <th valign="middle" class="col text-right">Precio Unitario</th> | 26 | <th valign="middle" class="col text-right">Precio Unitario</th> |
27 | <th valign="middle" class="col text-right">SubTotal</th> | 27 | <th valign="middle" class="col text-right">SubTotal</th> |
28 | <th valign="middle" class="text-right"> | 28 | <th valign="middle" class="text-right"> |
29 | <button | 29 | <button |
30 | class="btn btn-outline-light selectable" | 30 | class="btn btn-outline-light selectable" |
31 | ng-click="show = !show; masMenos()" | 31 | ng-click="show = !show; masMenos()" |
32 | > | 32 | > |
33 | <i | 33 | <i |
34 | class="fa fa-chevron-down" | 34 | class="fa fa-chevron-down" |
35 | ng-show="show" | 35 | ng-show="show" |
36 | aria-hidden="true" | 36 | aria-hidden="true" |
37 | > | 37 | > |
38 | </i> | 38 | </i> |
39 | <i | 39 | <i |
40 | class="fa fa-chevron-up" | 40 | class="fa fa-chevron-up" |
41 | ng-hide="show" | 41 | ng-hide="show" |
42 | aria-hidden="true"> | 42 | aria-hidden="true"> |
43 | </i> | 43 | </i> |
44 | </button> | 44 | </button> |
45 | </th> | 45 | </th> |
46 | </tr> | 46 | </tr> |
47 | </thead> | 47 | </thead> |
48 | <tbody class="tabla-articulo-body"> | 48 | <tbody class="tabla-articulo-body"> |
49 | <tr | 49 | <tr |
50 | ng-repeat="(key, articulo) in articulosTabla" | 50 | ng-repeat="(key, articulo) in notaPedido.articulosNotaPedido" |
51 | ng-show="show || key == (articulosTabla.length - 1)" | 51 | ng-show="show || key == (notaPedido.articulosNotaPedido.length - 1)" |
52 | class="d-flex" | 52 | class="d-flex" |
53 | > | 53 | > |
54 | <td ng-bind="key + 1"></td> | 54 | <td ng-bind="key + 1"></td> |
55 | <td | 55 | <td |
56 | class="col" | 56 | class="col" |
57 | ng-bind="articulo.sector + '-' + articulo.codigo" | 57 | ng-bind="articulo.sector + '-' + articulo.codigo" |
58 | ></td> | 58 | ></td> |
59 | <td | 59 | <td |
60 | class="col-4" | 60 | class="col-4" |
61 | ng-bind="articulo.descripcion" | 61 | ng-bind="articulo.descripcion" |
62 | ></td> | 62 | ></td> |
63 | <td class="col text-right"> | 63 | <td class="col text-right"> |
64 | <input | 64 | <input |
65 | ng-show="articulo.editCantidad" | 65 | ng-show="articulo.editCantidad" |
66 | ng-model="articulo.cantidad" | 66 | ng-model="articulo.cantidad" |
67 | class="form-control" | 67 | class="form-control" |
68 | foca-tipo-input | 68 | foca-tipo-input |
69 | min="1" | 69 | min="1" |
70 | step="0.001" | 70 | step="0.001" |
71 | foca-focus="articulo.editCantidad" | 71 | foca-focus="articulo.editCantidad" |
72 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 72 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
73 | ng-focus="selectFocus($event)" | 73 | ng-focus="selectFocus($event)" |
74 | teclado-virtual | 74 | teclado-virtual |
75 | > | 75 | > |
76 | <i | 76 | <i |
77 | class="selectable" | 77 | class="selectable" |
78 | ng-click="cambioEdit(articulo, 'cantidad')" | 78 | ng-click="cambioEdit(articulo, 'cantidad')" |
79 | ng-hide="articulo.editCantidad" | 79 | ng-hide="articulo.editCantidad" |
80 | ng-bind="articulo.cantidad"> | 80 | ng-bind="articulo.cantidad"> |
81 | </i> | 81 | </i> |
82 | </td> | 82 | </td> |
83 | <td class="col text-right"> | 83 | <td class="col text-right"> |
84 | <input | 84 | <input |
85 | ng-show="articulo.editPrecio" | 85 | ng-show="articulo.editPrecio" |
86 | ng-model="articulo.precio" | 86 | ng-model="articulo.precio" |
87 | class="form-control" | 87 | class="form-control" |
88 | foca-tipo-input | 88 | foca-tipo-input |
89 | min="0" | 89 | min="0" |
90 | step="0.0001" | 90 | step="0.0001" |
91 | foca-focus="articulo.editPrecio" | 91 | foca-focus="articulo.editPrecio" |
92 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 92 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
93 | ng-focus="selectFocus($event)" | 93 | ng-focus="selectFocus($event)" |
94 | teclado-virtual | 94 | teclado-virtual |
95 | > | 95 | > |
96 | <i | 96 | <i |
97 | class="selectable" | 97 | class="selectable" |
98 | ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" | 98 | ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" |
99 | ng-hide="articulo.editPrecio" | 99 | ng-hide="articulo.editPrecio" |
100 | ng-bind="articulo.precio | | 100 | ng-bind="articulo.precio | |
101 | number: 4"> | 101 | number: 4"> |
102 | </i> | 102 | </i> |
103 | </td> | 103 | </td> |
104 | <td | 104 | <td |
105 | class="col text-right" | 105 | class="col text-right" |
106 | ng-bind="(articulo.precio * articulo.cantidad) | | 106 | ng-bind="(articulo.precio * articulo.cantidad) | |
107 | number: 2"> | 107 | number: 2"> |
108 | </td> | 108 | </td> |
109 | <td class="text-center"> | 109 | <td class="text-center"> |
110 | <button | 110 | <button |
111 | ng-show="articulo.editCantidad || articulo.editPrecio" | 111 | ng-show="articulo.editCantidad || articulo.editPrecio" |
112 | class="btn btn-outline-light" | 112 | class="btn btn-outline-light" |
113 | ng-click="editarArticulo(13, articulo)" | 113 | ng-click="editarArticulo(13, articulo)" |
114 | > | 114 | > |
115 | <i class="fa fa-save"></i> | 115 | <i class="fa fa-save"></i> |
116 | </button> | 116 | </button> |
117 | <button | 117 | <button |
118 | class="btn btn-outline-light" | 118 | class="btn btn-outline-light" |
119 | ng-click="quitarArticulo(key)" | 119 | ng-click="quitarArticulo(key)" |
120 | > | 120 | > |
121 | <i class="fa fa-trash"></i> | 121 | <i class="fa fa-trash"></i> |
122 | </button> | 122 | </button> |
123 | </td> | 123 | </td> |
124 | </tr> | 124 | </tr> |
125 | </tbody> | 125 | </tbody> |
126 | <tfoot> | 126 | <tfoot> |
127 | <tr ng-show="!cargando" class="d-flex"> | 127 | <tr ng-show="!cargando" class="d-flex"> |
128 | <td | 128 | <td |
129 | class="align-middle" | 129 | class="align-middle" |
130 | ng-bind="articulosTabla.length + 1" | 130 | ng-bind="notaPedido.articulosNotaPedido.length + 1" |
131 | ></td> | 131 | ></td> |
132 | <td class="col"> | 132 | <td class="col"> |
133 | <input | 133 | <input |
134 | class="form-control" | 134 | class="form-control" |
135 | ng-model="articuloACargar.sectorCodigo" | 135 | ng-model="articuloACargar.sectorCodigo" |
136 | readonly | 136 | readonly |
137 | > | 137 | > |
138 | </td> | 138 | </td> |
139 | <td class="col-4 tabla-articulo-descripcion"> | 139 | <td class="col-4 tabla-articulo-descripcion"> |
140 | <input | 140 | <input |
141 | class="form-control" | 141 | class="form-control" |
142 | ng-model="articuloACargar.descripcion" | 142 | ng-model="articuloACargar.descripcion" |
143 | readonly | 143 | readonly |
144 | > | 144 | > |
145 | </td> | 145 | </td> |
146 | <td class="col text-right"> | 146 | <td class="col text-right"> |
147 | <input | 147 | <input |
148 | class="form-control" | 148 | class="form-control" |
149 | foca-tipo-input | 149 | foca-tipo-input |
150 | min="1" | 150 | min="1" |
151 | step="0.001" | 151 | step="0.001" |
152 | ng-model="articuloACargar.cantidad" | 152 | ng-model="articuloACargar.cantidad" |
153 | foca-focus="!cargando" | 153 | foca-focus="!cargando" |
154 | esc-key="resetFilter()" | 154 | esc-key="resetFilter()" |
155 | ng-keypress="agregarATabla($event.keyCode)" | 155 | ng-keypress="agregarATabla($event.keyCode)" |
156 | teclado-virtual | 156 | teclado-virtual |
157 | > | 157 | > |
158 | </td> | 158 | </td> |
159 | <td class="col text-right"> | 159 | <td class="col text-right"> |
160 | <input | 160 | <input |
161 | class="form-control" | 161 | class="form-control" |
162 | ng-value="articuloACargar.precio | number: 2" | 162 | ng-value="articuloACargar.precio | number: 2" |
163 | ng-show="idLista != -1" | 163 | ng-show="idLista != -1" |
164 | readonly | 164 | readonly |
165 | > | 165 | > |
166 | <input | 166 | <input |
167 | class="form-control" | 167 | class="form-control" |
168 | foca-tipo-input | 168 | foca-tipo-input |
169 | min="0" | 169 | min="0" |
170 | step="0.0001" | 170 | step="0.0001" |
171 | ng-model="articuloACargar.precio" | 171 | ng-model="articuloACargar.precio" |
172 | esc-key="resetFilter()" | 172 | esc-key="resetFilter()" |
173 | ng-keypress="agregarATabla($event.keyCode)" | 173 | ng-keypress="agregarATabla($event.keyCode)" |
174 | ng-show="idLista == -1" | 174 | ng-show="idLista == -1" |
175 | teclado-virtual | 175 | teclado-virtual |
176 | > | 176 | > |
177 | </td> | 177 | </td> |
178 | <td class="col text-right"> | 178 | <td class="col text-right"> |
179 | <input | 179 | <input |
180 | class="form-control" | 180 | class="form-control" |
181 | ng-value="getSubTotal() | number: 2" | 181 | ng-value="getSubTotal() | number: 2" |
182 | readonly | 182 | readonly |
183 | ></td> | 183 | ></td> |
184 | <td class="text-center align-middle"> | 184 | <td class="text-center align-middle"> |
185 | <button | 185 | <button |
186 | class="btn btn-outline-light" | 186 | class="btn btn-outline-light" |
187 | ng-click="agregarATabla(13)" | 187 | ng-click="agregarATabla(13)" |
188 | > | 188 | > |
189 | <i class="fa fa-save"></i> | 189 | <i class="fa fa-save"></i> |
190 | </button> | 190 | </button> |
191 | </td> | 191 | </td> |
192 | </tr> | 192 | </tr> |
193 | <tr class="d-flex"> | 193 | <tr class="d-flex"> |
194 | <td colspan="4" class="no-border-top"> | 194 | <td colspan="4" class="no-border-top"> |
195 | <strong>Items:</strong> | 195 | <strong>Items:</strong> |
196 | <a ng-bind="articulosTabla.length"></a> | 196 | <a ng-bind="notaPedido.articulosNotaPedido.length"></a> |
197 | </td> | 197 | </td> |
198 | <td class="text-right ml-auto table-celda-total no-border-top"> | 198 | <td class="text-right ml-auto table-celda-total no-border-top"> |
199 | <h3>Total:</h3> | 199 | <h3>Total:</h3> |
200 | </td> | 200 | </td> |
201 | <td class="table-celda-total text-right no-border-top" colspan="1"> | 201 | <td class="table-celda-total text-right no-border-top" colspan="1"> |
202 | <h3>{{getTotal() | currency: notaPedido.moneda.SIMBOLO}}</h3> | 202 | <h3>{{getTotal() | currency: notaPedido.moneda.SIMBOLO}}</h3> |
203 | </td> | 203 | </td> |
204 | <td class="text-right no-border-top"> | 204 | <td class="text-right no-border-top"> |
205 | <button | 205 | <button |
206 | type="button" | 206 | type="button" |
207 | class="btn btn-default btn-sm" | 207 | class="btn btn-default btn-sm" |
208 | > | 208 | > |
209 | Totales | 209 | Totales |
210 | </button> | 210 | </button> |
211 | </td> | 211 | </td> |
212 | </tr> | 212 | </tr> |
213 | </tfoot> | 213 | </tfoot> |
214 | </table> | 214 | </table> |
215 | </div> | 215 | </div> |
216 | <!-- MOBILE --> | 216 | <!-- MOBILE --> |
217 | <div class="row d-sm-none"> | 217 | <div class="row d-sm-none"> |
218 | <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile"> | 218 | <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile"> |
219 | <thead> | 219 | <thead> |
220 | <tr class="d-flex"> | 220 | <tr class="d-flex"> |
221 | <th class="">#</th> | 221 | <th class="">#</th> |
222 | <th class="col px-0"> | 222 | <th class="col px-0"> |
223 | <div class="d-flex"> | 223 | <div class="d-flex"> |
224 | <div class="col-4 px-1">Código</div> | 224 | <div class="col-4 px-1">Código</div> |
225 | <div class="col-8 px-1">Descripción</div> | 225 | <div class="col-8 px-1">Descripción</div> |
226 | </div> | 226 | </div> |
227 | <div class="d-flex"> | 227 | <div class="d-flex"> |
228 | <div class="col-3 px-1">Cantidad</div> | 228 | <div class="col-3 px-1">Cantidad</div> |
229 | <div class="col px-1 text-right">P. Uni.</div> | 229 | <div class="col px-1 text-right">P. Uni.</div> |
230 | <div class="col px-1 text-right">Subtotal</div> | 230 | <div class="col px-1 text-right">Subtotal</div> |
231 | </div> | 231 | </div> |
232 | </th> | 232 | </th> |
233 | <th class="text-center tamaño-boton"> | 233 | <th class="text-center tamaño-boton"> |
234 | | 234 | |
235 | </th> | 235 | </th> |
236 | </tr> | 236 | </tr> |
237 | </thead> | 237 | </thead> |
238 | <tbody> | 238 | <tbody> |
239 | <tr | 239 | <tr |
240 | ng-repeat="(key, articulo) in articulosTabla" | 240 | ng-repeat="(key, articulo) in notaPedido.articulosNotaPedido" |
241 | ng-show="show || key == articulosTabla.length - 1" | 241 | ng-show="show || key == notaPedido.articulosNotaPedido.length - 1" |
242 | > | 242 | > |
243 | <td class="w-100 align-middle d-flex p-0"> | 243 | <td class="w-100 align-middle d-flex p-0"> |
244 | <div class="align-middle p-1"> | 244 | <div class="align-middle p-1"> |
245 | <span ng-bind="key+1" class="align-middle"></span> | 245 | <span ng-bind="key+1" class="align-middle"></span> |
246 | </div> | 246 | </div> |
247 | <div class="col px-0"> | 247 | <div class="col px-0"> |
248 | <div class="d-flex"> | 248 | <div class="d-flex"> |
249 | <div class="col-4 px-1"> | 249 | <div class="col-4 px-1"> |
250 | <span | 250 | <span |
251 | ng-bind="articulo.sector + '-' + articulo.codigo" | 251 | ng-bind="articulo.sector + '-' + articulo.codigo" |
252 | ></span> | 252 | ></span> |
253 | </div> | 253 | </div> |
254 | <div class="col-8 px-1"> | 254 | <div class="col-8 px-1"> |
255 | <span ng-bind="articulo.descripcion"></span> | 255 | <span ng-bind="articulo.descripcion"></span> |
256 | </div> | 256 | </div> |
257 | </div> | 257 | </div> |
258 | <div class="d-flex"> | 258 | <div class="d-flex"> |
259 | <div class="col-3 px-1"> | 259 | <div class="col-3 px-1"> |
260 | <span | 260 | <span |
261 | ng-bind="'x' + articulo.cantidad" | 261 | ng-bind="'x' + articulo.cantidad" |
262 | ng-hide="articulo.editCantidad" | 262 | ng-hide="articulo.editCantidad" |
263 | ></span> | 263 | ></span> |
264 | <i | 264 | <i |
265 | class="fa fa-pencil text-white-50" | 265 | class="fa fa-pencil text-white-50" |
266 | aria-hidden="true" | 266 | aria-hidden="true" |
267 | ng-hide="articulo.editCantidad" | 267 | ng-hide="articulo.editCantidad" |
268 | ng-click="articulo.editCantidad = true" | 268 | ng-click="articulo.editCantidad = true" |
269 | ></i> | 269 | ></i> |
270 | <input | 270 | <input |
271 | ng-show="articulo.editCantidad" | 271 | ng-show="articulo.editCantidad" |
272 | ng-model="articulo.cantidad" | 272 | ng-model="articulo.cantidad" |
273 | class="form-control" | 273 | class="form-control" |
274 | foca-tipo-input | 274 | foca-tipo-input |
275 | min="1" | 275 | min="1" |
276 | step="0.001" | 276 | step="0.001" |
277 | foca-focus="articulo.editCantidad" | 277 | foca-focus="articulo.editCantidad" |
278 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 278 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
279 | ng-focus="selectFocus($event)" | 279 | ng-focus="selectFocus($event)" |
280 | > | 280 | > |
281 | </div> | 281 | </div> |
282 | <div class="col px-1 text-right"> | 282 | <div class="col px-1 text-right"> |
283 | <span ng-bind="articulo.precio | | 283 | <span ng-bind="articulo.precio | |
284 | currency: notaPedido.moneda.SIMBOLO : 4"></span> | 284 | currency: notaPedido.moneda.SIMBOLO : 4"></span> |
285 | ></span> | 285 | ></span> |
286 | </div> | 286 | </div> |
287 | <div class="col px-1 text-right"> | 287 | <div class="col px-1 text-right"> |
288 | <span | 288 | <span |
289 | ng-bind="(articulo.precio * articulo.cantidad) | | 289 | ng-bind="(articulo.precio * articulo.cantidad) | |
290 | currency: notaPedido.moneda.SIMBOLO" | 290 | currency: notaPedido.moneda.SIMBOLO" |
291 | > | 291 | > |
292 | </span> | 292 | </span> |
293 | </div> | 293 | </div> |
294 | </div> | 294 | </div> |
295 | </div> | 295 | </div> |
296 | <div class="align-middle p-1"> | 296 | <div class="align-middle p-1"> |
297 | <button | 297 | <button |
298 | class="btn btn-outline-light" | 298 | class="btn btn-outline-light" |
299 | ng-click="quitarArticulo(key)" | 299 | ng-click="quitarArticulo(key)" |
300 | > | 300 | > |
301 | <i class="fa fa-trash"></i> | 301 | <i class="fa fa-trash"></i> |
302 | </button> | 302 | </button> |
303 | </div> | 303 | </div> |
304 | </td> | 304 | </td> |
305 | </tr> | 305 | </tr> |
306 | </tbody> | 306 | </tbody> |
307 | <tfoot> | 307 | <tfoot> |
308 | <!-- CARGANDO ITEM --> | 308 | <!-- CARGANDO ITEM --> |
309 | <tr ng-show="!cargando" class="d-flex"> | 309 | <tr ng-show="!cargando" class="d-flex"> |
310 | <td | 310 | <td |
311 | class="align-middle p-1" | 311 | class="align-middle p-1" |
312 | ng-bind="articulosTabla.length + 1" | 312 | ng-bind="notaPedido.articulosNotaPedido.length + 1" |
313 | ></td> | 313 | ></td> |
314 | <td class="col p-0"> | 314 | <td class="col p-0"> |
315 | <div class="d-flex"> | 315 | <div class="d-flex"> |
316 | <div class="col-4 px-1"> | 316 | <div class="col-4 px-1"> |
317 | <span | 317 | <span |
318 | ng-bind="articuloACargar.sectorCodigo" | 318 | ng-bind="articuloACargar.sectorCodigo" |
319 | ></span> | 319 | ></span> |
320 | </div> | 320 | </div> |
321 | <div class="col-8 px-1"> | 321 | <div class="col-8 px-1"> |
322 | <span ng-bind="articuloACargar.descripcion"></span> | 322 | <span ng-bind="articuloACargar.descripcion"></span> |
323 | </div> | 323 | </div> |
324 | </div> | 324 | </div> |
325 | <div class="d-flex"> | 325 | <div class="d-flex"> |
326 | <div class="col-3 px-1 m-1"> | 326 | <div class="col-3 px-1 m-1"> |
327 | <input | 327 | <input |
328 | class="form-control p-1" | 328 | class="form-control p-1" |
329 | foca-tipo-input | 329 | foca-tipo-input |
330 | min="1" | 330 | min="1" |
331 | ng-model="articuloACargar.cantidad" | 331 | ng-model="articuloACargar.cantidad" |
332 | foca-focus="!cargando" | 332 | foca-focus="!cargando" |
333 | ng-keypress="agregarATabla($event.keyCode)" | 333 | ng-keypress="agregarATabla($event.keyCode)" |
334 | style="height: auto; line-height: 1.1em" | 334 | style="height: auto; line-height: 1.1em" |
335 | > | 335 | > |
336 | </div> | 336 | </div> |
337 | <div class="col px-1 text-right"> | 337 | <div class="col px-1 text-right"> |
338 | <span ng-bind="articuloACargar.precio | | 338 | <span ng-bind="articuloACargar.precio | |
339 | currency: notaPedido.moneda.SIMBOLO : 4" | 339 | currency: notaPedido.moneda.SIMBOLO : 4" |
340 | ></span> | 340 | ></span> |
341 | </div> | 341 | </div> |
342 | <div class="col px-1 text-right"> | 342 | <div class="col px-1 text-right"> |
343 | <span | 343 | <span |
344 | ng-bind="getSubTotal() | | 344 | ng-bind="getSubTotal() | |
345 | currency: notaPedido.moneda.SIMBOLO" | 345 | currency: notaPedido.moneda.SIMBOLO" |
346 | > | 346 | > |
347 | </span> | 347 | </span> |
348 | </div> | 348 | </div> |
349 | </div> | 349 | </div> |
350 | </td> | 350 | </td> |
351 | <td class="text-center align-middle"> | 351 | <td class="text-center align-middle"> |
352 | <button | 352 | <button |
353 | class="btn btn-outline-light" | 353 | class="btn btn-outline-light" |
354 | ng-click="agregarATabla(13)" | 354 | ng-click="agregarATabla(13)" |
355 | > | 355 | > |
356 | <i class="fa fa-save"></i> | 356 | <i class="fa fa-save"></i> |
357 | </button> | 357 | </button> |
358 | </td> | 358 | </td> |
359 | </tr> | 359 | </tr> |
360 | <!-- TOOGLE EXPANDIR --> | 360 | <!-- TOOGLE EXPANDIR --> |
361 | <tr> | 361 | <tr> |
362 | <td class="col"> | 362 | <td class="col"> |
363 | <button | 363 | <button |
364 | class="btn btn-outline-light selectable w-100" | 364 | class="btn btn-outline-light selectable w-100" |
365 | ng-click="show = !show; masMenos()" | 365 | ng-click="show = !show; masMenos()" |
366 | ng-show="articulosTabla.length > 0" | 366 | ng-show="notaPedido.articulosNotaPedido.length > 0" |
367 | > | 367 | > |
368 | <i | 368 | <i |
369 | class="fa fa-chevron-down" | 369 | class="fa fa-chevron-down" |
370 | ng-hide="show" | 370 | ng-hide="show" |
371 | aria-hidden="true" | 371 | aria-hidden="true" |
372 | > | 372 | > |
373 | </i> | 373 | </i> |
374 | <i | 374 | <i |
375 | class="fa fa-chevron-up" | 375 | class="fa fa-chevron-up" |
376 | ng-show="show" | 376 | ng-show="show" |
377 | aria-hidden="true"> | 377 | aria-hidden="true"> |
378 | </i> | 378 | </i> |
379 | </button> | 379 | </button> |
380 | </td> | 380 | </td> |
381 | </tr> | 381 | </tr> |
382 | <!-- FOOTER --> | 382 | <!-- FOOTER --> |
383 | <tr class="d-flex"> | 383 | <tr class="d-flex"> |
384 | <td class="align-middle no-border-top" colspan="2"> | 384 | <td class="align-middle no-border-top" colspan="2"> |
385 | <strong>Cantidad Items:</strong> | 385 | <strong>Cantidad Items:</strong> |
386 | <a ng-bind="articulosTabla.length"></a> | 386 | <a ng-bind="notaPedido.articulosNotaPedido.length"></a> |
387 | </td> | 387 | </td> |
388 | <td class="text-right ml-auto table-celda-total no-border-top"> | 388 | <td class="text-right ml-auto table-celda-total no-border-top"> |
389 | <h3>Total:</h3> | 389 | <h3>Total:</h3> |
390 | </td> | 390 | </td> |
391 | <td class="table-celda-total text-right no-border-top"> | 391 | <td class="table-celda-total text-right no-border-top"> |
392 | <h3>{{getTotal() | currency: notaPedido.moneda.SIMBOLO}}</h3> | 392 | <h3>{{getTotal() | currency: notaPedido.moneda.SIMBOLO}}</h3> |
393 | </td> | 393 | </td> |
394 | </tr> | 394 | </tr> |
395 | </tfoot> | 395 | </tfoot> |
396 | </table> | 396 | </table> |
397 | </div> | 397 | </div> |
398 | </div> | 398 | </div> |
399 | </div> | 399 | </div> |
400 | </div> | 400 | </div> |
401 | <div class="row d-md-none fixed-bottom"> | 401 | <div class="row d-md-none fixed-bottom"> |
402 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> | 402 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> |
403 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> | 403 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> |
404 | <span | 404 | <span |
405 | class="mr-3 ml-auto" | 405 | class="mr-3 ml-auto" |
406 | ng-class="saveLoading ? 'text-muted' : ''" | 406 | ng-class="saveLoading ? 'text-muted' : ''" |
407 | ng-click="crearNotaPedido()" | 407 | ng-click="crearNotaPedido()" |
408 | ladda="saveLoading" | 408 | ladda="saveLoading" |
409 | data-style="expand-left" | 409 | data-style="expand-left" |
410 | >Guardar</span> | 410 | >Guardar</span> |
411 | </div> | 411 | </div> |
412 | </div> | 412 | </div> |
413 | </div> | 413 | </div> |
414 | 414 |