Commit 85038ca7fab989fd446332f18322266e77ac1f75
Exists in
master
Merge branch 'develop' into 'master'
Develop See merge request !70
Showing
6 changed files
Show diff stats
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 | const gulpSequence = require('gulp-sequence'); |
15 | 15 | ||
16 | var paths = { | 16 | var paths = { |
17 | srcJS: 'src/js/*.js', | 17 | srcJS: 'src/js/*.js', |
18 | srcViews: 'src/views/*.html', | 18 | srcViews: 'src/views/*.html', |
19 | specs: 'spec/*.js', | 19 | specs: 'spec/*.js', |
20 | tmp: 'tmp', | 20 | tmp: 'tmp', |
21 | dist: 'dist/' | 21 | dist: 'dist/' |
22 | }; | 22 | }; |
23 | 23 | ||
24 | gulp.task('uglify', gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')); | 24 | gulp.task('uglify', function(callback) { |
25 | gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')(callback); | ||
26 | }); | ||
25 | 27 | ||
26 | 28 | ||
27 | gulp.task('templates', function() { | 29 | gulp.task('templates', function() { |
28 | return pump( | 30 | return pump( |
29 | [ | 31 | [ |
30 | gulp.src(paths.srcViews), | 32 | gulp.src(paths.srcViews), |
31 | htmlmin(), | 33 | htmlmin(), |
32 | templateCache('views.js', { | 34 | templateCache('views.js', { |
33 | module: 'focaCrearCobranza', | 35 | module: 'focaCrearCobranza', |
34 | root: '' | 36 | root: '' |
35 | }), | 37 | }), |
36 | gulp.dest(paths.tmp) | 38 | gulp.dest(paths.tmp) |
37 | ] | 39 | ] |
38 | ); | 40 | ); |
39 | }); | 41 | }); |
40 | 42 | ||
41 | gulp.task('uglify-app', function() { | 43 | gulp.task('uglify-app', function() { |
42 | return pump( | 44 | return pump( |
43 | [ | 45 | [ |
44 | gulp.src([ | 46 | gulp.src([ |
45 | paths.srcJS, | 47 | paths.srcJS, |
46 | 'tmp/views.js' | 48 | 'tmp/views.js' |
47 | ]), | 49 | ]), |
48 | concat('foca-crear-cobranza.js'), | 50 | concat('foca-crear-cobranza.js'), |
49 | replace('src/views/', ''), | 51 | replace('src/views/', ''), |
50 | gulp.dest(paths.tmp), | 52 | gulp.dest(paths.tmp), |
51 | rename('foca-crear-cobranza.min.js'), | 53 | rename('foca-crear-cobranza.min.js'), |
52 | uglify(), | 54 | uglify(), |
53 | gulp.dest(paths.dist) | 55 | gulp.dest(paths.dist) |
54 | 56 | ||
55 | ] | 57 | ] |
56 | ); | 58 | ); |
57 | }); | 59 | }); |
58 | 60 | ||
59 | gulp.task('uglify-spec', function() { | 61 | gulp.task('uglify-spec', function() { |
60 | return pump([ | 62 | return pump([ |
61 | gulp.src(paths.specs), | 63 | gulp.src(paths.specs), |
62 | concat('foca-crear-cobranza.spec.js'), | 64 | concat('foca-crear-cobranza.spec.js'), |
63 | replace("src/views/", ''), | 65 | replace("src/views/", ''), |
64 | header("describe('Módulo foca-crear-cobranza', function() { \n"), | 66 | header("describe('Módulo foca-crear-cobranza', function() { \n"), |
65 | footer("});"), | 67 | footer("});"), |
66 | gulp.dest(paths.dist) | 68 | gulp.dest(paths.dist) |
67 | ]); | 69 | ]); |
68 | }); | 70 | }); |
69 | 71 | ||
70 | gulp.task('clean', function() { | 72 | gulp.task('clean', function() { |
71 | return gulp.src(['tmp', 'dist'], {read: false}) | 73 | return gulp.src(['tmp', 'dist'], {read: false}) |
72 | .pipe(clean()); | 74 | .pipe(clean()); |
73 | }); | 75 | }); |
74 | 76 | ||
75 | gulp.task('pre-commit', function() { | 77 | gulp.task('pre-commit', function() { |
76 | return pump( | 78 | return pump( |
77 | [ | 79 | [ |
78 | gulp.src([paths.srcJS, paths.specs]), | 80 | gulp.src([paths.srcJS, paths.specs]), |
79 | jshint('.jshintrc'), | 81 | jshint('.jshintrc'), |
80 | jshint.reporter('default'), | 82 | jshint.reporter('default'), |
81 | jshint.reporter('fail') | 83 | jshint.reporter('fail') |
82 | ] | 84 | ] |
83 | ); | 85 | ); |
84 | 86 | ||
85 | gulp.start('uglify'); | 87 | gulp.start('uglify'); |
86 | }); | 88 | }); |
87 | 89 | ||
88 | gulp.task('webserver', function() { | 90 | gulp.task('webserver', function() { |
89 | pump [ | 91 | pump [ |
90 | connect.server({port: 3300, host: '0.0.0.0'}) | 92 | connect.server({port: 3300, host: '0.0.0.0'}) |
91 | ] | 93 | ] |
92 | }); | 94 | }); |
93 | 95 | ||
94 | gulp.task('clean-post-install', function() { | 96 | gulp.task('clean-post-install', function() { |
95 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 97 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
96 | 'index.html', 'test.html', 'spec'], {read: false}) | 98 | 'index.html', 'test.html', 'spec'], {read: false}) |
97 | .pipe(clean()); | 99 | .pipe(clean()); |
98 | }); | 100 | }); |
99 | 101 | ||
100 | gulp.task('default', ['webserver']); | 102 | gulp.task('default', ['webserver']); |
101 | 103 | ||
102 | gulp.task('watch', function() { | 104 | gulp.task('watch', function() { |
103 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | 105 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); |
104 | }); | 106 | }); |
105 | 107 |
spec/controllerSpec.js
1 | describe('controladores módulo crear cobranza', function() { | 1 | describe('controladores módulo crear cobranza', function() { |
2 | 2 | ||
3 | var $controller; | 3 | var $controller; |
4 | 4 | ||
5 | beforeEach(function() { | 5 | beforeEach(function() { |
6 | 6 | ||
7 | module('focaCrearCobranza'); | 7 | module('focaCrearCobranza'); |
8 | 8 | ||
9 | inject(function(_$controller_) { | 9 | inject(function(_$controller_) { |
10 | 10 | ||
11 | $controller = _$controller_; | 11 | $controller = _$controller_; |
12 | }); | 12 | }); |
13 | }); | 13 | }); |
14 | 14 | ||
15 | describe('Controlador cobranzaController', function() { | 15 | describe('Controlador cobranzaController', function() { |
16 | 16 | ||
17 | var $filter = function() { | 17 | var $filter = function() { |
18 | return function() { }; | 18 | return function() { }; |
19 | }; | 19 | }; |
20 | 20 | ||
21 | var $timeout = function() { }; | 21 | var $timeout = function() { }; |
22 | 22 | ||
23 | it('existe el controlador cobranzaController', function() { | 23 | it('existe el controlador cobranzaController', function() { |
24 | 24 | ||
25 | //act | 25 | //act |
26 | var controlador = $controller('cobranzaController', { | 26 | var controlador = $controller('cobranzaController', { |
27 | $scope: { | 27 | $scope: { |
28 | $broadcast: function() { }, | 28 | $broadcast: function() { }, |
29 | $watch: function() { } | 29 | $watch: function() { } |
30 | }, | 30 | }, |
31 | $timeout: $timeout, | 31 | $timeout: $timeout, |
32 | $uibModal: {}, | 32 | $uibModal: {}, |
33 | $location: {}, | 33 | $location: {}, |
34 | focaCrearCobranzaService: { | 34 | focaCrearCobranzaService: { |
35 | getCotizacionByIdMoneda: function() { | 35 | getCotizacionByIdMoneda: function() { |
36 | return { | 36 | return { |
37 | then: function() { } | 37 | then: function() { } |
38 | }; | 38 | }; |
39 | }, | 39 | }, |
40 | getBotonera: function() { }, | 40 | getBotonera: function() { }, |
41 | getNumeroRecibo: function() { | 41 | getNumeroRecibo: function() { |
42 | return { | 42 | return { |
43 | then: function() { } | 43 | then: function() { } |
44 | }; | 44 | }; |
45 | } | 45 | } |
46 | }, | 46 | }, |
47 | focaModalService: {}, | 47 | focaModalService: {}, |
48 | $filter: $filter, | 48 | $filter: $filter, |
49 | focaSeguimientoService: {}, | 49 | focaSeguimientoService: {}, |
50 | focaBotoneraLateralService: {}, | 50 | focaBotoneraLateralService: {}, |
51 | APP: {}, | 51 | APP: {}, |
52 | focaLoginService: {}, | 52 | focaLoginService: {}, |
53 | $localStorage: true | 53 | $localStorage: true |
54 | }); | 54 | }); |
55 | 55 | ||
56 | //assert | 56 | //assert |
57 | expect(typeof controlador).toEqual('object'); | 57 | expect(typeof controlador).toEqual('object'); |
58 | }); | 58 | }); |
59 | 59 | ||
60 | it('function crearCobranza muestra alerta cuando no hay cliente', function() { | 60 | it('function crearCobranza muestra alerta cuando no hay cliente', function() { |
61 | 61 | ||
62 | //arrange | 62 | //arrange |
63 | var scope = { | 63 | var scope = { |
64 | $broadcast: function() { }, | 64 | $broadcast: function() { }, |
65 | $watch: function() { } | 65 | $watch: function() { } |
66 | }; | 66 | }; |
67 | var focaModalService = { | 67 | var focaModalService = { |
68 | alert: function() { } | 68 | alert: function() { } |
69 | }; | 69 | }; |
70 | 70 | ||
71 | $controller('cobranzaController', { | 71 | $controller('cobranzaController', { |
72 | $scope: scope, | 72 | $scope: scope, |
73 | $timeout: $timeout, | 73 | $timeout: $timeout, |
74 | $uibModal: {}, | 74 | $uibModal: {}, |
75 | $location: {}, | 75 | $location: {}, |
76 | focaCrearCobranzaService: { | 76 | focaCrearCobranzaService: { |
77 | getCotizacionByIdMoneda: function() { | 77 | getCotizacionByIdMoneda: function() { |
78 | return { | 78 | return { |
79 | then: function() { } | 79 | then: function() { } |
80 | }; | 80 | }; |
81 | }, | 81 | }, |
82 | getBotonera: function() { }, | 82 | getBotonera: function() { }, |
83 | getNumeroRecibo: function() { | 83 | getNumeroRecibo: function() { |
84 | return { | 84 | return { |
85 | then: function() { } | 85 | then: function() { } |
86 | }; | 86 | }; |
87 | } | 87 | } |
88 | }, | 88 | }, |
89 | focaModalService: focaModalService, | 89 | focaModalService: focaModalService, |
90 | $filter: $filter, | 90 | $filter: $filter, |
91 | focaSeguimientoService: {}, | 91 | focaSeguimientoService: {}, |
92 | focaBotoneraLateralService: {}, | 92 | focaBotoneraLateralService: {}, |
93 | APP: {}, | 93 | APP: {}, |
94 | focaLoginService: {}, | 94 | focaLoginService: {}, |
95 | $localStorage: true | 95 | $localStorage: true |
96 | }); | 96 | }); |
97 | 97 | ||
98 | //act | 98 | //act |
99 | spyOn(focaModalService, 'alert'); | 99 | spyOn(focaModalService, 'alert'); |
100 | scope.crearCobranza(); | 100 | scope.crearCobranza(); |
101 | 101 | ||
102 | //assert | 102 | //assert |
103 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cliente'); | 103 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cliente'); |
104 | }); | 104 | }); |
105 | 105 | ||
106 | it('function crearCobranza muestra alerta cuando no hay cobrador', function() { | 106 | it('function crearCobranza muestra alerta cuando no hay cobrador', function() { |
107 | 107 | ||
108 | //arrange | 108 | //arrange |
109 | var scope = { | 109 | var scope = { |
110 | $broadcast: function() { }, | 110 | $broadcast: function() { }, |
111 | $watch: function() { } | 111 | $watch: function() { } |
112 | }; | 112 | }; |
113 | var focaModalService = { | 113 | var focaModalService = { |
114 | alert: function() { } | 114 | alert: function() { } |
115 | }; | 115 | }; |
116 | 116 | ||
117 | $controller('cobranzaController', { | 117 | $controller('cobranzaController', { |
118 | $scope: scope, | 118 | $scope: scope, |
119 | $timeout: $timeout, | 119 | $timeout: $timeout, |
120 | $uibModal: {}, | 120 | $uibModal: {}, |
121 | $location: {}, | 121 | $location: {}, |
122 | focaCrearCobranzaService: { | 122 | focaCrearCobranzaService: { |
123 | getCotizacionByIdMoneda: function() { | 123 | getCotizacionByIdMoneda: function() { |
124 | return { | 124 | return { |
125 | then: function() { } | 125 | then: function() { } |
126 | }; | 126 | }; |
127 | }, | 127 | }, |
128 | getBotonera: function() { }, | 128 | getBotonera: function() { }, |
129 | getNumeroRecibo: function() { | 129 | getNumeroRecibo: function() { |
130 | return { | 130 | return { |
131 | then: function() { } | 131 | then: function() { } |
132 | }; | 132 | }; |
133 | } | 133 | } |
134 | }, | 134 | }, |
135 | focaModalService: focaModalService, | 135 | focaModalService: focaModalService, |
136 | $filter: $filter, | 136 | $filter: $filter, |
137 | focaSeguimientoService: {}, | 137 | focaSeguimientoService: {}, |
138 | focaBotoneraLateralService: {}, | 138 | focaBotoneraLateralService: {}, |
139 | APP: {}, | 139 | APP: {}, |
140 | focaLoginService: {}, | 140 | focaLoginService: {}, |
141 | $localStorage: true | 141 | $localStorage: true |
142 | }); | 142 | }); |
143 | scope.cobranza = { | 143 | scope.cobranza = { |
144 | cliente: { | 144 | cliente: { |
145 | COD: true | 145 | COD: true |
146 | }, | 146 | }, |
147 | cobrador: {} | 147 | cobrador: {} |
148 | }; | 148 | }; |
149 | 149 | ||
150 | //act | 150 | //act |
151 | spyOn(focaModalService, 'alert'); | 151 | spyOn(focaModalService, 'alert'); |
152 | scope.crearCobranza(); | 152 | scope.crearCobranza(); |
153 | 153 | ||
154 | //assert | 154 | //assert |
155 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cobrador'); | 155 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cobrador'); |
156 | }); | 156 | }); |
157 | 157 | ||
158 | it('function crearCobranza muestra alerta cuando no hay facturas', function() { | 158 | it('function crearCobranza muestra alerta cuando no hay facturas', function() { |
159 | 159 | ||
160 | //arrange | 160 | //arrange |
161 | var scope = { | 161 | var scope = { |
162 | $broadcast: function() { }, | 162 | $broadcast: function() { }, |
163 | $watch: function() { } | 163 | $watch: function() { } |
164 | }; | 164 | }; |
165 | var focaModalService = { | 165 | var focaModalService = { |
166 | alert: function() { } | 166 | alert: function() { } |
167 | }; | 167 | }; |
168 | 168 | ||
169 | $controller('cobranzaController', { | 169 | $controller('cobranzaController', { |
170 | $scope: scope, | 170 | $scope: scope, |
171 | $timeout: $timeout, | 171 | $timeout: $timeout, |
172 | $uibModal: {}, | 172 | $uibModal: {}, |
173 | $location: {}, | 173 | $location: {}, |
174 | focaCrearCobranzaService: { | 174 | focaCrearCobranzaService: { |
175 | getCotizacionByIdMoneda: function() { | 175 | getCotizacionByIdMoneda: function() { |
176 | return { | 176 | return { |
177 | then: function() { } | 177 | then: function() { } |
178 | }; | 178 | }; |
179 | }, | 179 | }, |
180 | getBotonera: function() { }, | 180 | getBotonera: function() { }, |
181 | getNumeroRecibo: function() { | 181 | getNumeroRecibo: function() { |
182 | return { | 182 | return { |
183 | then: function() { } | 183 | then: function() { } |
184 | }; | 184 | }; |
185 | } | 185 | } |
186 | }, | 186 | }, |
187 | focaModalService: focaModalService, | 187 | focaModalService: focaModalService, |
188 | $filter: $filter, | 188 | $filter: $filter, |
189 | focaSeguimientoService: {}, | 189 | focaSeguimientoService: {}, |
190 | focaBotoneraLateralService: {}, | 190 | focaBotoneraLateralService: {}, |
191 | APP: {}, | 191 | APP: {}, |
192 | focaLoginService: {}, | 192 | focaLoginService: {}, |
193 | $localStorage: true | 193 | $localStorage: true |
194 | }); | 194 | }); |
195 | scope.cobranza = { | 195 | scope.cobranza = { |
196 | cliente: { | 196 | cliente: { |
197 | COD: true | 197 | COD: true |
198 | }, | 198 | }, |
199 | cobrador: { | 199 | cobrador: { |
200 | NUM: true | 200 | NUM: true |
201 | }, | 201 | }, |
202 | facturas: [] | 202 | facturas: [] |
203 | }; | 203 | }; |
204 | 204 | ||
205 | //act | 205 | //act |
206 | spyOn(focaModalService, 'alert'); | 206 | spyOn(focaModalService, 'alert'); |
207 | scope.crearCobranza(); | 207 | scope.crearCobranza(); |
208 | 208 | ||
209 | //assert | 209 | //assert |
210 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese al menos una factura'); | 210 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese al menos una factura'); |
211 | }); | 211 | }); |
212 | 212 | ||
213 | it('crearCobranza muestra alerta cuando la diferencia no es 0', function() { | 213 | it('crearCobranza muestra alerta cuando la diferencia no es 0', function() { |
214 | 214 | ||
215 | //arrange | 215 | //arrange |
216 | var scope = { | 216 | var scope = { |
217 | $broadcast: function() { }, | 217 | $broadcast: function() { }, |
218 | $watch: function() { } | 218 | $watch: function() { } |
219 | }; | 219 | }; |
220 | var focaModalService = { | 220 | var focaModalService = { |
221 | alert: function() { } | 221 | alert: function() { } |
222 | }; | 222 | }; |
223 | 223 | ||
224 | $controller('cobranzaController', { | 224 | $controller('cobranzaController', { |
225 | $scope: scope, | 225 | $scope: scope, |
226 | $timeout: $timeout, | 226 | $timeout: $timeout, |
227 | $uibModal: {}, | 227 | $uibModal: {}, |
228 | $location: {}, | 228 | $location: {}, |
229 | focaCrearCobranzaService: { | 229 | focaCrearCobranzaService: { |
230 | getCotizacionByIdMoneda: function() { | 230 | getCotizacionByIdMoneda: function() { |
231 | return { | 231 | return { |
232 | then: function() { } | 232 | then: function() { } |
233 | }; | 233 | }; |
234 | }, | 234 | }, |
235 | getBotonera: function() { }, | 235 | getBotonera: function() { }, |
236 | getNumeroRecibo: function() { | 236 | getNumeroRecibo: function() { |
237 | return { | 237 | return { |
238 | then: function() { } | 238 | then: function() { } |
239 | }; | 239 | }; |
240 | } | 240 | } |
241 | }, | 241 | }, |
242 | focaModalService: focaModalService, | 242 | focaModalService: focaModalService, |
243 | $filter: $filter, | 243 | $filter: $filter, |
244 | focaSeguimientoService: {}, | 244 | focaSeguimientoService: {}, |
245 | focaBotoneraLateralService: {}, | 245 | focaBotoneraLateralService: {}, |
246 | APP: {}, | 246 | APP: {}, |
247 | focaLoginService: {}, | 247 | focaLoginService: {}, |
248 | $localStorage: true | 248 | $localStorage: true |
249 | }); | 249 | }); |
250 | scope.cobranza = { | 250 | scope.cobranza = { |
251 | cliente: { | 251 | cliente: { |
252 | COD: true | 252 | COD: true |
253 | }, | 253 | }, |
254 | cobrador: { | 254 | cobrador: { |
255 | NUM: true | 255 | NUM: true |
256 | }, | 256 | }, |
257 | cotizacion: { | 257 | moneda: { |
258 | moneda: { SIMBOLO: '' }, | 258 | SIMBOLO: '' |
259 | }, | 259 | }, |
260 | facturas: [1] | 260 | facturas: [1] |
261 | }; | 261 | }; |
262 | scope.facturaTabla = [1]; | 262 | scope.facturaTabla = [1]; |
263 | 263 | ||
264 | //act | 264 | //act |
265 | spyOn(focaModalService, 'alert'); | 265 | spyOn(focaModalService, 'alert'); |
266 | spyOn(scope, 'getTotalCobrado').and.returnValue(1); | 266 | spyOn(scope, 'getTotalCobrado').and.returnValue(1); |
267 | spyOn(scope, 'getTotalDeuda').and.returnValue(1); | 267 | spyOn(scope, 'getTotalDeuda').and.returnValue(1); |
268 | scope.crearCobranza(); | 268 | scope.crearCobranza(); |
269 | 269 | ||
270 | //assert | 270 | //assert |
271 | expect(focaModalService.alert).toHaveBeenCalledWith('La diferencia debe ser 0,00'); | 271 | expect(focaModalService.alert).toHaveBeenCalledWith('La diferencia debe ser 0,00'); |
272 | }); | 272 | }); |
273 | 273 | ||
274 | it('crearCobranza llama a startGuardar y guardarCobranza', function() { | 274 | it('crearCobranza llama a startGuardar y guardarCobranza', function() { |
275 | 275 | ||
276 | //arrange | 276 | //arrange |
277 | var scope = { | 277 | var scope = { |
278 | $broadcast: function() { }, | 278 | $broadcast: function() { }, |
279 | $watch: function() { } | 279 | $watch: function() { } |
280 | }; | 280 | }; |
281 | var focaBotoneraLateralService = { | 281 | var focaBotoneraLateralService = { |
282 | startGuardar: function() { } | 282 | startGuardar: function() { } |
283 | }; | 283 | }; |
284 | var focaCrearCobranzaService = { | 284 | var focaCrearCobranzaService = { |
285 | guardarCobranza: function() { }, | 285 | guardarCobranza: function() { }, |
286 | getCotizacionByIdMoneda: function() { | 286 | getCotizacionByIdMoneda: function() { |
287 | return { | 287 | return { |
288 | then: function() { } | 288 | then: function() { } |
289 | }; | 289 | }; |
290 | }, | 290 | }, |
291 | getBotonera: function() { }, | 291 | getBotonera: function() { }, |
292 | getNumeroRecibo: function() { | 292 | getNumeroRecibo: function() { |
293 | return { | 293 | return { |
294 | then: function() { } | 294 | then: function() { } |
295 | }; | 295 | }; |
296 | } | 296 | } |
297 | }; | 297 | }; |
298 | 298 | ||
299 | $controller('cobranzaController', { | 299 | $controller('cobranzaController', { |
300 | $scope: scope, | 300 | $scope: scope, |
301 | $timeout: $timeout, | 301 | $timeout: $timeout, |
302 | $uibModal: {}, | 302 | $uibModal: {}, |
303 | $location: {}, | 303 | $location: {}, |
304 | focaCrearCobranzaService: focaCrearCobranzaService, | 304 | focaCrearCobranzaService: focaCrearCobranzaService, |
305 | focaModalService: { | 305 | focaModalService: { |
306 | alert: function() {} | 306 | alert: function() {} |
307 | }, | 307 | }, |
308 | $filter: $filter, | 308 | $filter: $filter, |
309 | focaSeguimientoService: {}, | 309 | focaSeguimientoService: {}, |
310 | focaBotoneraLateralService: focaBotoneraLateralService, | 310 | focaBotoneraLateralService: focaBotoneraLateralService, |
311 | APP: {}, | 311 | APP: {}, |
312 | focaLoginService: {}, | 312 | focaLoginService: {}, |
313 | $localStorage: true | 313 | $localStorage: true |
314 | }); | 314 | }); |
315 | scope.cobranza = { | 315 | scope.cobranza = { |
316 | cliente: { | 316 | cliente: { |
317 | COD: true | 317 | COD: true |
318 | }, | 318 | }, |
319 | cobrador: { | 319 | cobrador: { |
320 | NUM: true | 320 | NUM: true |
321 | }, | 321 | }, |
322 | cotizacion: { | 322 | moneda: { |
323 | moneda: { | 323 | cotizacion: {} |
324 | ID: true, | ||
325 | SIMBOLO: '' | ||
326 | } | ||
327 | }, | 324 | }, |
328 | facturas: [1], | 325 | facturas: [1], |
329 | cobros: [{ | 326 | cobros: [{ |
330 | fecha: new Date(), | 327 | FEC: new Date(), |
331 | fechaPresentacion: new Date(), | 328 | fechaPresentacion: new Date(), |
332 | fechaEmision: new Date(), | 329 | fechaEmision: new Date(), |
333 | tipo: true, | 330 | tipo: true, |
334 | banco: { | 331 | banco: { |
335 | ID: true | 332 | ID: true |
336 | }, | 333 | }, |
337 | localidad: { | 334 | localidad: { |
338 | ID: true, | 335 | ID: true, |
339 | NOMBRE: true | 336 | NOMBRE: true |
340 | }, | 337 | }, |
341 | provincia: { | 338 | provincia: { |
342 | ID: true | 339 | ID: true |
343 | } | 340 | } |
344 | }], | 341 | }], |
345 | fecha: new Date() | 342 | FEC: new Date() |
346 | }; | 343 | }; |
347 | 344 | ||
348 | //act | 345 | //act |
349 | spyOn(focaBotoneraLateralService, 'startGuardar'); | 346 | spyOn(focaBotoneraLateralService, 'startGuardar'); |
350 | spyOn(focaCrearCobranzaService, 'guardarCobranza') | 347 | spyOn(focaCrearCobranzaService, 'guardarCobranza') |
351 | .and.returnValue({ then: function() { } }); | 348 | .and.returnValue({ then: function() { } }); |
352 | spyOn(scope, 'getTotalCobrado').and.returnValue(0); | 349 | spyOn(scope, 'getTotalCobrado').and.returnValue(0); |
353 | spyOn(scope, 'getTotalDeuda').and.returnValue(0); | 350 | spyOn(scope, 'getTotalDeuda').and.returnValue(0); |
354 | scope.crearCobranza(); | 351 | scope.crearCobranza(); |
355 | 352 | ||
356 | //assert | 353 | //assert |
357 | expect(focaBotoneraLateralService.startGuardar).toHaveBeenCalled(); | 354 | expect(focaBotoneraLateralService.startGuardar).toHaveBeenCalled(); |
358 | expect(focaCrearCobranzaService.guardarCobranza).toHaveBeenCalled(); | 355 | expect(focaCrearCobranzaService.guardarCobranza).toHaveBeenCalled(); |
359 | }); | 356 | }); |
360 | 357 | ||
361 | it('seleccionarCobros seatea cobroDeuda en false', function() { | 358 | it('seleccionarCobros seatea cobroDeuda en false', function() { |
362 | 359 | ||
363 | //arrange | 360 | //arrange |
364 | var scope = { | 361 | var scope = { |
365 | $broadcast: function() { }, | 362 | $broadcast: function() { }, |
366 | $watch: function() { } | 363 | $watch: function() { } |
367 | }; | 364 | }; |
368 | 365 | ||
369 | $controller('cobranzaController', { | 366 | $controller('cobranzaController', { |
370 | $scope: scope, | 367 | $scope: scope, |
371 | $timeout: $timeout, | 368 | $timeout: $timeout, |
372 | $uibModal: {}, | 369 | $uibModal: {}, |
373 | $location: {}, | 370 | $location: {}, |
374 | focaCrearCobranzaService: { | 371 | focaCrearCobranzaService: { |
375 | getCotizacionByIdMoneda: function() { | 372 | getCotizacionByIdMoneda: function() { |
376 | return { | 373 | return { |
377 | then: function() { } | 374 | then: function() { } |
378 | }; | 375 | }; |
379 | }, | 376 | }, |
380 | getBotonera: function() { }, | 377 | getBotonera: function() { }, |
381 | getNumeroRecibo: function() { | 378 | getNumeroRecibo: function() { |
382 | return { | 379 | return { |
383 | then: function() { } | 380 | then: function() { } |
384 | }; | 381 | }; |
385 | } | 382 | } |
386 | }, | 383 | }, |
387 | focaModalService: {}, | 384 | focaModalService: {}, |
388 | $filter: $filter, | 385 | $filter: $filter, |
389 | focaSeguimientoService: {}, | 386 | focaSeguimientoService: {}, |
390 | focaBotoneraLateralService: {}, | 387 | focaBotoneraLateralService: {}, |
391 | APP: {}, | 388 | APP: {}, |
392 | focaLoginService: {}, | 389 | focaLoginService: {}, |
393 | $localStorage: true | 390 | $localStorage: true |
394 | }); | 391 | }); |
395 | 392 | ||
396 | //act | 393 | //act |
397 | scope.seleccionarCobros(); | 394 | scope.seleccionarCobros(); |
398 | 395 | ||
399 | //assert | 396 | //assert |
400 | expect(scope.cobroDeuda).toEqual(false); | 397 | expect(scope.cobroDeuda).toEqual(false); |
401 | }); | 398 | }); |
402 | 399 | ||
403 | it('seleccionarComprobantes seatea cobroDeuda en true', function() { | 400 | it('seleccionarComprobantes seatea cobroDeuda en true', function() { |
404 | 401 | ||
405 | //arrange | 402 | //arrange |
406 | var scope = { | 403 | var scope = { |
407 | $broadcast: function() { }, | 404 | $broadcast: function() { }, |
408 | $watch: function() { } | 405 | $watch: function() { } |
409 | }; | 406 | }; |
410 | 407 | ||
411 | $controller('cobranzaController', { | 408 | $controller('cobranzaController', { |
412 | $scope: scope, | 409 | $scope: scope, |
413 | $timeout: $timeout, | 410 | $timeout: $timeout, |
414 | $uibModal: {}, | 411 | $uibModal: {}, |
415 | $location: {}, | 412 | $location: {}, |
416 | focaCrearCobranzaService: { | 413 | focaCrearCobranzaService: { |
417 | getCotizacionByIdMoneda: function() { | 414 | getCotizacionByIdMoneda: function() { |
418 | return { | 415 | return { |
419 | then: function() { } | 416 | then: function() { } |
420 | }; | 417 | }; |
421 | }, | 418 | }, |
422 | getBotonera: function() { }, | 419 | getBotonera: function() { }, |
423 | getNumeroRecibo: function() { | 420 | getNumeroRecibo: function() { |
424 | return { | 421 | return { |
425 | then: function() { } | 422 | then: function() { } |
426 | }; | 423 | }; |
427 | } | 424 | } |
428 | }, | 425 | }, |
429 | focaModalService: {}, | 426 | focaModalService: {}, |
430 | $filter: $filter, | 427 | $filter: $filter, |
431 | focaSeguimientoService: {}, | 428 | focaSeguimientoService: {}, |
432 | focaBotoneraLateralService: {}, | 429 | focaBotoneraLateralService: {}, |
433 | APP: {}, | 430 | APP: {}, |
434 | focaLoginService: {}, | 431 | focaLoginService: {}, |
435 | $localStorage: true | 432 | $localStorage: true |
436 | }); | 433 | }); |
437 | 434 | ||
438 | //act | 435 | //act |
439 | scope.seleccionarComprobantes(); | 436 | scope.seleccionarComprobantes(); |
440 | 437 | ||
441 | //assert | 438 | //assert |
442 | expect(scope.cobroDeuda).toEqual(true); | 439 | expect(scope.cobroDeuda).toEqual(true); |
443 | }); | 440 | }); |
444 | 441 | ||
445 | it('seleccionarCobranza levanta modal y setea datos', function(done) { | 442 | it('seleccionarCobranza levanta modal y setea datos', function(done) { |
446 | 443 | ||
447 | //arrange | 444 | //arrange |
448 | var scope = { | 445 | var scope = { |
449 | $broadcast: function() { }, | 446 | $broadcast: function() { }, |
450 | $watch: function() { } | 447 | $watch: function() { } |
451 | }; | 448 | }; |
452 | var uibModal = { | 449 | var uibModal = { |
453 | open: function() { } | 450 | open: function() { } |
454 | }; | 451 | }; |
455 | 452 | ||
456 | $controller('cobranzaController', { | 453 | $controller('cobranzaController', { |
457 | $scope: scope, | 454 | $scope: scope, |
458 | $timeout: $timeout, | 455 | $timeout: $timeout, |
459 | $uibModal: uibModal, | 456 | $uibModal: uibModal, |
460 | $location: {}, | 457 | $location: {}, |
461 | focaCrearCobranzaService: { | 458 | focaCrearCobranzaService: { |
462 | getCotizacionByIdMoneda: function() { | 459 | getCotizacionByIdMoneda: function() { |
463 | return { | 460 | return { |
464 | then: function() { } | 461 | then: function() { } |
465 | }; | 462 | }; |
466 | }, | 463 | }, |
467 | getBotonera: function() { }, | 464 | getBotonera: function() { }, |
468 | getNumeroRecibo: function() { | 465 | getNumeroRecibo: function() { |
469 | return { | 466 | return { |
470 | then: function() { } | 467 | then: function() { } |
471 | }; | 468 | }; |
472 | } | 469 | } |
473 | }, | 470 | }, |
474 | focaModalService: {}, | 471 | focaModalService: {}, |
475 | $filter: $filter, | 472 | $filter: $filter, |
476 | focaSeguimientoService: {}, | 473 | focaSeguimientoService: {}, |
477 | focaBotoneraLateralService: {}, | 474 | focaBotoneraLateralService: {}, |
478 | APP: {}, | 475 | APP: {}, |
479 | focaLoginService: {}, | 476 | focaLoginService: {}, |
480 | $localStorage: true | 477 | $localStorage: true |
481 | }); | 478 | }); |
482 | var respuesta = { facturas: 1, cobros: 2, cliente: { } }; | 479 | var respuesta = { |
480 | facturas: 1, | ||
481 | cobros: 2, | ||
482 | cliente: { }, | ||
483 | moneda: { | ||
484 | cotizaciones: [] | ||
485 | } | ||
486 | }; | ||
483 | var promesa = { result: Promise.resolve(respuesta) }; | 487 | var promesa = { result: Promise.resolve(respuesta) }; |
484 | 488 | ||
485 | //act | 489 | //act |
486 | spyOn(uibModal, 'open').and.returnValue(promesa); | 490 | spyOn(uibModal, 'open').and.returnValue(promesa); |
487 | spyOn(scope, '$broadcast'); | 491 | spyOn(scope, '$broadcast'); |
488 | scope.seleccionarCobranza(); | 492 | scope.seleccionarCobranza(); |
489 | 493 | ||
490 | //assert | 494 | //assert |
491 | promesa.result.then(function() { | 495 | promesa.result.then(function() { |
492 | expect(uibModal.open).toHaveBeenCalled(); | 496 | expect(uibModal.open).toHaveBeenCalled(); |
493 | expect(scope.$broadcast).toHaveBeenCalledWith('cleanCabecera'); | 497 | expect(scope.$broadcast).toHaveBeenCalledWith('cleanCabecera'); |
494 | expect(scope.cobranza.facturas).toEqual(respuesta.facturas); | 498 | expect(scope.cobranza.facturas).toEqual(respuesta.facturas); |
495 | expect(scope.cobranza.cobros).toEqual(respuesta.cobros); | 499 | expect(scope.cobranza.cobros).toEqual(respuesta.cobros); |
496 | done(); | 500 | done(); |
497 | }); | 501 | }); |
498 | }); | 502 | }); |
499 | 503 | ||
500 | it('seleccionarCliente levanta modal y setea datos', function(done) { | 504 | it('seleccionarCliente levanta modal y setea datos', function(done) { |
501 | 505 | ||
502 | //arrange | 506 | //arrange |
503 | var scope = { | 507 | var scope = { |
504 | $broadcast: function() { }, | 508 | $broadcast: function() { }, |
505 | $watch: function() { } | 509 | $watch: function() { } |
506 | }; | 510 | }; |
507 | var uibModal = { | 511 | var uibModal = { |
508 | open: function() { } | 512 | open: function() { } |
509 | }; | 513 | }; |
510 | 514 | ||
511 | $controller('cobranzaController', { | 515 | $controller('cobranzaController', { |
512 | $scope: scope, | 516 | $scope: scope, |
513 | $timeout: $timeout, | 517 | $timeout: $timeout, |
514 | $uibModal: uibModal, | 518 | $uibModal: uibModal, |
515 | $location: {}, | 519 | $location: {}, |
516 | focaCrearCobranzaService: { | 520 | focaCrearCobranzaService: { |
517 | getCotizacionByIdMoneda: function() { | 521 | getCotizacionByIdMoneda: function() { |
518 | return { | 522 | return { |
519 | then: function() { } | 523 | then: function() { } |
520 | }; | 524 | }; |
521 | }, | 525 | }, |
522 | getBotonera: function() { }, | 526 | getBotonera: function() { }, |
523 | getNumeroRecibo: function() { | 527 | getNumeroRecibo: function() { |
524 | return { | 528 | return { |
525 | then: function() { } | 529 | then: function() { } |
526 | }; | 530 | }; |
527 | }, | 531 | }, |
528 | getCobradorById: function() { | 532 | getCobradorById: function() { |
529 | return { | 533 | return { |
530 | then: function() { } | 534 | then: function() { } |
531 | }; | 535 | }; |
532 | } | 536 | } |
533 | }, | 537 | }, |
534 | focaModalService: { | 538 | focaModalService: { |
535 | modal: function() { | 539 | modal: function() { |
536 | return { | 540 | return { |
537 | then: function() {} | 541 | then: function() {} |
538 | }; | 542 | }; |
539 | } | 543 | } |
540 | }, | 544 | }, |
541 | $filter: $filter, | 545 | $filter: $filter, |
542 | focaSeguimientoService: {}, | 546 | focaSeguimientoService: {}, |
543 | focaBotoneraLateralService: {}, | 547 | focaBotoneraLateralService: {}, |
544 | APP: 'cobranza', | 548 | APP: 'cobranza', |
545 | focaLoginService: { | 549 | focaLoginService: { |
546 | getLoginData: function() { | 550 | getLoginData: function() { |
547 | return { | 551 | return { |
548 | vendedorCobrador: true | 552 | vendedorCobrador: true |
549 | }; | 553 | }; |
550 | } | 554 | } |
551 | }, | 555 | }, |
552 | $localStorage: true | 556 | $localStorage: true |
553 | }); | 557 | }); |
554 | scope.cobranza = { | 558 | scope.cobranza = { |
555 | cobrador: {} | 559 | cobrador: {} |
556 | }; | 560 | }; |
557 | var respuesta = { facturas: 1, cobros: 2, cliente: { } }; | 561 | var respuesta = { facturas: 1, cobros: 2, cliente: { } }; |
558 | var promesa = { result: Promise.resolve(respuesta) }; | 562 | var promesa = { result: Promise.resolve(respuesta) }; |
559 | 563 | ||
560 | //act | 564 | //act |
561 | spyOn(uibModal, 'open').and.returnValue(promesa); | 565 | spyOn(uibModal, 'open').and.returnValue(promesa); |
562 | spyOn(scope, '$broadcast'); | 566 | spyOn(scope, '$broadcast'); |
563 | scope.seleccionarCliente(); | 567 | scope.seleccionarCliente(); |
564 | 568 | ||
565 | //assert | 569 | //assert |
566 | promesa.result.then(function() { | 570 | promesa.result.then(function() { |
567 | expect(uibModal.open).toHaveBeenCalled(); | 571 | expect(uibModal.open).toHaveBeenCalled(); |
568 | expect(scope.$broadcast).toHaveBeenCalled(); | 572 | expect(scope.$broadcast).toHaveBeenCalled(); |
569 | done(); | 573 | done(); |
570 | }); | 574 | }); |
571 | }); | 575 | }); |
572 | 576 | ||
573 | it('seleccionarFactura muestra alerta cuando no se seteo cliente', function() { | 577 | it('seleccionarFactura muestra alerta cuando no se seteo cliente', function() { |
574 | 578 | ||
575 | //arrange | 579 | //arrange |
576 | var scope = { | 580 | var scope = { |
577 | $broadcast: function() { }, | 581 | $broadcast: function() { }, |
578 | $watch: function() { } | 582 | $watch: function() { } |
579 | }; | 583 | }; |
580 | var focaModalService = { | 584 | var focaModalService = { |
581 | alert: function() { } | 585 | alert: function() { } |
582 | }; | 586 | }; |
583 | 587 | ||
584 | $controller('cobranzaController', { | 588 | $controller('cobranzaController', { |
585 | $scope: scope, | 589 | $scope: scope, |
586 | $timeout: $timeout, | 590 | $timeout: $timeout, |
587 | $uibModal: { | 591 | $uibModal: { |
588 | open: function() { | 592 | open: function() { |
589 | return { | 593 | return { |
590 | result: { | 594 | result: { |
591 | then: function() { } | 595 | then: function() { } |
592 | } | 596 | } |
593 | }; | 597 | }; |
594 | } | 598 | } |
595 | }, | 599 | }, |
596 | $location: {}, | 600 | $location: {}, |
597 | focaCrearCobranzaService: { | 601 | focaCrearCobranzaService: { |
598 | getCotizacionByIdMoneda: function() { | 602 | getCotizacionByIdMoneda: function() { |
599 | return { | 603 | return { |
600 | then: function() { } | 604 | then: function() { } |
601 | }; | 605 | }; |
602 | }, | 606 | }, |
603 | getBotonera: function() { }, | 607 | getBotonera: function() { }, |
604 | getNumeroRecibo: function() { | 608 | getNumeroRecibo: function() { |
605 | return { | 609 | return { |
606 | then: function() { } | 610 | then: function() { } |
607 | }; | 611 | }; |
608 | } | 612 | } |
609 | }, | 613 | }, |
610 | focaModalService: focaModalService, | 614 | focaModalService: focaModalService, |
611 | $filter: $filter, | 615 | $filter: $filter, |
612 | focaSeguimientoService: {}, | 616 | focaSeguimientoService: {}, |
613 | focaBotoneraLateralService: {}, | 617 | focaBotoneraLateralService: {}, |
614 | APP: {}, | 618 | APP: {}, |
615 | focaLoginService: {}, | 619 | focaLoginService: {}, |
616 | $localStorage: true | 620 | $localStorage: true |
617 | }); | 621 | }); |
618 | 622 | ||
619 | //act | 623 | //act |
620 | spyOn(focaModalService, 'alert'); | 624 | spyOn(focaModalService, 'alert'); |
621 | scope.seleccionarFactura(); | 625 | scope.seleccionarFactura(); |
622 | 626 | ||
623 | //assert | 627 | //assert |
624 | expect(focaModalService.alert).toHaveBeenCalledWith('Seleccione primero un cliente'); | 628 | expect(focaModalService.alert).toHaveBeenCalledWith('Seleccione primero un cliente'); |
625 | }); | 629 | }); |
626 | 630 | ||
627 | it('seleccionarFactura levanta modal', function() { | 631 | it('seleccionarFactura levanta modal', function() { |
628 | 632 | ||
629 | //arrange | 633 | //arrange |
630 | var scope = { | 634 | var scope = { |
631 | $broadcast: function() { }, | 635 | $broadcast: function() { }, |
632 | $watch: function() { } | 636 | $watch: function() { } |
633 | }; | 637 | }; |
634 | var uibModal = { | 638 | var uibModal = { |
635 | open: function() { } | 639 | open: function() { } |
636 | }; | 640 | }; |
637 | 641 | ||
638 | $controller('cobranzaController', { | 642 | $controller('cobranzaController', { |
639 | $scope: scope, | 643 | $scope: scope, |
640 | $timeout: $timeout, | 644 | $timeout: $timeout, |
641 | $uibModal: uibModal, | 645 | $uibModal: uibModal, |
642 | $location: {}, | 646 | $location: {}, |
643 | focaCrearCobranzaService: { | 647 | focaCrearCobranzaService: { |
644 | getCotizacionByIdMoneda: function() { | 648 | getCotizacionByIdMoneda: function() { |
645 | return { | 649 | return { |
646 | then: function() { } | 650 | then: function() { } |
647 | }; | 651 | }; |
648 | }, | 652 | }, |
649 | getBotonera: function() { }, | 653 | getBotonera: function() { }, |
650 | getNumeroRecibo: function() { | 654 | getNumeroRecibo: function() { |
651 | return { | 655 | return { |
652 | then: function() { } | 656 | then: function() { } |
653 | }; | 657 | }; |
654 | } | 658 | } |
655 | }, | 659 | }, |
656 | focaModalService: { | 660 | focaModalService: { |
657 | alert: function() {} | 661 | alert: function() {} |
658 | }, | 662 | }, |
659 | $filter: $filter, | 663 | $filter: $filter, |
660 | focaSeguimientoService: {}, | 664 | focaSeguimientoService: {}, |
661 | focaBotoneraLateralService: {}, | 665 | focaBotoneraLateralService: {}, |
662 | APP: {}, | 666 | APP: {}, |
663 | focaLoginService: {}, | 667 | focaLoginService: {}, |
664 | $localStorage: true | 668 | $localStorage: true |
665 | }); | 669 | }); |
666 | scope.cobranza = { | 670 | scope.cobranza = { |
667 | cliente: { | 671 | cliente: { |
668 | COD: true | 672 | COD: true |
669 | } | 673 | } |
670 | }; | 674 | }; |
671 | 675 | ||
672 | var respuesta = { result: { then: function() { } } }; | 676 | var respuesta = { result: { then: function() { } } }; |
673 | 677 | ||
674 | //act | 678 | //act |
675 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 679 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
676 | scope.seleccionarFactura(); | 680 | scope.seleccionarFactura(); |
677 | 681 | ||
678 | //assert | 682 | //assert |
679 | expect(uibModal.open).toHaveBeenCalled(); | 683 | expect(uibModal.open).toHaveBeenCalled(); |
680 | }); | 684 | }); |
681 | 685 | ||
682 | it('seleccionarCheque levanta modal', function() { | 686 | it('seleccionarCheque levanta modal', function() { |
683 | 687 | ||
684 | //arrange | 688 | //arrange |
685 | var scope = { | 689 | var scope = { |
686 | $broadcast: function() { }, | 690 | $broadcast: function() { }, |
687 | $watch: function() { } | 691 | $watch: function() { } |
688 | }; | 692 | }; |
689 | var uibModal = { | 693 | var uibModal = { |
690 | open: function() { } | 694 | open: function() { } |
691 | }; | 695 | }; |
692 | 696 | ||
693 | $controller('cobranzaController', { | 697 | $controller('cobranzaController', { |
694 | $scope: scope, | 698 | $scope: scope, |
695 | $timeout: $timeout, | 699 | $timeout: $timeout, |
696 | $uibModal: uibModal, | 700 | $uibModal: uibModal, |
697 | $location: {}, | 701 | $location: {}, |
698 | focaCrearCobranzaService: { | 702 | focaCrearCobranzaService: { |
699 | getCotizacionByIdMoneda: function() { | 703 | getCotizacionByIdMoneda: function() { |
700 | return { | 704 | return { |
701 | then: function() { } | 705 | then: function() { } |
702 | }; | 706 | }; |
703 | }, | 707 | }, |
704 | getBotonera: function() { }, | 708 | getBotonera: function() { }, |
705 | getNumeroRecibo: function() { | 709 | getNumeroRecibo: function() { |
706 | return { | 710 | return { |
707 | then: function() { } | 711 | then: function() { } |
708 | }; | 712 | }; |
709 | } | 713 | } |
710 | }, | 714 | }, |
711 | focaModalService: {}, | 715 | focaModalService: {}, |
712 | $filter: $filter, | 716 | $filter: $filter, |
713 | focaSeguimientoService: {}, | 717 | focaSeguimientoService: {}, |
714 | focaBotoneraLateralService: {}, | 718 | focaBotoneraLateralService: {}, |
715 | APP: {}, | 719 | APP: {}, |
716 | focaLoginService: {}, | 720 | focaLoginService: {}, |
717 | $localStorage: true | 721 | $localStorage: true |
718 | }); | 722 | }); |
719 | scope.cobranza = { | 723 | scope.cobranza = { |
720 | cliente: { } | 724 | cliente: { }, |
725 | facturas: [], | ||
726 | cobros: [] | ||
721 | }; | 727 | }; |
722 | 728 | ||
723 | var respuesta = { result: { then: function() { } } }; | 729 | var respuesta = { result: { then: function() { } } }; |
724 | 730 | ||
725 | //act | 731 | //act |
726 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 732 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
727 | scope.seleccionarCheque(); | 733 | scope.seleccionarCheque(); |
728 | 734 | ||
729 | //assert | 735 | //assert |
730 | expect(uibModal.open).toHaveBeenCalled(); | 736 | expect(uibModal.open).toHaveBeenCalled(); |
731 | }); | 737 | }); |
732 | 738 | ||
733 | it('seleccionarEfectivo levanta modal', function() { | 739 | it('seleccionarEfectivo levanta modal', function() { |
734 | 740 | ||
735 | //arrange | 741 | //arrange |
736 | var scope = { | 742 | var scope = { |
737 | $broadcast: function() { }, | 743 | $broadcast: function() { }, |
738 | $watch: function() { } | 744 | $watch: function() { } |
739 | }; | 745 | }; |
740 | var uibModal = { | 746 | var uibModal = { |
741 | open: function() { } | 747 | open: function() { } |
742 | }; | 748 | }; |
743 | 749 | ||
744 | $controller('cobranzaController', { | 750 | $controller('cobranzaController', { |
745 | $scope: scope, | 751 | $scope: scope, |
746 | $timeout: $timeout, | 752 | $timeout: $timeout, |
747 | $uibModal: uibModal, | 753 | $uibModal: uibModal, |
748 | $location: {}, | 754 | $location: {}, |
749 | focaCrearCobranzaService: { | 755 | focaCrearCobranzaService: { |
750 | getCotizacionByIdMoneda: function() { | 756 | getCotizacionByIdMoneda: function() { |
751 | return { | 757 | return { |
752 | then: function() { } | 758 | then: function() { } |
753 | }; | 759 | }; |
754 | }, | 760 | }, |
755 | getBotonera: function() { }, | 761 | getBotonera: function() { }, |
756 | getNumeroRecibo: function() { | 762 | getNumeroRecibo: function() { |
757 | return { | 763 | return { |
758 | then: function() { } | 764 | then: function() { } |
759 | }; | 765 | }; |
760 | } | 766 | } |
761 | }, | 767 | }, |
762 | focaModalService: {}, | 768 | focaModalService: {}, |
763 | $filter: $filter, | 769 | $filter: $filter, |
764 | focaSeguimientoService: {}, | 770 | focaSeguimientoService: {}, |
765 | focaBotoneraLateralService: {}, | 771 | focaBotoneraLateralService: {}, |
766 | APP: {}, | 772 | APP: {}, |
767 | focaLoginService: {}, | 773 | focaLoginService: {}, |
768 | $localStorage: true | 774 | $localStorage: true |
769 | }); | 775 | }); |
770 | scope.cobranza = { | 776 | scope.cobranza = { |
771 | cliente: { } | 777 | cliente: { }, |
778 | cobros: [] | ||
772 | }; | 779 | }; |
773 | 780 | ||
774 | var respuesta = { result: { then: function() { } } }; | 781 | var respuesta = { result: { then: function() { } } }; |
775 | 782 | ||
776 | //act | 783 | //act |
777 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 784 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
778 | scope.seleccionarEfectivo(); | 785 | scope.seleccionarEfectivo(); |
779 | 786 | ||
780 | //assert | 787 | //assert |
781 | expect(uibModal.open).toHaveBeenCalled(); | 788 | expect(uibModal.open).toHaveBeenCalled(); |
782 | }); | 789 | }); |
783 | 790 | ||
784 | it('seleccionarDetalles levanta modal', function() { | 791 | it('seleccionarDetalles levanta modal', function() { |
785 | 792 | ||
786 | //arrange | 793 | //arrange |
787 | var scope = { | 794 | var scope = { |
788 | $broadcast: function() { }, | 795 | $broadcast: function() { }, |
789 | $watch: function() { } | 796 | $watch: function() { } |
790 | }; | 797 | }; |
791 | var uibModal = { | 798 | var uibModal = { |
792 | open: function() { } | 799 | open: function() { } |
793 | }; | 800 | }; |
794 | 801 | ||
795 | $controller('cobranzaController', { | 802 | $controller('cobranzaController', { |
796 | $scope: scope, | 803 | $scope: scope, |
797 | $timeout: $timeout, | 804 | $timeout: $timeout, |
798 | $uibModal: uibModal, | 805 | $uibModal: uibModal, |
799 | $location: {}, | 806 | $location: {}, |
800 | focaCrearCobranzaService: { | 807 | focaCrearCobranzaService: { |
801 | getCotizacionByIdMoneda: function() { | 808 | getCotizacionByIdMoneda: function() { |
802 | return { | 809 | return { |
803 | then: function() { } | 810 | then: function() { } |
804 | }; | 811 | }; |
805 | }, | 812 | }, |
806 | getBotonera: function() { }, | 813 | getBotonera: function() { }, |
807 | getNumeroRecibo: function() { | 814 | getNumeroRecibo: function() { |
808 | return { | 815 | return { |
809 | then: function() { } | 816 | then: function() { } |
810 | }; | 817 | }; |
811 | } | 818 | } |
812 | }, | 819 | }, |
813 | focaModalService: {}, | 820 | focaModalService: {}, |
814 | $filter: $filter, | 821 | $filter: $filter, |
815 | focaSeguimientoService: {}, | 822 | focaSeguimientoService: {}, |
816 | focaBotoneraLateralService: {}, | 823 | focaBotoneraLateralService: {}, |
817 | APP: {}, | 824 | APP: {}, |
818 | focaLoginService: {}, | 825 | focaLoginService: {}, |
819 | $localStorage: true | 826 | $localStorage: true |
820 | }); | 827 | }); |
821 | scope.cobranza = { | 828 | scope.cobranza = { |
822 | cliente: { } | 829 | cliente: { }, |
830 | facturas: [], | ||
831 | cobros: [] | ||
823 | }; | 832 | }; |
824 | 833 | ||
825 | var respuesta = { result: { then: function() { } } }; | 834 | var respuesta = { result: { then: function() { } } }; |
826 | 835 | ||
827 | //act | 836 | //act |
828 | spyOn(uibModal, 'open').and.returnValue(respuesta); | 837 | spyOn(uibModal, 'open').and.returnValue(respuesta); |
829 | scope.seleccionarDetalles(); | 838 | scope.seleccionarDetalles(); |
830 | 839 | ||
831 | //assert | 840 | //assert |
832 | expect(uibModal.open).toHaveBeenCalled(); | 841 | expect(uibModal.open).toHaveBeenCalled(); |
833 | }); | 842 | }); |
834 | 843 | ||
835 | it('seleccionarMoneda levanta modal', function(done) { | 844 | it('seleccionarMoneda levanta modal', function(done) { |
836 | 845 | ||
837 | //arrange | 846 | //arrange |
838 | var scope = { | 847 | var scope = { |
839 | $broadcast: function() { }, | 848 | $broadcast: function() { }, |
840 | $watch: function() { } | 849 | $watch: function() { } |
841 | }; | 850 | }; |
842 | var focaModalService = { | 851 | var focaModalService = { |
843 | modal: function() { } | 852 | modal: function() { } |
844 | }; | 853 | }; |
845 | 854 | ||
846 | $controller('cobranzaController', { | 855 | $controller('cobranzaController', { |
847 | $scope: scope, | 856 | $scope: scope, |
848 | $timeout: $timeout, | 857 | $timeout: $timeout, |
849 | $uibModal: {}, | 858 | $uibModal: {}, |
850 | $location: {}, | 859 | $location: {}, |
851 | focaCrearCobranzaService: { | 860 | focaCrearCobranzaService: { |
852 | getCotizacionByIdMoneda: function() { | 861 | getCotizacionByIdMoneda: function() { |
853 | return { | 862 | return { |
854 | then: function() { } | 863 | then: function() { } |
855 | }; | 864 | }; |
856 | }, | 865 | }, |
857 | getBotonera: function() { }, | 866 | getBotonera: function() { }, |
858 | getNumeroRecibo: function() { | 867 | getNumeroRecibo: function() { |
859 | return { | 868 | return { |
860 | then: function() { } | 869 | then: function() { } |
861 | }; | 870 | }; |
862 | } | 871 | } |
863 | }, | 872 | }, |
864 | focaModalService: focaModalService, | 873 | focaModalService: focaModalService, |
865 | $filter: $filter, | 874 | $filter: $filter, |
866 | focaSeguimientoService: {}, | 875 | focaSeguimientoService: {}, |
867 | focaBotoneraLateralService: {}, | 876 | focaBotoneraLateralService: {}, |
868 | APP: {}, | 877 | APP: {}, |
869 | focaLoginService: {}, | 878 | focaLoginService: {}, |
870 | $localStorage: true | 879 | $localStorage: true |
871 | }); | 880 | }); |
872 | 881 | ||
873 | var respuesta = 1; | 882 | var respuesta = 1; |
874 | var promesa = Promise.resolve(respuesta); | 883 | var promesa = Promise.resolve(respuesta); |
875 | 884 | ||
876 | //act | 885 | //act |
877 | spyOn(focaModalService, 'modal').and.returnValue(promesa); | 886 | spyOn(focaModalService, 'modal').and.returnValue(promesa); |
878 | spyOn(scope, 'seleccionarCotizacion'); | 887 | spyOn(scope, 'seleccionarCotizacion'); |
879 | scope.seleccionarMoneda(); | 888 | scope.seleccionarMoneda(); |
880 | 889 | ||
881 | //assert | 890 | //assert |
882 | expect(focaModalService.modal).toHaveBeenCalled(); | 891 | expect(focaModalService.modal).toHaveBeenCalled(); |
883 | promesa.then(function() { | 892 | promesa.then(function() { |
884 | expect(scope.seleccionarCotizacion).toHaveBeenCalled(); | 893 | expect(scope.seleccionarCotizacion).toHaveBeenCalled(); |
885 | done(); | 894 | done(); |
886 | }); | 895 | }); |
887 | }); | 896 | }); |
888 | 897 | ||
889 | it('seleccionarCotizacion levanta modal', function(done) { | 898 | it('seleccionarCotizacion levanta modal', function(done) { |
890 | 899 | ||
891 | //arrange | 900 | //arrange |
892 | var scope = { | 901 | var scope = { |
893 | $broadcast: function() { }, | 902 | $broadcast: function() { }, |
894 | $watch: function() { } | 903 | $watch: function() { } |
895 | }; | 904 | }; |
896 | var uibModal = { | 905 | var uibModal = { |
897 | open: function() { } | 906 | open: function() { } |
898 | }; | 907 | }; |
899 | 908 | ||
900 | $controller('cobranzaController', { | 909 | $controller('cobranzaController', { |
901 | $scope: scope, | 910 | $scope: scope, |
902 | $timeout: $timeout, | 911 | $timeout: $timeout, |
903 | $uibModal: uibModal, | 912 | $uibModal: uibModal, |
904 | $location: {}, | 913 | $location: {}, |
905 | focaCrearCobranzaService: { | 914 | focaCrearCobranzaService: { |
906 | getCotizacionByIdMoneda: function() { | 915 | getCotizacionByIdMoneda: function() { |
907 | return { | 916 | return { |
908 | then: function() { } | 917 | then: function() { } |
909 | }; | 918 | }; |
910 | }, | 919 | }, |
911 | getBotonera: function() { }, | 920 | getBotonera: function() { }, |
912 | getNumeroRecibo: function() { | 921 | getNumeroRecibo: function() { |
913 | return { | 922 | return { |
914 | then: function() { } | 923 | then: function() { } |
915 | }; | 924 | }; |
916 | } | 925 | } |
917 | }, | 926 | }, |
918 | focaModalService: {}, | 927 | focaModalService: {}, |
919 | $filter: $filter, | 928 | $filter: $filter, |
920 | focaSeguimientoService: {}, | 929 | focaSeguimientoService: {}, |
921 | focaBotoneraLateralService: {}, | 930 | focaBotoneraLateralService: {}, |
922 | APP: {}, | 931 | APP: {}, |
923 | focaLoginService: {}, | 932 | focaLoginService: {}, |
924 | $localStorage: true | 933 | $localStorage: true |
925 | }); | 934 | }); |
926 | 935 | ||
927 | var respuesta = 1; | 936 | var respuesta = 1; |
928 | var promesa = { result: Promise.resolve(respuesta) }; | 937 | var promesa = { result: Promise.resolve(respuesta) }; |
929 | 938 | ||
930 | //act | 939 | //act |
931 | spyOn(uibModal, 'open').and.returnValue(promesa); | 940 | spyOn(uibModal, 'open').and.returnValue(promesa); |
932 | spyOn(scope, '$broadcast'); | 941 | spyOn(scope, '$broadcast'); |
933 | scope.seleccionarCotizacion({ }); | 942 | scope.seleccionarCotizacion({ }); |
934 | 943 | ||
935 | //assert | 944 | //assert |
936 | promesa.result.then(function() { | 945 | promesa.result.then(function() { |
937 | expect(uibModal.open).toHaveBeenCalled(); | 946 | expect(uibModal.open).toHaveBeenCalled(); |
938 | expect(scope.$broadcast).toHaveBeenCalled(); | 947 | expect(scope.$broadcast).toHaveBeenCalled(); |
939 | scope.cobranza.cotizacion = respuesta; | 948 | scope.cobranza.cotizacion = respuesta; |
940 | done(); | 949 | done(); |
941 | }); | 950 | }); |
942 | }); | 951 | }); |
943 | 952 | ||
944 | it('seleccionarCobrador levanta modal', function(done) { | 953 | it('seleccionarCobrador levanta modal', function(done) { |
945 | 954 | ||
946 | //arrange | 955 | //arrange |
947 | var scope = { | 956 | var scope = { |
948 | $broadcast: function() { }, | 957 | $broadcast: function() { }, |
949 | $watch: function() { } | 958 | $watch: function() { } |
950 | }; | 959 | }; |
951 | var focaModalService = { | 960 | var focaModalService = { |
952 | modal: function() { } | 961 | modal: function() { } |
953 | }; | 962 | }; |
954 | 963 | ||
955 | $controller('cobranzaController', { | 964 | $controller('cobranzaController', { |
956 | $scope: scope, | 965 | $scope: scope, |
957 | $timeout: $timeout, | 966 | $timeout: $timeout, |
958 | $uibModal: {}, | 967 | $uibModal: {}, |
959 | $location: {}, | 968 | $location: {}, |
960 | focaCrearCobranzaService: { | 969 | focaCrearCobranzaService: { |
961 | getCotizacionByIdMoneda: function() { | 970 | getCotizacionByIdMoneda: function() { |
962 | return { | 971 | return { |
963 | then: function() { } | 972 | then: function() { } |
964 | }; | 973 | }; |
965 | }, | 974 | }, |
966 | getBotonera: function() { }, | 975 | getBotonera: function() { }, |
967 | getNumeroRecibo: function() { | 976 | getNumeroRecibo: function() { |
968 | return { | 977 | return { |
969 | then: function() { } | 978 | then: function() { } |
970 | }; | 979 | }; |
971 | } | 980 | } |
972 | }, | 981 | }, |
973 | focaModalService: focaModalService, | 982 | focaModalService: focaModalService, |
974 | $filter: $filter, | 983 | $filter: $filter, |
975 | focaSeguimientoService: {}, | 984 | focaSeguimientoService: {}, |
976 | focaBotoneraLateralService: {}, | 985 | focaBotoneraLateralService: {}, |
977 | APP: {}, | 986 | APP: {}, |
978 | focaLoginService: {}, | 987 | focaLoginService: {}, |
979 | $localStorage: true | 988 | $localStorage: true |
980 | }); | 989 | }); |
981 | 990 | ||
982 | var respuesta = 1; | 991 | var respuesta = 1; |
983 | var promesa = Promise.resolve(respuesta); | 992 | var promesa = Promise.resolve(respuesta); |
984 | 993 | ||
985 | //act | 994 | //act |
986 | spyOn(focaModalService, 'modal').and.returnValue(promesa); | 995 | spyOn(focaModalService, 'modal').and.returnValue(promesa); |
987 | spyOn(scope, '$broadcast'); | 996 | spyOn(scope, '$broadcast'); |
988 | scope.seleccionarCobrador({ }); | 997 | scope.seleccionarCobrador({ }); |
989 | 998 | ||
990 | //assert | 999 | //assert |
991 | promesa.then(function() { | 1000 | promesa.then(function() { |
992 | expect(focaModalService.modal).toHaveBeenCalled(); | 1001 | expect(focaModalService.modal).toHaveBeenCalled(); |
993 | expect(scope.$broadcast).toHaveBeenCalled(); | 1002 | expect(scope.$broadcast).toHaveBeenCalled(); |
994 | scope.cobranza.cobrador = respuesta; | 1003 | scope.cobranza.cobrador = respuesta; |
995 | done(); | 1004 | done(); |
996 | }); | 1005 | }); |
997 | }); | 1006 | }); |
998 | 1007 | ||
999 | it('getTotalDeuda devuelve correcto', function() { | 1008 | it('getTotalDeuda devuelve correcto', function() { |
1000 | 1009 | ||
1001 | //arrange | 1010 | //arrange |
1002 | var scope = { | 1011 | var scope = { |
1003 | $broadcast: function() { }, | 1012 | $broadcast: function() { }, |
1004 | $watch: function() { } | 1013 | $watch: function() { } |
1005 | }; | 1014 | }; |
1006 | 1015 | ||
1007 | $controller('cobranzaController', { | 1016 | $controller('cobranzaController', { |
1008 | $scope: scope, | 1017 | $scope: scope, |
1009 | $timeout: $timeout, | 1018 | $timeout: $timeout, |
1010 | $uibModal: {}, | 1019 | $uibModal: {}, |
1011 | $location: {}, | 1020 | $location: {}, |
1012 | focaCrearCobranzaService: { | 1021 | focaCrearCobranzaService: { |
1013 | getCotizacionByIdMoneda: function() { | 1022 | getCotizacionByIdMoneda: function() { |
1014 | return { | 1023 | return { |
1015 | then: function() { } | 1024 | then: function() { } |
1016 | }; | 1025 | }; |
1017 | }, | 1026 | }, |
1018 | getBotonera: function() { }, | 1027 | getBotonera: function() { }, |
1019 | getNumeroRecibo: function() { | 1028 | getNumeroRecibo: function() { |
1020 | return { | 1029 | return { |
1021 | then: function() { } | 1030 | then: function() { } |
1022 | }; | 1031 | }; |
1023 | } | 1032 | } |
1024 | }, | 1033 | }, |
1025 | focaModalService: {}, | 1034 | focaModalService: {}, |
1026 | $filter: $filter, | 1035 | $filter: $filter, |
1027 | focaSeguimientoService: {}, | 1036 | focaSeguimientoService: {}, |
1028 | focaBotoneraLateralService: {}, | 1037 | focaBotoneraLateralService: {}, |
1029 | APP: {}, | 1038 | APP: {}, |
1030 | focaLoginService: {}, | 1039 | focaLoginService: {}, |
1031 | $localStorage: true | 1040 | $localStorage: true |
1032 | }); | 1041 | }); |
1033 | scope.cobranza = { | 1042 | scope.cobranza = { |
1034 | facturas: [{ IPA: 1 }] | 1043 | facturas: [{ IPA: 1 }] |
1035 | }; | 1044 | }; |
1036 | 1045 | ||
1037 | //act | 1046 | //act |
1038 | var esperado = 1; | 1047 | var esperado = 1; |
1039 | var resultado = scope.getTotalDeuda(); | 1048 | var resultado = scope.getTotalDeuda(); |
1040 | 1049 | ||
1041 | //assert | 1050 | //assert |
1042 | expect(resultado).toEqual(esperado); | 1051 | expect(resultado).toEqual(esperado); |
1043 | }); | 1052 | }); |
1044 | 1053 | ||
1045 | it('getTotalCobrado devuelve correcto', function() { | 1054 | it('getTotalCobrado devuelve correcto', function() { |
1046 | 1055 | ||
1047 | //arrange | 1056 | //arrange |
1048 | var scope = { | 1057 | var scope = { |
1049 | $broadcast: function() { }, | 1058 | $broadcast: function() { }, |
1050 | $watch: function() { } | 1059 | $watch: function() { } |
1051 | }; | 1060 | }; |
1052 | 1061 | ||
1053 | $controller('cobranzaController', { | 1062 | $controller('cobranzaController', { |
1054 | $scope: scope, | 1063 | $scope: scope, |
1055 | $timeout: $timeout, | 1064 | $timeout: $timeout, |
1056 | $uibModal: {}, | 1065 | $uibModal: {}, |
1057 | $location: {}, | 1066 | $location: {}, |
1058 | focaCrearCobranzaService: { | 1067 | focaCrearCobranzaService: { |
1059 | getCotizacionByIdMoneda: function() { | 1068 | getCotizacionByIdMoneda: function() { |
1060 | return { | 1069 | return { |
1061 | then: function() { } | 1070 | then: function() { } |
1062 | }; | 1071 | }; |
1063 | }, | 1072 | }, |
1064 | getBotonera: function() { }, | 1073 | getBotonera: function() { }, |
1065 | getNumeroRecibo: function() { | 1074 | getNumeroRecibo: function() { |
1066 | return { | 1075 | return { |
1067 | then: function() { } | 1076 | then: function() { } |
1068 | }; | 1077 | }; |
1069 | } | 1078 | } |
1070 | }, | 1079 | }, |
1071 | focaModalService: {}, | 1080 | focaModalService: {}, |
1072 | $filter: $filter, | 1081 | $filter: $filter, |
1073 | focaSeguimientoService: {}, | 1082 | focaSeguimientoService: {}, |
1074 | focaBotoneraLateralService: {}, | 1083 | focaBotoneraLateralService: {}, |
1075 | APP: {}, | 1084 | APP: {}, |
1076 | focaLoginService: {}, | 1085 | focaLoginService: {}, |
1077 | $localStorage: true | 1086 | $localStorage: true |
1078 | }); | 1087 | }); |
1079 | scope.cobranza = { | 1088 | scope.cobranza = { |
1080 | cobros: [{ importe: 1 }] | 1089 | cobros: [{ IMP: 1 }] |
1081 | }; | 1090 | }; |
1082 | 1091 | ||
1083 | //act | 1092 | //act |
1084 | var esperado = 1; | 1093 | var esperado = 1; |
1085 | var resultado = scope.getTotalCobrado(); | 1094 | var resultado = scope.getTotalCobrado(); |
1086 | 1095 | ||
1087 | //assert | 1096 | //assert |
1088 | expect(resultado).toEqual(esperado); | 1097 | expect(resultado).toEqual(esperado); |
1089 | }); | 1098 | }); |
1090 | 1099 | ||
1091 | it('getSubTotal devuelve correcto', function() { | 1100 | it('getSubTotal devuelve correcto', function() { |
1092 | 1101 | ||
1093 | //arrange | 1102 | //arrange |
1094 | var scope = { | 1103 | var scope = { |
1095 | $broadcast: function() { }, | 1104 | $broadcast: function() { }, |
1096 | $watch: function() { } | 1105 | $watch: function() { } |
1097 | }; | 1106 | }; |
1098 | 1107 | ||
1099 | $controller('cobranzaController', { | 1108 | $controller('cobranzaController', { |
1100 | $scope: scope, | 1109 | $scope: scope, |
1101 | $timeout: $timeout, | 1110 | $timeout: $timeout, |
1102 | $uibModal: {}, | 1111 | $uibModal: {}, |
1103 | $location: {}, | 1112 | $location: {}, |
1104 | focaCrearCobranzaService: { | 1113 | focaCrearCobranzaService: { |
1105 | getCotizacionByIdMoneda: function() { | 1114 | getCotizacionByIdMoneda: function() { |
1106 | return { | 1115 | return { |
1107 | then: function() { } | 1116 | then: function() { } |
1108 | }; | 1117 | }; |
1109 | }, | 1118 | }, |
1110 | getBotonera: function() { }, | 1119 | getBotonera: function() { }, |
1111 | getNumeroRecibo: function() { | 1120 | getNumeroRecibo: function() { |
1112 | return { | 1121 | return { |
1113 | then: function() { } | 1122 | then: function() { } |
1114 | }; | 1123 | }; |
1115 | } | 1124 | } |
1116 | }, | 1125 | }, |
1117 | focaModalService: {}, | 1126 | focaModalService: {}, |
1118 | $filter: $filter, | 1127 | $filter: $filter, |
1119 | focaSeguimientoService: {}, | 1128 | focaSeguimientoService: {}, |
1120 | focaBotoneraLateralService: {}, | 1129 | focaBotoneraLateralService: {}, |
1121 | APP: {}, | 1130 | APP: {}, |
1122 | focaLoginService: {}, | 1131 | focaLoginService: {}, |
1123 | $localStorage: true | 1132 | $localStorage: true |
1124 | }); | 1133 | }); |
1125 | scope.articuloACargar = { | 1134 | scope.articuloACargar = { |
1126 | precio: 2, | 1135 | precio: 2, |
1127 | cantidad: 5 | 1136 | cantidad: 5 |
1128 | }; | 1137 | }; |
1129 | 1138 | ||
1130 | //act | 1139 | //act |
1131 | var esperado = 10; | 1140 | var esperado = 10; |
1132 | var resultado = scope.getSubTotal(); | 1141 | var resultado = scope.getSubTotal(); |
1133 | 1142 | ||
1134 | //assert | 1143 | //assert |
1135 | expect(resultado).toEqual(esperado); | 1144 | expect(resultado).toEqual(esperado); |
1136 | }); | 1145 | }); |
1137 | 1146 | ||
1138 | it('salir lleva a la ruta correcta', function() { | 1147 | it('salir lleva a la ruta correcta', function() { |
1139 | 1148 | ||
1140 | inject(function($location) { | 1149 | inject(function($location) { |
1141 | 1150 | ||
1142 | //arrange | 1151 | //arrange |
1143 | var scope = { | 1152 | var scope = { |
1144 | $broadcast: function() { }, | 1153 | $broadcast: function() { }, |
1145 | $watch: function() { } | 1154 | $watch: function() { } |
1146 | }; | 1155 | }; |
1147 | 1156 | ||
1148 | $controller('cobranzaController', { | 1157 | $controller('cobranzaController', { |
1149 | $scope: scope, | 1158 | $scope: scope, |
1150 | $timeout: $timeout, | 1159 | $timeout: $timeout, |
1151 | $uibModal: {}, | 1160 | $uibModal: {}, |
1152 | $location: $location, | 1161 | $location: $location, |
1153 | focaCrearCobranzaService: { | 1162 | focaCrearCobranzaService: { |
1154 | getCotizacionByIdMoneda: function() { | 1163 | getCotizacionByIdMoneda: function() { |
1155 | return { | 1164 | return { |
1156 | then: function() { } | 1165 | then: function() { } |
1157 | }; | 1166 | }; |
1158 | }, | 1167 | }, |
1159 | getBotonera: function() { }, | 1168 | getBotonera: function() { }, |
1160 | getNumeroRecibo: function() { | 1169 | getNumeroRecibo: function() { |
1161 | return { | 1170 | return { |
1162 | then: function() { } | 1171 | then: function() { } |
1163 | }; | 1172 | }; |
1164 | } | 1173 | } |
1165 | }, | 1174 | }, |
1166 | focaModalService: {}, | 1175 | focaModalService: {}, |
1167 | $filter: $filter, | 1176 | $filter: $filter, |
1168 | focaSeguimientoService: {}, | 1177 | focaSeguimientoService: {}, |
1169 | focaBotoneraLateralService: {}, | 1178 | focaBotoneraLateralService: {}, |
1170 | APP: {}, | 1179 | APP: {}, |
1171 | focaLoginService: {}, | 1180 | focaLoginService: {}, |
1172 | $localStorage: true | 1181 | $localStorage: true |
1173 | }); | 1182 | }); |
1174 | 1183 | ||
1175 | //act | 1184 | //act |
1176 | scope.salir(); | 1185 | scope.salir(); |
1177 | 1186 | ||
1178 | //assert | 1187 | //assert |
1179 | expect($location.url()).toEqual('/'); | 1188 | expect($location.url()).toEqual('/'); |
1180 | }); | 1189 | }); |
1181 | }); | 1190 | }); |
1182 | 1191 | ||
1183 | it('parsearATexto parsea correctamente', function() { | 1192 | it('parsearATexto parsea correctamente', function() { |
1184 | 1193 | ||
1185 | //arrange | 1194 | //arrange |
1186 | var scope = { | 1195 | var scope = { |
1187 | $broadcast: function() { }, | 1196 | $broadcast: function() { }, |
1188 | $watch: function() { } | 1197 | $watch: function() { } |
1189 | }; | 1198 | }; |
1190 | 1199 | ||
1191 | $controller('cobranzaController', { | 1200 | $controller('cobranzaController', { |
1192 | $scope: scope, | 1201 | $scope: scope, |
1193 | $timeout: $timeout, | 1202 | $timeout: $timeout, |
1194 | $uibModal: {}, | 1203 | $uibModal: {}, |
1195 | $location: {}, | 1204 | $location: {}, |
1196 | focaCrearCobranzaService: { | 1205 | focaCrearCobranzaService: { |
1197 | getCotizacionByIdMoneda: function() { | 1206 | getCotizacionByIdMoneda: function() { |
1198 | return { | 1207 | return { |
1199 | then: function() { } | 1208 | then: function() { } |
1200 | }; | 1209 | }; |
1201 | }, | 1210 | }, |
1202 | getBotonera: function() { }, | 1211 | getBotonera: function() { }, |
1203 | getNumeroRecibo: function() { | 1212 | getNumeroRecibo: function() { |
1204 | return { | 1213 | return { |
1205 | then: function() { } | 1214 | then: function() { } |
1206 | }; | 1215 | }; |
1207 | } | 1216 | } |
1208 | }, | 1217 | }, |
1209 | focaModalService: {}, | 1218 | focaModalService: {}, |
1210 | $filter: $filter, | 1219 | $filter: $filter, |
1211 | focaSeguimientoService: {}, | 1220 | focaSeguimientoService: {}, |
1212 | focaBotoneraLateralService: {}, | 1221 | focaBotoneraLateralService: {}, |
1213 | APP: {}, | 1222 | APP: {}, |
1214 | focaLoginService: {}, | 1223 | focaLoginService: {}, |
1215 | $localStorage: true | 1224 | $localStorage: true |
1216 | }); | 1225 | }); |
1217 | 1226 | ||
1218 | var parametro = { | 1227 | var parametro = { |
1219 | cantidad: '1', | 1228 | cantidad: '1', |
1220 | precio: '2' | 1229 | precio: '2' |
1221 | }; | 1230 | }; |
1222 | 1231 | ||
1223 | //act | 1232 | //act |
1224 | scope.parsearATexto(parametro); | 1233 | scope.parsearATexto(parametro); |
1225 | 1234 | ||
1226 | //assert | 1235 | //assert |
1227 | expect(typeof parametro.cantidad).toEqual('number'); | 1236 | expect(typeof parametro.cantidad).toEqual('number'); |
1228 | expect(typeof parametro.precio).toEqual('number'); | 1237 | expect(typeof parametro.precio).toEqual('number'); |
1229 | }); | 1238 | }); |
1230 | 1239 |
spec/serviceSpec.js
1 | describe('Servicios módulo crear cobranza', function() { | 1 | describe('Servicios módulo crear cobranza', function() { |
2 | 2 | ||
3 | beforeEach(function() { | 3 | beforeEach(function() { |
4 | 4 | ||
5 | module('focaCrearCobranza'); | 5 | module('focaCrearCobranza'); |
6 | 6 | ||
7 | inject(module(function($provide) { | 7 | inject(module(function($provide) { |
8 | $provide.value('API_ENDPOINT', { | 8 | $provide.value('API_ENDPOINT', { |
9 | URL: 'localhost' | 9 | URL: 'localhost' |
10 | }); | 10 | }); |
11 | })); | 11 | })); |
12 | }); | 12 | }); |
13 | 13 | ||
14 | describe('servicio focaCrearCobranzaService', function() { | 14 | describe('servicio focaCrearCobranzaService', function() { |
15 | 15 | ||
16 | var servicio; | 16 | var servicio; |
17 | var httpBackend; | 17 | var httpBackend; |
18 | 18 | ||
19 | beforeEach(function() { | 19 | beforeEach(function() { |
20 | inject(function($httpBackend, _focaCrearCobranzaService_) { | 20 | inject(function($httpBackend, _focaCrearCobranzaService_) { |
21 | httpBackend = $httpBackend; | 21 | httpBackend = $httpBackend; |
22 | servicio = _focaCrearCobranzaService_; | 22 | servicio = _focaCrearCobranzaService_; |
23 | }); | 23 | }); |
24 | }); | 24 | }); |
25 | 25 | ||
26 | it('existe el servicio focaCrearCobranzaService', function() { | 26 | it('existe el servicio focaCrearCobranzaService', function() { |
27 | 27 | ||
28 | //assert | 28 | //assert |
29 | expect(typeof servicio).toEqual('object'); | 29 | expect(typeof servicio).toEqual('object'); |
30 | }); | 30 | }); |
31 | 31 | ||
32 | it('getNumeroRecibo llama a ruta correcta', function() { | 32 | it('getNumeroRecibo llama a ruta correcta', function() { |
33 | 33 | ||
34 | //arrange | 34 | //arrange |
35 | var responseFake = 'responseFake'; | 35 | var responseFake = 'responseFake'; |
36 | var result; | 36 | var result; |
37 | 37 | ||
38 | httpBackend.expectGET('localhost/recibo/numero-siguiente').respond(responseFake); | 38 | httpBackend.expectGET('localhost/recibo/numero-siguiente').respond(responseFake); |
39 | 39 | ||
40 | //act | 40 | //act |
41 | servicio.getNumeroRecibo().then(function(data) { | 41 | servicio.getNumeroRecibo().then(function(data) { |
42 | result = data.data; | 42 | result = data.data; |
43 | }); | 43 | }); |
44 | httpBackend.flush(); | 44 | httpBackend.flush(); |
45 | 45 | ||
46 | //assert | 46 | //assert |
47 | expect(result).toEqual(responseFake); | 47 | expect(result).toEqual(responseFake); |
48 | }); | 48 | }); |
49 | 49 | ||
50 | it('getCotizacionByIdMoneda llama a ruta correcta', function() { | 50 | it('getCotizacionByIdMoneda llama a ruta correcta', function() { |
51 | 51 | ||
52 | //arrange | 52 | //arrange |
53 | var responseFake = 'responseFake'; | 53 | var responseFake = 'responseFake'; |
54 | var result; | 54 | var result; |
55 | var paramFake = 1; | 55 | var paramFake = 1; |
56 | 56 | ||
57 | httpBackend.expectGET('localhost/moneda/' + paramFake).respond(responseFake); | 57 | httpBackend.expectGET('localhost/moneda/' + paramFake).respond(responseFake); |
58 | 58 | ||
59 | //act | 59 | //act |
60 | servicio.getCotizacionByIdMoneda(paramFake).then(function(data) { | 60 | servicio.getCotizacionByIdMoneda(paramFake).then(function(data) { |
61 | result = data.data; | 61 | result = data.data; |
62 | }); | 62 | }); |
63 | httpBackend.flush(); | 63 | httpBackend.flush(); |
64 | 64 | ||
65 | //assert | 65 | //assert |
66 | expect(result).toEqual(responseFake); | 66 | expect(result).toEqual(responseFake); |
67 | }); | 67 | }); |
68 | 68 | ||
69 | it('guardarCobranza llama a ruta correcta', function() { | 69 | it('guardarCobranza llama a ruta correcta', function() { |
70 | 70 | ||
71 | //arrange | 71 | //arrange |
72 | var responseFake = 'responseFake'; | 72 | var responseFake = 'responseFake'; |
73 | var result; | 73 | var result; |
74 | var paramFake = 1; | 74 | var paramFake = 1; |
75 | 75 | ||
76 | httpBackend.expectPOST('localhost/recibo/guardar', paramFake).respond(responseFake); | 76 | httpBackend.expectPOST('localhost/recibo/guardar', paramFake).respond(responseFake); |
77 | 77 | ||
78 | //act | 78 | //act |
79 | servicio.guardarCobranza(paramFake).then(function(data) { | 79 | servicio.guardarCobranza(paramFake).then(function(data) { |
80 | result = data.data; | 80 | result = data.data; |
81 | }); | 81 | }); |
82 | httpBackend.flush(); | 82 | httpBackend.flush(); |
83 | 83 | ||
84 | //assert | 84 | //assert |
85 | expect(result).toEqual(responseFake); | 85 | expect(result).toEqual(responseFake); |
86 | }); | 86 | }); |
87 | 87 | ||
88 | it('getCobradorById llama a ruta correcta', function() { | 88 | it('getCobradorById llama a ruta correcta', function() { |
89 | 89 | ||
90 | //arrange | 90 | //arrange |
91 | var responseFake = 'responseFake'; | 91 | var responseFake = 'responseFake'; |
92 | var result; | 92 | var result; |
93 | var paramFake = 1; | 93 | var paramFake = 1; |
94 | 94 | ||
95 | httpBackend.expectGET('localhost/vendedor-cobrador/' + paramFake).respond(responseFake); | 95 | httpBackend.expectGET('localhost/vendedor-cobrador/' + paramFake).respond(responseFake); |
96 | 96 | ||
97 | //act | 97 | //act |
98 | servicio.getCobradorById(paramFake).then(function(data) { | 98 | servicio.getCobradorById(paramFake).then(function(data) { |
99 | result = data.data; | 99 | result = data.data; |
100 | }); | 100 | }); |
101 | httpBackend.flush(); | 101 | httpBackend.flush(); |
102 | 102 | ||
103 | //assert | 103 | //assert |
104 | expect(result).toEqual(responseFake); | 104 | expect(result).toEqual(responseFake); |
105 | }); | 105 | }); |
106 | 106 | ||
107 | it('enviarComprobantePorMail llama a ruta correcta', function() { | ||
108 | |||
109 | //arrange | ||
110 | var responseFake = 'responseFake'; | ||
111 | var result; | ||
112 | var paramFake = 1; | ||
113 | |||
114 | httpBackend.expectPOST('localhost/mail/comprobante', | ||
115 | {receiver: paramFake}).respond(responseFake); | ||
116 | |||
117 | //act | ||
118 | servicio.enviarComprobantePorMail(paramFake).then(function(data) { | ||
119 | result = data.data; | ||
120 | }); | ||
121 | httpBackend.flush(); | ||
122 | |||
123 | //assert | ||
124 | expect(result).toEqual(responseFake); | ||
125 | }); | ||
126 | |||
127 | it('actualizarEmail llama a ruta correcta', function() { | 107 | it('actualizarEmail llama a ruta correcta', function() { |
128 | 108 | ||
129 | //arrange | 109 | //arrange |
130 | var responseFake = 'responseFake'; | 110 | var responseFake = 'responseFake'; |
131 | var result; | 111 | var result; |
132 | var paramFake = 1; | 112 | var paramFake = 1; |
133 | 113 | ||
134 | httpBackend.expectPOST('localhost/cliente/update/email', | 114 | httpBackend.expectPOST('localhost/cliente/update/email', |
135 | {mail: paramFake}).respond(responseFake); | 115 | {mail: paramFake}).respond(responseFake); |
136 | 116 | ||
137 | //act | 117 | //act |
138 | servicio.actualizarEmail(paramFake).then(function(data) { | 118 | servicio.actualizarEmail(paramFake).then(function(data) { |
139 | result = data.data; | 119 | result = data.data; |
140 | }); | 120 | }); |
141 | httpBackend.flush(); | 121 | httpBackend.flush(); |
142 | 122 | ||
143 | //assert | 123 | //assert |
144 | expect(result).toEqual(responseFake); | 124 | expect(result).toEqual(responseFake); |
145 | }); | 125 | }); |
146 | }); | 126 | }); |
147 | 127 | ||
148 | }); | 128 | }); |
src/js/controller.js
1 | angular.module('focaCrearCobranza') .controller('cobranzaController', | 1 | angular.module('focaCrearCobranza') .controller('cobranzaController', |
2 | [ | 2 | [ |
3 | '$scope', '$timeout', '$uibModal', '$location', | 3 | '$scope', '$timeout', '$uibModal', '$location', |
4 | 'focaCrearCobranzaService', 'focaModalService', '$filter', 'focaSeguimientoService', | 4 | 'focaCrearCobranzaService', 'focaModalService', '$filter', 'focaSeguimientoService', |
5 | 'focaBotoneraLateralService', 'APP', 'focaLoginService', '$localStorage', | 5 | 'focaBotoneraLateralService', 'APP', 'focaLoginService', '$localStorage', |
6 | function($scope, $timeout, $uibModal, $location, focaCrearCobranzaService, | 6 | function($scope, $timeout, $uibModal, $location, focaCrearCobranzaService, |
7 | focaModalService, $filter, focaSeguimientoService, focaBotoneraLateralService, | 7 | focaModalService, $filter, focaSeguimientoService, focaBotoneraLateralService, |
8 | APP, loginService, $localStorage) | 8 | APP, loginService, $localStorage) |
9 | { | 9 | { |
10 | config(); | 10 | config(); |
11 | 11 | ||
12 | function config() { | 12 | function config() { |
13 | $scope.datepickerAbierto = false; | 13 | $scope.datepickerAbierto = false; |
14 | $scope.cobroDeuda = true; | 14 | $scope.cobroDeuda = true; |
15 | $scope.show = false; | 15 | $scope.show = false; |
16 | $scope.cargando = true; | 16 | $scope.cargando = true; |
17 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); | 17 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
18 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); | 18 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
19 | $scope.botonera = focaCrearCobranzaService.getBotonera(); | 19 | $scope.botonera = focaCrearCobranzaService.getBotonera(); |
20 | $scope.dateOptions = { | 20 | $scope.dateOptions = { |
21 | maxDate: new Date(), | 21 | maxDate: new Date(), |
22 | minDate: new Date(2010, 0, 1) | 22 | minDate: new Date(2010, 0, 1) |
23 | }; | 23 | }; |
24 | 24 | ||
25 | var monedaPorDefecto; | ||
26 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 25 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
27 | focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) { | 26 | focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) { |
28 | monedaPorDefecto = res.data[0]; | 27 | var moneda = res.data[0]; |
29 | 28 | moneda.cotizacion = moneda.cotizaciones[0]; | |
30 | $scope.cobranza.cotizacion = Object.assign( | 29 | $scope.cobranza.moneda = $scope.inicial.moneda = moneda; |
31 | {moneda: monedaPorDefecto}, monedaPorDefecto.cotizaciones[0] | 30 | $timeout(function() {getLSCobranza();}); |
32 | ); | ||
33 | $scope.inicial.cotizacion = $scope.cobranza.cotizacion; | ||
34 | |||
35 | }); | 31 | }); |
36 | 32 | ||
37 | $timeout(function() { | 33 | $timeout(function() { |
38 | focaBotoneraLateralService.showSalir(false); | 34 | focaBotoneraLateralService.showSalir(false); |
39 | focaBotoneraLateralService.showPausar(true); | 35 | focaBotoneraLateralService.showPausar(true); |
40 | focaBotoneraLateralService.showGuardar(true, $scope.crearCobranza); | 36 | focaBotoneraLateralService.showGuardar(true, $scope.crearCobranza); |
41 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 37 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
42 | }); | 38 | }); |
43 | 39 | ||
44 | if (APP === 'cobranza') { | 40 | if (APP === 'cobranza') { |
45 | $scope.idCobrador = loginService.getLoginData().vendedorCobrador; | 41 | $scope.idCobrador = loginService.getLoginData().vendedorCobrador; |
46 | } | 42 | } |
47 | 43 | ||
48 | init(); | 44 | init(); |
49 | $timeout(function() {getLSCobranza();}); | 45 | |
50 | } | 46 | } |
51 | 47 | ||
52 | function init() { | 48 | function init() { |
53 | $scope.$broadcast('cleanCabecera'); | 49 | $scope.$broadcast('cleanCabecera'); |
54 | $scope.cobranza = { | 50 | $scope.cobranza = { |
55 | fecha: new Date(), | 51 | FEC: new Date(), |
56 | cotizacion: {}, | 52 | moneda: {}, |
57 | facturas: [], | 53 | facturas: [], |
58 | cobros: [], | 54 | cobros: [], |
59 | cliente: {}, | 55 | cliente: {}, |
60 | cobrador: {} | 56 | cobrador: {} |
61 | }; | 57 | }; |
62 | if (APP === 'cobranza') { | 58 | if (APP === 'cobranza') { |
63 | focaCrearCobranzaService.getCobradorById($scope.idCobrador).then( | 59 | focaCrearCobranzaService.getCobradorById($scope.idCobrador).then( |
64 | function(res) { | 60 | function(res) { |
65 | var cobrador = res.data; | 61 | var cobrador = res.data; |
66 | 62 | ||
67 | $scope.$broadcast('addCabecera', { | 63 | $scope.$broadcast('addCabecera', { |
68 | label: 'Cobrador:', | 64 | label: 'Cobrador:', |
69 | valor: $filter('rellenarDigitos')(cobrador.NUM, 3) + ' - ' + | 65 | valor: $filter('rellenarDigitos')(cobrador.NUM, 3) + ' - ' + |
70 | cobrador.NOM | 66 | cobrador.NOM |
71 | }); | 67 | }); |
72 | 68 | ||
73 | $scope.cobranza.cobrador = cobrador; | 69 | $scope.cobranza.cobrador = cobrador; |
74 | $scope.inicial.cobranza.cobrador = $scope.cobranza.cobrador; | 70 | $scope.inicial.cobranza.cobrador = $scope.cobranza.cobrador; |
75 | } | 71 | } |
76 | ); | 72 | ); |
77 | } | 73 | } |
78 | 74 | ||
79 | $scope.inicial = angular.copy($scope.cobranza); | 75 | $scope.inicial = angular.copy($scope.cobranza); |
80 | 76 | ||
81 | focaCrearCobranzaService.getNumeroRecibo().then( | 77 | focaCrearCobranzaService.getNumeroRecibo().then( |
82 | function(res) { | 78 | function(res) { |
83 | $scope.puntoVenta = $filter('rellenarDigitos')( | 79 | $scope.puntoVenta = $filter('rellenarDigitos')( |
84 | res.data.sucursal, 4 | 80 | res.data.sucursal, 4 |
85 | ); | 81 | ); |
86 | 82 | ||
87 | $scope.comprobante = $filter('rellenarDigitos')( | 83 | $scope.comprobante = $filter('rellenarDigitos')( |
88 | res.data.numeroRecibo, 8 | 84 | res.data.numeroRecibo, 8 |
89 | ); | 85 | ); |
90 | }, | 86 | }, |
91 | function(err) { | 87 | function(err) { |
92 | focaModalService.alert( | 88 | focaModalService.alert( |
93 | 'La terminal no esta configurada correctamente' | 89 | 'La terminal no esta configurada correctamente' |
94 | ); | 90 | ); |
95 | console.info(err); | 91 | console.info(err); |
96 | } | 92 | } |
97 | ); | 93 | ); |
98 | } | 94 | } |
99 | 95 | ||
100 | $scope.$watch('cobranza', function(newValue) { | 96 | $scope.$watch('cobranza', function(newValue) { |
101 | focaBotoneraLateralService.setPausarData({ | 97 | focaBotoneraLateralService.setPausarData({ |
102 | label: 'cobranza', | 98 | label: 'cobranza', |
103 | val: newValue | 99 | val: newValue |
104 | }); | 100 | }); |
105 | }, true); | 101 | }, true); |
106 | 102 | ||
107 | $scope.crearCobranza = function() { | 103 | $scope.crearCobranza = function() { |
108 | if (!$scope.cobranza.cliente.COD) { | 104 | if (!$scope.cobranza.cliente.COD) { |
109 | focaModalService.alert('Ingrese Cliente'); | 105 | focaModalService.alert('Ingrese Cliente'); |
110 | return; | 106 | return; |
111 | } | 107 | } |
112 | if (!$scope.cobranza.cobrador.NUM) { | 108 | if (!$scope.cobranza.cobrador.NUM) { |
113 | focaModalService.alert('Ingrese Cobrador'); | 109 | focaModalService.alert('Ingrese Cobrador'); |
114 | return; | 110 | return; |
115 | } | 111 | } |
116 | if ($scope.cobranza.facturas.length < 1) { | 112 | if ($scope.cobranza.facturas.length < 1) { |
117 | focaModalService.alert('Ingrese al menos una factura'); | 113 | focaModalService.alert('Ingrese al menos una factura'); |
118 | return; | 114 | return; |
119 | } | 115 | } |
120 | if ($scope.getTotalCobrado() + $scope.getTotalDeuda() !== 0) { | 116 | if ($scope.getTotalCobrado() + $scope.getTotalDeuda() !== 0) { |
121 | focaModalService.alert('La diferencia debe ser ' + | 117 | focaModalService.alert('La diferencia debe ser ' + |
122 | $scope.cobranza.cotizacion.moneda.SIMBOLO + '0,00'); | 118 | $scope.cobranza.moneda.SIMBOLO + '0,00'); |
123 | return; | 119 | return; |
124 | } | 120 | } |
125 | |||
126 | var cobranza = {}; | 121 | var cobranza = {}; |
127 | var cheques = []; | 122 | var cheques = []; |
128 | var cuerpos = []; | 123 | var cuerpos = []; |
129 | var imgs = []; | 124 | var imgs = []; |
130 | var observacion; | 125 | var observacion; |
131 | //TODO: habilitar edición | 126 | //TODO: habilitar edición |
132 | $scope.editando = false; | 127 | $scope.editando = false; |
133 | focaBotoneraLateralService.startGuardar(); | 128 | focaBotoneraLateralService.startGuardar(); |
134 | $scope.saveLoading = true; | 129 | $scope.saveLoading = true; |
135 | for(var i = 0; i < $scope.cobranza.facturas.length; i++) { | 130 | for(var i = 0; i < $scope.cobranza.facturas.length; i++) { |
136 | var cuerpoFactura = { | 131 | var cuerpoFactura = { |
137 | CYV: 'V', | 132 | CYV: 'V', |
138 | TIP: 'C', | 133 | TIP: 'C', |
139 | TCO: 'RC', | 134 | TCO: 'RC', |
140 | PVE: $scope.puntoVenta, | 135 | PVE: $scope.puntoVenta, |
141 | NCO: $scope.comprobante, | 136 | NCO: $scope.comprobante, |
142 | LOP: 'L', | 137 | LOP: 'L', |
143 | TIL: $scope.cobranza.facturas[i].TCO, | 138 | TIL: $scope.cobranza.facturas[i].TCO, |
144 | COM: $scope.cobranza.facturas[i].numeroFactura + '-' + | 139 | COM: $scope.cobranza.facturas[i].COM + '-' + |
145 | $filter('rellenarDigitos')($scope.cobranza.facturas[i].NCU,2), | 140 | $filter('rellenarDigitos')($scope.cobranza.facturas[i].NCU,2), |
146 | FEC: new Date($scope.cobranza.fecha) | 141 | FEC: new Date($scope.cobranza.FEC) |
147 | .toISOString().slice(0, 19).replace('T', ' '), | 142 | .toISOString().slice(0, 19).replace('T', ' '), |
148 | IMP: Math.abs($scope.cobranza.facturas[i].IPA), | 143 | IMP: Math.abs($scope.cobranza.facturas[i].IMP || |
144 | $scope.cobranza.facturas[i].IPA), | ||
149 | RES: 0,//caja de tesorería | 145 | RES: 0,//caja de tesorería |
150 | SUBM: 0, | 146 | SUBM: 0, |
151 | NCU: $scope.cobranza.facturas[i].NCU | 147 | NCU: $scope.cobranza.facturas[i].NCU |
152 | }; | 148 | }; |
153 | cuerpos.push(cuerpoFactura); | 149 | cuerpos.push(cuerpoFactura); |
154 | 150 | ||
155 | } | 151 | } |
156 | 152 | ||
157 | for (var j = 0; j < $scope.cobranza.cobros.length; j++) { | 153 | for (var j = 0; j < $scope.cobranza.cobros.length; j++) { |
158 | 154 | ||
159 | var efectivo = $scope.cobranza.cobros[j].tipo === 'Efectivo'; | 155 | var efectivo = $scope.cobranza.cobros[j].tipo === 'Efectivo'; |
160 | var cuerpoCobros = { | 156 | var cuerpoCobros = { |
161 | CYV: 'V', | 157 | CYV: 'V', |
162 | TIP: 'C', | 158 | TIP: 'C', |
163 | TCO: 'RC', | 159 | TCO: 'RC', |
164 | PVE: $scope.puntoVenta, | 160 | PVE: $scope.puntoVenta, |
165 | NCO: $scope.comprobante, | 161 | NCO: $scope.comprobante, |
166 | LOP: 'P', | 162 | LOP: 'P', |
167 | TIL: $scope.cobranza.cobros[j].til, | 163 | TIL: $scope.cobranza.cobros[j].TIL, |
168 | COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : $scope.cobranza.cobros[j].tipo, | 164 | COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : $scope.cobranza.cobros[j].COM, |
169 | FEC: !$scope.cobranza.cobros[j].fechaPresentacion ? | 165 | FEC: !$scope.cobranza.cobros[j].fechaPresentacion ? |
170 | new Date($scope.cobranza.cobros[j].fecha) | 166 | new Date($scope.cobranza.cobros[j].FEC) |
171 | .toISOString().slice(0, 19).replace('T', ' ') : | 167 | .toISOString().slice(0, 19).replace('T', ' ') : |
172 | new Date($scope.cobranza.cobros[j].fechaPresentacion) | 168 | new Date($scope.cobranza.cobros[j].fechaPresentacion) |
173 | .toISOString().slice(0, 19).replace('T', ' '), | 169 | .toISOString().slice(0, 19).replace('T', ' '), |
174 | IMP: Math.abs($scope.cobranza.cobros[j].importe), | 170 | IMP: Math.abs($scope.cobranza.cobros[j].IMP), |
175 | RES: 0,//caja de tesorería | 171 | RES: 0,//caja de tesorería |
176 | SUBM: 0 | 172 | SUBM: 0 |
177 | }; | 173 | }; |
178 | cuerpos.push(cuerpoCobros); | 174 | cuerpos.push(cuerpoCobros); |
179 | 175 | ||
180 | if ($scope.cobranza.cobros[j].observacion) | 176 | if ($scope.cobranza.cobros[j].observacion) |
181 | observacion = $scope.cobranza.cobros[j].observacion; | 177 | observacion = $scope.cobranza.cobros[j].observacion; |
182 | 178 | ||
183 | if ($scope.cobranza.cobros[j].banco) { | 179 | if ($scope.cobranza.cobros[j].banco) { |
184 | var cheque = { | 180 | var cheque = { |
185 | BCO: $scope.cobranza.cobros[j].banco.ID, | 181 | BCO: $scope.cobranza.cobros[j].banco.ID, |
186 | NUM: $scope.comprobante, | 182 | NUM: $scope.comprobante, |
187 | FEP: new Date($scope.cobranza.cobros[j].fechaPresentacion) | 183 | FEP: new Date($scope.cobranza.cobros[j].fechaPresentacion) |
188 | .toISOString().slice(0, 19).replace('T', ' '), | 184 | .toISOString().slice(0, 19).replace('T', ' '), |
189 | FEE: new Date($scope.cobranza.cobros[j].fechaEmision) | 185 | FEE: new Date($scope.cobranza.cobros[j].fechaEmision) |
190 | .toISOString().slice(0, 19).replace('T', ' '), | 186 | .toISOString().slice(0, 19).replace('T', ' '), |
191 | LUG: $scope.cobranza.cobros[j].localidad.NOMBRE, | 187 | LUG: $scope.cobranza.cobros[j].localidad.NOMBRE, |
192 | IMP: $scope.cobranza.cobros[j].importe, | 188 | IMP: $scope.cobranza.cobros[j].importe, |
193 | LIB: $scope.cobranza.cobros[j].librador, | 189 | LIB: $scope.cobranza.cobros[j].librador, |
194 | EST: 'C',//'D' depositado, 'E' entregado, 'C' en cartera | 190 | EST: 'C',//'D' depositado, 'E' entregado, 'C' en cartera |
195 | PCI: $scope.cobranza.cobros[j].provincia.ID, | 191 | PCI: $scope.cobranza.cobros[j].provincia.ID, |
196 | LPLA: 0, | 192 | LPLA: 0, |
197 | PLA: 0, | 193 | PLA: 0, |
198 | VEN: $scope.cobranza.cobrador.id,//Id vendedor | 194 | VEN: $scope.cobranza.cobrador.id,//Id vendedor |
199 | CCLIE: $scope.cobranza.cliente.COD,//Id cliente | 195 | CCLIE: $scope.cobranza.cliente.COD,//Id cliente |
200 | REN: 0, | 196 | REN: 0, |
201 | PVEC: $scope.puntoVenta, | 197 | PVEC: $scope.puntoVenta, |
202 | NCOC: $scope.comprobante, | 198 | NCOC: $scope.comprobante, |
203 | OBSE: $scope.cobranza.cobros[j].observaciones, | 199 | OBSE: $scope.cobranza.cobros[j].observaciones, |
204 | LUV: 0, | 200 | LUV: 0, |
205 | ORI: 've', | 201 | ORI: 've', |
206 | FER: '', | 202 | FER: '', |
207 | BIMP: 0, | 203 | BIMP: 0, |
208 | COMP: 'C ' +'RC ' + $scope.puntoVenta + '-' + $scope.comprobante, | 204 | COMP: 'C ' +'RC ' + $scope.puntoVenta + '-' + $scope.comprobante, |
209 | VAL_E: '',//Cuando egresa por ingresos y egresos en el numero de egreso | 205 | VAL_E: '',//Cuando egresa por ingresos y egresos en el numero de egreso |
210 | VAL_I: '',//Cuando Ingresa por ingresos y egresos en el numero ingreso | 206 | VAL_I: '',//Cuando Ingresa por ingresos y egresos en el numero ingreso |
211 | REC_CAJ: 'D', | 207 | REC_CAJ: 'D', |
212 | TIPO_C: 0,//?? | 208 | TIPO_C: 0,//?? |
213 | SALDO_CAJ: 'S', | 209 | SALDO_CAJ: 'S', |
214 | FECHA_INGRESO: new Date($scope.cobranza.fecha) | 210 | FECHA_INGRESO: new Date($scope.cobranza.FEC) |
215 | .toISOString().slice(0, 19).replace('T', ' '), | 211 | .toISOString().slice(0, 19).replace('T', ' '), |
216 | Vendedor_valor: 0, | 212 | Vendedor_valor: 0, |
217 | FAMILIA: 0, | 213 | FAMILIA: 0, |
218 | CUIT_LIB: '', | 214 | CUIT_LIB: '', |
219 | COD_LUG: $scope.cobranza.cobros[j].localidad.ID,//código lugar | 215 | COD_LUG: $scope.cobranza.cobros[j].localidad.ID,//código lugar |
220 | SEN: '', | 216 | SEN: '', |
221 | NRC: 0, | 217 | NRC: 0, |
222 | COD_LARGO: '', | 218 | COD_LARGO: '', |
223 | VN: 0, | 219 | VN: 0, |
224 | ID_LECTOR: 0, | 220 | ID_LECTOR: 0, |
225 | NATHB: '' | 221 | NATHB: '' |
226 | }; | 222 | }; |
227 | cheques.push(cheque); | 223 | cheques.push(cheque); |
228 | } | 224 | } |
229 | if ($scope.cobranza.cobros[j].imgs) imgs = $scope.cobranza.cobros[j].imgs; | 225 | if ($scope.cobranza.cobros[j].imgs) imgs = $scope.cobranza.cobros[j].imgs; |
230 | 226 | ||
231 | } | 227 | } |
232 | 228 | ||
233 | cobranza = { | 229 | cobranza = { |
234 | recibo: { | 230 | recibo: { |
235 | CYV: 'V', | 231 | CYV: 'V', |
236 | TIP: 'C', | 232 | TIP: 'C', |
237 | TCO: 'RC', | 233 | TCO: 'RC', |
238 | PVE: $scope.puntoVenta, //Sucursar, punto de venta | 234 | PVE: $scope.puntoVenta, //Sucursar, punto de venta |
239 | NCO: $scope.comprobante, //Numero de comprobante | 235 | NCO: $scope.comprobante, //Numero de comprobante |
240 | FEC: new Date($scope.cobranza.fecha) | 236 | FEC: new Date($scope.cobranza.FEC) |
241 | .toISOString().slice(0, 19).replace('T', ' '), | 237 | .toISOString().slice(0, 19).replace('T', ' '), |
242 | CLI: $scope.cobranza.cliente.COD, | 238 | CLI: $scope.cobranza.cliente.COD, |
243 | ATO: 0, //número de asiento | 239 | ATO: 0, //número de asiento |
244 | CFE: $scope.cobranza.cobrador.NOM, | 240 | CFE: $scope.cobranza.cobrador.NOM, |
245 | PLA: '',//Numero de planilla, sin uso | 241 | PLA: '',//Numero de planilla, sin uso |
246 | ID_MONEDA: $scope.cobranza.cotizacion.moneda.ID, | 242 | ID_MONEDA: $scope.cobranza.moneda.ID, |
247 | COTIZACION: $scope.cobranza.cotizacion.VENDEDOR, | 243 | COTIZACION: $scope.cobranza.moneda.cotizacion.VENDEDOR, |
248 | idCobrador: $scope.cobranza.cobrador.id | 244 | idCobrador: $scope.cobranza.cobrador.id |
249 | }, | 245 | }, |
250 | cuerpo: cuerpos, | 246 | cuerpo: cuerpos, |
251 | cheques: cheques, | 247 | cheques: cheques, |
252 | acobypag: { | 248 | acobypag: { |
253 | CYV: 'V', | 249 | CYV: 'V', |
254 | COD: $scope.cobranza.cliente.COD, | 250 | COD: $scope.cobranza.cliente.COD, |
255 | FEP: new Date($scope.cobranza.fecha) | 251 | FEP: new Date($scope.cobranza.FEC) |
256 | .toISOString().slice(0, 19).replace('T', ' '), | 252 | .toISOString().slice(0, 19).replace('T', ' '), |
257 | TIP: 'C', | 253 | TIP: 'C', |
258 | TCO: 'RC', | 254 | TCO: 'RC', |
259 | SUC: $scope.puntoVenta, | 255 | SUC: $scope.puntoVenta, |
260 | NCO: $scope.comprobante, | 256 | NCO: $scope.comprobante, |
261 | IPA: $scope.getTotalCobrado(), | 257 | IPA: $scope.getTotalCobrado(), |
262 | SAL: '',//?? | 258 | SAL: '',//?? |
263 | TCA: 1, | 259 | TCA: 1, |
264 | ZONA: 1, | 260 | ZONA: 1, |
265 | FPA: 2,//Forma de pago | 261 | FPA: 2,//Forma de pago |
266 | REC: 0, | 262 | REC: 0, |
267 | REP: 0, | 263 | REP: 0, |
268 | FER: null, | 264 | FER: null, |
269 | REM: 0, | 265 | REM: 0, |
270 | FRE: null,//?? | 266 | FRE: null,//?? |
271 | PRO: 'N', | 267 | PRO: 'N', |
272 | FEV: new Date($scope.cobranza.fecha) | 268 | FEV: new Date($scope.cobranza.FEC) |
273 | .toISOString().slice(0, 19).replace('T', ' ') | 269 | .toISOString().slice(0, 19).replace('T', ' ') |
274 | }, | 270 | }, |
275 | datosCobrador: { | 271 | datosCobrador: { |
276 | COD: $scope.cobranza.cobrador.NUM, | 272 | COD: $scope.cobranza.cobrador.NUM, |
277 | PVE: $scope.puntoVenta, | 273 | PVE: $scope.puntoVenta, |
278 | NUM: $scope.comprobante, | 274 | NUM: $scope.comprobante, |
279 | EST: 'C', | 275 | EST: 'C', |
280 | OBS: 'RC: ' + $scope.comprobante + '-' + | 276 | OBS: 'RC: ' + $scope.comprobante + '-' + |
281 | new Date($scope.cobranza.fecha).toLocaleDateString(), | 277 | new Date($scope.cobranza.FEC).toLocaleDateString(), |
282 | DAT1: 'C', | 278 | DAT1: 'C', |
283 | CLI: $scope.cobranza.cliente.COD | 279 | CLI: $scope.cobranza.cliente.COD |
284 | }, | 280 | }, |
285 | cliente: $scope.cobranza.cliente, | 281 | cliente: $scope.cobranza.cliente, |
286 | imgs: imgs, | 282 | imgs: imgs, |
287 | observacion: observacion | 283 | observacion: observacion |
288 | }; | 284 | }; |
289 | //COPIO cobranzaMail Y A cobranza LE ELIMINO EL VALOR NCU DE LOS CUERPOS | 285 | //COPIO cobranzaMail Y A cobranza LE ELIMINO EL VALOR NCU DE LOS CUERPOS |
290 | var cobranzaMail = angular.copy(cobranza); | 286 | var cobranzaMail = angular.copy(cobranza); |
291 | cobranza.cuerpo = cobranza.cuerpo.map(function(c) { | 287 | cobranza.cuerpo = cobranza.cuerpo.map(function(c) { |
292 | if (c.NCU) delete c.NCU; | 288 | if (c.NCU) delete c.NCU; |
293 | return c; | 289 | return c; |
294 | }); | 290 | }); |
295 | 291 | ||
296 | focaCrearCobranzaService | 292 | focaCrearCobranzaService |
297 | .guardarCobranza(cobranza) | 293 | .guardarCobranza(cobranza) |
298 | .then( | 294 | .then( |
299 | function(result) { | 295 | function(result) { |
300 | var cliente = angular.copy($scope.cobranza.cliente); | ||
301 | focaBotoneraLateralService.endGuardar(true); | 296 | focaBotoneraLateralService.endGuardar(true); |
302 | $scope.saveLoading = false; | 297 | $scope.saveLoading = false; |
303 | 298 | ||
304 | focaModalService | 299 | enviarMail(cobranzaMail); |
305 | .prompt({ | ||
306 | titulo: 'Ingrese los emails separados por' + | ||
307 | ' coma para enviar comprobante', | ||
308 | value: cliente.MAIL, | ||
309 | email: true | ||
310 | }) | ||
311 | .then(function(res) { | ||
312 | return Promise.all([ | ||
313 | focaCrearCobranzaService | ||
314 | .enviarComprobantePorMail(res, cobranzaMail), | ||
315 | focaCrearCobranzaService | ||
316 | .actualizarEmail(res, cliente.COD) | ||
317 | ]); | ||
318 | }) | ||
319 | .then(function() { | ||
320 | focaModalService.alert('Mensaje enviado correctamente'); | ||
321 | }); | ||
322 | 300 | ||
323 | focaSeguimientoService.guardarPosicion( | 301 | focaSeguimientoService.guardarPosicion( |
324 | 'Cobranza', | 302 | 'Cobranza', |
325 | result.data, | 303 | result.data, |
326 | '' | 304 | '' |
327 | ); | 305 | ); |
328 | 306 | ||
329 | init(); | 307 | init(); |
330 | }, function(error) { | 308 | }, function(error) { |
331 | focaModalService.alert('Hubo un problema al cargar la cobranza'); | 309 | focaModalService.alert('Hubo un problema al cargar la cobranza'); |
332 | focaBotoneraLateralService.endGuardar(); | 310 | focaBotoneraLateralService.endGuardar(); |
333 | $scope.saveLoading = false; | 311 | $scope.saveLoading = false; |
334 | console.info(error); | 312 | console.info(error); |
335 | } | 313 | } |
336 | ); | 314 | ); |
337 | }; | 315 | }; |
338 | 316 | ||
339 | $scope.seleccionarCobros = function() { | 317 | $scope.seleccionarCobros = function() { |
340 | $scope.cobroDeuda = false; | 318 | $scope.cobroDeuda = false; |
341 | }; | 319 | }; |
342 | 320 | ||
343 | $scope.seleccionarComprobantes = function() { | 321 | $scope.seleccionarComprobantes = function() { |
344 | $scope.cobroDeuda = true; | 322 | $scope.cobroDeuda = true; |
345 | }; | 323 | }; |
346 | 324 | ||
347 | $scope.seleccionarCobranza = function() { | 325 | $scope.seleccionarCobranza = function() { |
348 | 326 | ||
349 | var modalInstance = $uibModal.open( | 327 | var modalInstance = $uibModal.open( |
350 | { | 328 | { |
351 | ariaLabelledBy: 'Busqueda de Cobranzas', | 329 | ariaLabelledBy: 'Busqueda de Cobranzas', |
352 | templateUrl: 'foca-modal-cobranza.html', | 330 | templateUrl: 'foca-modal-cobranza.html', |
353 | controller: 'focaModalCobranzaController', | 331 | controller: 'focaModalCobranzaController', |
354 | size: 'lg' | 332 | size: 'lg' |
355 | } | 333 | } |
356 | ); | 334 | ); |
357 | modalInstance.result.then(setearCobranza); | 335 | modalInstance.result.then(function(cobranza) { |
336 | cobranza.moneda.cotizacion = cobranza.moneda.cotizaciones[0]; | ||
337 | setearCobranza(cobranza); | ||
338 | }); | ||
358 | }; | 339 | }; |
359 | 340 | ||
360 | $scope.seleccionarResumenDeCuenta = function() { | 341 | $scope.seleccionarResumenDeCuenta = function() { |
361 | if (!$scope.cobranza.cliente.COD) { | 342 | if (!$scope.cobranza.cliente.COD) { |
362 | focaModalService.alert('Seleccione primero un cliente'); | 343 | focaModalService.alert('Seleccione primero un cliente'); |
363 | return; | 344 | return; |
364 | } | 345 | } |
365 | var modalInstance = $uibModal.open( | 346 | var modalInstance = $uibModal.open( |
366 | { | 347 | { |
367 | ariaLabelledBy: 'Resumen de cuentas', | 348 | ariaLabelledBy: 'Resumen de cuentas', |
368 | templateUrl: 'modal-resumen-cuenta.html', | 349 | templateUrl: 'modal-resumen-cuenta.html', |
369 | controller: 'focaModalResumenCuentaController', | 350 | controller: 'focaModalResumenCuentaController', |
370 | resolve: { | 351 | resolve: { |
371 | idCliente: function() { return $scope.cobranza.cliente.COD; } | 352 | cliente: function() { return $scope.cobranza.cliente; } |
372 | }, | 353 | }, |
373 | size: 'lg' | 354 | size: 'lg' |
374 | } | 355 | } |
375 | ); | 356 | ); |
376 | modalInstance.result.then( | 357 | modalInstance.result.then( |
377 | function(cliente) { | 358 | function(cliente) { |
378 | $scope.abrirModalDomicilios(cliente); | 359 | $scope.abrirModalDomicilios(cliente); |
379 | $scope.cliente = cliente; | 360 | $scope.cliente = cliente; |
380 | }, function() {} | 361 | }, function() {} |
381 | ); | 362 | ); |
382 | }; | 363 | }; |
383 | 364 | ||
384 | $scope.seleccionarCliente = function() { | 365 | $scope.seleccionarCliente = function() { |
385 | $scope.seleccionarCobrador(function() { | 366 | $scope.seleccionarCobrador(function() { |
386 | var modalInstance = $uibModal.open( | 367 | var modalInstance = $uibModal.open( |
387 | { | 368 | { |
388 | ariaLabelledBy: 'Busqueda de Cliente', | 369 | ariaLabelledBy: 'Busqueda de Cliente', |
389 | templateUrl: 'foca-busqueda-cliente-modal.html', | 370 | templateUrl: 'foca-busqueda-cliente-modal.html', |
390 | controller: 'focaBusquedaClienteModalController', | 371 | controller: 'focaBusquedaClienteModalController', |
391 | resolve: { | 372 | resolve: { |
392 | vendedor: function() { return null; }, | 373 | vendedor: function() { return null; }, |
393 | cobrador: function() { return $scope.cobranza.cobrador; } | 374 | cobrador: function() { return $scope.cobranza.cobrador; } |
394 | }, | 375 | }, |
395 | size: 'lg' | 376 | size: 'lg' |
396 | } | 377 | } |
397 | ); | 378 | ); |
398 | modalInstance.result.then( | 379 | modalInstance.result.then( |
399 | function(cliente) { | 380 | function(cliente) { |
400 | var clienteMayus = { | 381 | var clienteMayus = { |
401 | COD: cliente.cod, | 382 | COD: cliente.cod, |
402 | NOM: cliente.nom, | 383 | NOM: cliente.nom, |
403 | CUIT: cliente.cuit | 384 | CUIT: cliente.cuit, |
385 | MAIL: cliente.mail | ||
404 | }; | 386 | }; |
405 | 387 | ||
406 | $scope.$broadcast('addCabecera', { | 388 | $scope.$broadcast('addCabecera', { |
407 | label: 'Cliente:', | 389 | label: 'Cliente:', |
408 | valor: $filter('rellenarDigitos')(clienteMayus.COD, 5) + ' - ' + | 390 | valor: $filter('rellenarDigitos')(clienteMayus.COD, 5) + ' - ' + |
409 | clienteMayus.NOM | 391 | clienteMayus.NOM |
410 | }); | 392 | }); |
411 | $scope.cobranza.cliente = clienteMayus; | 393 | $scope.cobranza.cliente = clienteMayus; |
412 | $scope.cobranza.facturas = []; | 394 | $scope.cobranza.facturas = []; |
413 | }, function() { | 395 | }, function() { |
414 | if (APP !== 'cobranza') $scope.seleccionarCliente(); | 396 | if (APP !== 'cobranza') $scope.seleccionarCliente(); |
415 | } | 397 | } |
416 | ); | 398 | ); |
417 | }); | 399 | }); |
418 | }; | 400 | }; |
419 | 401 | ||
420 | $scope.seleccionarCobrador = function(callback) { | 402 | $scope.seleccionarCobrador = function(callback) { |
421 | 403 | ||
422 | if (APP === 'cobranza') { | 404 | if (APP === 'cobranza') { |
423 | callback(); | 405 | callback(); |
424 | return; | 406 | return; |
425 | } | 407 | } |
426 | 408 | ||
427 | var parametrosModal = { | 409 | var parametrosModal = { |
428 | query: '/cobrador', | 410 | query: '/cobrador', |
429 | columnas: [ | 411 | columnas: [ |
430 | { | 412 | { |
431 | propiedad: 'NUM', | 413 | propiedad: 'NUM', |
432 | nombre: 'Codigo', | 414 | nombre: 'Codigo', |
433 | filtro: { | 415 | filtro: { |
434 | nombre: 'rellenarDigitos', | 416 | nombre: 'rellenarDigitos', |
435 | parametro: 3 | 417 | parametro: 3 |
436 | } | 418 | } |
437 | }, | 419 | }, |
438 | { | 420 | { |
439 | propiedad: 'NOM', | 421 | propiedad: 'NOM', |
440 | nombre: 'Nombre' | 422 | nombre: 'Nombre' |
441 | } | 423 | } |
442 | ], | 424 | ], |
443 | titulo:'Búsqueda de cobradores' | 425 | titulo:'Búsqueda de cobradores' |
444 | }; | 426 | }; |
445 | focaModalService.modal(parametrosModal).then( | 427 | focaModalService.modal(parametrosModal).then( |
446 | function(cobrador) { | 428 | function(cobrador) { |
447 | $scope.$broadcast('addCabecera', { | 429 | $scope.$broadcast('addCabecera', { |
448 | label: 'Cobrador:', | 430 | label: 'Cobrador:', |
449 | valor: $filter('rellenarDigitos')(cobrador.NUM, 3) + ' - ' + | 431 | valor: $filter('rellenarDigitos')(cobrador.NUM, 3) + ' - ' + |
450 | cobrador.NOM | 432 | cobrador.NOM |
451 | }); | 433 | }); |
452 | $scope.cobranza.cobrador = cobrador; | 434 | $scope.cobranza.cobrador = cobrador; |
453 | 435 | ||
454 | //ELIMINO CLIENTE | 436 | //ELIMINO CLIENTE |
455 | $scope.$broadcast('removeCabecera', 'Cliente:'); | 437 | $scope.$broadcast('removeCabecera', 'Cliente:'); |
456 | $scope.cobranza.cliente = {}; | 438 | $scope.cobranza.cliente = {}; |
457 | 439 | ||
458 | callback(); | 440 | callback(); |
459 | }, function() {} | 441 | }, function() {} |
460 | ); | 442 | ); |
461 | }; | 443 | }; |
462 | 444 | ||
463 | $scope.seleccionarFactura = function() { | 445 | $scope.seleccionarFactura = function() { |
464 | if (!$scope.cobranza.cliente.COD) { | 446 | if (!$scope.cobranza.cliente.COD) { |
465 | focaModalService.alert('Seleccione primero un cliente'); | 447 | focaModalService.alert('Seleccione primero un cliente'); |
466 | return; | 448 | return; |
467 | } | 449 | } |
468 | var modalInstance = $uibModal.open( | 450 | var modalInstance = $uibModal.open( |
469 | { | 451 | { |
470 | ariaLabelledBy: 'Busqueda de Facturas', | 452 | ariaLabelledBy: 'Busqueda de Facturas', |
471 | templateUrl: 'foca-modal-factura.html', | 453 | templateUrl: 'foca-modal-factura.html', |
472 | controller: 'focaModalFacturaController', | 454 | controller: 'focaModalFacturaController', |
473 | size: 'lg', | 455 | size: 'lg', |
474 | resolve: { | 456 | resolve: { |
475 | parametrosFactura: function() { | 457 | parametrosFactura: function() { |
476 | return { | 458 | return { |
477 | cliente: $scope.cobranza.cliente, | 459 | cliente: $scope.cobranza.cliente, |
478 | simbolo: $scope.cobranza.cotizacion.moneda.SIMBOLO, | 460 | simbolo: $scope.cobranza.moneda.SIMBOLO, |
479 | cotizacion: $scope.cobranza.cotizacion.VENDEDOR, | 461 | cotizacion: $scope.cobranza.moneda, |
480 | moneda: $scope.cobranza.cotizacion.moneda.ID | 462 | moneda: $scope.cobranza.moneda.ID |
481 | }; | 463 | }; |
482 | } | 464 | } |
483 | } | 465 | } |
484 | } | 466 | } |
485 | ); | 467 | ); |
486 | modalInstance.result.then( | 468 | modalInstance.result.then( |
487 | function(facturas) { | 469 | function(facturas) { |
488 | var facturasResult = []; | 470 | var facturasResult = []; |
489 | //AGREGO A FACTURASRESULT LAS FACTURAS QUE NO HAN SIDO SELECCIONADAS | 471 | //AGREGO A FACTURASRESULT LAS FACTURAS QUE NO HAN SIDO SELECCIONADAS |
490 | facturas.forEach(function(factura) { | 472 | facturas.forEach(function(factura) { |
491 | var existe = $scope.cobranza.facturas.filter(function(e) { | 473 | var existe = $scope.cobranza.facturas.filter(function(e) { |
492 | return angular.equals(factura, e); | 474 | return angular.equals(factura, e); |
493 | }); | 475 | }); |
494 | 476 | ||
495 | if (!existe.length) facturasResult.push(factura); | 477 | if (!existe.length) facturasResult.push(factura); |
496 | }); | 478 | }); |
497 | 479 | ||
498 | $scope.cobranza.facturas = $scope.cobranza.facturas.concat(facturasResult); | 480 | $scope.cobranza.facturas = $scope.cobranza.facturas.concat(facturasResult); |
499 | }, function() { } | 481 | }, function() { } |
500 | ); | 482 | ); |
501 | }; | 483 | }; |
502 | 484 | ||
503 | $scope.seleccionarCheque = function() { | 485 | $scope.seleccionarCheque = function(cheque) { |
486 | |||
487 | var parametros; | ||
488 | |||
489 | if(!cheque) { | ||
490 | parametros = { | ||
491 | importe: getSugerido(), | ||
492 | esNuevo : true | ||
493 | }; | ||
494 | } else { | ||
495 | parametros = cheque; | ||
496 | parametros.importe = cheque.IMP; | ||
497 | } | ||
498 | |||
504 | var modalInstance = $uibModal.open( | 499 | var modalInstance = $uibModal.open( |
505 | { | 500 | { |
506 | ariaLabelledBy: 'Carga de cheques', | 501 | ariaLabelledBy: 'Carga de cheques', |
507 | templateUrl: 'modal-cheque.html', | 502 | templateUrl: 'modal-cheque.html', |
508 | controller: 'focaModalChequeController', | 503 | controller: 'focaModalChequeController', |
509 | size: 'lg', | 504 | size: 'lg', |
510 | resolve: { | 505 | resolve: { |
511 | sugerido: function() { | 506 | cheque: function() { |
512 | var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); | 507 | return parametros; |
513 | return sugerido < 0 ? sugerido : null; | ||
514 | } | 508 | } |
515 | } | 509 | } |
516 | } | 510 | } |
517 | ); | 511 | ); |
518 | modalInstance.result.then( | 512 | modalInstance.result.then( |
519 | function(cheque) { | 513 | function(cheque) { |
520 | var cobro = { | 514 | var cobro = { |
521 | tipo: 'ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco, | 515 | COM: 'ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco, |
522 | numero: cheque.numero, | 516 | numero: cheque.numero, |
523 | banco: cheque.banco, | 517 | banco: cheque.banco, |
524 | fecha: cheque.fechaEmision.toLocaleDateString() + '-' + | 518 | FEC: cheque.fechaEmision.toLocaleDateString() + '-' + |
525 | cheque.fechaPresentacion.toLocaleDateString(), | 519 | cheque.fechaPresentacion.toLocaleDateString(), |
526 | fechaPresentacion: cheque.fechaPresentacion, | 520 | fechaPresentacion: cheque.fechaPresentacion, |
527 | fechaEmision: cheque.fechaEmision, | 521 | fechaEmision: cheque.fechaEmision, |
528 | importe: cheque.importe * $scope.cobranza.cotizacion.VENDEDOR, | 522 | IMP: cheque.importe, |
529 | localidad: cheque.localidad, | 523 | localidad: cheque.localidad, |
530 | librador: cheque.librador, | 524 | librador: cheque.librador, |
531 | provincia: cheque.provincia, | 525 | provincia: cheque.provincia, |
532 | observaciones: cheque.observaciones, | 526 | observaciones: cheque.observaciones, |
533 | til: 'EF' | 527 | TIL: 'EF' |
534 | }; | 528 | }; |
535 | $scope.cobranza.cobros.push(cobro); | 529 | pushearCobro(cobro, cheque.$$hashKey); |
536 | }, function() { | 530 | }, function() { |
537 | 531 | ||
538 | } | 532 | } |
539 | ); | 533 | ); |
540 | }; | 534 | }; |
541 | 535 | ||
542 | $scope.seleccionarEfectivo = function() { | 536 | $scope.seleccionarEfectivo = function() { |
537 | |||
538 | var importe = 0; | ||
539 | $scope.cobranza.cobros.filter(function(a) { | ||
540 | if(a.COM === 'Efectivo') { | ||
541 | importe = a.IMP; | ||
542 | } | ||
543 | }); | ||
544 | |||
543 | var modalInstance = $uibModal.open( | 545 | var modalInstance = $uibModal.open( |
544 | { | 546 | { |
545 | ariaLabelledBy: 'Carga de cheques', | 547 | ariaLabelledBy: 'Carga de cheques', |
546 | templateUrl: 'modal-efectivo.html', | 548 | templateUrl: 'modal-efectivo.html', |
547 | controller: 'focaModalEfectivoController', | 549 | controller: 'focaModalEfectivoController', |
548 | size: 'sm', | 550 | size: 'sm', |
549 | resolve: { | 551 | resolve: { |
550 | sugerido: function() { | 552 | sugerido: function() { |
551 | var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); | 553 | return parseFloat(getSugerido()) + parseFloat(importe); |
552 | return sugerido < 0 ? sugerido : null; | ||
553 | } | 554 | } |
554 | } | 555 | } |
555 | } | 556 | } |
556 | ); | 557 | ); |
557 | modalInstance.result.then( | 558 | modalInstance.result.then( |
558 | function(efectivo) { | 559 | function(efectivo) { |
560 | |||
559 | var cobro = { | 561 | var cobro = { |
560 | tipo: 'Efectivo', | 562 | COM: 'Efectivo', |
561 | fecha: new Date(), | 563 | FEC: new Date(), |
562 | importe: efectivo * $scope.cobranza.cotizacion.VENDEDOR, | 564 | IMP: efectivo, |
563 | til: 'EF' | 565 | TIL: 'EF' |
564 | }; | 566 | }; |
567 | |||
565 | $scope.cobranza.cobros = $scope.cobranza.cobros.filter(function(a) { | 568 | $scope.cobranza.cobros = $scope.cobranza.cobros.filter(function(a) { |
566 | return a.tipo !== 'Efectivo'; | 569 | return a.COM !== 'Efectivo'; |
567 | }); | 570 | }); |
571 | |||
568 | $scope.cobranza.cobros.push(cobro); | 572 | $scope.cobranza.cobros.push(cobro); |
569 | }, function() { | 573 | }, function() { |
570 | 574 | ||
571 | } | 575 | } |
572 | ); | 576 | ); |
573 | }; | 577 | }; |
574 | 578 | ||
575 | $scope.seleccionarDetalles = function() { | 579 | $scope.seleccionarDetalles = function(detalle) { |
580 | |||
581 | var parametro = {}; | ||
582 | |||
583 | if(!detalle) { | ||
584 | parametro = { | ||
585 | importe: getSugerido(), | ||
586 | files: [] | ||
587 | }; | ||
588 | } else { | ||
589 | parametro = detalle; | ||
590 | parametro.importe = detalle.IMP; | ||
591 | parametro.files= detalle.imgs; | ||
592 | } | ||
593 | |||
576 | var modalInstance = $uibModal.open( | 594 | var modalInstance = $uibModal.open( |
577 | { | 595 | { |
578 | ariaLabelledBy: 'Carga de detalles', | 596 | ariaLabelledBy: 'Carga de detalles', |
579 | templateUrl: 'modal-detalles.html', | 597 | templateUrl: 'modal-detalles.html', |
580 | controller: 'focaModalDetallesController', | 598 | controller: 'focaModalDetallesController', |
581 | size: 'lg', | 599 | size: 'lg', |
582 | resolve: { | 600 | resolve: { |
583 | sugerido: function() { | 601 | parametros: function() { |
584 | var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); | 602 | return parametro; |
585 | return sugerido < 0 ? sugerido : null; | ||
586 | } | 603 | } |
587 | } | 604 | } |
588 | } | 605 | } |
589 | ); | 606 | ); |
590 | modalInstance.result.then( | 607 | modalInstance.result.then( |
591 | function(detalles) { | 608 | function(detalles) { |
609 | |||
592 | var cobro = { | 610 | var cobro = { |
593 | tipo: 'de(COBRO POR DETALLES)', | 611 | COM: 'de(COBRO POR DETALLES)', |
594 | fecha: new Date(), | 612 | FEC: new Date(), |
595 | importe: detalles.monto * $scope.cobranza.cotizacion.VENDEDOR, | 613 | IMP: detalles.importe, |
596 | imgs: detalles.imgs, | 614 | imgs: detalles.files, |
597 | til: 'DE', | 615 | TIL: 'DE', |
598 | observacion: detalles.observacion | 616 | observacion: detalles.observacion |
599 | }; | 617 | }; |
600 | var existe = false; | 618 | pushearCobro(cobro, detalles.$$hashKey); |
601 | |||
602 | $scope.cobranza.cobros.forEach(function(c, idx) { | ||
603 | if (c.til === 'DE') { | ||
604 | $scope.cobranza.cobros[idx] = cobro; | ||
605 | existe = true; | ||
606 | } | ||
607 | }); | ||
608 | if (!existe) { | ||
609 | $scope.cobranza.cobros.push(cobro); | ||
610 | } | ||
611 | }, function() {} | 619 | }, function() {} |
612 | ); | 620 | ); |
613 | }; | 621 | }; |
614 | 622 | ||
615 | $scope.seleccionarMoneda = function() { | 623 | $scope.seleccionarMoneda = function() { |
616 | var parametrosModal = { | 624 | var parametrosModal = { |
617 | titulo: 'Búsqueda de monedas', | 625 | titulo: 'Búsqueda de monedas', |
618 | query: '/moneda', | 626 | query: '/moneda', |
619 | columnas: [ | 627 | columnas: [ |
620 | { | 628 | { |
621 | propiedad: 'DETALLE', | 629 | propiedad: 'DETALLE', |
622 | nombre: 'Nombre' | 630 | nombre: 'Nombre' |
623 | }, | 631 | }, |
624 | { | 632 | { |
625 | propiedad: 'SIMBOLO', | 633 | propiedad: 'SIMBOLO', |
626 | nombre: 'Símbolo' | 634 | nombre: 'Símbolo' |
627 | } | 635 | } |
628 | ], | 636 | ], |
629 | size: 'md' | 637 | size: 'md' |
630 | }; | 638 | }; |
631 | focaModalService.modal(parametrosModal).then( | 639 | focaModalService.modal(parametrosModal).then( |
632 | function(moneda) { | 640 | function(moneda) { |
633 | $scope.seleccionarCotizacion(moneda); | 641 | $scope.seleccionarCotizacion(moneda); |
634 | }, function() { | 642 | }, function() { |
635 | 643 | ||
636 | } | 644 | } |
637 | ); | 645 | ); |
638 | }; | 646 | }; |
639 | 647 | ||
640 | $scope.seleccionarCotizacion = function(moneda) { | 648 | $scope.seleccionarCotizacion = function(moneda) { |
641 | var modalInstance = $uibModal.open( | 649 | var modalInstance = $uibModal.open( |
642 | { | 650 | { |
643 | ariaLabelledBy: 'Busqueda de Cotización', | 651 | ariaLabelledBy: 'Busqueda de Cotización', |
644 | templateUrl: 'modal-cotizacion.html', | 652 | templateUrl: 'modal-cotizacion.html', |
645 | controller: 'focaModalCotizacionController', | 653 | controller: 'focaModalCotizacionController', |
646 | size: 'lg', | 654 | size: 'lg', |
647 | resolve: {idMoneda: function() {return moneda.ID;}} | 655 | resolve: {idMoneda: function() {return moneda.ID;}} |
648 | } | 656 | } |
649 | ); | 657 | ); |
650 | modalInstance.result.then( | 658 | modalInstance.result.then( |
651 | function(cotizacion) { | 659 | function(cotizacion) { |
652 | $scope.cobranza.cotizacion.moneda = moneda; | 660 | $scope.cobranza.moneda = moneda; |
653 | $scope.cobranza.cotizacion = cotizacion; | 661 | $scope.cobranza.moneda.cotizacion = cotizacion; |
654 | if (moneda.DETALLE === 'PESOS ARGENTINOS') { | 662 | if (moneda.DETALLE === 'PESOS ARGENTINOS') { |
655 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 663 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
656 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 664 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
657 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 665 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
658 | } else { | 666 | } else { |
659 | $scope.$broadcast('addCabecera', { | 667 | $scope.$broadcast('addCabecera', { |
660 | label: 'Moneda:', | 668 | label: 'Moneda:', |
661 | valor: moneda.DETALLE | 669 | valor: moneda.DETALLE |
662 | }); | 670 | }); |
663 | $scope.$broadcast('addCabecera', { | 671 | $scope.$broadcast('addCabecera', { |
664 | label: 'Fecha cotizacion:', | 672 | label: 'Fecha cotizacion:', |
665 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 673 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
666 | }); | 674 | }); |
667 | $scope.$broadcast('addCabecera', { | 675 | $scope.$broadcast('addCabecera', { |
668 | label: 'Cotizacion:', | 676 | label: 'Cotizacion:', |
669 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 677 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
670 | }); | 678 | }); |
671 | } | 679 | } |
680 | |||
672 | }, function() { | 681 | }, function() { |
673 | 682 | ||
674 | } | 683 | } |
675 | ); | 684 | ); |
676 | }; | 685 | }; |
677 | 686 | ||
678 | $scope.getTotalDeuda = function() { | 687 | $scope.getTotalDeuda = function() { |
679 | var total = 0; | 688 | var total = 0; |
680 | for (var i = 0; i < $scope.cobranza.facturas.length; i++) { | 689 | for (var i = 0; i < $scope.cobranza.facturas.length; i++) { |
681 | total += $scope.cobranza.facturas[i].IPA; | 690 | total += $scope.cobranza.facturas[i].IMP || $scope.cobranza.facturas[i].IPA; |
682 | } | 691 | } |
683 | return parseFloat(total.toFixed(2)); | 692 | return parseFloat(total.toFixed(2)); |
684 | }; | 693 | }; |
685 | 694 | ||
686 | $scope.getTotalCobrado = function() { | 695 | $scope.getTotalCobrado = function() { |
687 | var total = 0; | 696 | var total = 0; |
688 | for (var i = 0; i < $scope.cobranza.cobros.length; i++) { | 697 | for (var i = 0; i < $scope.cobranza.cobros.length; i++) { |
689 | total += $scope.cobranza.cobros[i].importe; | 698 | total += $scope.cobranza.cobros[i].IMP; |
690 | } | 699 | } |
691 | return parseFloat(total.toFixed(2)); | 700 | return parseFloat(total.toFixed(2)); |
692 | }; | 701 | }; |
693 | 702 | ||
694 | $scope.getSubTotal = function() { | 703 | $scope.getSubTotal = function() { |
695 | if ($scope.articuloACargar) { | 704 | if ($scope.articuloACargar) { |
696 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 705 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
697 | } | 706 | } |
698 | }; | 707 | }; |
699 | //Recibe aviso si el teclado está en uso | 708 | //Recibe aviso si el teclado está en uso |
700 | // $rootScope.$on('usarTeclado', function(event, data) { | 709 | // $rootScope.$on('usarTeclado', function(event, data) { |
701 | // if(data) { | 710 | // if(data) { |
702 | // $scope.mostrarTeclado = true; | 711 | // $scope.mostrarTeclado = true; |
703 | // return; | 712 | // return; |
704 | // } | 713 | // } |
705 | // $scope.mostrarTeclado = false; | 714 | // $scope.mostrarTeclado = false; |
706 | // }) | 715 | // }) |
707 | $scope.selectFocus = function($event) { | 716 | $scope.selectFocus = function($event) { |
708 | //Si el teclado esta en uso no selecciona el valor | 717 | //Si el teclado esta en uso no selecciona el valor |
709 | // if($scope.mostrarTeclado) { | 718 | // if($scope.mostrarTeclado) { |
710 | // return; | 719 | // return; |
711 | // } | 720 | // } |
712 | $event.target.select(); | 721 | $event.target.select(); |
713 | }; | 722 | }; |
714 | 723 | ||
715 | $scope.salir = function() { | 724 | $scope.salir = function() { |
716 | $location.path('/'); | 725 | $location.path('/'); |
717 | }; | 726 | }; |
718 | 727 | ||
719 | $scope.parsearATexto = function(articulo) { | 728 | $scope.parsearATexto = function(articulo) { |
720 | articulo.cantidad = parseFloat(articulo.cantidad); | 729 | articulo.cantidad = parseFloat(articulo.cantidad); |
721 | articulo.precio = parseFloat(articulo.precio); | 730 | articulo.precio = parseFloat(articulo.precio); |
722 | }; | 731 | }; |
723 | 732 | ||
724 | $scope.quitarFactura = function(key) { | 733 | $scope.quitarFactura = function(key) { |
725 | $scope.cobranza.facturas.splice(key, 1); | 734 | $scope.cobranza.facturas.splice(key, 1); |
726 | }; | 735 | }; |
727 | 736 | ||
728 | $scope.quitarCobro = function(key) { | 737 | $scope.quitarCobro = function(key) { |
729 | $scope.cobranza.cobros.splice(key, 1); | 738 | $scope.cobranza.cobros.splice(key, 1); |
730 | }; | 739 | }; |
731 | 740 | ||
741 | $scope.editarCobro = function(cobro) { | ||
742 | if(cobro.COM === 'Efectivo') { | ||
743 | $scope.seleccionarEfectivo(); | ||
744 | } else if(cobro.COM.substring(0, 2) === 'de') { | ||
745 | $scope.seleccionarDetalles(cobro); | ||
746 | } else if(cobro.COM.substring(0, 2) === 'ch') { | ||
747 | $scope.seleccionarCheque(cobro); | ||
748 | } | ||
749 | }; | ||
750 | |||
751 | function pushearCobro(cobro, hashKey) { | ||
752 | var existe; | ||
753 | |||
754 | $scope.cobranza.cobros.forEach(function(c, idx) { | ||
755 | if(c.$$hashKey === hashKey) { | ||
756 | $scope.cobranza.cobros[idx] = cobro; | ||
757 | existe = true; | ||
758 | } | ||
759 | }); | ||
760 | if (!existe) { | ||
761 | $scope.cobranza.cobros.push(cobro); | ||
762 | } | ||
763 | } | ||
764 | |||
732 | function salir() { | 765 | function salir() { |
733 | var confirmacion = false; | 766 | var confirmacion = false; |
734 | 767 | ||
735 | if (!angular.equals($scope.cobranza, $scope.inicial)) { | 768 | if (!angular.equals($scope.cobranza, $scope.inicial)) { |
736 | confirmacion = true; | 769 | confirmacion = true; |
737 | } | 770 | } |
738 | 771 | ||
739 | if (confirmacion) { | 772 | if (confirmacion) { |
740 | focaModalService.confirm( | 773 | focaModalService.confirm( |
741 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 774 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
742 | ).then(function(data) { | 775 | ).then(function(data) { |
743 | if (data) { | 776 | if (data) { |
744 | $location.path('/'); | 777 | $location.path('/'); |
745 | } | 778 | } |
746 | }); | 779 | }); |
747 | } else { | 780 | } else { |
748 | $location.path('/'); | 781 | $location.path('/'); |
749 | } | 782 | } |
750 | } | 783 | } |
751 | 784 | ||
752 | function setearCobranza(cobranza) { | 785 | function setearCobranza(cobranza) { |
753 | $scope.editando = true; | 786 | $scope.editando = true; |
754 | $scope.$broadcast('cleanCabecera'); | 787 | $scope.$broadcast('cleanCabecera'); |
755 | 788 | ||
756 | if (cobranza.cliente) { | 789 | if (cobranza.cliente) { |
757 | $scope.$broadcast('addCabecera', { | 790 | $scope.$broadcast('addCabecera', { |
758 | label: 'Cliente:', | 791 | label: 'Cliente:', |
759 | valor: $filter('rellenarDigitos')(cobranza.cliente.COD, 5) + ' - ' + | 792 | valor: $filter('rellenarDigitos')(cobranza.cliente.COD, 5) + ' - ' + |
760 | cobranza.cliente.NOM | 793 | cobranza.cliente.NOM |
761 | }); | 794 | }); |
762 | } | 795 | } |
763 | if (cobranza.cobrador && cobranza.cobrador.NUM) { | 796 | if (cobranza.cobrador && cobranza.cobrador.NUM) { |
764 | $scope.$broadcast('addCabecera', { | 797 | $scope.$broadcast('addCabecera', { |
765 | label: 'Cobrador:', | 798 | label: 'Cobrador:', |
766 | valor: (cobranza.cobrador.NUM) ? | 799 | valor: (cobranza.cobrador.NUM) ? |
767 | $filter('rellenarDigitos')(cobranza.cobrador.NUM, 5) + ' - ' + | 800 | $filter('rellenarDigitos')(cobranza.cobrador.NUM, 5) + ' - ' + |
768 | cobranza.cobrador.NOM : cobranza.cobrador | 801 | cobranza.cobrador.NOM : cobranza.cobrador |
769 | 802 | ||
770 | }); | 803 | }); |
771 | } | 804 | } |
772 | 805 | ||
773 | $scope.cobranza = cobranza; | 806 | $scope.cobranza = cobranza; |
774 | } | 807 | } |
775 | 808 | ||
776 | function getLSCobranza() { | 809 | function getLSCobranza() { |
777 | var cobranza = JSON.parse($localStorage.cobranza || null); | 810 | var cobranza = JSON.parse($localStorage.cobranza || null); |
778 | if (cobranza) { | 811 | if (cobranza) { |
779 | setearCobranza(cobranza); | 812 | setearCobranza(cobranza); |
780 | delete $localStorage.cobranza; | 813 | delete $localStorage.cobranza; |
src/js/service.js
1 | angular.module('focaCrearCobranza') | 1 | angular.module('focaCrearCobranza') |
2 | .service('focaCrearCobranzaService', ['$http', 'API_ENDPOINT', | 2 | .service('focaCrearCobranzaService', ['$http', 'API_ENDPOINT', |
3 | function($http, API_ENDPOINT) { | 3 | function($http, API_ENDPOINT) { |
4 | return { | 4 | return { |
5 | getNumeroRecibo: function() { | 5 | getNumeroRecibo: function() { |
6 | return $http.get(API_ENDPOINT.URL + '/recibo/numero-siguiente'); | 6 | return $http.get(API_ENDPOINT.URL + '/recibo/numero-siguiente'); |
7 | }, | 7 | }, |
8 | getCotizacionByIdMoneda: function(id) { | 8 | getCotizacionByIdMoneda: function(id) { |
9 | return $http.get(API_ENDPOINT.URL + '/moneda/' + id); | 9 | return $http.get(API_ENDPOINT.URL + '/moneda/' + id); |
10 | }, | 10 | }, |
11 | guardarCobranza: function(cobranza) { | 11 | guardarCobranza: function(cobranza) { |
12 | return $http.post(API_ENDPOINT.URL + '/recibo/guardar', cobranza); | 12 | return $http.post(API_ENDPOINT.URL + '/recibo/guardar', cobranza); |
13 | }, | 13 | }, |
14 | getCobradorById: function(id) { | 14 | getCobradorById: function(id) { |
15 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + id); | 15 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + id); |
16 | }, | 16 | }, |
17 | enviarComprobantePorMail: function(mail, data) { | ||
18 | return $http.post(API_ENDPOINT.URL + '/mail/comprobante', | ||
19 | {receiver: mail, comprobante: data}); | ||
20 | }, | ||
21 | actualizarEmail: function(mail, idCliente) { | 17 | actualizarEmail: function(mail, idCliente) { |
22 | return $http.post(API_ENDPOINT.URL + '/cliente/update/email', | 18 | return $http.post(API_ENDPOINT.URL + '/cliente/update/email', |
23 | {mail: mail, id: idCliente}); | 19 | {mail: mail, id: idCliente}); |
24 | }, | 20 | }, |
25 | getBotonera: function() { | 21 | getBotonera: function() { |
26 | var result = [ | 22 | var result = [ |
27 | { | 23 | { |
28 | label: 'Cliente', | 24 | label: 'Cliente', |
29 | image: 'cliente.png' | 25 | image: 'cliente.png' |
30 | }, | 26 | }, |
31 | { | 27 | { |
32 | label: 'Comprobantes', | 28 | label: 'Comprobantes', |
33 | image: 'comprobante.png' | 29 | image: 'comprobante.png' |
34 | }, | 30 | }, |
35 | { | 31 | { |
36 | label: 'Cobros', | 32 | label: 'Cobros', |
37 | image: 'cobros.png' | 33 | image: 'cobros.png' |
38 | }, | 34 | }, |
39 | { | 35 | { |
40 | label: 'Moneda', | 36 | label: 'Moneda', |
41 | image: 'moneda.png' | 37 | image: 'moneda.png' |
42 | }, | 38 | }, |
43 | { | 39 | { |
44 | label: 'Resumen de cuenta', | 40 | label: 'Resumen de cuenta', |
45 | image: 'moneda.png' | 41 | image: 'moneda.png' |
46 | } | 42 | } |
47 | ]; | 43 | ]; |
48 | return result; | 44 | return result; |
49 | } | 45 | } |
50 | }; | 46 | }; |
51 | }]); | 47 | }]); |
52 | 48 |
src/views/cobranza.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="'Recibo de cobranza'" | 3 | titulo="'Recibo de cobranza'" |
4 | numero="puntoVenta + '-' + comprobante" | 4 | numero="puntoVenta + '-' + comprobante" |
5 | fecha="cobranza.fecha" | 5 | fecha="cobranza.FEC" |
6 | class="mb-0 col-lg-12" | 6 | class="mb-0 col-lg-12" |
7 | busqueda="seleccionarCobranza" | 7 | busqueda="seleccionarCobranza" |
8 | ></foca-cabecera-facturador> | 8 | ></foca-cabecera-facturador> |
9 | <div class="col-lg-12"> | 9 | <div class="col-lg-12"> |
10 | <div class="row mt-4"> | 10 | <div class="row mt-4"> |
11 | <div class="col-12 col-md-10 border border-light rounded"> | 11 | <div class="col-12 col-md-10 border border-light rounded"> |
12 | <div class="row px-5 py-2 botonera-secundaria"> | 12 | <div class="row px-5 py-2 botonera-secundaria"> |
13 | <div class="col-12"> | 13 | <div class="col-12"> |
14 | <foca-botonera-facturador botones="botonera" extra="7" class="row"></foca-botonera-facturador> | 14 | <foca-botonera-facturador botones="botonera" extra="7" 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" ng-show="cobroDeuda"> | 18 | <div class="row grilla-articulo align-items-end d-none d-sm-flex" ng-show="cobroDeuda"> |
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 class="col-auto">#</th> | 22 | <th class="col-auto">#</th> |
23 | <th class="col">Comprobante</th> | 23 | <th class="col">Comprobante</th> |
24 | <th class="col">Fecha</th> | 24 | <th class="col">Fecha</th> |
25 | <th class="col">Importe</th> | 25 | <th class="col">Importe</th> |
26 | <th class="col-auto"> | 26 | <th class="col-auto"> |
27 | <button | 27 | <button |
28 | class="btn btn-outline-light selectable" | 28 | class="btn btn-outline-light selectable" |
29 | ng-click="show = !show; masMenos()" | 29 | ng-click="show = !show; masMenos()" |
30 | > | 30 | > |
31 | <i | 31 | <i |
32 | class="fa fa-chevron-down" | 32 | class="fa fa-chevron-down" |
33 | ng-show="show" | 33 | ng-show="show" |
34 | aria-hidden="true" | 34 | aria-hidden="true" |
35 | > | 35 | > |
36 | </i> | 36 | </i> |
37 | <i | 37 | <i |
38 | class="fa fa-chevron-up" | 38 | class="fa fa-chevron-up" |
39 | ng-hide="show" | 39 | ng-hide="show" |
40 | aria-hidden="true"> | 40 | aria-hidden="true"> |
41 | </i> | 41 | </i> |
42 | </button> | 42 | </button> |
43 | </th> | 43 | </th> |
44 | </th> | 44 | </th> |
45 | </tr> | 45 | </tr> |
46 | </thead> | 46 | </thead> |
47 | <tbody class="tabla-articulo-body"> | 47 | <tbody class="tabla-articulo-body"> |
48 | <tr | 48 | <tr |
49 | ng-repeat="(key, factura) in cobranza.facturas" | 49 | ng-repeat="(key, factura) in cobranza.facturas" |
50 | class="d-flex" | 50 | class="d-flex" |
51 | ng-show="show || key == cobranza.facturas.length - 1" | 51 | ng-show="show || key == cobranza.facturas.length - 1" |
52 | > | 52 | > |
53 | <td ng-bind="key + 1" class="col-auto"></td> | 53 | <td ng-bind="key + 1" class="col-auto"></td> |
54 | <td class="col" ng-bind="factura.numeroFactura" | 54 | <td class="col" ng-bind="factura.COM || factura.numeroFactura" |
55 | ></td> | 55 | ></td> |
56 | <td class="col" ng-bind="factura.FEP | date : 'dd/MM/yyyy'"></td> | 56 | <td class="col" ng-bind="factura.FEC || factura.FEP | date : 'dd/MM/yyyy'"></td> |
57 | <td | 57 | <td |
58 | class="col" | 58 | class="col" |
59 | ng-bind="(factura.IPA / cobranza.cotizacion.VENDEDOR) | | 59 | ng-bind="((factura.IMP ||factura.IPA) / cobranza.moneda.cotizacion.VENDEDOR) | |
60 | number: 4"></td> | 60 | number: 4"></td> |
61 | <td class="text-center col-auto"> | 61 | <td class="text-center col-auto"> |
62 | <button | 62 | <button |
63 | class="btn btn-outline-light" | 63 | class="btn btn-outline-light" |
64 | ng-click="quitarFactura(key)" | 64 | ng-click="quitarFactura(key)" |
65 | > | 65 | > |
66 | <i class="fa fa-trash"></i> | 66 | <i class="fa fa-trash"></i> |
67 | </button> | 67 | </button> |
68 | </td> | 68 | </td> |
69 | </tr> | 69 | </tr> |
70 | </tbody> | 70 | </tbody> |
71 | <tfoot> | 71 | <tfoot> |
72 | <tr ng-show="cargando" class="d-flex"> | 72 | <tr ng-show="cargando" class="d-flex"> |
73 | <td class="col-2 border-top-0"> | 73 | <td class="col-2 border-top-0"> |
74 | <a | 74 | <a |
75 | class="form-control form-control-sm btn btn-secondary" | 75 | class="form-control form-control-sm btn btn-secondary" |
76 | ng-click="seleccionarFactura()" | 76 | ng-click="seleccionarFactura()" |
77 | >Pendientes</a> | 77 | >Pendientes</a> |
78 | </td> | 78 | </td> |
79 | </tr> | 79 | </tr> |
80 | <tr class="d-flex"> | 80 | <tr class="d-flex"> |
81 | <td class="col-auto px-1 border-top-0"> | 81 | <td class="col-auto px-1 border-top-0"> |
82 | <strong>Comprobantes:</strong> | 82 | <strong>Comprobantes:</strong> |
83 | <a ng-bind="cobranza.facturas.length"></a> | 83 | <a ng-bind="cobranza.facturas.length"></a> |
84 | </td> | 84 | </td> |
85 | <td class="text-right ml-auto table-celda-total no-border-top"> | 85 | <td class="text-right ml-auto table-celda-total no-border-top"> |
86 | <strong>Cancela:</strong> | 86 | <strong>Cancela:</strong> |
87 | </td> | 87 | </td> |
88 | <td class="table-celda-total text-right no-border-top"> | 88 | <td class="table-celda-total text-right no-border-top"> |
89 | <strong>{{(getTotalDeuda() / cobranza.cotizacion.VENDEDOR) | | 89 | <strong>{{(getTotalDeuda() / cobranza.moneda.cotizacion.VENDEDOR) | |
90 | currency: cobranza.moneda.SIMBOLO}}</strong> | 90 | currency: cobranza.moneda.SIMBOLO}}</strong> |
91 | </td> | 91 | </td> |
92 | <td class="text-right ml-auto table-celda-total no-border-top"> | 92 | <td class="text-right ml-auto table-celda-total no-border-top"> |
93 | <strong>Total Cobrado:</strong> | 93 | <strong>Total Cobrado:</strong> |
94 | </td> | 94 | </td> |
95 | <td class="table-celda-total text-right no-border-top"> | 95 | <td class="table-celda-total text-right no-border-top"> |
96 | <strong>{{(getTotalCobrado() / cobranza.cotizacion.VENDEDOR) | | 96 | <strong>{{(getTotalCobrado() / cobranza.moneda.cotizacion.VENDEDOR) | |
97 | currency: cobranza.moneda.SIMBOLO}}</strong> | 97 | currency: cobranza.moneda.SIMBOLO}}</strong> |
98 | </td> | 98 | </td> |
99 | <td class="text-right ml-auto table-celda-total no-border-top"> | 99 | <td class="text-right ml-auto table-celda-total no-border-top"> |
100 | <strong>DF:</strong> | 100 | <strong>DF:</strong> |
101 | </td> | 101 | </td> |
102 | <td class="table-celda-total text-right no-border-top mr-1"> | 102 | <td class="table-celda-total text-right no-border-top mr-1"> |
103 | <strong>{{((getTotalCobrado() + getTotalDeuda()) / | 103 | <strong>{{((getTotalCobrado() + getTotalDeuda()) / |
104 | cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}} | 104 | cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}} |
105 | </strong> | 105 | </strong> |
106 | </td> | 106 | </td> |
107 | </tr> | 107 | </tr> |
108 | </tfoot> | 108 | </tfoot> |
109 | </table> | 109 | </table> |
110 | </div> | 110 | </div> |
111 | <div class="row grilla-articulo align-items-end d-none d-sm-flex" ng-show="!cobroDeuda"> | 111 | <div class="row grilla-articulo align-items-end d-none d-sm-flex" ng-show="!cobroDeuda"> |
112 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> | 112 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> |
113 | <thead> | 113 | <thead> |
114 | <tr class="d-flex"> | 114 | <tr class="d-flex"> |
115 | <th class="col-auto">#</th> | 115 | <th class="col-auto">#</th> |
116 | <th class="col">Cobro</th> | 116 | <th class="col">Cobro</th> |
117 | <th class="col">Fecha</th> | 117 | <th class="col">Fecha</th> |
118 | <th class="col">Importe</th> | 118 | <th class="col">Importe</th> |
119 | <th class="col-auto"> | 119 | <th class="col-auto"> |
120 | <button | 120 | <button |
121 | class="btn btn-outline-light selectable" | 121 | class="btn btn-outline-light selectable" |
122 | ng-click="show = !show; masMenos()" | 122 | ng-click="show = !show; masMenos()" |
123 | > | 123 | > |
124 | <i | 124 | <i |
125 | class="fa fa-chevron-down" | 125 | class="fa fa-chevron-down" |
126 | ng-show="show" | 126 | ng-show="show" |
127 | aria-hidden="true" | 127 | aria-hidden="true" |
128 | > | 128 | > |
129 | </i> | 129 | </i> |
130 | <i | 130 | <i |
131 | class="fa fa-chevron-up" | 131 | class="fa fa-chevron-up" |
132 | ng-hide="show" | 132 | ng-hide="show" |
133 | aria-hidden="true"> | 133 | aria-hidden="true"> |
134 | </i> | 134 | </i> |
135 | </button> | 135 | </button> |
136 | </th> | 136 | </th> |
137 | </th> | 137 | </th> |
138 | </tr> | 138 | </tr> |
139 | </thead> | 139 | </thead> |
140 | <tbody class="tabla-articulo-body"> | 140 | <tbody class="tabla-articulo-body"> |
141 | <tr | 141 | <tr |
142 | ng-repeat="(key, cobro) in cobranza.cobros" | 142 | ng-repeat="(key, cobro) in cobranza.cobros" |
143 | class="d-flex" | 143 | class="d-flex" |
144 | ng-show="show || key == cobranza.cobros.length - 1" | 144 | ng-show="show || key == cobranza.cobros.length - 1" |
145 | > | 145 | > |
146 | <td ng-bind="key + 1" class="col-auto"></td> | 146 | <td ng-bind="key + 1" class="col-auto"></td> |
147 | <td class="col" ng-bind="cobro.tipo"></td> | 147 | <td class="col" ng-bind="cobro.COM"></td> |
148 | <td class="col" ng-bind="cobro.fecha | date : 'dd/MM/yyyy'"></td> | 148 | <td class="col" ng-bind="cobro.FEC | date : 'dd/MM/yyyy'"></td> |
149 | <td | 149 | <td |
150 | class="col" | 150 | class="col" |
151 | ng-bind="(cobro.importe / cobranza.cotizacion.VENDEDOR) | | 151 | ng-bind="(cobro.IMP / cobranza.moneda.cotizacion.VENDEDOR) | |
152 | currency: cobranza.moneda.SIMBOLO : 4"></td> | 152 | currency: cobranza.moneda.SIMBOLO : 4"></td> |
153 | <td class="text-center col-auto"> | 153 | <td class="text-center col-auto"> |
154 | <button | 154 | <button |
155 | ng-disabled="cobranza.id" | ||
156 | class="btn btn-outline-light" | ||
157 | ng-click="editarCobro(cobro)" | ||
158 | > | ||
159 | <i class="fa fa-edit"></i> | ||
160 | </button> | ||
161 | <button | ||
155 | class="btn btn-outline-light" | 162 | class="btn btn-outline-light" |
156 | ng-click="quitarCobro(key)" | 163 | ng-click="quitarCobro(key)" |
157 | > | 164 | > |
158 | <i class="fa fa-trash"></i> | 165 | <i class="fa fa-trash"></i> |
159 | </button> | 166 | </button> |
160 | </td> | 167 | </td> |
161 | </tr> | 168 | </tr> |
162 | </tbody> | 169 | </tbody> |
163 | <tfoot> | 170 | <tfoot> |
164 | <tr ng-show="cargando" class="d-flex"> | 171 | <tr ng-show="cargando" class="d-flex"> |
165 | <td class="col-2 border-top-0"> | 172 | <td class="col-2 border-top-0"> |
166 | <a | 173 | <a |
167 | class="form-control form-control-sm btn btn-secondary" | 174 | class="form-control form-control-sm btn btn-secondary" |
168 | ng-click="seleccionarCheque()" | 175 | ng-click="seleccionarCheque()" |
169 | >Cheque</a> | 176 | >Cheque</a> |
170 | </td> | 177 | </td> |
171 | <td class="col-2 border-top-0"> | 178 | <td class="col-2 border-top-0"> |
172 | <a | 179 | <a |
173 | class="form-control form-control-sm btn btn-secondary" | 180 | class="form-control form-control-sm btn btn-secondary" |
174 | ng-click="seleccionarEfectivo()" | 181 | ng-click="seleccionarEfectivo()" |
175 | >Efectivo</a> | 182 | >Efectivo</a> |
176 | </td> | 183 | </td> |
177 | <td class="col-2 border-top-0"> | 184 | <td class="col-2 border-top-0"> |
178 | <a | 185 | <a |
179 | class="form-control form-control-sm btn btn-secondary" | 186 | class="form-control form-control-sm btn btn-secondary" |
180 | ng-click="seleccionarDetalles()" | 187 | ng-click="seleccionarDetalles()" |
181 | >Detalle</a> | 188 | >Detalle</a> |
182 | </td> | 189 | </td> |
183 | </tr> | 190 | </tr> |
184 | <tr class="d-flex"> | 191 | <tr class="d-flex"> |
185 | <td class="col-auto px-1 border-top-0"> | 192 | <td class="col-auto px-1 border-top-0"> |
186 | <strong>Cobros:</strong> | 193 | <strong>Cobros:</strong> |
187 | <a ng-bind="cobranza.cobros.length"></a> | 194 | <a ng-bind="cobranza.cobros.length"></a> |
188 | </td> | 195 | </td> |
189 | <td class="text-right ml-auto table-celda-total no-border-top"> | 196 | <td class="text-right ml-auto table-celda-total no-border-top"> |
190 | <strong>Cancela:</strong> | 197 | <strong>Cancela:</strong> |
191 | </td> | 198 | </td> |
192 | <td class="table-celda-total text-right no-border-top"> | 199 | <td class="table-celda-total text-right no-border-top"> |
193 | <strong>{{(getTotalDeuda() / cobranza.cotizacion.VENDEDOR) | | 200 | <strong>{{(getTotalDeuda() / cobranza.moneda.cotizacion.VENDEDOR) | |
194 | currency: cobranza.moneda.SIMBOLO}}</strong> | 201 | currency: cobranza.moneda.SIMBOLO}}</strong> |
195 | </td> | 202 | </td> |
196 | <td class="text-right ml-auto table-celda-total no-border-top"> | 203 | <td class="text-right ml-auto table-celda-total no-border-top"> |
197 | <strong>Total Cobrado:</strong> | 204 | <strong>Total Cobrado:</strong> |
198 | </td> | 205 | </td> |
199 | <td class="table-celda-total text-right no-border-top"> | 206 | <td class="table-celda-total text-right no-border-top"> |
200 | <strong>{{(getTotalCobrado() / cobranza.cotizacion.VENDEDOR) | | 207 | <strong>{{(getTotalCobrado() / cobranza.moneda.cotizacion.VENDEDOR) | |
201 | currency: cobranza.moneda.SIMBOLO}}</strong> | 208 | currency: cobranza.moneda.SIMBOLO}}</strong> |
202 | </td> | 209 | </td> |
203 | <td class="text-right ml-auto table-celda-total no-border-top"> | 210 | <td class="text-right ml-auto table-celda-total no-border-top"> |
204 | <strong>DF:</strong> | 211 | <strong>DF:</strong> |
205 | </td> | 212 | </td> |
206 | <td class="table-celda-total text-right no-border-top mr-1"> | 213 | <td class="table-celda-total text-right no-border-top mr-1"> |
207 | <strong>{{((getTotalCobrado() + getTotalDeuda()) / | 214 | <strong>{{((getTotalCobrado() + getTotalDeuda()) / |
208 | cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}} | 215 | cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}} |
209 | </strong> | 216 | </strong> |
210 | </td> | 217 | </td> |
211 | </tr> | 218 | </tr> |
212 | </tfoot> | 219 | </tfoot> |
213 | </table> | 220 | </table> |
214 | </div> | 221 | </div> |
215 | <!-- MOBILE --> | 222 | <!-- MOBILE --> |
216 | <div class="row d-sm-none mb-5"> | 223 | <div class="row d-sm-none mb-5"> |
217 | <!-- FACTURAS --> | 224 | <!-- FACTURAS --> |
218 | <table class="table table-sm table-striped tabla-articulo mb-5" ng-show="cobroDeuda"> | 225 | <table class="table table-sm table-striped tabla-articulo mb-5" ng-show="cobroDeuda"> |
219 | <thead> | 226 | <thead> |
220 | <tr class="d-flex"> | 227 | <tr class="d-flex"> |
221 | <th class="">#</th> | 228 | <th class="">#</th> |
222 | <th class="col px-0"> | 229 | <th class="col px-0"> |
223 | <div class="d-flex"> | 230 | <div class="d-flex"> |
224 | <div class="col-4 px-1">Factura</div> | 231 | <div class="col-4 px-1">Factura</div> |
225 | <div class="col-4 px-1">Fecha</div> | 232 | <div class="col-4 px-1">Fecha</div> |
226 | <div class="col-4 px-1">Importe</div> | 233 | <div class="col-4 px-1">Importe</div> |
227 | </div> | 234 | </div> |
228 | </th> | 235 | </th> |
229 | <th class="text-center tamaño-boton"> | 236 | <th class="text-center tamaño-boton"> |
230 | | 237 | |
231 | </th> | 238 | </th> |
232 | </tr> | 239 | </tr> |
233 | </thead> | 240 | </thead> |
234 | <tbody> | 241 | <tbody> |
235 | <tr | 242 | <tr |
236 | ng-repeat="(key, factura) in cobranza.facturas" | 243 | ng-repeat="(key, factura) in cobranza.facturas" |
237 | ng-show="show || key == cobranza.facturas.length - 1" | 244 | ng-show="show || key == cobranza.facturas.length - 1" |
238 | > | 245 | > |
239 | <td class="w-100 align-middle d-flex p-0"> | 246 | <td class="w-100 align-middle d-flex p-0"> |
240 | <div class="align-middle p-1"> | 247 | <div class="align-middle p-1"> |
241 | <span ng-bind="key+1" class="align-middle"></span> | 248 | <span ng-bind="key+1" class="align-middle"></span> |
242 | </div> | 249 | </div> |
243 | <div class="col px-0"> | 250 | <div class="col px-0"> |
244 | <div class="d-flex"> | 251 | <div class="d-flex"> |
245 | <div class="col-4 p-1"> | 252 | <div class="col-4 p-1"> |
246 | <span ng-bind="factura.numeroFactura" | 253 | <span ng-bind="factura.numeroFactura" |
247 | ></span> | 254 | ></span> |
248 | </div> | 255 | </div> |
249 | <div class="col-4 p-1"> | 256 | <div class="col-4 p-1"> |
250 | <span ng-bind="factura.FEP | date : 'dd/MM/yyyy'"></span> | 257 | <span ng-bind="factura.FEP | date : 'dd/MM/yyyy'"></span> |
251 | </div> | 258 | </div> |
252 | <div class="col-4 p-1"> | 259 | <div class="col-4 p-1"> |
253 | <span | 260 | <span |
254 | ng-bind="(factura.IPA / cobranza.cotizacion.VENDEDOR) | | 261 | ng-bind="(factura.IPA / cobranza.moneda.cotizacion.VENDEDOR) | |
255 | currency:cobranza.moneda.SIMBOLO : 4"></span> | 262 | currency: cobranza.moneda.SIMBOLO : 4"></span> |
256 | </div> | 263 | </div> |
257 | </div> | 264 | </div> |
258 | </div> | 265 | </div> |
259 | <div class="align-middle p-1"> | 266 | <div class="align-middle p-1"> |
260 | <button | 267 | <button |
261 | class="btn btn-outline-light" | 268 | class="btn btn-outline-light" |
262 | ng-click="quitarFactura(key)" | 269 | ng-click="quitarFactura(key)" |
263 | > | 270 | > |
264 | <i class="fa fa-trash"></i> | 271 | <i class="fa fa-trash"></i> |
265 | </button> | 272 | </button> |
266 | </div> | 273 | </div> |
267 | </td> | 274 | </td> |
268 | </tr> | 275 | </tr> |
269 | </tbody> | 276 | </tbody> |
270 | <tfoot> | 277 | <tfoot> |
271 | <!-- SELECCIONAR PRODUCTO --> | 278 | <!-- SELECCIONAR PRODUCTO --> |
272 | <tr ng-show="cargando" class="d-flex"> | 279 | <tr ng-show="cargando" class="d-flex"> |
273 | <td class="col-12"> | 280 | <td class="col-12"> |
274 | <input | 281 | <input |
275 | placeholder="Seleccione Factura" | 282 | placeholder="Seleccione Factura" |
276 | class="form-control form-control-sm" | 283 | class="form-control form-control-sm" |
277 | readonly | 284 | readonly |
278 | ng-click="seleccionarFactura()" | 285 | ng-click="seleccionarFactura()" |
279 | /> | 286 | /> |
280 | </td> | 287 | </td> |
281 | </tr> | 288 | </tr> |
282 | <!-- TOOGLE EXPANDIR --> | 289 | <!-- TOOGLE EXPANDIR --> |
283 | <tr> | 290 | <tr> |
284 | <td class="col"> | 291 | <td class="col"> |
285 | <button | 292 | <button |
286 | class="btn btn-outline-light selectable w-100" | 293 | class="btn btn-outline-light selectable w-100" |
287 | ng-click="show = !show; masMenos()" | 294 | ng-click="show = !show; masMenos()" |
288 | ng-show="cobranza.facturas.length > 0" | 295 | ng-show="cobranza.facturas.length > 0" |
289 | > | 296 | > |
290 | <i | 297 | <i |
291 | class="fa fa-chevron-down" | 298 | class="fa fa-chevron-down" |
292 | ng-hide="show" | 299 | ng-hide="show" |
293 | aria-hidden="true" | 300 | aria-hidden="true" |
294 | > | 301 | > |
295 | </i> | 302 | </i> |
296 | <i | 303 | <i |
297 | class="fa fa-chevron-up" | 304 | class="fa fa-chevron-up" |
298 | ng-show="show" | 305 | ng-show="show" |
299 | aria-hidden="true"> | 306 | aria-hidden="true"> |
300 | </i> | 307 | </i> |
301 | </button> | 308 | </button> |
302 | </td> | 309 | </td> |
303 | </tr> | 310 | </tr> |
304 | <!-- FOOTER --> | 311 | <!-- FOOTER --> |
305 | <tr class="d-flex"> | 312 | <tr class="d-flex"> |
306 | <td class="align-middle no-border-top" colspan="2"> | 313 | <td class="align-middle no-border-top" colspan="2"> |
307 | <strong>Cantidad Items:</strong> | 314 | <strong>Cantidad Items:</strong> |
308 | <a ng-bind="cobranza.facturas.length"></a> | 315 | <a ng-bind="cobranza.facturas.length"></a> |
309 | </td> | 316 | </td> |
310 | </tr> | 317 | </tr> |
311 | </tfoot> | 318 | </tfoot> |
312 | </table> | 319 | </table> |
313 | <!-- COBROS --> | 320 | <!-- COBROS --> |
314 | <table class="table table-sm table-striped tabla-articulo mb-5" ng-show="!cobroDeuda"> | 321 | <table class="table table-sm table-striped tabla-articulo mb-5" ng-show="!cobroDeuda"> |
315 | <thead> | 322 | <thead> |
316 | <tr class="d-flex"> | 323 | <tr class="d-flex"> |
317 | <th class="">#</th> | 324 | <th class="">#</th> |
318 | <th class="col px-0"> | 325 | <th class="col px-0"> |
319 | <div class="d-flex"> | 326 | <div class="d-flex"> |
320 | <div class="col-4 px-1">Cobro</div> | 327 | <div class="col-4 px-1">Cobro</div> |
321 | <div class="col-4 px-1">Fecha</div> | 328 | <div class="col-4 px-1">Fecha</div> |
322 | <div class="col-4 px-1">Importe</div> | 329 | <div class="col-4 px-1">Importe</div> |
323 | </div> | 330 | </div> |
324 | </th> | 331 | </th> |
325 | <th class="text-center tamaño-boton"> | 332 | <th class="text-center tamaño-boton"> |
326 | | 333 | |
327 | </th> | 334 | </th> |
328 | </tr> | 335 | </tr> |
329 | </thead> | 336 | </thead> |
330 | <tbody> | 337 | <tbody> |
331 | <tr | 338 | <tr |
332 | ng-repeat="(key, cobro) in cobranza.cobros" | 339 | ng-repeat="(key, cobro) in cobranza.cobros" |
333 | ng-show="show || key == cobranza.cobros.length - 1" | 340 | ng-show="show || key == cobranza.cobros.length - 1" |
334 | > | 341 | > |
335 | <td class="w-100 align-middle d-flex p-0"> | 342 | <td class="w-100 align-middle d-flex p-0"> |
336 | <div class="align-middle p-1"> | 343 | <div class="align-middle p-1"> |
337 | <span ng-bind="key+1" class="align-middle"></span> | 344 | <span ng-bind="key+1" class="align-middle"></span> |
338 | </div> | 345 | </div> |
339 | <div class="col px-0"> | 346 | <div class="col px-0"> |
340 | <div class="d-flex"> | 347 | <div class="d-flex"> |
341 | <div class="col-4 p-1"> | 348 | <div class="col-4 p-1"> |
342 | <span ng-bind="cobro.tipo" | 349 | <span ng-bind="cobro.COM" |
343 | ></span> | 350 | ></span> |
344 | </div> | 351 | </div> |
345 | <div class="col-4 p-1"> | 352 | <div class="col-4 p-1"> |
346 | <span ng-bind="cobro.fecha | date : 'dd/MM/yyyy'"></span> | 353 | <span ng-bind="cobro.FEC | date : 'dd/MM/yyyy'"></span> |
347 | </div> | 354 | </div> |
348 | <div class="col-4 p-1"> | 355 | <div class="col-4 p-1"> |
349 | <span | 356 | <span |
350 | ng-bind="(cobro.importe / cobranza.cotizacion.VENDEDOR) | | 357 | ng-bind="(cobro.IMP / cobranza.moneda.cotizacion.VENDEDOR) | |
351 | currency: cobranza.moneda.SIMBOLO : 4"></span> | 358 | currency: cobranza.moneda.SIMBOLO : 4"></span> |
352 | </div> | 359 | </div> |
353 | </div> | 360 | </div> |
354 | </div> | 361 | </div> |
355 | <div class="align-middle p-1"> | 362 | <div class="col-2 align-middle p-1"> |
363 | <button | ||
364 | ng-disabled="cobranza.id" | ||
365 | class="btn btn-outline-light" | ||
366 | ng-click="editarCobro(cobro)" | ||
367 | > | ||
368 | <i class="fa fa-edit"></i> | ||
369 | </button> | ||
356 | <button | 370 | <button |
357 | class="btn btn-outline-light" | 371 | class="btn btn-outline-light" |
358 | ng-click="quitarCobro(key)" | 372 | ng-click="quitarCobro(key)" |
359 | > | 373 | > |
360 | <i class="fa fa-trash"></i> | 374 | <i class="fa fa-trash"></i> |
361 | </button> | 375 | </button> |
362 | </div> | 376 | </div> |
363 | </td> | 377 | </td> |
364 | </tr> | 378 | </tr> |
365 | </tbody> | 379 | </tbody> |
366 | <tfoot> | 380 | <tfoot> |
367 | <!-- SELECCIONAR PRODUCTO --> | 381 | <!-- SELECCIONAR PRODUCTO --> |
368 | <tr ng-show="cargando" class="d-flex"> | 382 | <tr ng-show="cargando" class="d-flex"> |
369 | <td class="col-4"> | 383 | <td class="col-4"> |
370 | <input | 384 | <input |
371 | placeholder="Cheque" | 385 | placeholder="Cheque" |
372 | class="form-control form-control-sm" | 386 | class="form-control form-control-sm" |
373 | readonly | 387 | readonly |
374 | ng-click="seleccionarCheque()" | 388 | ng-click="seleccionarCheque()" |
375 | /> | 389 | /> |
376 | </td> | 390 | </td> |
377 | <td class="col-4"> | 391 | <td class="col-4"> |
378 | <input | 392 | <input |
379 | placeholder="Efectivo" | 393 | placeholder="Efectivo" |
380 | class="form-control form-control-sm" | 394 | class="form-control form-control-sm" |
381 | readonly | 395 | readonly |
382 | ng-click="seleccionarEfectivo()" | 396 | ng-click="seleccionarEfectivo()" |
383 | /> | 397 | /> |
384 | </td> | 398 | </td> |
385 | <td class="col-4"> | 399 | <td class="col-4"> |
386 | <input | 400 | <input |
387 | placeholder="Detalles" | 401 | placeholder="Detalles" |
388 | class="form-control form-control-sm" | 402 | class="form-control form-control-sm" |
389 | readonly | 403 | readonly |
390 | ng-click="seleccionarDetalles()" | 404 | ng-click="seleccionarDetalles()" |
391 | /> | 405 | /> |
392 | </td> | 406 | </td> |
393 | </tr> | 407 | </tr> |
394 | <!-- TOOGLE EXPANDIR --> | 408 | <!-- TOOGLE EXPANDIR --> |
395 | <tr> | 409 | <tr> |
396 | <td class="col"> | 410 | <td class="col"> |
397 | <button | 411 | <button |
398 | class="btn btn-outline-light selectable w-100" | 412 | class="btn btn-outline-light selectable w-100" |
399 | ng-click="show = !show; masMenos()" | 413 | ng-click="show = !show; masMenos()" |
400 | ng-show="cobranza.cobros.length > 0" | 414 | ng-show="cobranza.cobros.length > 0" |
401 | > | 415 | > |
402 | <i | 416 | <i |
403 | class="fa fa-chevron-down" | 417 | class="fa fa-chevron-down" |
404 | ng-hide="show" | 418 | ng-hide="show" |
405 | aria-hidden="true" | 419 | aria-hidden="true" |
406 | > | 420 | > |
407 | </i> | 421 | </i> |
408 | <i | 422 | <i |
409 | class="fa fa-chevron-up" | 423 | class="fa fa-chevron-up" |
410 | ng-show="show" | 424 | ng-show="show" |
411 | aria-hidden="true"> | 425 | aria-hidden="true"> |
412 | </i> | 426 | </i> |
413 | </button> | 427 | </button> |
414 | </td> | 428 | </td> |
415 | </tr> | 429 | </tr> |
416 | <!-- FOOTER --> | 430 | <!-- FOOTER --> |
417 | <tr class="d-flex"> | 431 | <tr class="d-flex"> |
418 | <td class="align-middle no-border-top col-6"> | 432 | <td class="align-middle no-border-top col-6"> |
419 | <strong>Cantidad Items:</strong> | 433 | <strong>Cantidad Items:</strong> |
420 | <a ng-bind="cobranza.cobros.length"></a> | 434 | <a ng-bind="cobranza.cobros.length"></a> |
421 | </td> | 435 | </td> |
422 | </tfoot> | 436 | </tfoot> |
423 | </table> | 437 | </table> |
424 | </tr> | 438 | </tr> |
425 | <!-- DEUDA, COBRADO, DIFERENCIA --> | 439 | <!-- DEUDA, COBRADO, DIFERENCIA --> |
426 | <table class="table-responsive fixed-bottom mb-5"> | 440 | <table class="table-responsive fixed-bottom mb-5"> |
427 | <tr class="d-flex row"> | 441 | <tr class="d-flex row"> |
428 | <td class="text-center ml-auto table-celda-total no-border-top col-4"> | 442 | <td class="text-center ml-auto table-celda-total no-border-top col-4"> |
429 | <strong>Cancela:</strong> | 443 | <strong>Cancela:</strong> |
430 | </td> | 444 | </td> |
431 | <td class="text-center ml-auto table-celda-total no-border-top col-4"> | 445 | <td class="text-center ml-auto table-celda-total no-border-top col-4"> |
432 | <strong>Cobrado:</strong> | 446 | <strong>Cobrado:</strong> |
433 | </td> | 447 | </td> |
434 | <td class="text-center ml-auto table-celda-total no-border-top col-4"> | 448 | <td class="text-center ml-auto table-celda-total no-border-top col-4"> |
435 | <strong>Diferencia:</strong> | 449 | <strong>Diferencia:</strong> |
436 | </td> | 450 | </td> |
437 | <td class="table-celda-total text-center no-border-top col-4"> | 451 | <td class="table-celda-total text-center no-border-top col-4"> |
438 | <strong>{{(getTotalDeuda() / cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong> | 452 | <strong>{{(getTotalDeuda() / cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong> |
439 | </td> | 453 | </td> |
440 | <td class="table-celda-total text-center no-border-top col-4"> | 454 | <td class="table-celda-total text-center no-border-top col-4"> |
441 | <strong>{{(getTotalCobrado() / cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong> | 455 | <strong>{{(getTotalCobrado() / cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong> |
442 | </td> | 456 | </td> |
443 | <td class="table-celda-total text-center no-border-top col-4"> | 457 | <td class="table-celda-total text-center no-border-top col-4"> |
444 | <strong>{{((getTotalCobrado() + getTotalDeuda()) / cobranza.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong> | 458 | <strong>{{((getTotalCobrado() + getTotalDeuda()) / cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong> |
445 | </td> | 459 | </td> |
446 | </tr> | 460 | </tr> |
447 | </table> | 461 | </table> |
448 | </div> | 462 | </div> |
449 | </div> | 463 | </div> |
450 | </div> | 464 | </div> |
451 | </div> | 465 | </div> |
452 | <div class="row d-md-none fixed-bottom"> | 466 | <div class="row d-md-none fixed-bottom"> |
453 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> | 467 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> |
454 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> | 468 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> |
455 | <span | 469 | <span |
456 | class="mr-3 ml-auto" | 470 | class="mr-3 ml-auto" |
457 | ng-class="saveLoading ? 'text-muted' : ''" | 471 | ng-class="saveLoading ? 'text-muted' : ''" |
458 | ng-click="crearCobranza()" | 472 | ng-click="crearCobranza()" |
459 | ng-show="!editando" | 473 | ng-show="!editando" |
460 | ladda="saveLoading" | 474 | ladda="saveLoading" |
461 | data-style="expand-left" | 475 | data-style="expand-left" |
462 | >Guardar</span> | 476 | >Guardar</span> |
463 | </div> | 477 | </div> |
464 | </div> | 478 | </div> |
465 | </div> | 479 | </div> |
466 | 480 |