Commit 560b5953f770fcaf45a6fd8dc6d6b6e09b5fc4c7
1 parent
68473ec2f2
Exists in
master
edit cobros, unit test
Showing
5 changed files
with
124 additions
and
64 deletions
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 | //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]' |
26 | focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) { | 26 | focaCrearCobranzaService.getCotizacionByIdMoneda(1).then(function(res) { |
27 | var moneda = res.data[0]; | 27 | var moneda = res.data[0]; |
28 | moneda.cotizacion = moneda.cotizaciones[0]; | 28 | moneda.cotizacion = moneda.cotizaciones[0]; |
29 | $scope.cobranza.moneda = $scope.inicial.moneda = moneda; | 29 | $scope.cobranza.moneda = $scope.inicial.moneda = moneda; |
30 | }); | 30 | }); |
31 | 31 | ||
32 | $timeout(function() { | 32 | $timeout(function() { |
33 | focaBotoneraLateralService.showSalir(false); | 33 | focaBotoneraLateralService.showSalir(false); |
34 | focaBotoneraLateralService.showPausar(true); | 34 | focaBotoneraLateralService.showPausar(true); |
35 | focaBotoneraLateralService.showGuardar(true, $scope.crearCobranza); | 35 | focaBotoneraLateralService.showGuardar(true, $scope.crearCobranza); |
36 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 36 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
37 | }); | 37 | }); |
38 | 38 | ||
39 | if (APP === 'cobranza') { | 39 | if (APP === 'cobranza') { |
40 | $scope.idCobrador = loginService.getLoginData().vendedorCobrador; | 40 | $scope.idCobrador = loginService.getLoginData().vendedorCobrador; |
41 | } | 41 | } |
42 | 42 | ||
43 | init(); | 43 | init(); |
44 | $timeout(function() {getLSCobranza();}); | 44 | $timeout(function() {getLSCobranza();}); |
45 | } | 45 | } |
46 | 46 | ||
47 | function init() { | 47 | function init() { |
48 | $scope.$broadcast('cleanCabecera'); | 48 | $scope.$broadcast('cleanCabecera'); |
49 | $scope.cobranza = { | 49 | $scope.cobranza = { |
50 | FEC: new Date(), | 50 | FEC: new Date(), |
51 | moneda: {}, | 51 | moneda: {}, |
52 | facturas: [], | 52 | facturas: [], |
53 | cobros: [], | 53 | cobros: [], |
54 | cliente: {}, | 54 | cliente: {}, |
55 | cobrador: {} | 55 | cobrador: {} |
56 | }; | 56 | }; |
57 | if (APP === 'cobranza') { | 57 | if (APP === 'cobranza') { |
58 | focaCrearCobranzaService.getCobradorById($scope.idCobrador).then( | 58 | focaCrearCobranzaService.getCobradorById($scope.idCobrador).then( |
59 | function(res) { | 59 | function(res) { |
60 | var cobrador = res.data; | 60 | var cobrador = res.data; |
61 | 61 | ||
62 | $scope.$broadcast('addCabecera', { | 62 | $scope.$broadcast('addCabecera', { |
63 | label: 'Cobrador:', | 63 | label: 'Cobrador:', |
64 | valor: $filter('rellenarDigitos')(cobrador.NUM, 3) + ' - ' + | 64 | valor: $filter('rellenarDigitos')(cobrador.NUM, 3) + ' - ' + |
65 | cobrador.NOM | 65 | cobrador.NOM |
66 | }); | 66 | }); |
67 | 67 | ||
68 | $scope.cobranza.cobrador = cobrador; | 68 | $scope.cobranza.cobrador = cobrador; |
69 | $scope.inicial.cobranza.cobrador = $scope.cobranza.cobrador; | 69 | $scope.inicial.cobranza.cobrador = $scope.cobranza.cobrador; |
70 | } | 70 | } |
71 | ); | 71 | ); |
72 | } | 72 | } |
73 | 73 | ||
74 | $scope.inicial = angular.copy($scope.cobranza); | 74 | $scope.inicial = angular.copy($scope.cobranza); |
75 | 75 | ||
76 | focaCrearCobranzaService.getNumeroRecibo().then( | 76 | focaCrearCobranzaService.getNumeroRecibo().then( |
77 | function(res) { | 77 | function(res) { |
78 | $scope.puntoVenta = $filter('rellenarDigitos')( | 78 | $scope.puntoVenta = $filter('rellenarDigitos')( |
79 | res.data.sucursal, 4 | 79 | res.data.sucursal, 4 |
80 | ); | 80 | ); |
81 | 81 | ||
82 | $scope.comprobante = $filter('rellenarDigitos')( | 82 | $scope.comprobante = $filter('rellenarDigitos')( |
83 | res.data.numeroRecibo, 8 | 83 | res.data.numeroRecibo, 8 |
84 | ); | 84 | ); |
85 | }, | 85 | }, |
86 | function(err) { | 86 | function(err) { |
87 | focaModalService.alert( | 87 | focaModalService.alert( |
88 | 'La terminal no esta configurada correctamente' | 88 | 'La terminal no esta configurada correctamente' |
89 | ); | 89 | ); |
90 | console.info(err); | 90 | console.info(err); |
91 | } | 91 | } |
92 | ); | 92 | ); |
93 | } | 93 | } |
94 | 94 | ||
95 | $scope.$watch('cobranza', function(newValue) { | 95 | $scope.$watch('cobranza', function(newValue) { |
96 | focaBotoneraLateralService.setPausarData({ | 96 | focaBotoneraLateralService.setPausarData({ |
97 | label: 'cobranza', | 97 | label: 'cobranza', |
98 | val: newValue | 98 | val: newValue |
99 | }); | 99 | }); |
100 | }, true); | 100 | }, true); |
101 | 101 | ||
102 | $scope.crearCobranza = function() { | 102 | $scope.crearCobranza = function() { |
103 | if (!$scope.cobranza.cliente.COD) { | 103 | if (!$scope.cobranza.cliente.COD) { |
104 | focaModalService.alert('Ingrese Cliente'); | 104 | focaModalService.alert('Ingrese Cliente'); |
105 | return; | 105 | return; |
106 | } | 106 | } |
107 | if (!$scope.cobranza.cobrador.NUM) { | 107 | if (!$scope.cobranza.cobrador.NUM) { |
108 | focaModalService.alert('Ingrese Cobrador'); | 108 | focaModalService.alert('Ingrese Cobrador'); |
109 | return; | 109 | return; |
110 | } | 110 | } |
111 | if ($scope.cobranza.facturas.length < 1) { | 111 | if ($scope.cobranza.facturas.length < 1) { |
112 | focaModalService.alert('Ingrese al menos una factura'); | 112 | focaModalService.alert('Ingrese al menos una factura'); |
113 | return; | 113 | return; |
114 | } | 114 | } |
115 | if ($scope.getTotalCobrado() + (Math.abs($scope.getTotalDeuda()) * -1) !== 0) { | 115 | if ($scope.getTotalCobrado() + $scope.getTotalDeuda() !== 0) { |
116 | focaModalService.alert('La diferencia debe ser ' + | 116 | focaModalService.alert('La diferencia debe ser ' + |
117 | $scope.cobranza.moneda.SIMBOLO + '0,00'); | 117 | $scope.cobranza.moneda.SIMBOLO + '0,00'); |
118 | return; | 118 | return; |
119 | } | 119 | } |
120 | var cobranza = {}; | 120 | var cobranza = {}; |
121 | var cheques = []; | 121 | var cheques = []; |
122 | var cuerpos = []; | 122 | var cuerpos = []; |
123 | var imgs = []; | 123 | var imgs = []; |
124 | var observacion; | 124 | var observacion; |
125 | //TODO: habilitar edición | 125 | //TODO: habilitar edición |
126 | $scope.editando = false; | 126 | $scope.editando = false; |
127 | focaBotoneraLateralService.startGuardar(); | 127 | focaBotoneraLateralService.startGuardar(); |
128 | $scope.saveLoading = true; | 128 | $scope.saveLoading = true; |
129 | for(var i = 0; i < $scope.cobranza.facturas.length; i++) { | 129 | for(var i = 0; i < $scope.cobranza.facturas.length; i++) { |
130 | var cuerpoFactura = { | 130 | var cuerpoFactura = { |
131 | CYV: 'V', | 131 | CYV: 'V', |
132 | TIP: 'C', | 132 | TIP: 'C', |
133 | TCO: 'RC', | 133 | TCO: 'RC', |
134 | PVE: $scope.puntoVenta, | 134 | PVE: $scope.puntoVenta, |
135 | NCO: $scope.comprobante, | 135 | NCO: $scope.comprobante, |
136 | LOP: 'L', | 136 | LOP: 'L', |
137 | TIL: $scope.cobranza.facturas[i].TCO, | 137 | TIL: $scope.cobranza.facturas[i].TCO, |
138 | COM: $scope.cobranza.facturas[i].COM + '-' + | 138 | COM: $scope.cobranza.facturas[i].COM + '-' + |
139 | $filter('rellenarDigitos')($scope.cobranza.facturas[i].NCU,2), | 139 | $filter('rellenarDigitos')($scope.cobranza.facturas[i].NCU,2), |
140 | FEC: new Date($scope.cobranza.FEC) | 140 | FEC: new Date($scope.cobranza.FEC) |
141 | .toISOString().slice(0, 19).replace('T', ' '), | 141 | .toISOString().slice(0, 19).replace('T', ' '), |
142 | IMP: Math.abs($scope.cobranza.facturas[i].IMP || | 142 | IMP: Math.abs($scope.cobranza.facturas[i].IMP || |
143 | $scope.cobranza.facturas[i].IPA), | 143 | $scope.cobranza.facturas[i].IPA), |
144 | RES: 0,//caja de tesorería | 144 | RES: 0,//caja de tesorería |
145 | SUBM: 0, | 145 | SUBM: 0, |
146 | NCU: $scope.cobranza.facturas[i].NCU | 146 | NCU: $scope.cobranza.facturas[i].NCU |
147 | }; | 147 | }; |
148 | cuerpos.push(cuerpoFactura); | 148 | cuerpos.push(cuerpoFactura); |
149 | 149 | ||
150 | } | 150 | } |
151 | 151 | ||
152 | for (var j = 0; j < $scope.cobranza.cobros.length; j++) { | 152 | for (var j = 0; j < $scope.cobranza.cobros.length; j++) { |
153 | 153 | ||
154 | var efectivo = $scope.cobranza.cobros[j].tipo === 'Efectivo'; | 154 | var efectivo = $scope.cobranza.cobros[j].tipo === 'Efectivo'; |
155 | var cuerpoCobros = { | 155 | var cuerpoCobros = { |
156 | CYV: 'V', | 156 | CYV: 'V', |
157 | TIP: 'C', | 157 | TIP: 'C', |
158 | TCO: 'RC', | 158 | TCO: 'RC', |
159 | PVE: $scope.puntoVenta, | 159 | PVE: $scope.puntoVenta, |
160 | NCO: $scope.comprobante, | 160 | NCO: $scope.comprobante, |
161 | LOP: 'P', | 161 | LOP: 'P', |
162 | TIL: $scope.cobranza.cobros[j].TIL, | 162 | TIL: $scope.cobranza.cobros[j].TIL, |
163 | COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : $scope.cobranza.cobros[j].COM, | 163 | COM: efectivo ? 'ef(COBRO EN EFECTIVO)' : $scope.cobranza.cobros[j].COM, |
164 | FEC: !$scope.cobranza.cobros[j].fechaPresentacion ? | 164 | FEC: !$scope.cobranza.cobros[j].fechaPresentacion ? |
165 | new Date($scope.cobranza.cobros[j].FEC) | 165 | new Date($scope.cobranza.cobros[j].FEC) |
166 | .toISOString().slice(0, 19).replace('T', ' ') : | 166 | .toISOString().slice(0, 19).replace('T', ' ') : |
167 | new Date($scope.cobranza.cobros[j].fechaPresentacion) | 167 | new Date($scope.cobranza.cobros[j].fechaPresentacion) |
168 | .toISOString().slice(0, 19).replace('T', ' '), | 168 | .toISOString().slice(0, 19).replace('T', ' '), |
169 | IMP: Math.abs($scope.cobranza.cobros[j].IMP), | 169 | IMP: Math.abs($scope.cobranza.cobros[j].IMP), |
170 | RES: 0,//caja de tesorería | 170 | RES: 0,//caja de tesorería |
171 | SUBM: 0 | 171 | SUBM: 0 |
172 | }; | 172 | }; |
173 | cuerpos.push(cuerpoCobros); | 173 | cuerpos.push(cuerpoCobros); |
174 | 174 | ||
175 | if ($scope.cobranza.cobros[j].observacion) | 175 | if ($scope.cobranza.cobros[j].observacion) |
176 | observacion = $scope.cobranza.cobros[j].observacion; | 176 | observacion = $scope.cobranza.cobros[j].observacion; |
177 | 177 | ||
178 | if ($scope.cobranza.cobros[j].banco) { | 178 | if ($scope.cobranza.cobros[j].banco) { |
179 | var cheque = { | 179 | var cheque = { |
180 | BCO: $scope.cobranza.cobros[j].banco.ID, | 180 | BCO: $scope.cobranza.cobros[j].banco.ID, |
181 | NUM: $scope.comprobante, | 181 | NUM: $scope.comprobante, |
182 | FEP: new Date($scope.cobranza.cobros[j].fechaPresentacion) | 182 | FEP: new Date($scope.cobranza.cobros[j].fechaPresentacion) |
183 | .toISOString().slice(0, 19).replace('T', ' '), | 183 | .toISOString().slice(0, 19).replace('T', ' '), |
184 | FEE: new Date($scope.cobranza.cobros[j].fechaEmision) | 184 | FEE: new Date($scope.cobranza.cobros[j].fechaEmision) |
185 | .toISOString().slice(0, 19).replace('T', ' '), | 185 | .toISOString().slice(0, 19).replace('T', ' '), |
186 | LUG: $scope.cobranza.cobros[j].localidad.NOMBRE, | 186 | LUG: $scope.cobranza.cobros[j].localidad.NOMBRE, |
187 | IMP: $scope.cobranza.cobros[j].importe, | 187 | IMP: $scope.cobranza.cobros[j].importe, |
188 | LIB: $scope.cobranza.cobros[j].librador, | 188 | LIB: $scope.cobranza.cobros[j].librador, |
189 | EST: 'C',//'D' depositado, 'E' entregado, 'C' en cartera | 189 | EST: 'C',//'D' depositado, 'E' entregado, 'C' en cartera |
190 | PCI: $scope.cobranza.cobros[j].provincia.ID, | 190 | PCI: $scope.cobranza.cobros[j].provincia.ID, |
191 | LPLA: 0, | 191 | LPLA: 0, |
192 | PLA: 0, | 192 | PLA: 0, |
193 | VEN: $scope.cobranza.cobrador.id,//Id vendedor | 193 | VEN: $scope.cobranza.cobrador.id,//Id vendedor |
194 | CCLIE: $scope.cobranza.cliente.COD,//Id cliente | 194 | CCLIE: $scope.cobranza.cliente.COD,//Id cliente |
195 | REN: 0, | 195 | REN: 0, |
196 | PVEC: $scope.puntoVenta, | 196 | PVEC: $scope.puntoVenta, |
197 | NCOC: $scope.comprobante, | 197 | NCOC: $scope.comprobante, |
198 | OBSE: $scope.cobranza.cobros[j].observaciones, | 198 | OBSE: $scope.cobranza.cobros[j].observaciones, |
199 | LUV: 0, | 199 | LUV: 0, |
200 | ORI: 've', | 200 | ORI: 've', |
201 | FER: '', | 201 | FER: '', |
202 | BIMP: 0, | 202 | BIMP: 0, |
203 | COMP: 'C ' +'RC ' + $scope.puntoVenta + '-' + $scope.comprobante, | 203 | COMP: 'C ' +'RC ' + $scope.puntoVenta + '-' + $scope.comprobante, |
204 | VAL_E: '',//Cuando egresa por ingresos y egresos en el numero de egreso | 204 | VAL_E: '',//Cuando egresa por ingresos y egresos en el numero de egreso |
205 | VAL_I: '',//Cuando Ingresa por ingresos y egresos en el numero ingreso | 205 | VAL_I: '',//Cuando Ingresa por ingresos y egresos en el numero ingreso |
206 | REC_CAJ: 'D', | 206 | REC_CAJ: 'D', |
207 | TIPO_C: 0,//?? | 207 | TIPO_C: 0,//?? |
208 | SALDO_CAJ: 'S', | 208 | SALDO_CAJ: 'S', |
209 | FECHA_INGRESO: new Date($scope.cobranza.fecha) | 209 | FECHA_INGRESO: new Date($scope.cobranza.FEC) |
210 | .toISOString().slice(0, 19).replace('T', ' '), | 210 | .toISOString().slice(0, 19).replace('T', ' '), |
211 | Vendedor_valor: 0, | 211 | Vendedor_valor: 0, |
212 | FAMILIA: 0, | 212 | FAMILIA: 0, |
213 | CUIT_LIB: '', | 213 | CUIT_LIB: '', |
214 | COD_LUG: $scope.cobranza.cobros[j].localidad.ID,//código lugar | 214 | COD_LUG: $scope.cobranza.cobros[j].localidad.ID,//código lugar |
215 | SEN: '', | 215 | SEN: '', |
216 | NRC: 0, | 216 | NRC: 0, |
217 | COD_LARGO: '', | 217 | COD_LARGO: '', |
218 | VN: 0, | 218 | VN: 0, |
219 | ID_LECTOR: 0, | 219 | ID_LECTOR: 0, |
220 | NATHB: '' | 220 | NATHB: '' |
221 | }; | 221 | }; |
222 | cheques.push(cheque); | 222 | cheques.push(cheque); |
223 | } | 223 | } |
224 | if ($scope.cobranza.cobros[j].imgs) imgs = $scope.cobranza.cobros[j].imgs; | 224 | if ($scope.cobranza.cobros[j].imgs) imgs = $scope.cobranza.cobros[j].imgs; |
225 | 225 | ||
226 | } | 226 | } |
227 | 227 | ||
228 | cobranza = { | 228 | cobranza = { |
229 | recibo: { | 229 | recibo: { |
230 | CYV: 'V', | 230 | CYV: 'V', |
231 | TIP: 'C', | 231 | TIP: 'C', |
232 | TCO: 'RC', | 232 | TCO: 'RC', |
233 | PVE: $scope.puntoVenta, //Sucursar, punto de venta | 233 | PVE: $scope.puntoVenta, //Sucursar, punto de venta |
234 | NCO: $scope.comprobante, //Numero de comprobante | 234 | NCO: $scope.comprobante, //Numero de comprobante |
235 | FEC: new Date($scope.cobranza.FEC) | 235 | FEC: new Date($scope.cobranza.FEC) |
236 | .toISOString().slice(0, 19).replace('T', ' '), | 236 | .toISOString().slice(0, 19).replace('T', ' '), |
237 | CLI: $scope.cobranza.cliente.COD, | 237 | CLI: $scope.cobranza.cliente.COD, |
238 | ATO: 0, //número de asiento | 238 | ATO: 0, //número de asiento |
239 | CFE: $scope.cobranza.cobrador.NOM, | 239 | CFE: $scope.cobranza.cobrador.NOM, |
240 | PLA: '',//Numero de planilla, sin uso | 240 | PLA: '',//Numero de planilla, sin uso |
241 | ID_MONEDA: $scope.cobranza.moneda.ID, | 241 | ID_MONEDA: $scope.cobranza.moneda.ID, |
242 | COTIZACION: $scope.cobranza.moneda.cotizacion.VENDEDOR, | 242 | COTIZACION: $scope.cobranza.moneda.cotizacion.VENDEDOR, |
243 | idCobrador: $scope.cobranza.cobrador.id | 243 | idCobrador: $scope.cobranza.cobrador.id |
244 | }, | 244 | }, |
245 | cuerpo: cuerpos, | 245 | cuerpo: cuerpos, |
246 | cheques: cheques, | 246 | cheques: cheques, |
247 | acobypag: { | 247 | acobypag: { |
248 | CYV: 'V', | 248 | CYV: 'V', |
249 | COD: $scope.cobranza.cliente.COD, | 249 | COD: $scope.cobranza.cliente.COD, |
250 | FEP: new Date($scope.cobranza.FEC) | 250 | FEP: new Date($scope.cobranza.FEC) |
251 | .toISOString().slice(0, 19).replace('T', ' '), | 251 | .toISOString().slice(0, 19).replace('T', ' '), |
252 | TIP: 'C', | 252 | TIP: 'C', |
253 | TCO: 'RC', | 253 | TCO: 'RC', |
254 | SUC: $scope.puntoVenta, | 254 | SUC: $scope.puntoVenta, |
255 | NCO: $scope.comprobante, | 255 | NCO: $scope.comprobante, |
256 | IPA: $scope.getTotalCobrado(), | 256 | IPA: $scope.getTotalCobrado(), |
257 | SAL: '',//?? | 257 | SAL: '',//?? |
258 | TCA: 1, | 258 | TCA: 1, |
259 | ZONA: 1, | 259 | ZONA: 1, |
260 | FPA: 2,//Forma de pago | 260 | FPA: 2,//Forma de pago |
261 | REC: 0, | 261 | REC: 0, |
262 | REP: 0, | 262 | REP: 0, |
263 | FER: null, | 263 | FER: null, |
264 | REM: 0, | 264 | REM: 0, |
265 | FRE: null,//?? | 265 | FRE: null,//?? |
266 | PRO: 'N', | 266 | PRO: 'N', |
267 | FEV: new Date($scope.cobranza.FEC) | 267 | FEV: new Date($scope.cobranza.FEC) |
268 | .toISOString().slice(0, 19).replace('T', ' ') | 268 | .toISOString().slice(0, 19).replace('T', ' ') |
269 | }, | 269 | }, |
270 | datosCobrador: { | 270 | datosCobrador: { |
271 | COD: $scope.cobranza.cobrador.NUM, | 271 | COD: $scope.cobranza.cobrador.NUM, |
272 | PVE: $scope.puntoVenta, | 272 | PVE: $scope.puntoVenta, |
273 | NUM: $scope.comprobante, | 273 | NUM: $scope.comprobante, |
274 | EST: 'C', | 274 | EST: 'C', |
275 | OBS: 'RC: ' + $scope.comprobante + '-' + | 275 | OBS: 'RC: ' + $scope.comprobante + '-' + |
276 | new Date($scope.cobranza.FEC).toLocaleDateString(), | 276 | new Date($scope.cobranza.FEC).toLocaleDateString(), |
277 | DAT1: 'C', | 277 | DAT1: 'C', |
278 | CLI: $scope.cobranza.cliente.COD | 278 | CLI: $scope.cobranza.cliente.COD |
279 | }, | 279 | }, |
280 | cliente: $scope.cobranza.cliente, | 280 | cliente: $scope.cobranza.cliente, |
281 | imgs: imgs, | 281 | imgs: imgs, |
282 | observacion: observacion | 282 | observacion: observacion |
283 | }; | 283 | }; |
284 | //COPIO cobranzaMail Y A cobranza LE ELIMINO EL VALOR NCU DE LOS CUERPOS | 284 | //COPIO cobranzaMail Y A cobranza LE ELIMINO EL VALOR NCU DE LOS CUERPOS |
285 | var cobranzaMail = angular.copy(cobranza); | 285 | var cobranzaMail = angular.copy(cobranza); |
286 | cobranza.cuerpo = cobranza.cuerpo.map(function(c) { | 286 | cobranza.cuerpo = cobranza.cuerpo.map(function(c) { |
287 | if (c.NCU) delete c.NCU; | 287 | if (c.NCU) delete c.NCU; |
288 | return c; | 288 | return c; |
289 | }); | 289 | }); |
290 | 290 | ||
291 | focaCrearCobranzaService | 291 | focaCrearCobranzaService |
292 | .guardarCobranza(cobranza) | 292 | .guardarCobranza(cobranza) |
293 | .then( | 293 | .then( |
294 | function(result) { | 294 | function(result) { |
295 | focaBotoneraLateralService.endGuardar(true); | 295 | focaBotoneraLateralService.endGuardar(true); |
296 | $scope.saveLoading = false; | 296 | $scope.saveLoading = false; |
297 | 297 | ||
298 | enviarMail(cobranzaMail); | 298 | enviarMail(cobranzaMail); |
299 | 299 | ||
300 | focaSeguimientoService.guardarPosicion( | 300 | focaSeguimientoService.guardarPosicion( |
301 | 'Cobranza', | 301 | 'Cobranza', |
302 | result.data, | 302 | result.data, |
303 | '' | 303 | '' |
304 | ); | 304 | ); |
305 | 305 | ||
306 | init(); | 306 | init(); |
307 | }, function(error) { | 307 | }, function(error) { |
308 | focaModalService.alert('Hubo un problema al cargar la cobranza'); | 308 | focaModalService.alert('Hubo un problema al cargar la cobranza'); |
309 | focaBotoneraLateralService.endGuardar(); | 309 | focaBotoneraLateralService.endGuardar(); |
310 | $scope.saveLoading = false; | 310 | $scope.saveLoading = false; |
311 | console.info(error); | 311 | console.info(error); |
312 | } | 312 | } |
313 | ); | 313 | ); |
314 | }; | 314 | }; |
315 | 315 | ||
316 | $scope.seleccionarCobros = function() { | 316 | $scope.seleccionarCobros = function() { |
317 | $scope.cobroDeuda = false; | 317 | $scope.cobroDeuda = false; |
318 | }; | 318 | }; |
319 | 319 | ||
320 | $scope.seleccionarComprobantes = function() { | 320 | $scope.seleccionarComprobantes = function() { |
321 | $scope.cobroDeuda = true; | 321 | $scope.cobroDeuda = true; |
322 | }; | 322 | }; |
323 | 323 | ||
324 | $scope.seleccionarCobranza = function() { | 324 | $scope.seleccionarCobranza = function() { |
325 | 325 | ||
326 | var modalInstance = $uibModal.open( | 326 | var modalInstance = $uibModal.open( |
327 | { | 327 | { |
328 | ariaLabelledBy: 'Busqueda de Cobranzas', | 328 | ariaLabelledBy: 'Busqueda de Cobranzas', |
329 | templateUrl: 'foca-modal-cobranza.html', | 329 | templateUrl: 'foca-modal-cobranza.html', |
330 | controller: 'focaModalCobranzaController', | 330 | controller: 'focaModalCobranzaController', |
331 | size: 'lg' | 331 | size: 'lg' |
332 | } | 332 | } |
333 | ); | 333 | ); |
334 | modalInstance.result.then(function(cobranza) { | 334 | modalInstance.result.then(function(cobranza) { |
335 | cobranza.moneda.cotizacion = cobranza.moneda.cotizaciones[0]; | 335 | cobranza.moneda.cotizacion = cobranza.moneda.cotizaciones[0]; |
336 | setearCobranza(cobranza); | 336 | setearCobranza(cobranza); |
337 | }); | 337 | }); |
338 | }; | 338 | }; |
339 | 339 | ||
340 | $scope.seleccionarResumenDeCuenta = function() { | 340 | $scope.seleccionarResumenDeCuenta = function() { |
341 | if (!$scope.cobranza.cliente.COD) { | 341 | if (!$scope.cobranza.cliente.COD) { |
342 | focaModalService.alert('Seleccione primero un cliente'); | 342 | focaModalService.alert('Seleccione primero un cliente'); |
343 | return; | 343 | return; |
344 | } | 344 | } |
345 | var modalInstance = $uibModal.open( | 345 | var modalInstance = $uibModal.open( |
346 | { | 346 | { |
347 | ariaLabelledBy: 'Resumen de cuentas', | 347 | ariaLabelledBy: 'Resumen de cuentas', |
348 | templateUrl: 'modal-resumen-cuenta.html', | 348 | templateUrl: 'modal-resumen-cuenta.html', |
349 | controller: 'focaModalResumenCuentaController', | 349 | controller: 'focaModalResumenCuentaController', |
350 | resolve: { | 350 | resolve: { |
351 | cliente: function() { return $scope.cobranza.cliente; } | 351 | cliente: function() { return $scope.cobranza.cliente; } |
352 | }, | 352 | }, |
353 | size: 'lg' | 353 | size: 'lg' |
354 | } | 354 | } |
355 | ); | 355 | ); |
356 | modalInstance.result.then( | 356 | modalInstance.result.then( |
357 | function(cliente) { | 357 | function(cliente) { |
358 | $scope.abrirModalDomicilios(cliente); | 358 | $scope.abrirModalDomicilios(cliente); |
359 | $scope.cliente = cliente; | 359 | $scope.cliente = cliente; |
360 | }, function() {} | 360 | }, function() {} |
361 | ); | 361 | ); |
362 | }; | 362 | }; |
363 | 363 | ||
364 | $scope.seleccionarCliente = function() { | 364 | $scope.seleccionarCliente = function() { |
365 | $scope.seleccionarCobrador(function() { | 365 | $scope.seleccionarCobrador(function() { |
366 | var modalInstance = $uibModal.open( | 366 | var modalInstance = $uibModal.open( |
367 | { | 367 | { |
368 | ariaLabelledBy: 'Busqueda de Cliente', | 368 | ariaLabelledBy: 'Busqueda de Cliente', |
369 | templateUrl: 'foca-busqueda-cliente-modal.html', | 369 | templateUrl: 'foca-busqueda-cliente-modal.html', |
370 | controller: 'focaBusquedaClienteModalController', | 370 | controller: 'focaBusquedaClienteModalController', |
371 | resolve: { | 371 | resolve: { |
372 | vendedor: function() { return null; }, | 372 | vendedor: function() { return null; }, |
373 | cobrador: function() { return $scope.cobranza.cobrador; } | 373 | cobrador: function() { return $scope.cobranza.cobrador; } |
374 | }, | 374 | }, |
375 | size: 'lg' | 375 | size: 'lg' |
376 | } | 376 | } |
377 | ); | 377 | ); |
378 | modalInstance.result.then( | 378 | modalInstance.result.then( |
379 | function(cliente) { | 379 | function(cliente) { |
380 | var clienteMayus = { | 380 | var clienteMayus = { |
381 | COD: cliente.cod, | 381 | COD: cliente.cod, |
382 | NOM: cliente.nom, | 382 | NOM: cliente.nom, |
383 | CUIT: cliente.cuit, | 383 | CUIT: cliente.cuit, |
384 | MAIL: cliente.mail | 384 | MAIL: cliente.mail |
385 | }; | 385 | }; |
386 | 386 | ||
387 | $scope.$broadcast('addCabecera', { | 387 | $scope.$broadcast('addCabecera', { |
388 | label: 'Cliente:', | 388 | label: 'Cliente:', |
389 | valor: $filter('rellenarDigitos')(clienteMayus.COD, 5) + ' - ' + | 389 | valor: $filter('rellenarDigitos')(clienteMayus.COD, 5) + ' - ' + |
390 | clienteMayus.NOM | 390 | clienteMayus.NOM |
391 | }); | 391 | }); |
392 | $scope.cobranza.cliente = clienteMayus; | 392 | $scope.cobranza.cliente = clienteMayus; |
393 | $scope.cobranza.facturas = []; | 393 | $scope.cobranza.facturas = []; |
394 | }, function() { | 394 | }, function() { |
395 | if (APP !== 'cobranza') $scope.seleccionarCliente(); | 395 | if (APP !== 'cobranza') $scope.seleccionarCliente(); |
396 | } | 396 | } |
397 | ); | 397 | ); |
398 | }); | 398 | }); |
399 | }; | 399 | }; |
400 | 400 | ||
401 | $scope.seleccionarCobrador = function(callback) { | 401 | $scope.seleccionarCobrador = function(callback) { |
402 | 402 | ||
403 | if (APP === 'cobranza') { | 403 | if (APP === 'cobranza') { |
404 | callback(); | 404 | callback(); |
405 | return; | 405 | return; |
406 | } | 406 | } |
407 | 407 | ||
408 | var parametrosModal = { | 408 | var parametrosModal = { |
409 | query: '/cobrador', | 409 | query: '/cobrador', |
410 | columnas: [ | 410 | columnas: [ |
411 | { | 411 | { |
412 | propiedad: 'NUM', | 412 | propiedad: 'NUM', |
413 | nombre: 'Codigo', | 413 | nombre: 'Codigo', |
414 | filtro: { | 414 | filtro: { |
415 | nombre: 'rellenarDigitos', | 415 | nombre: 'rellenarDigitos', |
416 | parametro: 3 | 416 | parametro: 3 |
417 | } | 417 | } |
418 | }, | 418 | }, |
419 | { | 419 | { |
420 | propiedad: 'NOM', | 420 | propiedad: 'NOM', |
421 | nombre: 'Nombre' | 421 | nombre: 'Nombre' |
422 | } | 422 | } |
423 | ], | 423 | ], |
424 | titulo:'Búsqueda de cobradores' | 424 | titulo:'Búsqueda de cobradores' |
425 | }; | 425 | }; |
426 | focaModalService.modal(parametrosModal).then( | 426 | focaModalService.modal(parametrosModal).then( |
427 | function(cobrador) { | 427 | function(cobrador) { |
428 | $scope.$broadcast('addCabecera', { | 428 | $scope.$broadcast('addCabecera', { |
429 | label: 'Cobrador:', | 429 | label: 'Cobrador:', |
430 | valor: $filter('rellenarDigitos')(cobrador.NUM, 3) + ' - ' + | 430 | valor: $filter('rellenarDigitos')(cobrador.NUM, 3) + ' - ' + |
431 | cobrador.NOM | 431 | cobrador.NOM |
432 | }); | 432 | }); |
433 | $scope.cobranza.cobrador = cobrador; | 433 | $scope.cobranza.cobrador = cobrador; |
434 | 434 | ||
435 | //ELIMINO CLIENTE | 435 | //ELIMINO CLIENTE |
436 | $scope.$broadcast('removeCabecera', 'Cliente:'); | 436 | $scope.$broadcast('removeCabecera', 'Cliente:'); |
437 | $scope.cobranza.cliente = {}; | 437 | $scope.cobranza.cliente = {}; |
438 | 438 | ||
439 | callback(); | 439 | callback(); |
440 | }, function() {} | 440 | }, function() {} |
441 | ); | 441 | ); |
442 | }; | 442 | }; |
443 | 443 | ||
444 | $scope.seleccionarFactura = function() { | 444 | $scope.seleccionarFactura = function() { |
445 | if (!$scope.cobranza.cliente.COD) { | 445 | if (!$scope.cobranza.cliente.COD) { |
446 | focaModalService.alert('Seleccione primero un cliente'); | 446 | focaModalService.alert('Seleccione primero un cliente'); |
447 | return; | 447 | return; |
448 | } | 448 | } |
449 | var modalInstance = $uibModal.open( | 449 | var modalInstance = $uibModal.open( |
450 | { | 450 | { |
451 | ariaLabelledBy: 'Busqueda de Facturas', | 451 | ariaLabelledBy: 'Busqueda de Facturas', |
452 | templateUrl: 'foca-modal-factura.html', | 452 | templateUrl: 'foca-modal-factura.html', |
453 | controller: 'focaModalFacturaController', | 453 | controller: 'focaModalFacturaController', |
454 | size: 'lg', | 454 | size: 'lg', |
455 | resolve: { | 455 | resolve: { |
456 | parametrosFactura: function() { | 456 | parametrosFactura: function() { |
457 | return { | 457 | return { |
458 | cliente: $scope.cobranza.cliente, | 458 | cliente: $scope.cobranza.cliente, |
459 | simbolo: $scope.cobranza.moneda.SIMBOLO, | 459 | simbolo: $scope.cobranza.moneda.SIMBOLO, |
460 | cotizacion: $scope.cobranza.moneda, | 460 | cotizacion: $scope.cobranza.moneda, |
461 | moneda: $scope.cobranza.moneda.ID | 461 | moneda: $scope.cobranza.moneda.ID |
462 | }; | 462 | }; |
463 | } | 463 | } |
464 | } | 464 | } |
465 | } | 465 | } |
466 | ); | 466 | ); |
467 | modalInstance.result.then( | 467 | modalInstance.result.then( |
468 | function(facturas) { | 468 | function(facturas) { |
469 | var facturasResult = []; | 469 | var facturasResult = []; |
470 | //AGREGO A FACTURASRESULT LAS FACTURAS QUE NO HAN SIDO SELECCIONADAS | 470 | //AGREGO A FACTURASRESULT LAS FACTURAS QUE NO HAN SIDO SELECCIONADAS |
471 | facturas.forEach(function(factura) { | 471 | facturas.forEach(function(factura) { |
472 | var existe = $scope.cobranza.facturas.filter(function(e) { | 472 | var existe = $scope.cobranza.facturas.filter(function(e) { |
473 | return angular.equals(factura, e); | 473 | return angular.equals(factura, e); |
474 | }); | 474 | }); |
475 | 475 | ||
476 | if (!existe.length) facturasResult.push(factura); | 476 | if (!existe.length) facturasResult.push(factura); |
477 | }); | 477 | }); |
478 | 478 | ||
479 | $scope.cobranza.facturas = $scope.cobranza.facturas.concat(facturasResult); | 479 | $scope.cobranza.facturas = $scope.cobranza.facturas.concat(facturasResult); |
480 | }, function() { } | 480 | }, function() { } |
481 | ); | 481 | ); |
482 | }; | 482 | }; |
483 | 483 | ||
484 | $scope.seleccionarCheque = function() { | 484 | $scope.seleccionarCheque = function(cheque) { |
485 | |||
486 | var parametros; | ||
487 | |||
488 | if(!cheque) { | ||
489 | parametros = { | ||
490 | importe: getSugerido(), | ||
491 | esNuevo : true | ||
492 | }; | ||
493 | } else { | ||
494 | parametros = cheque; | ||
495 | parametros.importe = cheque.IMP; | ||
496 | } | ||
497 | |||
485 | var modalInstance = $uibModal.open( | 498 | var modalInstance = $uibModal.open( |
486 | { | 499 | { |
487 | ariaLabelledBy: 'Carga de cheques', | 500 | ariaLabelledBy: 'Carga de cheques', |
488 | templateUrl: 'modal-cheque.html', | 501 | templateUrl: 'modal-cheque.html', |
489 | controller: 'focaModalChequeController', | 502 | controller: 'focaModalChequeController', |
490 | size: 'lg', | 503 | size: 'lg', |
491 | resolve: { | 504 | resolve: { |
492 | sugerido: function() { | 505 | cheque: function() { |
493 | var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); | 506 | return parametros; |
494 | return sugerido < 0 ? sugerido : null; | ||
495 | } | 507 | } |
496 | } | 508 | } |
497 | } | 509 | } |
498 | ); | 510 | ); |
499 | modalInstance.result.then( | 511 | modalInstance.result.then( |
500 | function(cheque) { | 512 | function(cheque) { |
501 | var cobro = { | 513 | var cobro = { |
502 | COM: 'ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco, | 514 | COM: 'ch' + '(' + cheque.numero + ')' + ' ' + cheque.banco.desbco, |
503 | numero: cheque.numero, | 515 | numero: cheque.numero, |
504 | banco: cheque.banco, | 516 | banco: cheque.banco, |
505 | FEC: cheque.fechaEmision.toLocaleDateString() + '-' + | 517 | FEC: cheque.fechaEmision.toLocaleDateString() + '-' + |
506 | cheque.fechaPresentacion.toLocaleDateString(), | 518 | cheque.fechaPresentacion.toLocaleDateString(), |
507 | fechaPresentacion: cheque.fechaPresentacion, | 519 | fechaPresentacion: cheque.fechaPresentacion, |
508 | fechaEmision: cheque.fechaEmision, | 520 | fechaEmision: cheque.fechaEmision, |
509 | IMP: cheque.importe * $scope.cobranza.moneda.cotizacion.VENDEDOR, | 521 | IMP: cheque.importe, |
510 | localidad: cheque.localidad, | 522 | localidad: cheque.localidad, |
511 | librador: cheque.librador, | 523 | librador: cheque.librador, |
512 | provincia: cheque.provincia, | 524 | provincia: cheque.provincia, |
513 | observaciones: cheque.observaciones, | 525 | observaciones: cheque.observaciones, |
514 | TIL: 'EF' | 526 | TIL: 'EF' |
515 | }; | 527 | }; |
516 | $scope.cobranza.cobros.push(cobro); | 528 | pushearCobro(cobro, cheque.$$hashKey); |
517 | }, function() { | 529 | }, function() { |
518 | 530 | ||
519 | } | 531 | } |
520 | ); | 532 | ); |
521 | }; | 533 | }; |
522 | 534 | ||
523 | $scope.seleccionarEfectivo = function() { | 535 | $scope.seleccionarEfectivo = function() { |
536 | |||
537 | var importe = 0; | ||
538 | $scope.cobranza.cobros.filter(function(a) { | ||
539 | if(a.COM === 'Efectivo') { | ||
540 | importe = a.IMP; | ||
541 | } | ||
542 | }); | ||
543 | |||
544 | |||
524 | var modalInstance = $uibModal.open( | 545 | var modalInstance = $uibModal.open( |
525 | { | 546 | { |
526 | ariaLabelledBy: 'Carga de cheques', | 547 | ariaLabelledBy: 'Carga de cheques', |
527 | templateUrl: 'modal-efectivo.html', | 548 | templateUrl: 'modal-efectivo.html', |
528 | controller: 'focaModalEfectivoController', | 549 | controller: 'focaModalEfectivoController', |
529 | size: 'sm', | 550 | size: 'sm', |
530 | resolve: { | 551 | resolve: { |
531 | sugerido: function() { | 552 | sugerido: function() { |
532 | var sugerido = $scope.getTotalDeuda() - $scope.getTotalCobrado(); | 553 | return parseFloat(getSugerido()) + parseFloat(importe); |
533 | return sugerido < 0 ? sugerido : null; | ||
534 | } | 554 | } |
535 | } | 555 | } |
536 | } | 556 | } |
537 | ); | 557 | ); |
538 | modalInstance.result.then( | 558 | modalInstance.result.then( |
539 | function(efectivo) { | 559 | function(efectivo) { |
560 | |||
540 | var cobro = { | 561 | var cobro = { |
541 | COM: 'Efectivo', | 562 | COM: 'Efectivo', |
542 | FEC: new Date(), | 563 | FEC: new Date(), |
543 | IMP: efectivo * $scope.cobranza.moneda.cotizacion.VENDEDOR, | 564 | IMP: efectivo, |
544 | TIL: 'EF' | 565 | TIL: 'EF' |
545 | }; | 566 | }; |
567 | |||
546 | $scope.cobranza.cobros = $scope.cobranza.cobros.filter(function(a) { | 568 | $scope.cobranza.cobros = $scope.cobranza.cobros.filter(function(a) { |
547 | return a.tipo !== 'Efectivo'; | 569 | return a.COM !== 'Efectivo'; |
548 | }); | 570 | }); |
571 | |||
549 | $scope.cobranza.cobros.push(cobro); | 572 | $scope.cobranza.cobros.push(cobro); |
550 | }, function() { | 573 | }, function() { |
551 | 574 | ||
552 | } | 575 | } |
553 | ); | 576 | ); |
554 | }; | 577 | }; |
555 | 578 | ||
556 | $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 | |||
557 | var modalInstance = $uibModal.open( | 594 | var modalInstance = $uibModal.open( |
558 | { | 595 | { |
559 | ariaLabelledBy: 'Carga de detalles', | 596 | ariaLabelledBy: 'Carga de detalles', |
560 | templateUrl: 'modal-detalles.html', | 597 | templateUrl: 'modal-detalles.html', |
561 | controller: 'focaModalDetallesController', | 598 | controller: 'focaModalDetallesController', |
562 | size: 'lg', | 599 | size: 'lg', |
563 | resolve: { | 600 | resolve: { |
564 | sugerido: function() { | 601 | parametros: function() { |
565 | var sugerido = $scope.getTotalDeuda() + $scope.getTotalCobrado(); | 602 | return parametro; |
566 | return sugerido < 0 ? sugerido : null; | ||
567 | } | 603 | } |
568 | } | 604 | } |
569 | } | 605 | } |
570 | ); | 606 | ); |
571 | modalInstance.result.then( | 607 | modalInstance.result.then( |
572 | function(detalles) { | 608 | function(detalles) { |
609 | |||
573 | var cobro = { | 610 | var cobro = { |
574 | COM: 'de(COBRO POR DETALLES)', | 611 | COM: 'de(COBRO POR DETALLES)', |
575 | FEC: new Date(), | 612 | FEC: new Date(), |
576 | IMP: detalles.monto * $scope.cobranza.moneda.cotizacion.VENDEDOR, | 613 | IMP: detalles.importe, |
577 | imgs: detalles.imgs, | 614 | imgs: detalles.files, |
578 | TIL: 'DE', | 615 | TIL: 'DE', |
579 | observacion: detalles.observacion | 616 | observacion: detalles.observacion |
580 | }; | 617 | }; |
581 | var existe = false; | 618 | pushearCobro(cobro, detalles.$$hashKey); |
582 | |||
583 | $scope.cobranza.cobros.forEach(function(c, idx) { | ||
584 | if (c.til === 'DE') { | ||
585 | $scope.cobranza.cobros[idx] = cobro; | ||
586 | existe = true; | ||
587 | } | ||
588 | }); | ||
589 | if (!existe) { | ||
590 | $scope.cobranza.cobros.push(cobro); | ||
591 | } | ||
592 | }, function() {} | 619 | }, function() {} |
593 | ); | 620 | ); |
594 | }; | 621 | }; |
595 | 622 | ||
596 | $scope.seleccionarMoneda = function() { | 623 | $scope.seleccionarMoneda = function() { |
597 | var parametrosModal = { | 624 | var parametrosModal = { |
598 | titulo: 'Búsqueda de monedas', | 625 | titulo: 'Búsqueda de monedas', |
599 | query: '/moneda', | 626 | query: '/moneda', |
600 | columnas: [ | 627 | columnas: [ |
601 | { | 628 | { |
602 | propiedad: 'DETALLE', | 629 | propiedad: 'DETALLE', |
603 | nombre: 'Nombre' | 630 | nombre: 'Nombre' |
604 | }, | 631 | }, |
605 | { | 632 | { |
606 | propiedad: 'SIMBOLO', | 633 | propiedad: 'SIMBOLO', |
607 | nombre: 'Símbolo' | 634 | nombre: 'Símbolo' |
608 | } | 635 | } |
609 | ], | 636 | ], |
610 | size: 'md' | 637 | size: 'md' |
611 | }; | 638 | }; |
612 | focaModalService.modal(parametrosModal).then( | 639 | focaModalService.modal(parametrosModal).then( |
613 | function(moneda) { | 640 | function(moneda) { |
614 | $scope.seleccionarCotizacion(moneda); | 641 | $scope.seleccionarCotizacion(moneda); |
615 | }, function() { | 642 | }, function() { |
616 | 643 | ||
617 | } | 644 | } |
618 | ); | 645 | ); |
619 | }; | 646 | }; |
620 | 647 | ||
621 | $scope.seleccionarCotizacion = function(moneda) { | 648 | $scope.seleccionarCotizacion = function(moneda) { |
622 | var modalInstance = $uibModal.open( | 649 | var modalInstance = $uibModal.open( |
623 | { | 650 | { |
624 | ariaLabelledBy: 'Busqueda de Cotización', | 651 | ariaLabelledBy: 'Busqueda de Cotización', |
625 | templateUrl: 'modal-cotizacion.html', | 652 | templateUrl: 'modal-cotizacion.html', |
626 | controller: 'focaModalCotizacionController', | 653 | controller: 'focaModalCotizacionController', |
627 | size: 'lg', | 654 | size: 'lg', |
628 | resolve: {idMoneda: function() {return moneda.ID;}} | 655 | resolve: {idMoneda: function() {return moneda.ID;}} |
629 | } | 656 | } |
630 | ); | 657 | ); |
631 | modalInstance.result.then( | 658 | modalInstance.result.then( |
632 | function(cotizacion) { | 659 | function(cotizacion) { |
633 | $scope.cobranza.moneda = moneda; | 660 | $scope.cobranza.moneda = moneda; |
634 | $scope.cobranza.moneda.cotizacion = cotizacion; | 661 | $scope.cobranza.moneda.cotizacion = cotizacion; |
635 | if (moneda.DETALLE === 'PESOS ARGENTINOS') { | 662 | if (moneda.DETALLE === 'PESOS ARGENTINOS') { |
636 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 663 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
637 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 664 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
638 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 665 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
639 | } else { | 666 | } else { |
640 | $scope.$broadcast('addCabecera', { | 667 | $scope.$broadcast('addCabecera', { |
641 | label: 'Moneda:', | 668 | label: 'Moneda:', |
642 | valor: moneda.DETALLE | 669 | valor: moneda.DETALLE |
643 | }); | 670 | }); |
644 | $scope.$broadcast('addCabecera', { | 671 | $scope.$broadcast('addCabecera', { |
645 | label: 'Fecha cotizacion:', | 672 | label: 'Fecha cotizacion:', |
646 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 673 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
647 | }); | 674 | }); |
648 | $scope.$broadcast('addCabecera', { | 675 | $scope.$broadcast('addCabecera', { |
649 | label: 'Cotizacion:', | 676 | label: 'Cotizacion:', |
650 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 677 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
651 | }); | 678 | }); |
652 | } | 679 | } |
653 | 680 | ||
654 | }, function() { | 681 | }, function() { |
655 | 682 | ||
656 | } | 683 | } |
657 | ); | 684 | ); |
658 | }; | 685 | }; |
659 | 686 | ||
660 | $scope.getTotalDeuda = function() { | 687 | $scope.getTotalDeuda = function() { |
661 | var total = 0; | 688 | var total = 0; |
662 | for (var i = 0; i < $scope.cobranza.facturas.length; i++) { | 689 | for (var i = 0; i < $scope.cobranza.facturas.length; i++) { |
663 | total += $scope.cobranza.facturas[i].IMP || $scope.cobranza.facturas[i].IPA; | 690 | total += $scope.cobranza.facturas[i].IMP || $scope.cobranza.facturas[i].IPA; |
664 | } | 691 | } |
665 | return parseFloat(total.toFixed(2)); | 692 | return parseFloat(total.toFixed(2)); |
666 | }; | 693 | }; |
667 | 694 | ||
668 | $scope.getTotalCobrado = function() { | 695 | $scope.getTotalCobrado = function() { |
669 | var total = 0; | 696 | var total = 0; |
670 | for (var i = 0; i < $scope.cobranza.cobros.length; i++) { | 697 | for (var i = 0; i < $scope.cobranza.cobros.length; i++) { |
671 | total += $scope.cobranza.cobros[i].IMP; | 698 | total += $scope.cobranza.cobros[i].IMP; |
672 | } | 699 | } |
673 | return parseFloat(total.toFixed(2)); | 700 | return parseFloat(total.toFixed(2)); |
674 | }; | 701 | }; |
675 | 702 | ||
676 | $scope.getSubTotal = function() { | 703 | $scope.getSubTotal = function() { |
677 | if ($scope.articuloACargar) { | 704 | if ($scope.articuloACargar) { |
678 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 705 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
679 | } | 706 | } |
680 | }; | 707 | }; |
681 | //Recibe aviso si el teclado está en uso | 708 | //Recibe aviso si el teclado está en uso |
682 | // $rootScope.$on('usarTeclado', function(event, data) { | 709 | // $rootScope.$on('usarTeclado', function(event, data) { |
683 | // if(data) { | 710 | // if(data) { |
684 | // $scope.mostrarTeclado = true; | 711 | // $scope.mostrarTeclado = true; |
685 | // return; | 712 | // return; |
686 | // } | 713 | // } |
687 | // $scope.mostrarTeclado = false; | 714 | // $scope.mostrarTeclado = false; |
688 | // }) | 715 | // }) |
689 | $scope.selectFocus = function($event) { | 716 | $scope.selectFocus = function($event) { |
690 | //Si el teclado esta en uso no selecciona el valor | 717 | //Si el teclado esta en uso no selecciona el valor |
691 | // if($scope.mostrarTeclado) { | 718 | // if($scope.mostrarTeclado) { |
692 | // return; | 719 | // return; |
693 | // } | 720 | // } |
694 | $event.target.select(); | 721 | $event.target.select(); |
695 | }; | 722 | }; |
696 | 723 | ||
697 | $scope.salir = function() { | 724 | $scope.salir = function() { |
698 | $location.path('/'); | 725 | $location.path('/'); |
699 | }; | 726 | }; |
700 | 727 | ||
701 | $scope.parsearATexto = function(articulo) { | 728 | $scope.parsearATexto = function(articulo) { |
702 | articulo.cantidad = parseFloat(articulo.cantidad); | 729 | articulo.cantidad = parseFloat(articulo.cantidad); |
703 | articulo.precio = parseFloat(articulo.precio); | 730 | articulo.precio = parseFloat(articulo.precio); |
704 | }; | 731 | }; |
705 | 732 | ||
706 | $scope.quitarFactura = function(key) { | 733 | $scope.quitarFactura = function(key) { |
707 | $scope.cobranza.facturas.splice(key, 1); | 734 | $scope.cobranza.facturas.splice(key, 1); |
708 | }; | 735 | }; |
709 | 736 | ||
710 | $scope.quitarCobro = function(key) { | 737 | $scope.quitarCobro = function(key) { |
711 | $scope.cobranza.cobros.splice(key, 1); | 738 | $scope.cobranza.cobros.splice(key, 1); |
712 | }; | 739 | }; |
713 | 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 | |||
714 | function salir() { | 765 | function salir() { |
715 | var confirmacion = false; | 766 | var confirmacion = false; |
716 | 767 | ||
717 | if (!angular.equals($scope.cobranza, $scope.inicial)) { | 768 | if (!angular.equals($scope.cobranza, $scope.inicial)) { |
718 | confirmacion = true; | 769 | confirmacion = true; |
719 | } | 770 | } |
720 | 771 | ||
721 | if (confirmacion) { | 772 | if (confirmacion) { |
722 | focaModalService.confirm( | 773 | focaModalService.confirm( |
723 | '¿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.' |
724 | ).then(function(data) { | 775 | ).then(function(data) { |
725 | if (data) { | 776 | if (data) { |
726 | $location.path('/'); | 777 | $location.path('/'); |
727 | } | 778 | } |
728 | }); | 779 | }); |
729 | } else { | 780 | } else { |
730 | $location.path('/'); | 781 | $location.path('/'); |
731 | } | 782 | } |
732 | } | 783 | } |
733 | 784 | ||
734 | function setearCobranza(cobranza) { | 785 | function setearCobranza(cobranza) { |
735 | $scope.editando = true; | 786 | $scope.editando = true; |
736 | $scope.$broadcast('cleanCabecera'); | 787 | $scope.$broadcast('cleanCabecera'); |
737 | 788 | ||
738 | if (cobranza.cliente) { | 789 | if (cobranza.cliente) { |
739 | $scope.$broadcast('addCabecera', { | 790 | $scope.$broadcast('addCabecera', { |
740 | label: 'Cliente:', | 791 | label: 'Cliente:', |
741 | valor: $filter('rellenarDigitos')(cobranza.cliente.COD, 5) + ' - ' + | 792 | valor: $filter('rellenarDigitos')(cobranza.cliente.COD, 5) + ' - ' + |
742 | cobranza.cliente.NOM | 793 | cobranza.cliente.NOM |
743 | }); | 794 | }); |
744 | } | 795 | } |
745 | if (cobranza.cobrador && cobranza.cobrador.NUM) { | 796 | if (cobranza.cobrador && cobranza.cobrador.NUM) { |
746 | $scope.$broadcast('addCabecera', { | 797 | $scope.$broadcast('addCabecera', { |
747 | label: 'Cobrador:', | 798 | label: 'Cobrador:', |
748 | valor: (cobranza.cobrador.NUM) ? | 799 | valor: (cobranza.cobrador.NUM) ? |
749 | $filter('rellenarDigitos')(cobranza.cobrador.NUM, 5) + ' - ' + | 800 | $filter('rellenarDigitos')(cobranza.cobrador.NUM, 5) + ' - ' + |
750 | cobranza.cobrador.NOM : cobranza.cobrador | 801 | cobranza.cobrador.NOM : cobranza.cobrador |
751 | 802 | ||
752 | }); | 803 | }); |
753 | } | 804 | } |
754 | 805 | ||
755 | $scope.cobranza = cobranza; | 806 | $scope.cobranza = cobranza; |
756 | } | 807 | } |
757 | 808 | ||
758 | function getLSCobranza() { | 809 | function getLSCobranza() { |
759 | var cobranza = JSON.parse($localStorage.cobranza || null); | 810 | var cobranza = JSON.parse($localStorage.cobranza || null); |
760 | if (cobranza) { | 811 | if (cobranza) { |
761 | setearCobranza(cobranza); | 812 | setearCobranza(cobranza); |
762 | delete $localStorage.cobranza; | 813 | delete $localStorage.cobranza; |
763 | } | 814 | } |
764 | } | 815 | } |
765 | 816 | ||
766 | function enviarMail(recibo) { | 817 | function enviarMail(recibo) { |
767 | focaModalService.mail( | 818 | focaModalService.mail( |
768 | { | 819 | { |
769 | titulo: 'Enviar recibo', | 820 | titulo: 'Enviar recibo', |
770 | descarga: { | 821 | descarga: { |
771 | nombre: recibo.recibo.PVE + '-' + recibo.recibo.NCO + '.pdf', | 822 | nombre: recibo.recibo.PVE + '-' + recibo.recibo.NCO + '.pdf', |
772 | url: '/mail/recibo/descargar', | 823 | url: '/mail/recibo/descargar', |
773 | }, | 824 | }, |
774 | envio: { | 825 | envio: { |
775 | mailCliente: recibo.cliente.MAIL, | 826 | mailCliente: recibo.cliente.MAIL, |
776 | url: '/mail/recibo', | 827 | url: '/mail/recibo', |
777 | }, | 828 | }, |
778 | options: { | 829 | options: { |
779 | recibo: recibo | 830 | recibo: recibo |
780 | } | 831 | } |
781 | } | 832 | } |
782 | ); | 833 | ); |
783 | } | 834 | } |
835 | |||
836 | function getSugerido() { |
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.FEC" | 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.COM || factura.numeroFactura" | 54 | <td class="col" ng-bind="factura.COM || factura.numeroFactura" |
55 | ></td> | 55 | ></td> |
56 | <td class="col" ng-bind="factura.FEC || 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.IMP ||factura.IPA) / cobranza.moneda.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.moneda.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.moneda.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.moneda.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.COM"></td> | 147 | <td class="col" ng-bind="cobro.COM"></td> |
148 | <td class="col" ng-bind="cobro.FEC | 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.IMP / cobranza.moneda.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 | class="btn btn-outline-light" | 155 | class="btn btn-outline-light" |
156 | ng-click="editarCobro(cobro)" | ||
157 | > | ||
158 | <i class="fa fa-edit"></i> | ||
159 | </button> | ||
160 | <button | ||
161 | class="btn btn-outline-light" | ||
156 | ng-click="quitarCobro(key)" | 162 | ng-click="quitarCobro(key)" |
157 | > | 163 | > |
158 | <i class="fa fa-trash"></i> | 164 | <i class="fa fa-trash"></i> |
159 | </button> | 165 | </button> |
160 | </td> | 166 | </td> |
161 | </tr> | 167 | </tr> |
162 | </tbody> | 168 | </tbody> |
163 | <tfoot> | 169 | <tfoot> |
164 | <tr ng-show="cargando" class="d-flex"> | 170 | <tr ng-show="cargando" class="d-flex"> |
165 | <td class="col-2 border-top-0"> | 171 | <td class="col-2 border-top-0"> |
166 | <a | 172 | <a |
167 | class="form-control form-control-sm btn btn-secondary" | 173 | class="form-control form-control-sm btn btn-secondary" |
168 | ng-click="seleccionarCheque()" | 174 | ng-click="seleccionarCheque()" |
169 | >Cheque</a> | 175 | >Cheque</a> |
170 | </td> | 176 | </td> |
171 | <td class="col-2 border-top-0"> | 177 | <td class="col-2 border-top-0"> |
172 | <a | 178 | <a |
173 | class="form-control form-control-sm btn btn-secondary" | 179 | class="form-control form-control-sm btn btn-secondary" |
174 | ng-click="seleccionarEfectivo()" | 180 | ng-click="seleccionarEfectivo()" |
175 | >Efectivo</a> | 181 | >Efectivo</a> |
176 | </td> | 182 | </td> |
177 | <td class="col-2 border-top-0"> | 183 | <td class="col-2 border-top-0"> |
178 | <a | 184 | <a |
179 | class="form-control form-control-sm btn btn-secondary" | 185 | class="form-control form-control-sm btn btn-secondary" |
180 | ng-click="seleccionarDetalles()" | 186 | ng-click="seleccionarDetalles()" |
181 | >Detalle</a> | 187 | >Detalle</a> |
182 | </td> | 188 | </td> |
183 | </tr> | 189 | </tr> |
184 | <tr class="d-flex"> | 190 | <tr class="d-flex"> |
185 | <td class="col-auto px-1 border-top-0"> | 191 | <td class="col-auto px-1 border-top-0"> |
186 | <strong>Cobros:</strong> | 192 | <strong>Cobros:</strong> |
187 | <a ng-bind="cobranza.cobros.length"></a> | 193 | <a ng-bind="cobranza.cobros.length"></a> |
188 | </td> | 194 | </td> |
189 | <td class="text-right ml-auto table-celda-total no-border-top"> | 195 | <td class="text-right ml-auto table-celda-total no-border-top"> |
190 | <strong>Cancela:</strong> | 196 | <strong>Cancela:</strong> |
191 | </td> | 197 | </td> |
192 | <td class="table-celda-total text-right no-border-top"> | 198 | <td class="table-celda-total text-right no-border-top"> |
193 | <strong>{{(getTotalDeuda() / cobranza.moneda.cotizacion.VENDEDOR) | | 199 | <strong>{{(getTotalDeuda() / cobranza.moneda.cotizacion.VENDEDOR) | |
194 | currency: cobranza.moneda.SIMBOLO}}</strong> | 200 | currency: cobranza.moneda.SIMBOLO}}</strong> |
195 | </td> | 201 | </td> |
196 | <td class="text-right ml-auto table-celda-total no-border-top"> | 202 | <td class="text-right ml-auto table-celda-total no-border-top"> |
197 | <strong>Total Cobrado:</strong> | 203 | <strong>Total Cobrado:</strong> |
198 | </td> | 204 | </td> |
199 | <td class="table-celda-total text-right no-border-top"> | 205 | <td class="table-celda-total text-right no-border-top"> |
200 | <strong>{{(getTotalCobrado() / cobranza.moneda.cotizacion.VENDEDOR) | | 206 | <strong>{{(getTotalCobrado() / cobranza.moneda.cotizacion.VENDEDOR) | |
201 | currency: cobranza.moneda.SIMBOLO}}</strong> | 207 | currency: cobranza.moneda.SIMBOLO}}</strong> |
202 | </td> | 208 | </td> |
203 | <td class="text-right ml-auto table-celda-total no-border-top"> | 209 | <td class="text-right ml-auto table-celda-total no-border-top"> |
204 | <strong>DF:</strong> | 210 | <strong>DF:</strong> |
205 | </td> | 211 | </td> |
206 | <td class="table-celda-total text-right no-border-top mr-1"> | 212 | <td class="table-celda-total text-right no-border-top mr-1"> |
207 | <strong>{{((getTotalCobrado() + getTotalDeuda()) / | 213 | <strong>{{((getTotalCobrado() + getTotalDeuda()) / |
208 | cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}} | 214 | cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}} |
209 | </strong> | 215 | </strong> |
210 | </td> | 216 | </td> |
211 | </tr> | 217 | </tr> |
212 | </tfoot> | 218 | </tfoot> |
213 | </table> | 219 | </table> |
214 | </div> | 220 | </div> |
215 | <!-- MOBILE --> | 221 | <!-- MOBILE --> |
216 | <div class="row d-sm-none mb-5"> | 222 | <div class="row d-sm-none mb-5"> |
217 | <!-- FACTURAS --> | 223 | <!-- FACTURAS --> |
218 | <table class="table table-sm table-striped tabla-articulo mb-5" ng-show="cobroDeuda"> | 224 | <table class="table table-sm table-striped tabla-articulo mb-5" ng-show="cobroDeuda"> |
219 | <thead> | 225 | <thead> |
220 | <tr class="d-flex"> | 226 | <tr class="d-flex"> |
221 | <th class="">#</th> | 227 | <th class="">#</th> |
222 | <th class="col px-0"> | 228 | <th class="col px-0"> |
223 | <div class="d-flex"> | 229 | <div class="d-flex"> |
224 | <div class="col-4 px-1">Factura</div> | 230 | <div class="col-4 px-1">Factura</div> |
225 | <div class="col-4 px-1">Fecha</div> | 231 | <div class="col-4 px-1">Fecha</div> |
226 | <div class="col-4 px-1">Importe</div> | 232 | <div class="col-4 px-1">Importe</div> |
227 | </div> | 233 | </div> |
228 | </th> | 234 | </th> |
229 | <th class="text-center tamaño-boton"> | 235 | <th class="text-center tamaño-boton"> |
230 | | 236 | |
231 | </th> | 237 | </th> |
232 | </tr> | 238 | </tr> |
233 | </thead> | 239 | </thead> |
234 | <tbody> | 240 | <tbody> |
235 | <tr | 241 | <tr |
236 | ng-repeat="(key, factura) in cobranza.facturas" | 242 | ng-repeat="(key, factura) in cobranza.facturas" |
237 | ng-show="show || key == cobranza.facturas.length - 1" | 243 | ng-show="show || key == cobranza.facturas.length - 1" |
238 | > | 244 | > |
239 | <td class="w-100 align-middle d-flex p-0"> | 245 | <td class="w-100 align-middle d-flex p-0"> |
240 | <div class="align-middle p-1"> | 246 | <div class="align-middle p-1"> |
241 | <span ng-bind="key+1" class="align-middle"></span> | 247 | <span ng-bind="key+1" class="align-middle"></span> |
242 | </div> | 248 | </div> |
243 | <div class="col px-0"> | 249 | <div class="col px-0"> |
244 | <div class="d-flex"> | 250 | <div class="d-flex"> |
245 | <div class="col-4 p-1"> | 251 | <div class="col-4 p-1"> |
246 | <span ng-bind="factura.COM" | 252 | <span ng-bind="factura.COM" |
247 | ></span> | 253 | ></span> |
248 | </div> | 254 | </div> |
249 | <div class="col-4 p-1"> | 255 | <div class="col-4 p-1"> |
250 | <span ng-bind="factura.FEC | date : 'dd/MM/yyyy'"></span> | 256 | <span ng-bind="factura.FEC | date : 'dd/MM/yyyy'"></span> |
251 | </div> | 257 | </div> |
252 | <div class="col-4 p-1"> | 258 | <div class="col-4 p-1"> |
253 | <span | 259 | <span |
254 | ng-bind="(factura.IMP / cobranza.COTIZACION) | | 260 | ng-bind="(factura.IMP / cobranza.COTIZACION) | |
255 | currency:cobranza.moneda.SIMBOLO : 4"></span> | 261 | currency:cobranza.moneda.SIMBOLO : 4"></span> |
256 | </div> | 262 | </div> |
257 | </div> | 263 | </div> |
258 | </div> | 264 | </div> |
259 | <div class="align-middle p-1"> | 265 | <div class="align-middle p-1"> |
260 | <button | 266 | <button |
261 | class="btn btn-outline-light" | 267 | class="btn btn-outline-light" |
262 | ng-click="quitarFactura(key)" | 268 | ng-click="quitarFactura(key)" |
263 | > | 269 | > |
264 | <i class="fa fa-trash"></i> | 270 | <i class="fa fa-trash"></i> |
265 | </button> | 271 | </button> |
266 | </div> | 272 | </div> |
267 | </td> | 273 | </td> |
268 | </tr> | 274 | </tr> |
269 | </tbody> | 275 | </tbody> |
270 | <tfoot> | 276 | <tfoot> |
271 | <!-- SELECCIONAR PRODUCTO --> | 277 | <!-- SELECCIONAR PRODUCTO --> |
272 | <tr ng-show="cargando" class="d-flex"> | 278 | <tr ng-show="cargando" class="d-flex"> |
273 | <td class="col-12"> | 279 | <td class="col-12"> |
274 | <input | 280 | <input |
275 | placeholder="Seleccione Factura" | 281 | placeholder="Seleccione Factura" |
276 | class="form-control form-control-sm" | 282 | class="form-control form-control-sm" |
277 | readonly | 283 | readonly |
278 | ng-click="seleccionarFactura()" | 284 | ng-click="seleccionarFactura()" |
279 | /> | 285 | /> |
280 | </td> | 286 | </td> |
281 | </tr> | 287 | </tr> |
282 | <!-- TOOGLE EXPANDIR --> | 288 | <!-- TOOGLE EXPANDIR --> |
283 | <tr> | 289 | <tr> |
284 | <td class="col"> | 290 | <td class="col"> |
285 | <button | 291 | <button |
286 | class="btn btn-outline-light selectable w-100" | 292 | class="btn btn-outline-light selectable w-100" |
287 | ng-click="show = !show; masMenos()" | 293 | ng-click="show = !show; masMenos()" |
288 | ng-show="cobranza.facturas.length > 0" | 294 | ng-show="cobranza.facturas.length > 0" |
289 | > | 295 | > |
290 | <i | 296 | <i |
291 | class="fa fa-chevron-down" | 297 | class="fa fa-chevron-down" |
292 | ng-hide="show" | 298 | ng-hide="show" |
293 | aria-hidden="true" | 299 | aria-hidden="true" |
294 | > | 300 | > |
295 | </i> | 301 | </i> |
296 | <i | 302 | <i |
297 | class="fa fa-chevron-up" | 303 | class="fa fa-chevron-up" |
298 | ng-show="show" | 304 | ng-show="show" |
299 | aria-hidden="true"> | 305 | aria-hidden="true"> |
300 | </i> | 306 | </i> |
301 | </button> | 307 | </button> |
302 | </td> | 308 | </td> |
303 | </tr> | 309 | </tr> |
304 | <!-- FOOTER --> | 310 | <!-- FOOTER --> |
305 | <tr class="d-flex"> | 311 | <tr class="d-flex"> |
306 | <td class="align-middle no-border-top" colspan="2"> | 312 | <td class="align-middle no-border-top" colspan="2"> |
307 | <strong>Cantidad Items:</strong> | 313 | <strong>Cantidad Items:</strong> |
308 | <a ng-bind="cobranza.facturas.length"></a> | 314 | <a ng-bind="cobranza.facturas.length"></a> |
309 | </td> | 315 | </td> |
310 | </tr> | 316 | </tr> |
311 | </tfoot> | 317 | </tfoot> |
312 | </table> | 318 | </table> |
313 | <!-- COBROS --> | 319 | <!-- COBROS --> |
314 | <table class="table table-sm table-striped tabla-articulo mb-5" ng-show="!cobroDeuda"> | 320 | <table class="table table-sm table-striped tabla-articulo mb-5" ng-show="!cobroDeuda"> |
315 | <thead> | 321 | <thead> |
316 | <tr class="d-flex"> | 322 | <tr class="d-flex"> |
317 | <th class="">#</th> | 323 | <th class="">#</th> |
318 | <th class="col px-0"> | 324 | <th class="col px-0"> |
319 | <div class="d-flex"> | 325 | <div class="d-flex"> |
320 | <div class="col-4 px-1">Cobro</div> | 326 | <div class="col-4 px-1">Cobro</div> |
321 | <div class="col-4 px-1">Fecha</div> | 327 | <div class="col-4 px-1">Fecha</div> |
322 | <div class="col-4 px-1">Importe</div> | 328 | <div class="col-4 px-1">Importe</div> |
323 | </div> | 329 | </div> |
324 | </th> | 330 | </th> |
325 | <th class="text-center tamaño-boton"> | 331 | <th class="text-center tamaño-boton"> |
326 | | 332 | |
327 | </th> | 333 | </th> |
328 | </tr> | 334 | </tr> |
329 | </thead> | 335 | </thead> |
330 | <tbody> | 336 | <tbody> |
331 | <tr | 337 | <tr |
332 | ng-repeat="(key, cobro) in cobranza.cobros" | 338 | ng-repeat="(key, cobro) in cobranza.cobros" |
333 | ng-show="show || key == cobranza.cobros.length - 1" | 339 | ng-show="show || key == cobranza.cobros.length - 1" |
334 | > | 340 | > |
335 | <td class="w-100 align-middle d-flex p-0"> | 341 | <td class="w-100 align-middle d-flex p-0"> |
336 | <div class="align-middle p-1"> | 342 | <div class="align-middle p-1"> |
337 | <span ng-bind="key+1" class="align-middle"></span> | 343 | <span ng-bind="key+1" class="align-middle"></span> |
338 | </div> | 344 | </div> |
339 | <div class="col px-0"> | 345 | <div class="col px-0"> |
340 | <div class="d-flex"> | 346 | <div class="d-flex"> |
341 | <div class="col-4 p-1"> | 347 | <div class="col-4 p-1"> |
342 | <span ng-bind="cobro.tipo" | 348 | <span ng-bind="cobro.tipo" |
343 | ></span> | 349 | ></span> |
344 | </div> | 350 | </div> |
345 | <div class="col-4 p-1"> | 351 | <div class="col-4 p-1"> |
346 | <span ng-bind="cobro.fecha | date : 'dd/MM/yyyy'"></span> | 352 | <span ng-bind="cobro.fecha | date : 'dd/MM/yyyy'"></span> |
347 | </div> | 353 | </div> |
348 | <div class="col-4 p-1"> | 354 | <div class="col-4 p-1"> |
349 | <span | 355 | <span |
350 | ng-bind="(cobro.importe / cobranza.moneda.cotizacion.VENDEDOR) | | 356 | ng-bind="(cobro.importe / cobranza.moneda.cotizacion.VENDEDOR) | |
351 | currency: cobranza.moneda.SIMBOLO : 4"></span> | 357 | currency: cobranza.moneda.SIMBOLO : 4"></span> |
352 | </div> | 358 | </div> |
353 | </div> | 359 | </div> |
354 | </div> | 360 | </div> |
355 | <div class="align-middle p-1"> | 361 | <div class="align-middle p-1"> |
356 | <button | 362 | <button |
357 | class="btn btn-outline-light" | 363 | class="btn btn-outline-light" |
358 | ng-click="quitarCobro(key)" | 364 | ng-click="quitarCobro(key)" |
359 | > | 365 | > |
360 | <i class="fa fa-trash"></i> | 366 | <i class="fa fa-trash"></i> |
361 | </button> | 367 | </button> |
362 | </div> | 368 | </div> |
363 | </td> | 369 | </td> |
364 | </tr> | 370 | </tr> |
365 | </tbody> | 371 | </tbody> |
366 | <tfoot> | 372 | <tfoot> |
367 | <!-- SELECCIONAR PRODUCTO --> | 373 | <!-- SELECCIONAR PRODUCTO --> |
368 | <tr ng-show="cargando" class="d-flex"> | 374 | <tr ng-show="cargando" class="d-flex"> |
369 | <td class="col-4"> | 375 | <td class="col-4"> |
370 | <input | 376 | <input |
371 | placeholder="Cheque" | 377 | placeholder="Cheque" |
372 | class="form-control form-control-sm" | 378 | class="form-control form-control-sm" |
373 | readonly | 379 | readonly |
374 | ng-click="seleccionarCheque()" | 380 | ng-click="seleccionarCheque()" |
375 | /> | 381 | /> |
376 | </td> | 382 | </td> |
377 | <td class="col-4"> | 383 | <td class="col-4"> |
378 | <input | 384 | <input |
379 | placeholder="Efectivo" | 385 | placeholder="Efectivo" |
380 | class="form-control form-control-sm" | 386 | class="form-control form-control-sm" |
381 | readonly | 387 | readonly |
382 | ng-click="seleccionarEfectivo()" | 388 | ng-click="seleccionarEfectivo()" |
383 | /> | 389 | /> |
384 | </td> | 390 | </td> |
385 | <td class="col-4"> | 391 | <td class="col-4"> |
386 | <input | 392 | <input |
387 | placeholder="Detalles" | 393 | placeholder="Detalles" |
388 | class="form-control form-control-sm" | 394 | class="form-control form-control-sm" |
389 | readonly | 395 | readonly |
390 | ng-click="seleccionarDetalles()" | 396 | ng-click="seleccionarDetalles()" |
391 | /> | 397 | /> |
392 | </td> | 398 | </td> |
393 | </tr> | 399 | </tr> |
394 | <!-- TOOGLE EXPANDIR --> | 400 | <!-- TOOGLE EXPANDIR --> |
395 | <tr> | 401 | <tr> |
396 | <td class="col"> | 402 | <td class="col"> |
397 | <button | 403 | <button |
398 | class="btn btn-outline-light selectable w-100" | 404 | class="btn btn-outline-light selectable w-100" |
399 | ng-click="show = !show; masMenos()" | 405 | ng-click="show = !show; masMenos()" |
400 | ng-show="cobranza.cobros.length > 0" | 406 | ng-show="cobranza.cobros.length > 0" |
401 | > | 407 | > |
402 | <i | 408 | <i |
403 | class="fa fa-chevron-down" | 409 | class="fa fa-chevron-down" |
404 | ng-hide="show" | 410 | ng-hide="show" |
405 | aria-hidden="true" | 411 | aria-hidden="true" |
406 | > | 412 | > |
407 | </i> | 413 | </i> |
408 | <i | 414 | <i |
409 | class="fa fa-chevron-up" | 415 | class="fa fa-chevron-up" |
410 | ng-show="show" | 416 | ng-show="show" |
411 | aria-hidden="true"> | 417 | aria-hidden="true"> |
412 | </i> | 418 | </i> |
413 | </button> | 419 | </button> |
414 | </td> | 420 | </td> |
415 | </tr> | 421 | </tr> |
416 | <!-- FOOTER --> | 422 | <!-- FOOTER --> |
417 | <tr class="d-flex"> | 423 | <tr class="d-flex"> |
418 | <td class="align-middle no-border-top col-6"> | 424 | <td class="align-middle no-border-top col-6"> |
419 | <strong>Cantidad Items:</strong> | 425 | <strong>Cantidad Items:</strong> |
420 | <a ng-bind="cobranza.cobros.length"></a> | 426 | <a ng-bind="cobranza.cobros.length"></a> |
421 | </td> | 427 | </td> |
422 | </tfoot> | 428 | </tfoot> |
423 | </table> | 429 | </table> |
424 | </tr> | 430 | </tr> |
425 | <!-- DEUDA, COBRADO, DIFERENCIA --> | 431 | <!-- DEUDA, COBRADO, DIFERENCIA --> |
426 | <table class="table-responsive fixed-bottom mb-5"> | 432 | <table class="table-responsive fixed-bottom mb-5"> |
427 | <tr class="d-flex row"> | 433 | <tr class="d-flex row"> |
428 | <td class="text-center ml-auto table-celda-total no-border-top col-4"> | 434 | <td class="text-center ml-auto table-celda-total no-border-top col-4"> |
429 | <strong>Cancela:</strong> | 435 | <strong>Cancela:</strong> |
430 | </td> | 436 | </td> |
431 | <td class="text-center ml-auto table-celda-total no-border-top col-4"> | 437 | <td class="text-center ml-auto table-celda-total no-border-top col-4"> |
432 | <strong>Cobrado:</strong> | 438 | <strong>Cobrado:</strong> |
433 | </td> | 439 | </td> |
434 | <td class="text-center ml-auto table-celda-total no-border-top col-4"> | 440 | <td class="text-center ml-auto table-celda-total no-border-top col-4"> |
435 | <strong>Diferencia:</strong> | 441 | <strong>Diferencia:</strong> |
436 | </td> | 442 | </td> |
437 | <td class="table-celda-total text-center no-border-top col-4"> | 443 | <td class="table-celda-total text-center no-border-top col-4"> |
438 | <strong>{{(getTotalDeuda() / cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong> | 444 | <strong>{{(getTotalDeuda() / cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong> |
439 | </td> | 445 | </td> |
440 | <td class="table-celda-total text-center no-border-top col-4"> | 446 | <td class="table-celda-total text-center no-border-top col-4"> |
441 | <strong>{{(getTotalCobrado() / cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong> | 447 | <strong>{{(getTotalCobrado() / cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong> |
442 | </td> | 448 | </td> |
443 | <td class="table-celda-total text-center no-border-top col-4"> | 449 | <td class="table-celda-total text-center no-border-top col-4"> |
444 | <strong>{{((getTotalCobrado() + getTotalDeuda()) / cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong> | 450 | <strong>{{((getTotalCobrado() + getTotalDeuda()) / cobranza.moneda.cotizacion.VENDEDOR) | currency: cobranza.moneda.SIMBOLO}}</strong> |
445 | </td> | 451 | </td> |
446 | </tr> | 452 | </tr> |
447 | </table> | 453 | </table> |
448 | </div> | 454 | </div> |
449 | </div> | 455 | </div> |
450 | </div> | 456 | </div> |
451 | </div> | 457 | </div> |
452 | <div class="row d-md-none fixed-bottom"> | 458 | <div class="row d-md-none fixed-bottom"> |
453 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> | 459 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> |
454 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> | 460 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> |
455 | <span | 461 | <span |
456 | class="mr-3 ml-auto" | 462 | class="mr-3 ml-auto" |
457 | ng-class="saveLoading ? 'text-muted' : ''" | 463 | ng-class="saveLoading ? 'text-muted' : ''" |
458 | ng-click="crearCobranza()" | 464 | ng-click="crearCobranza()" |
459 | ng-show="!editando" | 465 | ng-show="!editando" |
460 | ladda="saveLoading" | 466 | ladda="saveLoading" |
461 | data-style="expand-left" | 467 | data-style="expand-left" |
462 | >Guardar</span> | 468 | >Guardar</span> |
463 | </div> | 469 | </div> |
464 | </div> | 470 | </div> |
465 | </div> | 471 | </div> |
466 | 472 |