Commit 34f75fc292c48d366056c1336cf83edcbf28721d
Exists in
master
Merge branch 'develop' of http://git.focasoftware.com/npm/foca-crear-remito
Showing
7 changed files
Show diff stats
gulpfile.js
1 | const templateCache = require('gulp-angular-templatecache'); | 1 | const templateCache = require('gulp-angular-templatecache'); |
2 | const clean = require('gulp-clean'); | 2 | const clean = require('gulp-clean'); |
3 | const concat = require('gulp-concat'); | 3 | const concat = require('gulp-concat'); |
4 | const htmlmin = require('gulp-htmlmin'); | 4 | const htmlmin = require('gulp-htmlmin'); |
5 | const rename = require('gulp-rename'); | 5 | const rename = require('gulp-rename'); |
6 | const uglify = require('gulp-uglify'); | 6 | const uglify = require('gulp-uglify'); |
7 | const gulp = require('gulp'); | 7 | const gulp = require('gulp'); |
8 | const pump = require('pump'); | 8 | const pump = require('pump'); |
9 | const jshint = require('gulp-jshint'); | 9 | const jshint = require('gulp-jshint'); |
10 | const replace = require('gulp-replace'); | 10 | const replace = require('gulp-replace'); |
11 | const connect = require('gulp-connect'); | 11 | const connect = require('gulp-connect'); |
12 | const header = require('gulp-header'); | ||
13 | const footer = require('gulp-footer'); | ||
14 | const gulpSequence = require('gulp-sequence'); | ||
12 | const header = require('gulp-header'); | 15 | |
13 | const footer = require('gulp-footer'); | 16 | var paths = { |
14 | const gulpSequence = require('gulp-sequence'); | 17 | srcJS: 'src/js/*.js', |
15 | 18 | srcViews: 'src/views/*.html', | |
19 | specs: 'spec/*.js', | ||
16 | var paths = { | 20 | tmp: 'tmp', |
17 | srcJS: 'src/js/*.js', | 21 | dist: 'dist/' |
18 | srcViews: 'src/views/*.html', | 22 | }; |
19 | specs: 'spec/*.js', | 23 | |
20 | tmp: 'tmp', | 24 | gulp.task('uglify', function(callback) { |
25 | gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')(callback); | ||
26 | }); | ||
27 | |||
28 | gulp.task('templates', function() { | ||
21 | dist: 'dist/' | 29 | return pump( |
22 | }; | 30 | [ |
23 | 31 | gulp.src(paths.srcViews), | |
24 | gulp.task('uglify', gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')); | 32 | htmlmin(), |
25 | 33 | templateCache('views.js', { | |
26 | gulp.task('templates', ['clean'], function() { | 34 | module: 'focaCrearRemito', |
27 | return pump( | 35 | root: '' |
28 | [ | 36 | }), |
29 | gulp.src(paths.srcViews), | 37 | gulp.dest(paths.tmp) |
30 | htmlmin(), | 38 | ] |
31 | templateCache('views.js', { | 39 | ); |
32 | module: 'focaCrearRemito', | 40 | }); |
33 | root: '' | 41 | |
34 | }), | 42 | gulp.task('uglify-app', function() { |
35 | gulp.dest(paths.tmp) | 43 | return pump( |
36 | ] | 44 | [ |
37 | ); | 45 | gulp.src([ |
38 | }); | 46 | paths.srcJS, |
39 | 47 | 'tmp/views.js' | |
40 | gulp.task('uglify-app', function() { | 48 | ]), |
41 | return pump( | 49 | concat('foca-crear-remito.js'), |
42 | [ | 50 | replace('src/views/', ''), |
43 | gulp.src([ | 51 | gulp.dest(paths.tmp), |
44 | paths.srcJS, | 52 | rename('foca-crear-remito.min.js'), |
45 | 'tmp/views.js' | 53 | uglify(), |
46 | ]), | 54 | gulp.dest(paths.dist) |
47 | concat('foca-crear-remito.js'), | 55 | ] |
48 | replace('src/views/', ''), | 56 | ); |
49 | gulp.dest(paths.tmp), | 57 | }); |
50 | rename('foca-crear-remito.min.js'), | 58 | |
59 | gulp.task('uglify-spec', function() { | ||
60 | return pump( | ||
61 | [ | ||
62 | gulp.src(paths.specs), | ||
63 | concat('foca-crear-remito.spec.js'), | ||
64 | replace('src/views/', ''), | ||
65 | header("describe('Módulo foca-crear-remito', function() { \n"), | ||
66 | footer("});"), | ||
67 | gulp.dest(paths.dist) | ||
68 | ] | ||
69 | ); | ||
70 | }); | ||
71 | |||
51 | uglify(), | 72 | gulp.task('clean', function() { |
52 | gulp.dest(paths.dist) | 73 | return gulp.src(['tmp', 'dist'], {read: false}).pipe(clean()); |
53 | ] | ||
54 | ); | 74 | }); |
55 | }); | 75 | |
56 | 76 | gulp.task('pre-commit', function() { | |
57 | gulp.task('uglify-spec', function() { | 77 | return pump( |
58 | return pump( | 78 | [ |
59 | [ | 79 | gulp.src([paths.srcJS, paths.specs]), |
60 | gulp.src(paths.specs), | 80 | jshint('.jshintrc'), |
61 | concat('foca-crear-remito.spec.js'), | 81 | jshint.reporter('default'), |
62 | replace('src/views/', ''), | 82 | jshint.reporter('fail') |
63 | header("describe('Módulo foca-crear-remito', function() { \n"), | 83 | ] |
64 | footer("});"), | 84 | ); |
65 | gulp.dest(paths.dist) | 85 | |
66 | ] | 86 | gulp.start('uglify'); |
67 | ); | 87 | }); |
68 | }); | 88 | |
69 | 89 | gulp.task('webserver', function() { | |
70 | gulp.task('clean', function() { | 90 | pump [ |
71 | return gulp.src(['tmp', 'dist'], {read: false}) | 91 | connect.server({port: 3300, host: '0.0.0.0'}) |
72 | .pipe(clean()); | 92 | ] |
73 | }); | 93 | }); |
74 | 94 | ||
75 | gulp.task('pre-commit', function() { | 95 | gulp.task('clean-post-install', function() { |
76 | return pump( | 96 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
77 | [ | 97 | 'index.html'], {read: false}) |
78 | gulp.src([paths.srcJS, paths.specs]), | 98 | .pipe(clean()); |
79 | jshint('.jshintrc'), | 99 | }); |
80 | jshint.reporter('default'), | 100 | |
81 | jshint.reporter('fail') | 101 | gulp.task('default', ['webserver']); |
82 | ] | 102 | |
83 | ); | 103 | gulp.task('watch', function() { |
84 | 104 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | |
85 | gulp.start('uglify'); | 105 | }); |
86 | }); | 106 | |
87 | 107 | gulp.task('copy', ['uglify'], function() { | |
88 | gulp.task('webserver', function() { | 108 | return gulp.src('dist/*.js') |
89 | pump [ | 109 | .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-crear-remito/dist/')); |
90 | connect.server({port: 3300, host: '0.0.0.0'}) | 110 | }); |
91 | ] | 111 | |
92 | }); | 112 | gulp.task('watchAndCopy', function() { |
93 | 113 | return gulp.watch([paths.srcJS, paths.srcViews], ['copy']); | |
94 | gulp.task('clean-post-install', function() { | 114 | }); |
spec/controllerSpec.js
1 | describe('Controlador modulo crear remito', function() { | ||
2 | |||
3 | var $controller; | ||
4 | |||
5 | beforeEach(function() { | ||
6 | |||
7 | module('focaCrearRemito'); | ||
8 | |||
9 | inject(function(_$controller_) { | ||
10 | $controller = _$controller_; | ||
11 | }); | ||
12 | }); | ||
13 | |||
14 | describe('Controlador remitoController', function() { | ||
15 | |||
16 | var timeout; | ||
17 | |||
18 | beforeEach(function() { | ||
19 | |||
20 | inject(function($timeout) { | ||
21 | timeout = $timeout; | ||
22 | }); | ||
23 | }); | ||
24 | |||
25 | it('Existe el controlador remitoController', function() { | ||
26 | |||
27 | //act | ||
28 | var controlador = $controller('remitoController', { | ||
29 | $scope: { | ||
30 | $broadcast: function() { }, | ||
31 | $watch: function() { } | ||
32 | }, | ||
33 | $uibModal: {}, | ||
34 | $location: {}, | ||
35 | $filter: {}, | ||
36 | crearRemitoService: { | ||
37 | getBotonera: function() { }, | ||
38 | getCotizacionByIdMoneda: function() { | ||
39 | return { | ||
40 | then: function() { } | ||
41 | }; | ||
42 | }, | ||
43 | getNumeroRemito: function() { | ||
44 | return { | ||
45 | then: function() { } | ||
46 | }; | ||
47 | } | ||
48 | }, | ||
49 | $timeout: timeout, | ||
50 | focaModalService: {}, | ||
51 | remitoBusinessService: {}, | ||
52 | $rootScope: { | ||
53 | $on: function() { } | ||
54 | }, | ||
55 | focaBotoneraLateralService: {}, | ||
56 | $localStorage: {} | ||
57 | }); | ||
58 | |||
59 | //assert | ||
60 | expect(typeof controlador).toEqual('object'); | ||
61 | |||
62 | }); | ||
63 | |||
64 | it('seleccionarNotaPedido levanta modal', function() { | ||
65 | |||
66 | //arrange | ||
67 | var scope = { | ||
68 | $broadcast: function() { }, | ||
69 | $watch: function() { } | ||
70 | }; | ||
71 | var uibModal = { | ||
72 | open: function() { } | ||
73 | }; | ||
74 | |||
75 | $controller('remitoController', { | ||
76 | $scope: scope, | ||
77 | $uibModal: uibModal, | ||
78 | $location: {}, | ||
79 | $filter: {}, | ||
80 | crearRemitoService: { | ||
81 | getBotonera: function() { }, | ||
82 | getCotizacionByIdMoneda: function() { | ||
83 | return { | ||
84 | then: function() { } | ||
85 | }; | ||
86 | }, | ||
87 | getNumeroRemito: function() { | ||
88 | return { | ||
89 | then: function() { } | ||
90 | }; | ||
91 | } | ||
92 | }, | ||
93 | $timeout: timeout, | ||
94 | focaModalService: {}, | ||
95 | remitoBusinessService: {}, | ||
96 | $rootScope: { | ||
97 | $on: function() { } | ||
98 | }, | ||
99 | focaBotoneraLateralService: {}, | ||
100 | $localStorage: {} | ||
101 | }); | ||
102 | |||
103 | //act | ||
104 | spyOn(uibModal, 'open').and.returnValue({ result: { then: function() { } } }); | ||
105 | spyOn(scope, 'seleccionarNotaPedido'); | ||
106 | scope.seleccionarNotaPedido(); | ||
107 | |||
108 | //assert | ||
109 | expect(scope.seleccionarNotaPedido).toHaveBeenCalled(); | ||
110 | |||
111 | }); | ||
112 | |||
113 | it('seleccionarRemito levanta modal', function() { | ||
114 | |||
115 | //arrange | ||
116 | var scope = { | ||
117 | $broadcast: function() { }, | ||
118 | $watch: function() { } | ||
119 | }; | ||
120 | var uibModal = { | ||
121 | open: function() { } | ||
122 | }; | ||
123 | |||
124 | $controller('remitoController', { | ||
125 | $scope: scope, | ||
126 | $uibModal: uibModal, | ||
127 | $location: {}, | ||
128 | $filter: {}, | ||
129 | crearRemitoService: { | ||
130 | getBotonera: function() { }, | ||
131 | getCotizacionByIdMoneda: function() { | ||
132 | return { | ||
133 | then: function() { } | ||
134 | }; | ||
135 | }, | ||
136 | getNumeroRemito: function() { | ||
137 | return { | ||
138 | then: function() { } | ||
139 | }; | ||
140 | } | ||
141 | }, | ||
142 | $timeout: timeout, | ||
143 | focaModalService: {}, | ||
144 | remitoBusinessService: {}, | ||
145 | $rootScope: { | ||
146 | $on: function() { } | ||
147 | }, | ||
148 | focaBotoneraLateralService: {}, | ||
149 | $localStorage: {} | ||
150 | }); | ||
151 | |||
152 | //act | ||
153 | spyOn(uibModal, 'open').and.returnValue({ result: { then: function() { } } }); | ||
154 | spyOn(scope, 'seleccionarRemito'); | ||
155 | scope.seleccionarRemito(); | ||
156 | |||
157 | //assert | ||
158 | expect(scope.seleccionarRemito).toHaveBeenCalled(); | ||
159 | |||
160 | }); | ||
161 | |||
162 | it('crearRemito muestra alerta cuando no se eligió vendedor', function() { | ||
163 | |||
164 | //arrange | ||
165 | var scope = { | ||
166 | $broadcast: function() { }, | ||
167 | $watch: function() { } | ||
168 | }; | ||
169 | var focaModalService = { | ||
170 | alert: function() { } | ||
171 | }; | ||
172 | |||
173 | $controller('remitoController', { | ||
174 | $scope: scope, | ||
175 | $uibModal: {}, | ||
176 | $location: {}, | ||
177 | $filter: {}, | ||
178 | crearRemitoService: { | ||
179 | getBotonera: function() { }, | ||
180 | getCotizacionByIdMoneda: function() { | ||
181 | return { | ||
182 | then: function() { } | ||
183 | }; | ||
184 | }, | ||
185 | getNumeroRemito: function() { | ||
186 | return { | ||
187 | then: function() { } | ||
188 | }; | ||
189 | } | ||
190 | }, | ||
191 | $timeout: timeout, | ||
192 | focaModalService: focaModalService, | ||
193 | remitoBusinessService: {}, | ||
194 | $rootScope: { | ||
195 | $on: function() { } | ||
196 | }, | ||
197 | focaBotoneraLateralService: {}, | ||
198 | $localStorage: {} | ||
199 | }); | ||
200 | |||
201 | //act | ||
202 | spyOn(focaModalService, 'alert'); | ||
203 | scope.crearRemito(); | ||
204 | |||
205 | //assert | ||
206 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Vendedor'); | ||
207 | |||
208 | }); | ||
209 | |||
210 | it('crearRemito muestra alerta cuando no se eligió cliente', function() { | ||
211 | |||
212 | //arrange | ||
213 | var scope = { | ||
214 | $broadcast: function() { }, | ||
215 | $watch: function() { } | ||
216 | }; | ||
217 | var focaModalService = { | ||
218 | alert: function() { } | ||
219 | }; | ||
220 | |||
221 | $controller('remitoController', { | ||
222 | $scope: scope, | ||
223 | $uibModal: {}, | ||
224 | $location: {}, | ||
225 | $filter: {}, | ||
226 | crearRemitoService: { | ||
227 | getBotonera: function() { }, | ||
228 | getCotizacionByIdMoneda: function() { | ||
229 | return { | ||
230 | then: function() { } | ||
231 | }; | ||
232 | }, | ||
233 | getNumeroRemito: function() { | ||
234 | return { | ||
235 | then: function() { } | ||
236 | }; | ||
237 | } | ||
238 | }, | ||
239 | $timeout: timeout, | ||
240 | focaModalService: focaModalService, | ||
241 | remitoBusinessService: {}, | ||
242 | $rootScope: { | ||
243 | $on: function() { } | ||
244 | }, | ||
245 | focaBotoneraLateralService: {}, | ||
246 | $localStorage: {} | ||
247 | }); | ||
248 | |||
249 | scope.remito = { | ||
250 | vendedor: { NUM: true }, | ||
251 | cliente: {} | ||
252 | }; | ||
253 | |||
254 | //act | ||
255 | spyOn(focaModalService, 'alert'); | ||
256 | scope.crearRemito(); | ||
257 | |||
258 | //assert | ||
259 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cliente'); | ||
260 | |||
261 | }); | ||
262 | |||
263 | it('crearRemito muestra alerta cuando no se eligió Proveedor', function() { | ||
264 | |||
265 | //arrange | ||
266 | var scope = { | ||
267 | $broadcast: function() { }, | ||
268 | $watch: function() { } | ||
269 | }; | ||
270 | var focaModalService = { | ||
271 | alert: function() { } | ||
272 | }; | ||
273 | |||
274 | $controller('remitoController', { | ||
275 | $scope: scope, | ||
276 | $uibModal: {}, | ||
277 | $location: {}, | ||
278 | $filter: {}, | ||
279 | crearRemitoService: { | ||
280 | getBotonera: function() { }, | ||
281 | getCotizacionByIdMoneda: function() { | ||
282 | return { | ||
283 | then: function() { } | ||
284 | }; | ||
285 | }, | ||
286 | getNumeroRemito: function() { | ||
287 | return { | ||
288 | then: function() { } | ||
289 | }; | ||
290 | } | ||
291 | }, | ||
292 | $timeout: timeout, | ||
293 | focaModalService: focaModalService, | ||
294 | remitoBusinessService: {}, | ||
295 | $rootScope: { | ||
296 | $on: function() { } | ||
297 | }, | ||
298 | focaBotoneraLateralService: {}, | ||
299 | $localStorage: {} | ||
300 | }); | ||
301 | |||
302 | scope.remito = { | ||
303 | vendedor: { NUM: true }, | ||
304 | cliente: { COD: true } | ||
305 | }; | ||
306 | |||
307 | //act | ||
308 | spyOn(focaModalService, 'alert'); | ||
309 | scope.crearRemito(); | ||
310 | |||
311 | //assert | ||
312 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Proveedor'); | ||
313 | |||
314 | }); | ||
315 | |||
316 | it('crearRemito muestra alerta cuando no se eligió moneda', function() { | ||
317 | |||
318 | //arrange | ||
319 | var scope = { | ||
320 | $broadcast: function() { }, | ||
321 | $watch: function() { } | ||
322 | }; | ||
323 | var focaModalService = { | ||
324 | alert: function() { } | ||
325 | }; | ||
326 | |||
327 | $controller('remitoController', { | ||
328 | $scope: scope, | ||
329 | $uibModal: {}, | ||
330 | $location: {}, | ||
331 | $filter: {}, | ||
332 | crearRemitoService: { | ||
333 | getBotonera: function() { }, | ||
334 | getCotizacionByIdMoneda: function() { | ||
335 | return { | ||
336 | then: function() { } | ||
337 | }; | ||
338 | }, | ||
339 | getNumeroRemito: function() { | ||
340 | return { | ||
341 | then: function() { } | ||
342 | }; | ||
343 | } | ||
344 | }, | ||
345 | $timeout: timeout, | ||
346 | focaModalService: focaModalService, | ||
347 | remitoBusinessService: {}, | ||
348 | $rootScope: { | ||
349 | $on: function() { } | ||
350 | }, | ||
351 | focaBotoneraLateralService: {}, | ||
352 | $localStorage: {} | ||
353 | }); | ||
354 | |||
355 | scope.remito = { | ||
356 | vendedor: { NUM: true }, | ||
357 | cliente: { COD: true }, | ||
358 | proveedor: {}, | ||
359 | cotizacion: { moneda: {} } | ||
360 | }; | ||
361 | |||
362 | //act | ||
363 | spyOn(focaModalService, 'alert'); | ||
364 | scope.crearRemito(); | ||
365 | |||
366 | //assert | ||
367 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Moneda'); | ||
368 | |||
369 | }); | ||
370 | |||
371 | it('crearRemito muestra alerta cuando no se eligió Cotización', function() { | ||
372 | |||
373 | //arrange | ||
374 | var scope = { | ||
375 | $broadcast: function() { }, | ||
376 | $watch: function() { } | ||
377 | }; | ||
378 | var focaModalService = { | ||
379 | alert: function() { } | ||
380 | }; | ||
381 | |||
382 | $controller('remitoController', { | ||
383 | $scope: scope, | ||
384 | $uibModal: {}, | ||
385 | $location: {}, | ||
386 | $filter: {}, | ||
387 | crearRemitoService: { | ||
388 | getBotonera: function() { }, | ||
389 | getCotizacionByIdMoneda: function() { | ||
390 | return { | ||
391 | then: function() { } | ||
392 | }; | ||
393 | }, | ||
394 | getNumeroRemito: function() { | ||
395 | return { | ||
396 | then: function() { } | ||
397 | }; | ||
398 | } | ||
399 | }, | ||
400 | $timeout: timeout, | ||
401 | focaModalService: focaModalService, | ||
402 | remitoBusinessService: {}, | ||
403 | $rootScope: { | ||
404 | $on: function() { } | ||
405 | }, | ||
406 | focaBotoneraLateralService: {}, | ||
407 | $localStorage: {} | ||
408 | }); | ||
409 | |||
410 | scope.remito = { | ||
411 | vendedor: { NUM: true }, | ||
412 | cliente: { COD: true }, | ||
413 | proveedor: {}, | ||
414 | cotizacion: { moneda: { id: true } } | ||
415 | }; | ||
416 | |||
417 | //act | ||
418 | spyOn(focaModalService, 'alert'); | ||
419 | scope.crearRemito(); | ||
420 | |||
421 | //assert | ||
422 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Cotización'); | ||
423 | |||
424 | }); | ||
425 | |||
426 | it('crearRemito muestra alerta cuando no se eligió flete', function() { | ||
427 | |||
428 | //arrange | ||
429 | var scope = { | ||
430 | $broadcast: function() { }, | ||
431 | $watch: function() { } | ||
432 | }; | ||
433 | var focaModalService = { | ||
434 | alert: function() { } | ||
435 | }; | ||
436 | |||
437 | $controller('remitoController', { | ||
438 | $scope: scope, | ||
439 | $uibModal: {}, | ||
440 | $location: {}, | ||
441 | $filter: {}, | ||
442 | crearRemitoService: { | ||
443 | getBotonera: function() { }, | ||
444 | getCotizacionByIdMoneda: function() { | ||
445 | return { | ||
446 | then: function() { } | ||
447 | }; | ||
448 | }, | ||
449 | getNumeroRemito: function() { | ||
450 | return { | ||
451 | then: function() { } | ||
452 | }; | ||
453 | } | ||
454 | }, | ||
455 | $timeout: timeout, | ||
456 | focaModalService: focaModalService, | ||
457 | remitoBusinessService: {}, | ||
458 | $rootScope: { | ||
459 | $on: function() { } | ||
460 | }, | ||
461 | focaBotoneraLateralService: {}, | ||
462 | $localStorage: {} | ||
463 | }); | ||
464 | |||
465 | scope.remito = { | ||
466 | vendedor: { NUM: true }, | ||
467 | cliente: { COD: true }, | ||
468 | proveedor: {}, | ||
469 | cotizacion: { | ||
470 | moneda: { id: true }, | ||
471 | ID: true | ||
472 | } | ||
473 | }; | ||
474 | |||
475 | //act | ||
476 | spyOn(focaModalService, 'alert'); | ||
477 | scope.crearRemito(); | ||
478 | |||
479 | //assert | ||
480 | expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Flete'); | ||
481 | |||
482 | }); | ||
483 | |||
484 | it('crearRemito muestra alerta cuando no se eligió articulos', function() { | ||
485 | |||
486 | //arrange | ||
487 | var scope = { | ||
488 | $broadcast: function() { }, | ||
489 | $watch: function() { } | ||
490 | }; | ||
491 | var focaModalService = { | ||
492 | alert: function() { } | ||
493 | }; | ||
494 | |||
495 | $controller('remitoController', { | ||
496 | $scope: scope, | ||
497 | $uibModal: {}, | ||
498 | $location: {}, | ||
499 | $filter: {}, | ||
500 | crearRemitoService: { | ||
501 | getBotonera: function() { }, | ||
502 | getCotizacionByIdMoneda: function() { | ||
503 | return { | ||
504 | then: function() { } | ||
505 | }; | ||
506 | }, | ||
507 | getNumeroRemito: function() { | ||
508 | return { | ||
509 | then: function() { } | ||
510 | }; | ||
511 | } | ||
512 | }, | ||
513 | $timeout: timeout, | ||
514 | focaModalService: focaModalService, | ||
515 | remitoBusinessService: {}, | ||
516 | $rootScope: { | ||
517 | $on: function() { } | ||
518 | }, | ||
519 | focaBotoneraLateralService: {}, | ||
520 | $localStorage: {} | ||
521 | }); | ||
522 | |||
523 | scope.remito = { | ||
524 | vendedor: { NUM: true }, | ||
525 | cliente: { COD: true }, | ||
526 | proveedor: {}, | ||
527 | cotizacion: { | ||
528 | moneda: { id: true }, | ||
529 | ID: true | ||
530 | }, | ||
531 | flete: true, | ||
532 | articulosRemito: [] | ||
533 | }; | ||
534 | |||
535 | //act | ||
536 | spyOn(focaModalService, 'alert'); | ||
537 | scope.crearRemito(); | ||
538 | |||
539 | //assert | ||
540 | expect(focaModalService.alert).toHaveBeenCalledWith('Debe cargar al menos un articulo'); | ||
541 | |||
542 | }); | ||
543 | |||
544 | it('crearRemito llama a startGuardar', function() { | ||
545 | |||
546 | //arrange | ||
547 | var scope = { | ||
548 | $broadcast: function() { }, | ||
549 | $watch: function() { } | ||
550 | }; | ||
551 | var focaBotoneraLateralService = { | ||
552 | startGuardar: function() { } | ||
553 | }; | ||
554 | |||
555 | $controller('remitoController', { | ||
556 | $scope: scope, | ||
557 | $uibModal: {}, | ||
558 | $location: {}, | ||
559 | $filter: {}, | ||
560 | crearRemitoService: { | ||
561 | getBotonera: function() { }, | ||
562 | getCotizacionByIdMoneda: function() { | ||
563 | return { | ||
564 | then: function() { } | ||
565 | }; | ||
566 | }, | ||
567 | getNumeroRemito: function() { | ||
568 | return { | ||
569 | then: function() { } | ||
570 | }; | ||
571 | }, | ||
572 | crearRemito: function() { | ||
573 | return { | ||
574 | then: function() { } | ||
575 | }; | ||
576 | } | ||
577 | }, | ||
578 | $timeout: timeout, | ||
579 | focaModalService: {}, | ||
580 | remitoBusinessService: {}, | ||
581 | $rootScope: { | ||
582 | $on: function() { } | ||
583 | }, | ||
584 | focaBotoneraLateralService: focaBotoneraLateralService, | ||
585 | $localStorage: {} | ||
586 | }); | ||
587 | |||
588 | scope.remito = { | ||
589 | vendedor: { NUM: true }, | ||
590 | cliente: { COD: true }, | ||
591 | proveedor: {}, | ||
592 | cotizacion: { | ||
593 | moneda: { id: true }, | ||
594 | ID: true | ||
595 | }, | ||
596 | flete: true, | ||
597 | articulosRemito: [ 1 ] | ||
598 | }; | ||
599 | |||
600 | //act | ||
601 | spyOn(focaBotoneraLateralService, 'startGuardar'); | ||
602 | scope.crearRemito(); | ||
603 | |||
604 | //assert | ||
605 | expect(focaBotoneraLateralService.startGuardar).toHaveBeenCalled(); | ||
606 | |||
607 | }); | ||
608 | |||
609 | it('crearRemito llama a endGuardar y abre modal', function(done) { | ||
610 | |||
611 | //arrange | ||
612 | var scope = { | ||
613 | $broadcast: function() { }, | ||
614 | $watch: function() { } | ||
615 | }; | ||
616 | var focaBotoneraLateralService = { | ||
617 | startGuardar: function() { }, | ||
618 | endGuardar: function() { } | ||
619 | }; | ||
620 | var uibModal = { | ||
621 | open: function() { } | ||
622 | }; | ||
623 | var crearRemitoService = { | ||
624 | getBotonera: function() { }, | ||
625 | getCotizacionByIdMoneda: function() { | ||
626 | return { | ||
627 | then: function() { } | ||
628 | }; | ||
629 | }, | ||
630 | getNumeroRemito: function() { | ||
631 | return { | ||
632 | then: function() { } | ||
633 | }; | ||
634 | }, | ||
635 | crearRemito: function() { } | ||
636 | }; | ||
637 | |||
638 | $controller('remitoController', { | ||
639 | $scope: scope, | ||
640 | $uibModal: uibModal, | ||
641 | $location: {}, | ||
642 | $filter: {}, | ||
643 | crearRemitoService: crearRemitoService, | ||
644 | $timeout: timeout, | ||
645 | focaModalService: {}, | ||
646 | remitoBusinessService: { | ||
647 | addArticulos: function() { } | ||
648 | }, | ||
649 | $rootScope: { | ||
650 | $on: function() { } | ||
651 | }, | ||
652 | focaBotoneraLateralService: focaBotoneraLateralService, | ||
653 | $localStorage: {} | ||
654 | }); | ||
655 | |||
656 | scope.remito = { | ||
657 | vendedor: { NUM: true }, | ||
658 | cliente: { COD: true }, | ||
659 | proveedor: {}, | ||
660 | cotizacion: { | ||
661 | moneda: { id: true }, | ||
662 | ID: true | ||
663 | }, | ||
664 | flete: true, | ||
665 | articulosRemito: [1] | ||
666 | }; | ||
667 | var promiseRespond = Promise.resolve({ data: {} }); | ||
668 | |||
669 | //act | ||
670 | spyOn(crearRemitoService, 'crearRemito').and.returnValue(promiseRespond); | ||
671 | spyOn(focaBotoneraLateralService, 'endGuardar'); | ||
672 | spyOn(uibModal, 'open'); | ||
673 | scope.crearRemito(); | ||
674 | |||
675 | //assert | ||
676 | promiseRespond.then(function() { | ||
677 | |||
678 | expect(focaBotoneraLateralService.endGuardar).toHaveBeenCalled(); | ||
679 | done(); | ||
680 | }); | ||
681 | }); | ||
682 | |||
683 | it('seleccionarProductos abre modal', function() { | ||
684 | |||
685 | //arrange | ||
686 | var scope = { | ||
687 | $broadcast: function() { }, | ||
688 | $watch: function() { } | ||
689 | }; | ||
690 | var uibModal = { | ||
691 | open: function() { } | ||
692 | }; | ||
693 | |||
694 | $controller('remitoController', { | ||
695 | $scope: scope, | ||
696 | $uibModal: uibModal, | ||
697 | $location: {}, | ||
698 | $filter: {}, | ||
699 | crearRemitoService: { | ||
700 | getBotonera: function() {}, | ||
701 | getCotizacionByIdMoneda: function() { | ||
702 | return { | ||
703 | then: function() {} | ||
704 | }; | ||
705 | }, | ||
706 | getNumeroRemito: function() { | ||
707 | return { | ||
708 | then: function() {} | ||
709 | }; | ||
710 | } | ||
711 | }, | ||
712 | $timeout: timeout, | ||
713 | focaModalService: {}, | ||
714 | remitoBusinessService: { | ||
715 | addArticulos: function() { } | ||
716 | }, | ||
717 | $rootScope: { | ||
718 | $on: function() { } | ||
719 | }, | ||
720 | focaBotoneraLateralService: {}, | ||
721 | $localStorage: {} | ||
722 | }); | ||
723 | |||
724 | scope.remito = { | ||
725 | cotizacion: { | ||
726 | moneda: { }, | ||
727 | }, | ||
728 | }; | ||
729 | scope.idLista = true; | ||
730 | |||
731 | //act | ||
732 | spyOn(uibModal, 'open').and.returnValue({ result: { then: function() {} } }); | ||
733 | scope.seleccionarProductos(); | ||
734 | |||
735 | //assert | ||
736 | expect(uibModal.open).toHaveBeenCalled(); | ||
737 | }); | ||
738 | |||
739 | it('seleccionarProductos abre alerta si no se eligió lista', function() { | ||
740 | |||
741 | //arrange | ||
742 | var scope = { | ||
743 | $broadcast: function() { }, | ||
744 | $watch: function() { } | ||
745 | }; | ||
746 | var focaModalService = { | ||
747 | alert: function() { } | ||
748 | }; | ||
749 | |||
750 | $controller('remitoController', { | ||
751 | $scope: scope, | ||
752 | $uibModal: {}, | ||
753 | $location: {}, | ||
754 | $filter: {}, | ||
755 | crearRemitoService: { | ||
756 | getBotonera: function() {}, | ||
757 | getCotizacionByIdMoneda: function() { | ||
758 | return { | ||
759 | then: function() {} | ||
760 | }; | ||
761 | }, | ||
762 | getNumeroRemito: function() { | ||
763 | return { | ||
764 | then: function() {} | ||
765 | }; | ||
766 | } | ||
767 | }, | ||
768 | $timeout: timeout, | ||
769 | focaModalService: focaModalService, | ||
770 | remitoBusinessService: { | ||
771 | addArticulos: function() { } | ||
772 | }, | ||
773 | $rootScope: { | ||
774 | $on: function() { } | ||
775 | }, | ||
776 | focaBotoneraLateralService: {}, | ||
777 | $localStorage: {} | ||
778 | }); | ||
779 | |||
780 | //act | ||
781 | spyOn(focaModalService, 'alert'); | ||
782 | scope.seleccionarProductos(); | ||
783 | |||
784 | //assert | ||
785 | expect(focaModalService.alert) | ||
786 | .toHaveBeenCalledWith('Primero seleccione una lista de precio y condicion'); | ||
787 | }); | ||
788 | |||
789 | it('seleccionarPuntosDeDescarga abre modal', function() { | ||
790 | |||
791 | //arrange | ||
792 | var scope = { | ||
793 | $broadcast: function() { }, | ||
794 | $watch: function() { } | ||
795 | }; | ||
796 | var uibModal = { | ||
797 | open: function() { } | ||
798 | }; | ||
799 | |||
800 | $controller('remitoController', { | ||
801 | $scope: scope, | ||
802 | $uibModal: uibModal, | ||
803 | $location: {}, | ||
804 | $filter: {}, | ||
805 | crearRemitoService: { | ||
806 | getBotonera: function() {}, | ||
807 | getCotizacionByIdMoneda: function() { | ||
808 | return { | ||
809 | then: function() {} | ||
810 | }; | ||
811 | }, | ||
812 | getNumeroRemito: function() { | ||
813 | return { | ||
814 | then: function() {} | ||
815 | }; | ||
816 | } | ||
817 | }, | ||
818 | $timeout: timeout, | ||
819 | focaModalService: {}, | ||
820 | remitoBusinessService: { | ||
821 | addArticulos: function() { } | ||
822 | }, | ||
823 | $rootScope: { | ||
824 | $on: function() { } | ||
825 | }, | ||
826 | focaBotoneraLateralService: {}, | ||
827 | $localStorage: {} | ||
828 | }); | ||
829 | scope.remito = { | ||
830 | cliente: { COD: true }, | ||
831 | domicilio: { id: true } | ||
832 | }; | ||
833 | |||
834 | //act | ||
835 | spyOn(uibModal, 'open').and.returnValue({ result: { then: function() { } } }); | ||
836 | scope.seleccionarPuntosDeDescarga(); | ||
837 | |||
838 | //assert | ||
839 | expect(uibModal.open).toHaveBeenCalled(); | ||
840 | }); | ||
841 | |||
842 | it('seleccionarVendedor abre modal', function() { | ||
843 | |||
844 | //arrange | ||
845 | var scope = { | ||
846 | $broadcast: function() { }, | ||
847 | $watch: function() { } | ||
848 | }; | ||
849 | var focaModalService = { | ||
850 | modal: function() { } | ||
851 | }; | ||
852 | |||
853 | $controller('remitoController', { | ||
854 | $scope: scope, | ||
855 | $uibModal: {}, | ||
856 | $location: {}, | ||
857 | $filter: {}, | ||
858 | crearRemitoService: { | ||
859 | getBotonera: function() {}, | ||
860 | getCotizacionByIdMoneda: function() { | ||
861 | return { | ||
862 | then: function() {} | ||
863 | }; | ||
864 | }, | ||
865 | getNumeroRemito: function() { | ||
866 | return { | ||
867 | then: function() {} | ||
868 | }; | ||
869 | } | ||
870 | }, | ||
871 | $timeout: timeout, | ||
872 | focaModalService: focaModalService, | ||
873 | remitoBusinessService: { | ||
874 | addArticulos: function() { } | ||
875 | }, | ||
876 | $rootScope: { | ||
877 | $on: function() { } | ||
878 | }, | ||
879 | focaBotoneraLateralService: {}, | ||
880 | $localStorage: {} | ||
881 | }); | ||
882 | |||
883 | //act | ||
884 | spyOn(focaModalService, 'modal').and.returnValue({ then: function() { } }); | ||
885 | scope.seleccionarVendedor(); | ||
886 | |||
887 | //assert | ||
888 | expect(focaModalService.modal).toHaveBeenCalled(); | ||
889 | }); | ||
890 | |||
891 | it('seleccionarCliente abre modal', function() { | ||
892 | |||
893 | //arrange | ||
894 | var scope = { | ||
895 | $broadcast: function() { }, | ||
896 | $watch: function() { } | ||
897 | }; | ||
898 | var uibModal = { | ||
899 | open: function() { } | ||
900 | }; | ||
901 | |||
902 | $controller('remitoController', { | ||
903 | $scope: scope, | ||
904 | $uibModal: uibModal, | ||
905 | $location: {}, | ||
906 | $filter: {}, | ||
907 | crearRemitoService: { | ||
908 | getBotonera: function() {}, | ||
909 | getCotizacionByIdMoneda: function() { | ||
910 | return { | ||
911 | then: function() {} | ||
912 | }; | ||
913 | }, | ||
914 | getNumeroRemito: function() { | ||
915 | return { | ||
916 | then: function() {} | ||
917 | }; | ||
918 | } | ||
919 | }, | ||
920 | $timeout: timeout, | ||
921 | focaModalService: {}, | ||
922 | remitoBusinessService: { | ||
923 | addArticulos: function() { } | ||
924 | }, | ||
925 | $rootScope: { | ||
926 | $on: function() { } | ||
927 | }, | ||
928 | focaBotoneraLateralService: {}, | ||
929 | $localStorage: {} | ||
930 | }); | ||
931 | |||
932 | //act | ||
933 | spyOn(uibModal, 'open').and.returnValue({ result: { then: function() { } } }); | ||
934 | scope.seleccionarCliente(true); | ||
935 | |||
936 | //assert | ||
937 | expect(uibModal.open).toHaveBeenCalled(); | ||
938 | }); | ||
939 | |||
940 | it('seleccionarCliente setea cliente y llama a abrirModalDomicilios', function(done) { | ||
941 | |||
942 | //arrange | ||
943 | var scope = { | ||
944 | $broadcast: function() { }, | ||
945 | $watch: function() { } | ||
946 | }; | ||
947 | var uibModal = { | ||
948 | open: function() { } | ||
949 | }; | ||
950 | |||
951 | $controller('remitoController', { | ||
952 | $scope: scope, | ||
953 | $uibModal: uibModal, | ||
954 | $location: {}, | ||
955 | $filter: {}, | ||
956 | crearRemitoService: { | ||
957 | getBotonera: function() {}, | ||
958 | getCotizacionByIdMoneda: function() { | ||
959 | return { | ||
960 | then: function() {} | ||
961 | }; | ||
962 | }, | ||
963 | getNumeroRemito: function() { | ||
964 | return { | ||
965 | then: function() {} | ||
966 | }; | ||
967 | } | ||
968 | }, | ||
969 | $timeout: timeout, | ||
970 | focaModalService: {}, | ||
971 | remitoBusinessService: { | ||
972 | addArticulos: function() { } | ||
973 | }, | ||
974 | $rootScope: { | ||
975 | $on: function() { } | ||
976 | }, | ||
977 | focaBotoneraLateralService: {}, | ||
978 | $localStorage: {} | ||
979 | }); | ||
980 | var response = 'test'; | ||
981 | var promesa = { result: Promise.resolve(response) }; | ||
982 | |||
983 | //act | ||
984 | spyOn(uibModal, 'open').and.returnValue(promesa); | ||
985 | spyOn(scope, 'abrirModalDomicilios'); | ||
986 | scope.seleccionarCliente(true); | ||
987 | |||
988 | //assert | ||
989 | promesa.result.then(function() { | ||
990 | expect(scope.abrirModalDomicilios).toHaveBeenCalledWith(response); | ||
991 | expect(scope.cliente).toEqual(response); | ||
992 | done(); | ||
993 | }); | ||
994 | }); | ||
995 | |||
996 | it('seleccionarProveedor abre modal', function() { | ||
997 | |||
998 | //arrange | ||
999 | var scope = { | ||
1000 | $broadcast: function() { }, | ||
1001 | $watch: function() { } | ||
1002 | }; | ||
1003 | var focaModalService = { | ||
1004 | modal: function() { } | ||
1005 | }; | ||
1006 | |||
1007 | $controller('remitoController', { | ||
1008 | $scope: scope, | ||
1009 | $uibModal: {}, | ||
1010 | $location: {}, | ||
1011 | $filter: {}, | ||
1012 | crearRemitoService: { | ||
1013 | getBotonera: function() {}, | ||
1014 | getCotizacionByIdMoneda: function() { | ||
1015 | return { | ||
1016 | then: function() {} | ||
1017 | }; | ||
1018 | }, | ||
1019 | getNumeroRemito: function() { | ||
1020 | return { | ||
1021 | then: function() {} | ||
1022 | }; | ||
1023 | } | ||
1024 | }, | ||
1025 | $timeout: timeout, | ||
1026 | focaModalService: focaModalService, | ||
1027 | remitoBusinessService: { | ||
1028 | addArticulos: function() { } | ||
1029 | }, | ||
1030 | $rootScope: { | ||
1031 | $on: function() { } | ||
1032 | }, | ||
1033 | focaBotoneraLateralService: {}, | ||
1034 | $localStorage: {} | ||
1035 | }); | ||
1036 | |||
1037 | //act | ||
1038 | spyOn(focaModalService, 'modal').and.returnValue({ then: function() { } }); | ||
1039 | scope.seleccionarProveedor(); | ||
1040 | |||
1041 | //assert | ||
1042 | expect(focaModalService.modal).toHaveBeenCalled(); | ||
1043 | }); | ||
1044 | |||
1045 | it('seleccionarProveedor setea provedor y llama a callback', function(done) { | ||
1046 | |||
1047 | //arrange | ||
1048 | var scope = { | ||
1049 | $broadcast: function() { }, | ||
1050 | $watch: function() { } | ||
1051 | }; | ||
1052 | var focaModalService = { | ||
1053 | modal: function() { } | ||
1054 | }; | ||
1055 | |||
1056 | $controller('remitoController', { | ||
1057 | $scope: scope, | ||
1058 | $uibModal: {}, | ||
1059 | $location: {}, | ||
1060 | $filter: function() { | ||
1061 | return function() { }; | ||
1062 | }, | ||
1063 | crearRemitoService: { | ||
1064 | getBotonera: function() {}, | ||
1065 | getCotizacionByIdMoneda: function() { | ||
1066 | return { | ||
1067 | then: function() {} | ||
1068 | }; | ||
1069 | }, | ||
1070 | getNumeroRemito: function() { | ||
1071 | return { | ||
1072 | then: function() {} | ||
1073 | }; | ||
1074 | } | ||
1075 | }, | ||
1076 | $timeout: timeout, | ||
1077 | focaModalService: focaModalService, | ||
1078 | remitoBusinessService: { | ||
1079 | addArticulos: function() { } | ||
1080 | }, | ||
1081 | $rootScope: { | ||
1082 | $on: function() { } | ||
1083 | }, | ||
1084 | focaBotoneraLateralService: {}, | ||
1085 | $localStorage: {} | ||
1086 | }); | ||
1087 | var response = { COD: 1 }; | ||
1088 | var promesa = Promise.resolve(response); | ||
1089 | window.callback = function() { }; | ||
1090 | |||
1091 | //act | ||
1092 | spyOn(focaModalService, 'modal').and.returnValue(promesa); | ||
1093 | spyOn(window, 'callback'); | ||
1094 | scope.seleccionarProveedor(window.callback); | ||
1095 | |||
1096 | //assert | ||
1097 | promesa.then(function() { | ||
1098 | expect(window.callback).toHaveBeenCalled(); | ||
1099 | expect(scope.remito.proveedor).toBe(response); | ||
1100 | expect(scope.remito.idProveedor).toBe(response.COD); | ||
1101 | done(); | ||
1102 | }); | ||
1103 | }); | ||
1104 | |||
1105 | it('abrirModalDomicilios abre modal', function() { | ||
1106 | |||
1107 | //arrange | ||
1108 | var scope = { | ||
1109 | $broadcast: function() { }, | ||
1110 | $watch: function() { } | ||
1111 | }; | ||
1112 | var uibModal = { | ||
1113 | open: function() { } | ||
1114 | }; | ||
1115 | |||
1116 | $controller('remitoController', { | ||
1117 | $scope: scope, | ||
1118 | $uibModal: uibModal, | ||
1119 | $location: {}, | ||
1120 | $filter: {}, | ||
1121 | crearRemitoService: { | ||
1122 | getBotonera: function() {}, | ||
1123 | getCotizacionByIdMoneda: function() { | ||
1124 | return { | ||
1125 | then: function() {} | ||
1126 | }; | ||
1127 | }, | ||
1128 | getNumeroRemito: function() { | ||
1129 | return { | ||
1130 | then: function() {} | ||
1131 | }; | ||
1132 | } | ||
1133 | }, | ||
1134 | $timeout: timeout, | ||
1135 | focaModalService: {}, | ||
1136 | remitoBusinessService: { | ||
1137 | addArticulos: function() { } | ||
1138 | }, | ||
1139 | $rootScope: { | ||
1140 | $on: function() { } | ||
1141 | }, | ||
1142 | focaBotoneraLateralService: {}, | ||
1143 | $localStorage: {} | ||
1144 | }); | ||
1145 | |||
1146 | //act | ||
1147 | spyOn(uibModal, 'open').and.returnValue({ result: { then: function() { } } }); | ||
1148 | scope.abrirModalDomicilios(); | ||
1149 | |||
1150 | //assert | ||
1151 | expect(uibModal.open).toHaveBeenCalled(); | ||
1152 | |||
1153 | }); | ||
1154 | |||
1155 | it('getTotal devuelve correctamente', function() { | ||
1156 | |||
1157 | //arrange | ||
1158 | var scope = { | ||
1159 | $broadcast: function() { }, | ||
1160 | $watch: function() { } | ||
1161 | }; | ||
1162 | |||
1163 | $controller('remitoController', { | ||
1164 | $scope: scope, | ||
1165 | $uibModal: {}, | ||
1166 | $location: {}, | ||
1167 | $filter: {}, | ||
1168 | crearRemitoService: { | ||
1169 | getBotonera: function() {}, | ||
1170 | getCotizacionByIdMoneda: function() { | ||
1171 | return { | ||
1172 | then: function() {} | ||
1173 | }; | ||
1174 | }, | ||
1175 | getNumeroRemito: function() { | ||
1176 | return { | ||
1177 | then: function() {} | ||
1178 | }; | ||
1179 | } | ||
1180 | }, | ||
1181 | $timeout: timeout, | ||
1182 | focaModalService: {}, | ||
1183 | remitoBusinessService: { | ||
1184 | addArticulos: function() { } | ||
1185 | }, | ||
1186 | $rootScope: { | ||
1187 | $on: function() { } | ||
1188 | }, | ||
1189 | focaBotoneraLateralService: {}, | ||
1190 | $localStorage: {} | ||
1191 | }); | ||
1192 | scope.remito = { | ||
1193 | articulosRemito: [ | ||
1194 | { | ||
1195 | precio: 100, | ||
1196 | cantidad: 3 | ||
1197 | } | ||
1198 | ] | ||
1199 | }; | ||
1200 | |||
1201 | //act | ||
1202 | var result = scope.getTotal(); | ||
1203 | |||
1204 | //assert | ||
1205 | expect(result).toEqual(300); | ||
1206 | |||
1207 | }); | ||
1208 | |||
1209 | it('getSubTotal devuelve correctamente', function() { | ||
1210 | |||
1211 | //arrange | ||
1212 | var scope = { | ||
1213 | $broadcast: function() { }, | ||
1214 | $watch: function() { } | ||
1215 | }; | ||
1216 | |||
1217 | $controller('remitoController', { | ||
1218 | $scope: scope, | ||
1219 | $uibModal: {}, | ||
1220 | $location: {}, | ||
1221 | $filter: {}, | ||
1222 | crearRemitoService: { | ||
1223 | getBotonera: function() {}, | ||
1224 | getCotizacionByIdMoneda: function() { | ||
1225 | return { | ||
1226 | then: function() {} | ||
1227 | }; | ||
1228 | }, | ||
1229 | getNumeroRemito: function() { | ||
1230 | return { | ||
1231 | then: function() {} | ||
1232 | }; | ||
1233 | } | ||
1234 | }, | ||
1235 | $timeout: timeout, | ||
1236 | focaModalService: {}, | ||
1237 | remitoBusinessService: { | ||
1238 | addArticulos: function() { } | ||
1239 | }, | ||
1240 | $rootScope: { | ||
1241 | $on: function() { } | ||
1242 | }, | ||
1243 | focaBotoneraLateralService: {}, | ||
1244 | $localStorage: {} | ||
1245 | }); | ||
1246 | scope.articuloACargar = { | ||
1247 | precio: 200, | ||
1248 | cantidad: 4 | ||
1249 | }; | ||
1250 | |||
1251 | //act | ||
1252 | var result = scope.getSubTotal(); | ||
1253 | |||
1254 | //assert | ||
1255 | expect(result).toEqual(800); | ||
1256 | |||
1257 | }); | ||
1258 | |||
1259 | it('seleccionarPreciosYCondiciones muestra alerta sino se eligió cliente', function() { | ||
1260 | |||
1261 | //arrange | ||
1262 | var scope = { | ||
1263 | $broadcast: function() { }, | ||
1264 | $watch: function() { } | ||
1265 | }; | ||
1266 | var focaModalService = { | ||
1267 | alert: function() {} | ||
1268 | }; | ||
1269 | |||
1270 | $controller('remitoController', { | ||
1271 | $scope: scope, | ||
1272 | $uibModal: {}, | ||
1273 | $location: {}, | ||
1274 | $filter: {}, | ||
1275 | crearRemitoService: { | ||
1276 | getBotonera: function() {}, | ||
1277 | getCotizacionByIdMoneda: function() { | ||
1278 | return { | ||
1279 | then: function() {} | ||
1280 | }; | ||
1281 | }, | ||
1282 | getNumeroRemito: function() { | ||
1283 | return { | ||
1284 | then: function() {} | ||
1285 | }; | ||
1286 | } | ||
1287 | }, | ||
1288 | $timeout: timeout, | ||
1289 | focaModalService: focaModalService, | ||
1290 | remitoBusinessService: { | ||
1291 | addArticulos: function() { } | ||
1292 | }, | ||
1293 | $rootScope: { | ||
1294 | $on: function() { } | ||
1295 | }, | ||
1296 | focaBotoneraLateralService: {}, | ||
1297 | $localStorage: {} | ||
1298 | }); | ||
1299 | |||
1300 | //act | ||
1301 | spyOn(focaModalService, 'alert'); | ||
1302 | scope.seleccionarPreciosYCondiciones(); | ||
1303 | |||
1304 | //assert | ||
1305 | expect(focaModalService.alert).toHaveBeenCalledWith('Primero seleccione un cliente'); | ||
1306 | |||
1307 | }); | ||
1308 | |||
1309 | it('seleccionarPreciosYCondiciones abre modal', function() { | ||
1310 | |||
1311 | //arrange | ||
1312 | var scope = { | ||
1313 | $broadcast: function() { }, | ||
1314 | $watch: function() { } | ||
1315 | }; | ||
1316 | var uibModal = { | ||
1317 | open: function() {} | ||
1318 | }; | ||
1319 | |||
1320 | $controller('remitoController', { | ||
1321 | $scope: scope, | ||
1322 | $uibModal: uibModal, | ||
1323 | $location: {}, | ||
1324 | $filter: {}, | ||
1325 | crearRemitoService: { | ||
1326 | getBotonera: function() {}, | ||
1327 | getCotizacionByIdMoneda: function() { | ||
1328 | return { | ||
1329 | then: function() {} | ||
1330 | }; | ||
1331 | }, | ||
1332 | getNumeroRemito: function() { | ||
1333 | return { | ||
1334 | then: function() {} | ||
1335 | }; | ||
1336 | } | ||
1337 | }, | ||
1338 | $timeout: timeout, | ||
1339 | focaModalService: {}, | ||
1340 | remitoBusinessService: { | ||
1341 | addArticulos: function() { } | ||
1342 | }, | ||
1343 | $rootScope: { | ||
1344 | $on: function() { } | ||
1345 | }, | ||
1346 | focaBotoneraLateralService: {}, | ||
1347 | $localStorage: {} | ||
1348 | }); | ||
1349 | scope.remito = { | ||
1350 | cliente: { COD: true } | ||
1351 | }; | ||
1352 | |||
1353 | //act | ||
1354 | spyOn(uibModal, 'open').and.returnValue({ result: { then: function() { } } }); | ||
1355 | scope.seleccionarPreciosYCondiciones(); | ||
1356 | |||
1357 | //assert | ||
1358 | expect(uibModal.open).toHaveBeenCalled(); | ||
1359 | |||
1360 | }); | ||
1361 | |||
1362 | it('seleccionarMoneda abre modal y llama a cotizacion', function(done) { | ||
1363 | |||
1364 | //arrange | ||
1365 | var scope = { | ||
1366 | $broadcast: function() { }, | ||
1367 | $watch: function() { } | ||
1368 | }; | ||
1369 | var focaModalService = { | ||
1370 | modal: function() {} | ||
1371 | }; | ||
1372 | var uibModal = { | ||
1373 | open: function() { | ||
1374 | return { | ||
1375 | result: { | ||
1376 | then: function() {} | ||
1377 | } | ||
1378 | }; | ||
1379 | } | ||
1380 | }; | ||
1381 | |||
1382 | $controller('remitoController', { | ||
1383 | $scope: scope, | ||
1384 | $uibModal: uibModal, | ||
1385 | $location: {}, | ||
1386 | $filter: {}, | ||
1387 | crearRemitoService: { | ||
1388 | getBotonera: function() {}, | ||
1389 | getCotizacionByIdMoneda: function() { | ||
1390 | return { | ||
1391 | then: function() {} | ||
1392 | }; | ||
1393 | }, | ||
1394 | getNumeroRemito: function() { | ||
1395 | return { | ||
1396 | then: function() {} | ||
1397 | }; | ||
1398 | } | ||
1399 | }, | ||
1400 | $timeout: timeout, | ||
1401 | focaModalService: focaModalService, | ||
1402 | remitoBusinessService: { | ||
1403 | addArticulos: function() { } | ||
1404 | }, | ||
1405 | $rootScope: { | ||
1406 | $on: function() { } | ||
1407 | }, | ||
1408 | focaBotoneraLateralService: {}, | ||
1409 | $localStorage: {} | ||
1410 | }); | ||
1411 | var promesa = Promise.resolve('test'); | ||
1412 | |||
1413 | //act | ||
1414 | spyOn(focaModalService, 'modal').and.returnValue(promesa); | ||
1415 | scope.seleccionarMoneda(); | ||
1416 | |||
1417 | //assert | ||
1418 | promesa.then(function() { | ||
1419 | expect(focaModalService.modal).toHaveBeenCalled(); | ||
1420 | done(); | ||
1421 | }); | ||
1422 | }); | ||
1423 | |||
1424 | it('seleccionarObservaciones levanta prompt', function() { | ||
1425 | |||
1426 | //arrange | ||
1427 | var scope = { | ||
1428 | $broadcast: function() { }, | ||
1429 | $watch: function() { } | ||
1430 | }; | ||
1431 | var focaModalService = { | ||
1432 | prompt: function() {} | ||
1433 | }; | ||
1434 | |||
1435 | $controller('remitoController', { | ||
1436 | $scope: scope, | ||
1437 | $uibModal: {}, | ||
1438 | $location: {}, | ||
1439 | $filter: {}, | ||
1440 | crearRemitoService: { | ||
1441 | getBotonera: function() {}, | ||
1442 | getCotizacionByIdMoneda: function() { | ||
1443 | return { | ||
1444 | then: function() {} | ||
1445 | }; | ||
1446 | }, | ||
1447 | getNumeroRemito: function() { | ||
1448 | return { | ||
1449 | then: function() {} | ||
1450 | }; | ||
1451 | } | ||
1452 | }, | ||
1453 | $timeout: timeout, | ||
1454 | focaModalService: focaModalService, | ||
1455 | remitoBusinessService: { | ||
1456 | addArticulos: function() { } | ||
1457 | }, | ||
1458 | $rootScope: { | ||
1459 | $on: function() { } | ||
1460 | }, | ||
1461 | focaBotoneraLateralService: {}, | ||
1462 | $localStorage: {} | ||
1463 | }); | ||
1464 | |||
1465 | //act | ||
1466 | spyOn(focaModalService, 'prompt').and.returnValue({ then: function() { } }); | ||
1467 | scope.seleccionarObservaciones(); | ||
1468 | |||
1469 | //assert | ||
1470 | expect(focaModalService.prompt).toHaveBeenCalled(); | ||
1471 | }); | ||
1472 | |||
1473 | it('abrirModalCotizacion abre modal', function() { | ||
1474 | |||
1475 | //arrange | ||
1476 | var scope = { | ||
1477 | $broadcast: function() { }, | ||
1478 | $watch: function() { } | ||
1479 | }; | ||
1480 | var uibModal = { | ||
1481 | open: function() {} | ||
1482 | }; | ||
1483 | |||
1484 | $controller('remitoController', { | ||
1485 | $scope: scope, | ||
1486 | $uibModal: uibModal, | ||
1487 | $location: {}, | ||
1488 | $filter: {}, | ||
1489 | crearRemitoService: { | ||
1490 | getBotonera: function() {}, | ||
1491 | getCotizacionByIdMoneda: function() { | ||
1492 | return { | ||
1493 | then: function() {} | ||
1494 | }; | ||
1495 | }, | ||
1496 | getNumeroRemito: function() { | ||
1497 | return { | ||
1498 | then: function() {} | ||
1499 | }; | ||
1500 | } | ||
1501 | }, | ||
1502 | $timeout: timeout, | ||
1503 | focaModalService: {}, | ||
1504 | remitoBusinessService: { | ||
1505 | addArticulos: function() { } | ||
1506 | }, | ||
1507 | $rootScope: { | ||
1508 | $on: function() { } | ||
1509 | }, | ||
1510 | focaBotoneraLateralService: {}, | ||
1511 | $localStorage: {} | ||
1512 | }); | ||
1513 | |||
1514 | //act | ||
1515 | spyOn(uibModal, 'open').and.returnValue({ result: { then: function() { } } }); | ||
1516 | scope.abrirModalCotizacion(); | ||
1517 | |||
1518 | //assert | ||
1519 | expect(uibModal.open).toHaveBeenCalled(); | ||
1520 | }); | ||
1521 | }); | ||
1522 | }); | ||
1 | describe('Controlador modulo crear remito', function() { | 1523 |
spec/serviceSpec.js
1 | describe('Servicios modulo crear remito', function() { | 1 | describe('Servicios modulo crear remito', function() { |
2 | 2 | ||
3 | beforeEach(function(){ | 3 | beforeEach(function(){ |
4 | module('focaCrearRemito'); | 4 | module('focaCrearRemito'); |
5 | inject(module(function($provide) { | 5 | inject(module(function($provide) { |
6 | $provide.value('API_ENDPOINT', { | 6 | $provide.value('API_ENDPOINT', { |
7 | URL: 'localhost' | 7 | URL: 'localhost' |
8 | }); | 8 | }); |
9 | })); | 9 | })); |
10 | }); | 10 | }); |
11 | 11 | ||
12 | describe('servicio crearRemitoService', function() { | 12 | describe('servicio crearRemitoService', function() { |
13 | 13 | ||
14 | var servicio, httpBackend; | 14 | var servicio, httpBackend; |
15 | 15 | ||
16 | beforeEach(function() { | 16 | beforeEach(function() { |
17 | inject(function($httpBackend, _crearRemitoService_) { | 17 | inject(function($httpBackend, _crearRemitoService_) { |
18 | servicio = _crearRemitoService_; | 18 | servicio = _crearRemitoService_; |
19 | httpBackend = $httpBackend; | 19 | httpBackend = $httpBackend; |
20 | }); | 20 | }); |
21 | }); | 21 | }); |
22 | 22 | ||
23 | it('existe el servicio crearRemitoService', function() { | 23 | it('existe el servicio crearRemitoService', function() { |
24 | 24 | ||
25 | //assert | 25 | //assert |
26 | expect(typeof servicio).toEqual('object'); | 26 | expect(typeof servicio).toEqual('object'); |
27 | }); | 27 | }); |
28 | 28 | ||
29 | it('función crearRemito llama a ruta correcta', function() { | 29 | it('función crearRemito llama a ruta correcta', function() { |
30 | 30 | ||
31 | //arrange | 31 | //arrange |
32 | var result; | 32 | var result; |
33 | var fakeParam = 1; | 33 | var fakeParam = 1; |
34 | var respond = 'test'; | 34 | var respond = 'test'; |
35 | httpBackend.expectPOST('localhost/remito', fakeParam).respond(respond); | 35 | httpBackend.expectPOST('localhost/remito', fakeParam).respond(respond); |
36 | 36 | ||
37 | //act | 37 | //act |
38 | servicio.crearRemito(fakeParam).then(function(res) { | 38 | servicio.crearRemito(fakeParam).then(function(res) { |
39 | result = res.data; | 39 | result = res.data; |
40 | }); | 40 | }); |
41 | httpBackend.flush(); | 41 | httpBackend.flush(); |
42 | 42 | ||
43 | //assert | 43 | //assert |
44 | expect(result).toEqual(respond); | 44 | expect(result).toEqual(respond); |
45 | }); | 45 | }); |
46 | 46 | ||
47 | it('función getRemitoById llama a ruta correcta', function() { | 47 | it('función getRemitoById llama a ruta correcta', function() { |
48 | 48 | ||
49 | //arrange | 49 | //arrange |
50 | var result; | 50 | var result; |
51 | var fakeParam = 1; | 51 | var fakeParam = 1; |
52 | var respond = 'test'; | 52 | var respond = 'test'; |
53 | httpBackend.expectGET('localhost/remito/obtener/' + fakeParam).respond(respond); | 53 | httpBackend.expectGET('localhost/remito/obtener/' + fakeParam).respond(respond); |
54 | 54 | ||
55 | //act | 55 | //act |
56 | servicio.getRemitoById(fakeParam).then(function(res) { | 56 | servicio.getRemitoById(fakeParam).then(function(res) { |
57 | result = res.data; | 57 | result = res.data; |
58 | }); | 58 | }); |
59 | httpBackend.flush(); | 59 | httpBackend.flush(); |
60 | 60 | ||
61 | //assert | 61 | //assert |
62 | expect(result).toEqual(respond); | 62 | expect(result).toEqual(respond); |
63 | }); | 63 | }); |
64 | 64 | ||
65 | it('función obtenerRemito llama a ruta correcta', function() { | 65 | it('función obtenerRemito llama a ruta correcta', function() { |
66 | 66 | ||
67 | //arrange | 67 | //arrange |
68 | var result; | 68 | var result; |
69 | var fakeParam = 1; | 69 | var fakeParam = 1; |
70 | var respond = 'test'; | 70 | var respond = 'test'; |
71 | httpBackend.expectGET('localhost/nota-pedido').respond(respond); | 71 | httpBackend.expectGET('localhost/nota-pedido').respond(respond); |
72 | 72 | ||
73 | //act | 73 | //act |
74 | servicio.obtenerRemito(fakeParam).then(function(res) { | 74 | servicio.obtenerRemito(fakeParam).then(function(res) { |
75 | result = res.data; | 75 | result = res.data; |
76 | }); | 76 | }); |
77 | httpBackend.flush(); | 77 | httpBackend.flush(); |
78 | 78 | ||
79 | //assert | 79 | //assert |
80 | expect(result).toEqual(respond); | 80 | expect(result).toEqual(respond); |
81 | }); | 81 | }); |
82 | 82 | ||
83 | it('función setRemito setea correctamente', function() { | 83 | it('función setRemito setea correctamente', function() { |
84 | 84 | ||
85 | //arrange | 85 | //arrange |
86 | var fakeParam = 1; | ||
87 | 86 | var fakeParam = 1; | |
88 | //act | 87 | |
89 | servicio.setRemito(fakeParam); | 88 | //act |
90 | 89 | servicio.setRemito(fakeParam); | |
91 | //assert | 90 | |
92 | expect(servicio.remito).toEqual(fakeParam); | 91 | //assert |
93 | }); | 92 | expect(servicio.remito).toEqual(fakeParam); |
94 | 93 | }); | |
95 | it('función clearRemito setea correctamente', function() { | 94 | |
96 | 95 | it('función clearRemito setea correctamente', function() { | |
97 | //act | 96 | |
98 | servicio.clearRemito(); | 97 | //act |
99 | 98 | servicio.clearRemito(); | |
100 | //assert | 99 | |
101 | expect(servicio.remito).toEqual(undefined); | 100 | //assert |
102 | }); | 101 | expect(servicio.remito).toEqual(undefined); |
103 | 102 | }); | |
104 | it('función getRemito trae correctamente', function() { | 103 | |
105 | 104 | it('función getRemito trae correctamente', function() { | |
106 | //arrange | 105 | |
107 | var fakeParam = 1; | 106 | //arrange |
108 | 107 | var fakeParam = 1; | |
109 | //act | 108 | |
110 | servicio.remito = fakeParam; | 109 | //act |
111 | var result = servicio.getRemito(); | 110 | servicio.remito = fakeParam; |
112 | 111 | var result = servicio.getRemito(); | |
113 | //assert | 112 | |
114 | expect(result).toEqual(fakeParam); | 113 | //assert |
115 | }); | 114 | expect(result).toEqual(fakeParam); |
116 | 115 | }); | |
117 | it('función getArticulosByIdRemito llama a ruta correcta', function() { | 116 | |
118 | 117 | it('función getArticulosByIdRemito llama a ruta correcta', function() { | |
119 | //arrange | 118 | |
120 | var result; | 119 | //arrange |
121 | var fakeParam = 1; | 120 | var result; |
122 | var respond = 'test'; | 121 | var fakeParam = 1; |
123 | httpBackend.expectGET('localhost/articulos/nota-pedido/' + fakeParam).respond(respond); | 122 | var respond = 'test'; |
124 | 123 | httpBackend.expectGET('localhost/articulos/nota-pedido/' + fakeParam).respond(respond); | |
125 | //act | 124 | |
126 | servicio.getArticulosByIdRemito(fakeParam).then(function(res) { | 125 | //act |
127 | result = res.data; | 126 | servicio.getArticulosByIdRemito(fakeParam).then(function(res) { |
128 | }); | 127 | result = res.data; |
129 | httpBackend.flush(); | 128 | }); |
130 | 129 | httpBackend.flush(); | |
131 | //assert | 130 | |
132 | expect(result).toEqual(respond); | 131 | //assert |
133 | }); | 132 | expect(result).toEqual(respond); |
134 | 133 | }); | |
135 | it('función crearArticulosParaRemito llama a ruta correcta', function() { | 134 | |
136 | 135 | it('función crearArticulosParaRemito llama a ruta correcta', function() { | |
137 | //arrange | 136 | |
138 | var result; | 137 | //arrange |
139 | var fakeParam = 1; | 138 | var result; |
140 | var respond = 'test'; | 139 | var fakeParam = 1; |
141 | httpBackend.expectPOST('localhost/articulos/remito', {articuloRemito: fakeParam}) | 140 | var respond = 'test'; |
142 | .respond(respond); | 141 | httpBackend.expectPOST('localhost/articulos/remito', {articuloRemito: fakeParam}) |
143 | 142 | .respond(respond); | |
144 | //act | 143 | |
145 | servicio.crearArticulosParaRemito(fakeParam).then(function(res) { | 144 | //act |
146 | result = res.data; | 145 | servicio.crearArticulosParaRemito(fakeParam).then(function(res) { |
147 | }); | 146 | result = res.data; |
148 | httpBackend.flush(); | 147 | }); |
149 | 148 | httpBackend.flush(); | |
150 | //assert | 149 | |
151 | expect(result).toEqual(respond); | 150 | //assert |
152 | }); | 151 | expect(result).toEqual(respond); |
153 | 152 | }); | |
154 | it('función getDomiciliosByIdRemito llama a ruta correcta', function() { | 153 | |
155 | 154 | it('función getDomiciliosByIdRemito llama a ruta correcta', function() { | |
156 | //arrange | 155 | |
157 | var result; | 156 | //arrange |
158 | var fakeParam = 1; | 157 | var result; |
159 | var respond = 'test'; | 158 | var fakeParam = 1; |
160 | httpBackend.expectGET('localhost/nota-pedido/' + fakeParam + '/domicilios') | 159 | var respond = 'test'; |
161 | .respond(respond); | 160 | httpBackend.expectGET('localhost/nota-pedido/' + fakeParam + '/domicilios') |
162 | 161 | .respond(respond); | |
163 | //act | 162 | |
164 | servicio.getDomiciliosByIdRemito(fakeParam).then(function(res) { | 163 | //act |
165 | result = res.data; | 164 | servicio.getDomiciliosByIdRemito(fakeParam).then(function(res) { |
166 | }); | 165 | result = res.data; |
167 | httpBackend.flush(); | 166 | }); |
168 | 167 | httpBackend.flush(); | |
169 | //assert | 168 | |
170 | expect(result).toEqual(respond); | 169 | //assert |
171 | }); | 170 | expect(result).toEqual(respond); |
172 | 171 | }); | |
173 | it('función getDomiciliosByIdCliente llama a ruta correcta', function() { | 172 | |
174 | 173 | it('función getDomiciliosByIdCliente llama a ruta correcta', function() { | |
175 | //arrange | 174 | |
176 | var result; | 175 | //arrange |
177 | var fakeParam = 1; | 176 | var result; |
178 | var respond = 'test'; | 177 | var fakeParam = 1; |
179 | httpBackend.expectGET('localhost/domicilio/tipo/2/cliente/' + fakeParam) | 178 | var respond = 'test'; |
180 | .respond(respond); | 179 | httpBackend.expectGET('localhost/domicilio/tipo/2/cliente/' + fakeParam) |
181 | 180 | .respond(respond); | |
182 | //act | 181 | |
183 | servicio.getDomiciliosByIdCliente(fakeParam).then(function(res) { | 182 | //act |
184 | result = res.data; | 183 | servicio.getDomiciliosByIdCliente(fakeParam).then(function(res) { |
185 | }); | 184 | result = res.data; |
186 | httpBackend.flush(); | 185 | }); |
187 | 186 | httpBackend.flush(); | |
188 | //assert | 187 | |
189 | expect(result).toEqual(respond); | 188 | //assert |
190 | }); | 189 | expect(result).toEqual(respond); |
191 | 190 | }); | |
192 | it('función getPrecioCondicion llama a ruta correcta', function() { | 191 | |
193 | 192 | it('función getPrecioCondicion llama a ruta correcta', function() { | |
194 | //arrange | 193 | |
195 | var result; | 194 | //arrange |
196 | var respond = 'test'; | 195 | var result; |
197 | httpBackend.expectGET('localhost/precio-condicion').respond(respond); | 196 | var respond = 'test'; |
198 | 197 | httpBackend.expectGET('localhost/precio-condicion').respond(respond); | |
199 | //act | 198 | |
200 | servicio.getPrecioCondicion().then(function(res) { | 199 | //act |
201 | result = res.data; | 200 | servicio.getPrecioCondicion().then(function(res) { |
202 | }); | 201 | result = res.data; |
203 | httpBackend.flush(); | 202 | }); |
204 | 203 | httpBackend.flush(); | |
205 | //assert | 204 | |
206 | expect(result).toEqual(respond); | 205 | //assert |
207 | }); | 206 | expect(result).toEqual(respond); |
208 | 207 | }); | |
209 | it('función getPrecioCondicionById llama a ruta correcta', function() { | 208 | |
210 | 209 | it('función getPrecioCondicionById llama a ruta correcta', function() { | |
211 | //arrange | 210 | |
212 | var result; | 211 | //arrange |
213 | var fakeParam = 1; | 212 | var result; |
214 | var respond = 'test'; | 213 | var fakeParam = 1; |
215 | httpBackend.expectGET('localhost/precio-condicion/' + fakeParam).respond(respond); | 214 | var respond = 'test'; |
216 | 215 | httpBackend.expectGET('localhost/precio-condicion/' + fakeParam).respond(respond); | |
217 | //act | 216 | |
218 | servicio.getPrecioCondicionById(fakeParam).then(function(res) { | 217 | //act |
219 | result = res.data; | 218 | servicio.getPrecioCondicionById(fakeParam).then(function(res) { |
220 | }); | 219 | result = res.data; |
221 | httpBackend.flush(); | 220 | }); |
222 | 221 | httpBackend.flush(); | |
223 | //assert | 222 | |
224 | expect(result).toEqual(respond); | 223 | //assert |
225 | }); | 224 | expect(result).toEqual(respond); |
226 | 225 | }); | |
227 | it('función getPlazoPagoByPrecioCondicion llama a ruta correcta', function() { | 226 | |
228 | 227 | it('función getPlazoPagoByPrecioCondicion llama a ruta correcta', function() { | |
229 | //arrange | 228 | |
230 | var result; | 229 | //arrange |
231 | var fakeParam = 1; | 230 | var result; |
232 | var respond = 'test'; | 231 | var fakeParam = 1; |
233 | httpBackend.expectGET('localhost/plazo-pago/precio-condicion/' + fakeParam) | 232 | var respond = 'test'; |
234 | .respond(respond); | 233 | httpBackend.expectGET('localhost/plazo-pago/precio-condicion/' + fakeParam) |
235 | 234 | .respond(respond); | |
236 | //act | 235 | |
237 | servicio.getPlazoPagoByPrecioCondicion(fakeParam).then(function(res) { | 236 | //act |
238 | result = res.data; | 237 | servicio.getPlazoPagoByPrecioCondicion(fakeParam).then(function(res) { |
239 | }); | 238 | result = res.data; |
240 | httpBackend.flush(); | 239 | }); |
241 | 240 | httpBackend.flush(); | |
242 | //assert | 241 | |
243 | expect(result).toEqual(respond); | 242 | //assert |
244 | }); | 243 | expect(result).toEqual(respond); |
245 | 244 | }); | |
246 | it('función crearFlete llama a ruta correcta', function() { | 245 | |
247 | 246 | it('función crearFlete llama a ruta correcta', function() { | |
248 | //arrange | 247 | |
249 | var result; | 248 | //arrange |
250 | var fakeParam = 1; | 249 | var result; |
251 | var respond = 'test'; | 250 | var fakeParam = 1; |
252 | httpBackend.expectPOST('localhost/flete', {flete: fakeParam}).respond(respond); | 251 | var respond = 'test'; |
253 | 252 | httpBackend.expectPOST('localhost/flete', {flete: fakeParam}).respond(respond); | |
254 | //act | 253 | |
255 | servicio.crearFlete(fakeParam).then(function(res) { | 254 | //act |
256 | result = res.data; | 255 | servicio.crearFlete(fakeParam).then(function(res) { |
257 | }); | 256 | result = res.data; |
258 | httpBackend.flush(); | 257 | }); |
259 | 258 | httpBackend.flush(); | |
260 | //assert | 259 | |
261 | expect(result).toEqual(respond); | 260 | //assert |
262 | }); | 261 | expect(result).toEqual(respond); |
263 | 262 | }); | |
264 | it('función crearPlazosParaRemito llama a ruta correcta', function() { | 263 | |
265 | 264 | it('función crearPlazosParaRemito llama a ruta correcta', function() { | |
266 | //arrange | 265 | |
267 | var result; | 266 | //arrange |
268 | var fakeParam = 1; | 267 | var result; |
269 | var respond = 'test'; | 268 | var fakeParam = 1; |
270 | httpBackend.expectPOST('localhost/plazo-pago/remito', fakeParam).respond(respond); | 269 | var respond = 'test'; |
271 | 270 | httpBackend.expectPOST('localhost/plazo-pago/remito', fakeParam).respond(respond); | |
272 | //act | 271 | |
273 | servicio.crearPlazosParaRemito(fakeParam).then(function(res) { | 272 | //act |
274 | result = res.data; | 273 | servicio.crearPlazosParaRemito(fakeParam).then(function(res) { |
275 | }); | 274 | result = res.data; |
276 | httpBackend.flush(); | 275 | }); |
277 | 276 | httpBackend.flush(); | |
278 | //assert | 277 | |
279 | expect(result).toEqual(respond); | 278 | //assert |
280 | }); | 279 | expect(result).toEqual(respond); |
281 | 280 | }); | |
282 | it('función getCotizacionByIdMoneda llama a ruta correcta', function() { | 281 | |
283 | 282 | it('función getCotizacionByIdMoneda llama a ruta correcta', function() { | |
284 | //arrange | 283 | |
285 | var result; | 284 | //arrange |
286 | var fakeParam = 1; | 285 | var result; |
287 | var respond = 'test'; | 286 | var fakeParam = 1; |
288 | httpBackend.expectGET('localhost/moneda/' + fakeParam).respond(respond); | 287 | var respond = 'test'; |
289 | 288 | httpBackend.expectGET('localhost/moneda/' + fakeParam).respond(respond); | |
290 | //act | 289 | |
291 | servicio.getCotizacionByIdMoneda(fakeParam).then(function(res) { | 290 | //act |
292 | result = res.data; | 291 | servicio.getCotizacionByIdMoneda(fakeParam).then(function(res) { |
293 | }); | 292 | result = res.data; |
294 | httpBackend.flush(); | 293 | }); |
295 | 294 | httpBackend.flush(); | |
296 | //assert | 295 | |
297 | expect(result).toEqual(respond); | 296 | //assert |
298 | }); | 297 | expect(result).toEqual(respond); |
299 | 298 | }); | |
300 | it('función crearEstadoParaRemito llama a ruta correcta', function() { | 299 | |
301 | 300 | it('función crearEstadoParaRemito llama a ruta correcta', function() { | |
302 | //arrange | 301 | |
303 | var result; | 302 | //arrange |
304 | var fakeParam = 1; | 303 | var result; |
305 | var respond = 'test'; | 304 | var fakeParam = 1; |
306 | httpBackend.expectPOST('localhost/estado', { estado: fakeParam }).respond(respond); | 305 | var respond = 'test'; |
307 | 306 | httpBackend.expectPOST('localhost/estado', { estado: fakeParam }).respond(respond); | |
308 | //act | 307 | |
309 | servicio.crearEstadoParaRemito(fakeParam).then(function(res) { | 308 | //act |
310 | result = res.data; | 309 | servicio.crearEstadoParaRemito(fakeParam).then(function(res) { |
311 | }); | 310 | result = res.data; |
312 | httpBackend.flush(); | 311 | }); |
313 | 312 | httpBackend.flush(); | |
314 | //assert | 313 | |
315 | expect(result).toEqual(respond); | 314 | //assert |
316 | }); | 315 | expect(result).toEqual(respond); |
317 | 316 | }); | |
318 | it('función getNumeroRemito llama a ruta correcta', function() { | 317 | |
319 | 318 | it('función getNumeroRemito llama a ruta correcta', function() { | |
320 | //arrange | 319 | |
321 | var result; | 320 | //arrange |
322 | var respond = 'test'; | 321 | var result; |
323 | httpBackend.expectGET('localhost/remito/numero-siguiente').respond(respond); | 322 | var respond = 'test'; |
324 | 323 | httpBackend.expectGET('localhost/remito/numero-siguiente').respond(respond); | |
325 | //act | 324 | |
326 | servicio.getNumeroRemito().then(function(res) { | 325 | //act |
327 | result = res.data; | 326 | servicio.getNumeroRemito().then(function(res) { |
328 | }); | 327 | result = res.data; |
329 | httpBackend.flush(); | 328 | }); |
330 | 329 | httpBackend.flush(); | |
331 | //assert | 330 | |
332 | expect(result).toEqual(respond); | 331 | //assert |
333 | }); | 332 | expect(result).toEqual(respond); |
334 | 333 | }); | |
335 | it('función imprimirRemitoByIdRemito llama a ruta correcta', function() { | 334 | |
336 | 335 | it('función imprimirRemitoByIdRemito llama a ruta correcta', function() { | |
337 | //arrange | 336 | |
338 | var result; | 337 | //arrange |
339 | var fakeParam = 1; | 338 | var result; |
340 | var respond = new Blob(['test']); | 339 | var fakeParam = 1; |
341 | httpBackend.expectGET('localhost/remito/comprobante/' + fakeParam) | 340 | var respond = new Blob(['test']); |
342 | .respond(respond); | 341 | httpBackend.expectGET('localhost/remito/comprobante/' + fakeParam) |
343 | 342 | .respond(respond); | |
344 | //act | 343 | |
345 | servicio.imprimirRemitoByIdRemito(fakeParam).then(function(res) { | 344 | //act |
346 | result = res.data; | 345 | servicio.imprimirRemitoByIdRemito(fakeParam).then(function(res) { |
347 | }); | 346 | result = res.data; |
348 | httpBackend.flush(); | 347 | }); |
349 | 348 | httpBackend.flush(); | |
350 | //assert | 349 | |
351 | expect(result).toEqual(respond); | 350 | //assert |
352 | }); | 351 | expect(result).toEqual(respond); |
353 | 352 | }); | |
354 | it('función getPuntosDescargaByClienDom llama a ruta correcta', function() { | 353 | |
355 | 354 | it('función getPuntosDescargaByClienDom llama a ruta correcta', function() { | |
356 | //arrange | 355 | |
357 | var result; | 356 | //arrange |
358 | var fakeParam = 1; | 357 | var result; |
359 | var respond = 'test'; | 358 | var fakeParam = 1; |
360 | httpBackend.expectGET('localhost/punto-descarga/' + fakeParam + '/' + fakeParam) | 359 | var respond = 'test'; |
361 | .respond(respond); | 360 | httpBackend.expectGET('localhost/punto-descarga/' + fakeParam + '/' + fakeParam) |
362 | 361 | .respond(respond); | |
363 | //act | 362 | |
364 | servicio.getPuntosDescargaByClienDom(fakeParam, fakeParam).then(function(res) { | 363 | //act |
365 | result = res.data; | 364 | servicio.getPuntosDescargaByClienDom(fakeParam, fakeParam).then(function(res) { |
366 | }); | 365 | result = res.data; |
367 | httpBackend.flush(); | 366 | }); |
368 | 367 | httpBackend.flush(); | |
369 | //assert | 368 | |
370 | expect(result).toEqual(respond); | 369 | //assert |
371 | }); | 370 | expect(result).toEqual(respond); |
372 | 371 | }); | |
373 | it('función enviarCorreo llama a ruta correcta', function() { | 372 | |
374 | 373 | it('función enviarCorreo llama a ruta correcta', function() { | |
375 | //arrange | 374 | |
376 | var result; | 375 | //arrange |
377 | var fakeParam = 1; | 376 | var result; |
378 | var respond = 'test'; | 377 | var fakeParam = 1; |
379 | httpBackend.expectPOST('localhost/remito/mail', fakeParam) | 378 | var respond = 'test'; |
380 | .respond(respond); | 379 | httpBackend.expectPOST('localhost/remito/mail', fakeParam) |
381 | 380 | .respond(respond); | |
382 | //act | 381 | |
383 | servicio.enviarCorreo(fakeParam).then(function(res) { | 382 | //act |
384 | result = res.data; | 383 | servicio.enviarCorreo(fakeParam).then(function(res) { |
385 | }); | 384 | result = res.data; |
386 | httpBackend.flush(); | 385 | }); |
387 | 386 | httpBackend.flush(); | |
388 | //assert | 387 | |
389 | expect(result).toEqual(respond); | 388 | //assert |
390 | }); | 389 | expect(result).toEqual(respond); |
391 | }); | 390 | }); |
392 | }); | 391 | }); |
393 | 392 | }); |
src/js/businessService.js
1 | angular.module('focaCrearRemito') | 1 | angular.module('focaCrearRemito') |
2 | .factory('remitoBusinessService', [ | 2 | .factory('remitoBusinessService', [ |
3 | 'crearRemitoService', | 3 | 'crearRemitoService', |
4 | function(crearRemitoService) { | 4 | function(crearRemitoService) { |
5 | return { | 5 | return { |
6 | addArticulos: function(articulosRemito, idRemito, cotizacion) { | 6 | addArticulos: function(articulosRemito, idRemito, cotizacion) { |
7 | for(var i = 0; i < articulosRemito.length; i++) { | 7 | for(var i = 0; i < articulosRemito.length; i++) { |
8 | delete articulosRemito[i].editCantidad; | 8 | delete articulosRemito[i].editCantidad; |
9 | delete articulosRemito[i].editPrecio; | 9 | delete articulosRemito[i].editPrecio; |
10 | articulosRemito[i].idRemito = idRemito; | 10 | articulosRemito[i].idRemito = articulosRemito[i].idRemito !== -1 ? |
11 | idRemito : articulosRemito[i].idRemito; | ||
11 | articulosRemito[i].precio = articulosRemito[i].precio * cotizacion; | 12 | articulosRemito[i].precio = articulosRemito[i].precio * cotizacion; |
12 | delete articulosRemito[i].idNotaPedido; | 13 | delete articulosRemito[i].idNotaPedido; |
13 | crearRemitoService.crearArticulosParaRemito(articulosRemito[i]); | 14 | crearRemitoService.crearArticulosParaRemito(articulosRemito[i]); |
14 | } | 15 | } |
15 | }, | 16 | }, |
16 | addEstado: function(idRemito, idVendedor) { | 17 | addEstado: function(idRemito, idVendedor) { |
17 | var date = new Date(); | 18 | var date = new Date(); |
18 | var estado = { | 19 | var estado = { |
19 | idRemito: idRemito, | 20 | idRemito: idRemito, |
20 | fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 21 | fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
21 | .toISOString().slice(0, 19).replace('T', ' '), | 22 | .toISOString().slice(0, 19).replace('T', ' '), |
22 | estado: 0, | 23 | estado: 0, |
23 | idVendedor: idVendedor | 24 | idVendedor: idVendedor |
24 | }; | 25 | }; |
25 | crearRemitoService.crearEstadoParaRemito(estado); | 26 | crearRemitoService.crearEstadoParaRemito(estado); |
26 | }, | 27 | }, |
27 | calcularArticulos: function(articulos, cotizacion) { | 28 | calcularArticulos: function(articulos, cotizacion) { |
28 | for(var i = 0; i < articulos.length; i++) { | 29 | for(var i = 0; i < articulos.length; i++) { |
29 | articulos[i].precio = articulos[i].precio / cotizacion; | 30 | articulos[i].precio = articulos[i].precio / cotizacion; |
30 | } | 31 | } |
31 | }, | 32 | }, |
32 | plazoToString: function(plazos) { | 33 | plazoToString: function(plazos) { |
33 | var result = ''; | 34 | var result = ''; |
34 | for(var i = 0; i < plazos.length; i++) { | 35 | for(var i = 0; i < plazos.length; i++) { |
35 | result += plazos[i].dias + ' '; | 36 | result += plazos[i].dias + ' '; |
36 | } | 37 | } |
37 | return result.trim(); | 38 | return result.trim(); |
38 | } | 39 | } |
39 | }; | 40 | }; |
40 | }]); | 41 | }]); |
41 | 42 |
src/js/controller.js
1 | angular.module('focaCrearRemito') .controller('remitoController', | 1 | angular.module('focaCrearRemito') .controller('remitoController', |
2 | [ | 2 | [ |
3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearRemitoService', '$timeout', |
4 | 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', | 4 | 'focaModalService', 'remitoBusinessService', '$rootScope', 'focaBotoneraLateralService', |
5 | '$localStorage', | 5 | '$localStorage', |
6 | function( | 6 | function( |
7 | $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService, | 7 | $scope, $uibModal, $location, $filter, crearRemitoService, $timeout, focaModalService, |
8 | remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) | 8 | remitoBusinessService, $rootScope, focaBotoneraLateralService, $localStorage) |
9 | { | 9 | { |
10 | config(); | 10 | config(); |
11 | 11 | ||
12 | function config() { | 12 | function config() { |
13 | $scope.tmpCantidad = Number; | 13 | $scope.tmpCantidad = Number; |
14 | $scope.tmpPrecio = Number; | 14 | $scope.tmpPrecio = Number; |
15 | $scope.botonera = crearRemitoService.getBotonera(); | 15 | $scope.botonera = crearRemitoService.getBotonera(); |
16 | $scope.isNumber = angular.isNumber; | 16 | $scope.isNumber = angular.isNumber; |
17 | $scope.datepickerAbierto = false; | 17 | $scope.datepickerAbierto = false; |
18 | $scope.show = false; | 18 | $scope.show = false; |
19 | $scope.cargando = true; | 19 | $scope.cargando = true; |
20 | $scope.now = new Date(); | 20 | $scope.now = new Date(); |
21 | $scope.puntoVenta = rellenar(0, 4); | 21 | $scope.puntoVenta = rellenar(0, 4); |
22 | $scope.comprobante = rellenar(0, 8); | 22 | $scope.comprobante = rellenar(0, 8); |
23 | $scope.dateOptions = { | 23 | $scope.dateOptions = { |
24 | maxDate: new Date(), | 24 | maxDate: new Date(), |
25 | minDate: new Date(2010, 0, 1) | 25 | minDate: new Date(2010, 0, 1) |
26 | }; | 26 | }; |
27 | 27 | ||
28 | var monedaPorDefecto; | 28 | var monedaPorDefecto; |
29 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 29 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
30 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { | 30 | crearRemitoService.getCotizacionByIdMoneda(1).then(function(res) { |
31 | monedaPorDefecto = res.data[0]; | 31 | monedaPorDefecto = res.data[0]; |
32 | 32 | ||
33 | $scope.remito.cotizacion = Object.assign( | 33 | $scope.remito.cotizacion = Object.assign( |
34 | {moneda: monedaPorDefecto}, monedaPorDefecto.cotizaciones[0] | 34 | {moneda: monedaPorDefecto}, monedaPorDefecto.cotizaciones[0] |
35 | ); | 35 | ); |
36 | $scope.inicial.cotizacion = $scope.remito.cotizacion; | ||
37 | $scope.cotizacionPorDefecto = angular.copy($scope.remito.cotizacion); | ||
36 | $scope.inicial.cotizacion = $scope.remito.cotizacion; | 38 | |
37 | $scope.cotizacionPorDefecto = angular.copy($scope.remito.cotizacion); | 39 | $timeout(function() { getLSRemito(); }); |
38 | }); | 40 | }); |
39 | 41 | ||
40 | //SETEO BOTONERA LATERAL | 42 | //SETEO BOTONERA LATERAL |
41 | $timeout(function() { | 43 | $timeout(function() { |
42 | focaBotoneraLateralService.showSalir(false); | 44 | focaBotoneraLateralService.showSalir(false); |
43 | focaBotoneraLateralService.showPausar(true); | 45 | focaBotoneraLateralService.showPausar(true); |
44 | focaBotoneraLateralService.showGuardar(true, $scope.crearRemito); | 46 | focaBotoneraLateralService.showGuardar(true, $scope.crearRemito); |
45 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 47 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
46 | }); | 48 | }); |
47 | |||
48 | init(); | 49 | |
49 | $timeout(function() {getLSRemito();}); | 50 | init(); |
50 | } | 51 | } |
51 | 52 | ||
52 | function init() { | 53 | function init() { |
53 | $scope.$broadcast('cleanCabecera'); | 54 | $scope.$broadcast('cleanCabecera'); |
54 | 55 | ||
55 | $scope.remito = { | 56 | $scope.remito = { |
56 | id: 0, | 57 | id: 0, |
57 | estado: 0, | 58 | estado: 0, |
58 | vendedor: {}, | 59 | vendedor: {}, |
59 | cliente: {}, | 60 | cliente: {}, |
60 | proveedor: {}, | 61 | proveedor: {}, |
61 | domicilio: {dom: ''}, | 62 | domicilio: {dom: ''}, |
62 | moneda: {}, | 63 | moneda: {}, |
63 | cotizacion: $scope.cotizacionPorDefecto || {}, | 64 | cotizacion: $scope.cotizacionPorDefecto || {}, |
64 | articulosRemito: [] | 65 | articulosRemito: [] |
65 | }; | 66 | }; |
66 | 67 | ||
67 | $scope.notaPedido = { | 68 | $scope.notaPedido = { |
68 | id: 0 | 69 | id: 0 |
69 | }; | 70 | }; |
70 | 71 | ||
71 | $scope.remito.articulosRemito = []; | 72 | $scope.remito.articulosRemito = []; |
72 | $scope.idLista = undefined; | 73 | $scope.idLista = undefined; |
73 | 74 | ||
74 | crearRemitoService.getNumeroRemito().then( | 75 | crearRemitoService.getNumeroRemito().then( |
75 | function(res) { | 76 | function(res) { |
76 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 77 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
77 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); | 78 | $scope.comprobante = rellenar(res.data.numeroRemito, 8); |
78 | }, | 79 | }, |
79 | function(err) { | 80 | function(err) { |
80 | focaModalService.alert('La terminal no esta configurada correctamente'); | 81 | focaModalService.alert('La terminal no esta configurada correctamente'); |
81 | console.info(err); | 82 | console.info(err); |
82 | } | 83 | } |
83 | ); | 84 | ); |
84 | 85 | ||
85 | $scope.inicial = angular.copy($scope.remito); | 86 | $scope.inicial = angular.copy($scope.remito); |
86 | } | 87 | } |
87 | 88 | ||
88 | $scope.$watch('remito', function(newValue) { | 89 | $scope.$watch('remito', function(newValue) { |
89 | focaBotoneraLateralService.setPausarData({ | 90 | focaBotoneraLateralService.setPausarData({ |
90 | label: 'remito', | 91 | label: 'remito', |
91 | val: newValue | 92 | val: newValue |
92 | }); | 93 | }); |
93 | }, true); | 94 | }, true); |
94 | 95 | ||
95 | $scope.seleccionarNotaPedido = function() { | 96 | $scope.seleccionarNotaPedido = function() { |
96 | if (varlidarRemitoFacturado()) { | 97 | if (varlidarRemitoFacturado()) { |
97 | var modalInstance = $uibModal.open( | 98 | var modalInstance = $uibModal.open( |
98 | { | 99 | { |
99 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 100 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
100 | templateUrl: 'foca-modal-nota-pedido.html', | 101 | templateUrl: 'foca-modal-nota-pedido.html', |
101 | controller: 'focaModalNotaPedidoController', | 102 | controller: 'focaModalNotaPedidoController', |
102 | size: 'lg', | 103 | size: 'lg', |
103 | resolve: { | 104 | resolve: { |
104 | usadoPor: function() { return 'remito'; }, | 105 | usadoPor: function() { return 'remito'; }, |
105 | idVendedor: function() { return null; } | 106 | idVendedor: function() { return null; } |
106 | } | 107 | } |
107 | } | 108 | } |
108 | ); | 109 | ); |
109 | modalInstance.result.then( | 110 | modalInstance.result.then( |
110 | function(notaPedido) { | 111 | function(notaPedido) { |
111 | //añado cabeceras | 112 | //añado cabeceras |
112 | $scope.notaPedido.id = notaPedido.id; | 113 | $scope.notaPedido.id = notaPedido.id; |
113 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 114 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
114 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 115 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
115 | var cabeceras = [ | 116 | var cabeceras = [ |
116 | { | 117 | { |
117 | label: 'Moneda:', | 118 | label: 'Moneda:', |
118 | valor: notaPedido.cotizacion.moneda.DETALLE | 119 | valor: notaPedido.cotizacion.moneda.DETALLE |
119 | }, | 120 | }, |
120 | { | 121 | { |
121 | label: 'Fecha cotizacion:', | 122 | label: 'Fecha cotizacion:', |
122 | valor: $filter('date')(notaPedido.cotizacion.FECHA, | 123 | valor: $filter('date')(notaPedido.cotizacion.FECHA, |
123 | 'dd/MM/yyyy') | 124 | 'dd/MM/yyyy') |
124 | }, | 125 | }, |
125 | { | 126 | { |
126 | label: 'Cotizacion:', | 127 | label: 'Cotizacion:', |
127 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, | 128 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, |
128 | '2') | 129 | '2') |
129 | }, | 130 | }, |
130 | { | 131 | { |
131 | label: 'Cliente:', | 132 | label: 'Cliente:', |
132 | valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + | 133 | valor: $filter('rellenarDigitos')(notaPedido.cliente.COD, 3) + |
133 | ' - ' + notaPedido.cliente.NOM | 134 | ' - ' + notaPedido.cliente.NOM |
134 | }, | 135 | }, |
135 | { | 136 | { |
136 | label: 'Domicilio:', | 137 | label: 'Domicilio:', |
137 | valor: notaPedido.domicilioStamp | 138 | valor: notaPedido.domicilioStamp |
138 | }, | 139 | }, |
139 | { | 140 | { |
140 | label: 'Vendedor:', | 141 | label: 'Vendedor:', |
141 | valor: $filter('rellenarDigitos')( | 142 | valor: $filter('rellenarDigitos')( |
142 | notaPedido.vendedor.NUM, 3 | 143 | notaPedido.vendedor.NUM, 3 |
143 | ) + ' - ' + notaPedido.vendedor.NOM | 144 | ) + ' - ' + notaPedido.vendedor.NOM |
144 | }, | 145 | }, |
145 | { | 146 | { |
146 | label: 'Proveedor:', | 147 | label: 'Proveedor:', |
147 | valor: $filter('rellenarDigitos') | 148 | valor: $filter('rellenarDigitos') |
148 | (notaPedido.proveedor.COD, 5) + ' - ' + | 149 | (notaPedido.proveedor.COD, 5) + ' - ' + |
149 | notaPedido.proveedor.NOM | 150 | notaPedido.proveedor.NOM |
150 | }, | 151 | }, |
151 | { | 152 | { |
152 | label: 'Precio condicion:', | 153 | label: 'Precio condicion:', |
153 | valor: valorPrecioCondicion() + ' ' + | 154 | valor: valorPrecioCondicion() + ' ' + |
154 | remitoBusinessService | 155 | remitoBusinessService |
155 | .plazoToString(notaPedido.notaPedidoPlazo) | 156 | .plazoToString(notaPedido.notaPedidoPlazo) |
156 | }, | 157 | }, |
157 | { | 158 | { |
158 | label: 'Flete:', | 159 | label: 'Flete:', |
159 | valor: notaPedido.fob === 1 ? 'FOB' : ( | 160 | valor: notaPedido.fob === 1 ? 'FOB' : ( |
160 | notaPedido.flete === 1 ? 'Si' : 'No') | 161 | notaPedido.flete === 1 ? 'Si' : 'No') |
161 | } | 162 | } |
162 | ]; | ||
163 | |||
164 | if (notaPedido.observaciones) { | ||
165 | cabeceras.push({ | ||
166 | label: 'Observaciones:', | ||
167 | valor: notaPedido.observaciones | ||
168 | }); | ||
169 | } | 163 | ]; |
170 | 164 | ||
171 | function valorPrecioCondicion() { | 165 | function valorPrecioCondicion() { |
172 | if (notaPedido.idPrecioCondicion > 0) { | 166 | if (notaPedido.idPrecioCondicion > 0) { |
173 | return notaPedido.precioCondicion.nombre; | 167 | return notaPedido.precioCondicion.nombre; |
174 | } else { | 168 | } else { |
175 | return 'Ingreso Manual'; | 169 | return 'Ingreso Manual'; |
176 | } | 170 | } |
177 | } | 171 | } |
178 | 172 | ||
179 | if (notaPedido.flete === 1) { | 173 | if (notaPedido.flete === 1) { |
180 | var cabeceraBomba = { | 174 | var cabeceraBomba = { |
181 | label: 'Bomba:', | 175 | label: 'Bomba:', |
182 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 176 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
183 | }; | 177 | }; |
184 | if (notaPedido.kilometros) { | 178 | if (notaPedido.kilometros) { |
185 | var cabeceraKilometros = { | 179 | var cabeceraKilometros = { |
186 | label: 'Kilometros:', | 180 | label: 'Kilometros:', |
187 | valor: notaPedido.kilometros | 181 | valor: notaPedido.kilometros |
188 | }; | 182 | }; |
189 | cabeceras.push(cabeceraKilometros); | 183 | cabeceras.push(cabeceraKilometros); |
190 | } | 184 | } |
191 | cabeceras.push(cabeceraBomba); | 185 | cabeceras.push(cabeceraBomba); |
192 | } | 186 | } |
193 | 187 | ||
194 | delete notaPedido.id; | 188 | delete notaPedido.id; |
195 | $scope.remito = notaPedido; | 189 | $scope.remito = notaPedido; |
196 | $scope.remito.id = 0; | 190 | $scope.remito.id = 0; |
197 | $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; | 191 | $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; |
198 | 192 | ||
193 | for(var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) { | ||
199 | for(var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) { | 194 | notaPedido.articulosNotaPedido[i].id = 0; |
200 | notaPedido.articulosNotaPedido[i].id = 0; | 195 | notaPedido.articulosNotaPedido[i].idRemito = 0; |
201 | } | 196 | } |
202 | |||
203 | $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; | ||
204 | remitoBusinessService.calcularArticulos($scope.remito.articulosRemito, | 197 | |
205 | notaPedido.cotizacion.VENDEDOR); | 198 | $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; |
206 | 199 | ||
207 | if (notaPedido.idPrecioCondicion > 0) { | 200 | if (notaPedido.idPrecioCondicion > 0) { |
208 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | 201 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; |
209 | }else { | 202 | } else { |
210 | $scope.idLista = -1; | 203 | $scope.idLista = -1; |
211 | } | 204 | } |
212 | 205 | ||
213 | enableObservaciones(notaPedido.observaciones ? true : false); | 206 | enableObservaciones(notaPedido.observaciones ? true : false); |
214 | addArrayCabecera(cabeceras); | 207 | addArrayCabecera(cabeceras); |
215 | 208 | ||
216 | }, function() { | 209 | }, function() { |
217 | // funcion ejecutada cuando se cancela el modal | 210 | // funcion ejecutada cuando se cancela el modal |
218 | } | 211 | } |
219 | ); | 212 | ); |
220 | } | 213 | } |
221 | }; | 214 | }; |
222 | 215 | ||
223 | $scope.seleccionarRemito = function() { | 216 | $scope.seleccionarRemito = function() { |
224 | var modalInstance = $uibModal.open( | 217 | var modalInstance = $uibModal.open( |
225 | { | 218 | { |
226 | ariaLabelledBy: 'Busqueda de Remito', | 219 | ariaLabelledBy: 'Busqueda de Remito', |
227 | templateUrl: 'foca-modal-remito.html', | 220 | templateUrl: 'foca-modal-remito.html', |
228 | controller: 'focaModalRemitoController', | 221 | controller: 'focaModalRemitoController', |
229 | size: 'lg', | 222 | size: 'lg', |
230 | resolve: {usadoPor: function() {return 'remito';}} | 223 | resolve: {usadoPor: function() {return 'remito';}} |
231 | } | 224 | } |
232 | ); | 225 | ); |
233 | modalInstance.result.then( | 226 | modalInstance.result.then( |
234 | setearRemito, function() { | 227 | setearRemito, function() { |
235 | // funcion ejecutada cuando se cancela el modal | 228 | // funcion ejecutada cuando se cancela el modal |
236 | } | 229 | } |
237 | ); | 230 | ); |
238 | }; | 231 | }; |
239 | 232 | ||
240 | //validacion por domicilio y por plazo pago | 233 | //validacion por domicilio y por plazo pago |
241 | $scope.crearRemito = function() { | 234 | $scope.crearRemito = function() { |
242 | if (!$scope.remito.vendedor.NUM) { | 235 | if (!$scope.remito.vendedor.NUM) { |
243 | focaModalService.alert('Ingrese Vendedor'); | 236 | focaModalService.alert('Ingrese Vendedor'); |
244 | return; | 237 | return; |
245 | } else if (!$scope.remito.cliente.COD) { | 238 | } else if (!$scope.remito.cliente.COD) { |
246 | focaModalService.alert('Ingrese Cliente'); | 239 | focaModalService.alert('Ingrese Cliente'); |
247 | return; | 240 | return; |
248 | } else if (!$scope.remito.proveedor) { | 241 | } else if (!$scope.remito.proveedor) { |
249 | focaModalService.alert('Ingrese Proveedor'); | 242 | focaModalService.alert('Ingrese Proveedor'); |
250 | return; | 243 | return; |
251 | } else if (!$scope.remito.cotizacion.moneda.id && | ||
252 | !$scope.remito.cotizacion.moneda.ID) | 244 | } else if (!$scope.remito.cotizacion.moneda.id && |
253 | { | 245 | !$scope.remito.cotizacion.moneda.ID){ |
254 | focaModalService.alert('Ingrese Moneda'); | 246 | focaModalService.alert('Ingrese Moneda'); |
255 | return; | 247 | return; |
256 | } else if (!$scope.remito.cotizacion.ID) { | 248 | } else if (!$scope.remito.cotizacion.ID) { |
257 | focaModalService.alert('Ingrese Cotización'); | 249 | focaModalService.alert('Ingrese Cotización'); |
258 | return; | ||
259 | } else if ( | ||
260 | $scope.remito.flete === undefined || $scope.remito.flete === null) | 250 | return; |
261 | { | 251 | } else if ($scope.remito.flete === undefined || $scope.remito.flete === null){ |
262 | focaModalService.alert('Ingrese Flete'); | 252 | focaModalService.alert('Ingrese Flete'); |
263 | return; | 253 | return; |
264 | } else if ($scope.remito.articulosRemito.length === 0) { | 254 | } else if ($scope.articulosFiltro().length === 0) { |
265 | focaModalService.alert('Debe cargar al menos un articulo'); | 255 | focaModalService.alert('Debe cargar al menos un articulo'); |
266 | return; | 256 | return; |
267 | } | 257 | } |
268 | focaBotoneraLateralService.startGuardar(); | 258 | focaBotoneraLateralService.startGuardar(); |
269 | $scope.saveLoading = true; | 259 | $scope.saveLoading = true; |
270 | var save = { | 260 | var save = { |
271 | remito: { | 261 | remito: { |
272 | id: $scope.remito.id, | 262 | id: $scope.remito.id, |
273 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | 263 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), |
274 | idCliente: $scope.remito.cliente.COD, | 264 | idCliente: $scope.remito.cliente.COD, |
275 | nombreCliente: $scope.remito.cliente.NOM, | 265 | nombreCliente: $scope.remito.cliente.NOM, |
276 | cuitCliente: $scope.remito.cliente.CUIT, | 266 | cuitCliente: $scope.remito.cliente.CUIT, |
277 | responsabilidadIvaCliente: 0,//TODO, | 267 | responsabilidadIvaCliente: 0,//TODO, |
278 | descuento: 0,//TODO, | 268 | descuento: 0,//TODO, |
279 | importeNeto: 0,//TODO | 269 | importeNeto: 0,//TODO |
280 | importeExento: 0,//TODO | 270 | importeExento: 0,//TODO |
281 | importeIva: 0,//TODO | 271 | importeIva: 0,//TODO |
282 | importeIvaServicios: 0,//TODO | 272 | importeIvaServicios: 0,//TODO |
283 | importeImpuestoInterno: 0,//TODO | 273 | importeImpuestoInterno: 0,//TODO |
284 | importeImpuestoInterno1: 0,//TODO | 274 | importeImpuestoInterno1: 0,//TODO |
285 | importeImpuestoInterno2: 0,//TODO | 275 | importeImpuestoInterno2: 0,//TODO |
286 | percepcion: 0,//TODO | 276 | percepcion: 0,//TODO |
287 | percepcionIva: 0,//TODO | 277 | percepcionIva: 0,//TODO |
288 | redondeo: 0,//TODO | 278 | redondeo: 0,//TODO |
289 | total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR, | 279 | total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR, |
290 | numeroNotaPedido: $scope.remito.numeroNotaPedido, | 280 | numeroNotaPedido: $scope.remito.numeroNotaPedido, |
291 | anulado: false, | 281 | anulado: false, |
292 | planilla: 0,//TODO | 282 | planilla: 0,//TODO |
293 | lugar: 0,//TODO | 283 | lugar: 0,//TODO |
294 | cuentaMadre: 0,// | 284 | cuentaMadre: 0,// |
295 | cuentaContable: 0,//TODO | 285 | cuentaContable: 0,//TODO |
296 | asiento: 0,//TODO | 286 | asiento: 0,//TODO |
297 | e_hd: '',//TODO | 287 | e_hd: '',//TODO |
298 | c_hd: '', | 288 | c_hd: '', |
299 | numeroLiquidoProducto: 0,//TODO | 289 | numeroLiquidoProducto: 0,//TODO |
300 | idVendedor: $scope.remito.idVendedor, | 290 | idVendedor: $scope.remito.idVendedor, |
301 | idProveedor: $scope.remito.idProveedor, | 291 | idProveedor: $scope.remito.idProveedor, |
302 | idDomicilio: $scope.remito.idDomicilio, | 292 | idDomicilio: $scope.remito.idDomicilio, |
303 | idCotizacion: $scope.remito.cotizacion.ID, | 293 | idCotizacion: $scope.remito.cotizacion.ID, |
304 | idPrecioCondicion: $scope.remito.idPrecioCondicion, | 294 | idPrecioCondicion: $scope.remito.idPrecioCondicion, |
305 | flete: $scope.remito.flete, | 295 | flete: $scope.remito.flete, |
306 | fob: $scope.remito.fob, | 296 | fob: $scope.remito.fob, |
307 | bomba: $scope.remito.bomba, | 297 | bomba: $scope.remito.bomba, |
308 | kilometros: $scope.remito.kilometros, | 298 | kilometros: $scope.remito.kilometros, |
309 | domicilioStamp: $scope.remito.domicilioStamp, | 299 | domicilioStamp: $scope.remito.domicilioStamp, |
310 | estado: 0,//TODO | 300 | estado: 0,//TODO |
301 | destinoVenta: 0,//TODO | ||
302 | operacionTipo: 0, //TODO | ||
303 | observaciones: $scope.remito.observaciones, | ||
311 | destinoVenta: 0,//TODO | 304 | numeroRemito: parseInt($scope.comprobante), |
312 | operacionTipo: 0//TODO | 305 | sucursal: parseInt($scope.puntoVenta) |
313 | }, | 306 | }, |
314 | notaPedido: $scope.notaPedido | 307 | notaPedido: $scope.notaPedido |
315 | }; | 308 | }; |
316 | 309 | ||
317 | crearRemitoService.crearRemito(save).then( | ||
318 | function(data) { | ||
319 | remitoBusinessService.addArticulos($scope.remito.articulosRemito, | 310 | crearRemitoService.crearRemito(save).then( |
320 | data.data.id, $scope.remito.cotizacion.COTIZACION); | 311 | function(data) { |
321 | 312 | ||
322 | focaBotoneraLateralService.endGuardar(true); | 313 | focaBotoneraLateralService.endGuardar(true); |
323 | $scope.saveLoading = false; | 314 | $scope.saveLoading = false; |
315 | |||
316 | $scope.remito.id = data.data.id; | ||
317 | $scope.remito.numeroRemito = data.data.numero; | ||
318 | |||
319 | remitoBusinessService.addArticulos($scope.remito.articulosRemito, | ||
320 | $scope.remito.id, $scope.remito.cotizacion.VENDEDOR); | ||
321 | |||
322 | if(data.status === 500) { | ||
323 | focaModalService.alert(data.data); | ||
324 | return; | ||
325 | } | ||
324 | 326 | ||
325 | //TODO: updatear plazos | 327 | // TODO: updatear plazos |
326 | if ($scope.remito.id === 0) { | 328 | if ($scope.remito.id === 0) { |
327 | var plazos = $scope.remito.remitoPlazo; | 329 | var plazos = $scope.remito.remitoPlazo; |
328 | 330 | ||
329 | for(var j = 0; j < plazos.length; j++) { | 331 | for(var j = 0; j < plazos.length; j++) { |
330 | var json = { | 332 | var json = { |
331 | idRemito: $scope.remito.id, | 333 | idRemito: $scope.remito.id, |
332 | dias: plazos[j].dias | 334 | dias: plazos[j].dias |
333 | }; | 335 | }; |
334 | crearRemitoService.crearPlazosParaRemito(json); | 336 | crearRemitoService.crearPlazosParaRemito(json); |
335 | } | 337 | } |
336 | } | 338 | } |
337 | abrirModalMail(data.data.id, $scope.remito.cliente, $filter('comprobante')([ | 339 | |
338 | data.data.sucursal, | 340 | abrirModalMail($scope.remito.id, |
341 | $scope.remito.cliente, | ||
342 | $filter('comprobante')([ | ||
343 | $scope.puntoVenta, | ||
344 | $scope.remito.numeroRemito | ||
339 | data.data.numero | 345 | ]) |
340 | ])); | 346 | ); |
341 | 347 | ||
342 | init(); | 348 | init(); |
343 | 349 | ||
344 | }, function(error) { | 350 | }, function(error) { |
345 | focaModalService.alert('Hubo un error al crear el remito'); | 351 | focaModalService.alert(error.data || 'Hubo un error al crear el remito'); |
346 | focaBotoneraLateralService.endGuardar(); | 352 | focaBotoneraLateralService.endGuardar(); |
347 | $scope.saveLoading = false; | 353 | $scope.saveLoading = false; |
348 | console.info(error); | 354 | console.info(error); |
349 | } | 355 | } |
350 | ); | 356 | ); |
351 | }; | 357 | }; |
352 | 358 | ||
353 | $scope.seleccionarProductos = function() { | 359 | $scope.seleccionarProductos = function() { |
354 | if ($scope.idLista === undefined) { | 360 | if ($scope.idLista === undefined) { |
355 | focaModalService.alert( | 361 | focaModalService.alert( |
356 | 'Primero seleccione una lista de precio y condicion'); | 362 | 'Primero seleccione una lista de precio y condicion'); |
357 | return; | 363 | return; |
358 | } | 364 | } |
359 | var modalInstance = $uibModal.open( | 365 | var modalInstance = $uibModal.open( |
360 | { | 366 | { |
361 | ariaLabelledBy: 'Busqueda de Productos', | 367 | ariaLabelledBy: 'Busqueda de Productos', |
362 | templateUrl: 'modal-busqueda-productos.html', | 368 | templateUrl: 'modal-busqueda-productos.html', |
363 | controller: 'modalBusquedaProductosCtrl', | 369 | controller: 'modalBusquedaProductosCtrl', |
364 | resolve: { | 370 | resolve: { |
365 | parametroProducto: { | 371 | parametroProducto: { |
366 | idLista: $scope.idLista, | 372 | idLista: $scope.idLista, |
367 | cotizacion: $scope.remito.cotizacion.COTIZACION, | 373 | cotizacion: $scope.remito.cotizacion.VENDEDOR, |
368 | simbolo: $scope.remito.cotizacion.moneda.simbolo | 374 | simbolo: $scope.remito.cotizacion.moneda.SIMBOLO |
369 | } | 375 | } |
370 | }, | 376 | }, |
371 | size: 'lg' | 377 | size: 'lg' |
372 | } | 378 | } |
373 | ); | 379 | ); |
374 | modalInstance.result.then( | 380 | modalInstance.result.then( |
375 | function(producto) { | 381 | function(producto) { |
376 | var newArt = | 382 | var newArt = |
383 | { | ||
377 | { | 384 | id: 0, |
378 | id: 0, | 385 | idRemito: 0, |
379 | codigo: producto.codigo, | 386 | codigo: producto.codigo, |
380 | sector: producto.sector, | 387 | sector: producto.sector, |
381 | sectorCodigo: producto.sector + '-' + producto.codigo, | 388 | sectorCodigo: producto.sector + '-' + producto.codigo, |
382 | descripcion: producto.descripcion, | 389 | descripcion: producto.descripcion, |
383 | item: $scope.remito.articulosRemito.length + 1, | 390 | item: $scope.remito.articulosRemito.length + 1, |
384 | nombre: producto.descripcion, | 391 | nombre: producto.descripcion, |
385 | precio: parseFloat(producto.precio.toFixed(4)), | 392 | precio: parseFloat(producto.precio.toFixed(4)), |
386 | costoUnitario: producto.costo, | 393 | costoUnitario: producto.costo, |
387 | editCantidad: false, | 394 | editCantidad: false, |
388 | editPrecio: false, | 395 | editPrecio: false, |
389 | rubro: producto.CodRub, | 396 | rubro: producto.CodRub, |
390 | exentoUnitario: producto.precio, | 397 | exentoUnitario: producto.precio, |
391 | ivaUnitario: producto.IMPIVA, | 398 | ivaUnitario: producto.IMPIVA, |
392 | impuestoInternoUnitario: producto.ImpInt, | 399 | impuestoInternoUnitario: producto.ImpInt, |
393 | impuestoInterno1Unitario: producto.ImpInt2, | 400 | impuestoInterno1Unitario: producto.ImpInt2, |
394 | impuestoInterno2Unitario: producto.ImpInt3, | 401 | impuestoInterno2Unitario: producto.ImpInt3, |
395 | precioLista: producto.precio, | 402 | precioLista: producto.precio, |
396 | combustible: 1, | 403 | combustible: 1, |
397 | facturado: 0 | 404 | facturado: 0 |
398 | }; | 405 | }; |
399 | $scope.articuloACargar = newArt; | 406 | $scope.articuloACargar = newArt; |
400 | $scope.cargando = false; | 407 | $scope.cargando = false; |
401 | }, function() { | 408 | }, function() { |
402 | // funcion ejecutada cuando se cancela el modal | 409 | // funcion ejecutada cuando se cancela el modal |
403 | } | 410 | } |
404 | ); | 411 | ); |
405 | }; | 412 | }; |
406 | 413 | ||
407 | $scope.seleccionarPuntosDeDescarga = function() { | 414 | $scope.seleccionarPuntosDeDescarga = function() { |
408 | if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { | 415 | if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { |
409 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 416 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
410 | return; | 417 | return; |
411 | }else { | 418 | } else { |
412 | var modalInstance = $uibModal.open( | 419 | var modalInstance = $uibModal.open( |
413 | { | 420 | { |
414 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', | 421 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
415 | templateUrl: 'modal-punto-descarga.html', | 422 | templateUrl: 'modal-punto-descarga.html', |
416 | controller: 'focaModalPuntoDescargaController', | 423 | controller: 'focaModalPuntoDescargaController', |
417 | size: 'lg', | 424 | size: 'lg', |
418 | resolve: { | 425 | resolve: { |
419 | filters: { | 426 | filters: { |
420 | idDomicilio: $scope.remito.domicilio.id, | 427 | idDomicilio: $scope.remito.domicilio.id, |
421 | idCliente: $scope.remito.cliente.COD, | 428 | idCliente: $scope.remito.cliente.COD, |
429 | articulos: $scope.remito.articulosRemito, | ||
422 | articulos: $scope.remito.articulosRemito, | 430 | puntosDescarga: $scope.remito.domicilio.puntosDescarga, |
423 | puntosDescarga: $scope.remito.domicilio.puntosDescarga | 431 | domicilio: $scope.remito.domicilio |
424 | } | 432 | } |
425 | } | 433 | } |
426 | } | 434 | } |
427 | ); | 435 | ); |
428 | modalInstance.result.then( | 436 | modalInstance.result.then( |
429 | function(puntosDescarga) { | 437 | function(puntosDescarga) { |
430 | $scope.remito.puntosDescarga = puntosDescarga; | 438 | $scope.remito.puntosDescarga = puntosDescarga; |
431 | 439 | ||
432 | $scope.$broadcast('addCabecera', { | 440 | $scope.$broadcast('addCabecera', { |
433 | label: 'Puntos de descarga:', | 441 | label: 'Puntos de descarga:', |
434 | valor: getCabeceraPuntoDescarga(puntosDescarga) | 442 | valor: getCabeceraPuntoDescarga(puntosDescarga) |
435 | }); | 443 | }); |
436 | }, function() { | 444 | }, function() { |
437 | $scope.abrirModalDomicilios($scope.cliente); | 445 | $scope.abrirModalDomicilios($scope.cliente); |
438 | } | 446 | } |
439 | ); | 447 | ); |
440 | } | 448 | } |
441 | }; | 449 | }; |
442 | 450 | ||
443 | $scope.seleccionarVendedor = function(callback, ocultarVendedor) { | 451 | $scope.seleccionarVendedor = function(callback, ocultarVendedor) { |
444 | if (ocultarVendedor) { | 452 | if (ocultarVendedor) { |
445 | callback(); | 453 | callback(); |
446 | return; | 454 | return; |
447 | } | 455 | } |
448 | 456 | ||
449 | if (varlidarRemitoFacturado()) { | 457 | if (varlidarRemitoFacturado()) { |
450 | var parametrosModal = { | 458 | var parametrosModal = { |
451 | titulo: 'Búsqueda vendedores', | 459 | titulo: 'Búsqueda vendedores', |
452 | query: '/vendedor', | 460 | query: '/vendedor', |
453 | columnas: [ | 461 | columnas: [ |
454 | { | 462 | { |
455 | propiedad: 'NUM', | 463 | propiedad: 'NUM', |
456 | nombre: 'Código', | 464 | nombre: 'Código', |
457 | filtro: { | 465 | filtro: { |
458 | nombre: 'rellenarDigitos', | 466 | nombre: 'rellenarDigitos', |
459 | parametro: 3 | 467 | parametro: 3 |
460 | } | 468 | } |
461 | }, | 469 | }, |
462 | { | 470 | { |
463 | propiedad: 'NOM', | 471 | propiedad: 'NOM', |
464 | nombre: 'Nombre' | 472 | nombre: 'Nombre' |
465 | } | 473 | } |
466 | ], | 474 | ], |
467 | size: 'md' | 475 | size: 'md' |
468 | }; | 476 | }; |
469 | focaModalService.modal(parametrosModal).then( | 477 | focaModalService.modal(parametrosModal).then( |
470 | function(vendedor) { | 478 | function(vendedor) { |
471 | $scope.$broadcast('addCabecera',{ | 479 | $scope.$broadcast('addCabecera',{ |
472 | label: 'Vendedor:', | 480 | label: 'Vendedor:', |
473 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 481 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
474 | vendedor.NOM | 482 | vendedor.NOM |
475 | }); | 483 | }); |
476 | $scope.remito.idVendedor = vendedor.id; | 484 | $scope.remito.idVendedor = vendedor.id; |
477 | $scope.remito.vendedor = vendedor; | 485 | $scope.remito.vendedor = vendedor; |
478 | deleteCliente(); | 486 | deleteCliente(); |
479 | callback(); | 487 | callback(); |
480 | }, function() { | 488 | }, function() { |
481 | 489 | ||
482 | } | 490 | } |
483 | ); | 491 | ); |
484 | } | 492 | } |
485 | }; | 493 | }; |
486 | 494 | ||
487 | $scope.seleccionarCliente = function(ocultarVendedor) { | 495 | $scope.seleccionarCliente = function(ocultarVendedor) { |
488 | 496 | ||
489 | $scope.seleccionarVendedor(function() { | 497 | $scope.seleccionarVendedor(function() { |
490 | if (varlidarRemitoFacturado()) { | 498 | if (varlidarRemitoFacturado()) { |
491 | var modalInstance = $uibModal.open( | 499 | var modalInstance = $uibModal.open( |
492 | { | 500 | { |
493 | ariaLabelledBy: 'Busqueda de Cliente', | 501 | ariaLabelledBy: 'Busqueda de Cliente', |
494 | templateUrl: 'foca-busqueda-cliente-modal.html', | 502 | templateUrl: 'foca-busqueda-cliente-modal.html', |
495 | controller: 'focaBusquedaClienteModalController', | 503 | controller: 'focaBusquedaClienteModalController', |
496 | resolve: { | 504 | resolve: { |
497 | vendedor: function() { return $scope.remito.vendedor; }, | 505 | vendedor: function() { return $scope.remito.vendedor; }, |
498 | cobrador: function() { return null; } | 506 | cobrador: function() { return null; } |
499 | }, | 507 | }, |
500 | size: 'lg' | 508 | size: 'lg' |
501 | } | 509 | } |
502 | ); | 510 | ); |
503 | modalInstance.result.then( | 511 | modalInstance.result.then( |
504 | function(cliente) { | 512 | function(cliente) { |
505 | $scope.abrirModalDomicilios(cliente); | 513 | $scope.abrirModalDomicilios(cliente); |
506 | $scope.cliente = cliente; | 514 | $scope.cliente = cliente; |
507 | }, function() { | 515 | }, function() { |
508 | $scope.seleccionarCliente(); | 516 | $scope.seleccionarCliente(); |
509 | } | 517 | } |
510 | ); | 518 | ); |
511 | } | 519 | } |
512 | }, ocultarVendedor); | 520 | }, ocultarVendedor); |
513 | }; | 521 | }; |
514 | 522 | ||
515 | $scope.seleccionarProveedor = function(callback) { | 523 | $scope.seleccionarProveedor = function() { |
516 | if (varlidarRemitoFacturado()) { | 524 | if (varlidarRemitoFacturado()) { |
517 | var parametrosModal = { | 525 | var parametrosModal = { |
518 | titulo: 'Búsqueda de Proveedor', | 526 | titulo: 'Búsqueda de Proveedor', |
519 | query: '/proveedor', | 527 | query: '/proveedor', |
520 | columnas: [ | 528 | columnas: [ |
521 | { | 529 | { |
522 | nombre: 'Código', | 530 | nombre: 'Código', |
523 | propiedad: 'COD', | 531 | propiedad: 'COD', |
524 | filtro: { | 532 | filtro: { |
525 | nombre: 'rellenarDigitos', | 533 | nombre: 'rellenarDigitos', |
526 | parametro: 5 | 534 | parametro: 5 |
527 | } | 535 | } |
528 | }, | 536 | }, |
529 | { | 537 | { |
530 | nombre: 'Nombre', | 538 | nombre: 'Nombre', |
531 | propiedad: 'NOM' | 539 | propiedad: 'NOM' |
532 | }, | 540 | }, |
533 | { | 541 | { |
534 | nombre: 'CUIT', | 542 | nombre: 'CUIT', |
535 | propiedad: 'CUIT' | 543 | propiedad: 'CUIT' |
536 | } | 544 | } |
537 | ], | 545 | ], |
538 | tipo: 'POST', | 546 | tipo: 'POST', |
539 | json: {razonCuitCod: ''} | 547 | json: {razonCuitCod: ''} |
540 | }; | 548 | }; |
541 | focaModalService.modal(parametrosModal).then( | 549 | focaModalService.modal(parametrosModal).then( |
542 | function(proveedor) { | 550 | function(proveedor) { |
543 | $scope.remito.proveedor = proveedor; | 551 | $scope.seleccionarFlete(proveedor); |
544 | $scope.remito.idProveedor = proveedor.COD; | 552 | }, function() { } |
545 | 553 | ); | |
546 | $scope.$broadcast('addCabecera',{ | 554 | } |
547 | label: 'Proveedor:', | 555 | }; |
548 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 556 | |
549 | proveedor.NOM | ||
550 | }); | ||
551 | callback(); | ||
552 | }, function() { } | ||
553 | ); | ||
554 | } | ||
555 | }; | ||
556 | |||
557 | $scope.abrirModalDomicilios = function(cliente) { | 557 | $scope.abrirModalDomicilios = function(cliente) { |
558 | var modalInstanceDomicilio = $uibModal.open( | 558 | var modalInstanceDomicilio = $uibModal.open( |
559 | { | 559 | { |
560 | ariaLabelledBy: 'Busqueda de Domicilios', | 560 | ariaLabelledBy: 'Busqueda de Domicilios', |
561 | templateUrl: 'modal-domicilio.html', | 561 | templateUrl: 'modal-domicilio.html', |
562 | controller: 'focaModalDomicilioController', | 562 | controller: 'focaModalDomicilioController', |
563 | size: 'lg', | 563 | size: 'lg', |
564 | resolve: { | 564 | resolve: { |
565 | idCliente: function() { return cliente.cod; }, | 565 | idCliente: function() { return cliente.cod; }, |
566 | esNuevo: function() { return cliente.esNuevo; } | 566 | esNuevo: function() { return cliente.esNuevo; } |
567 | } | 567 | } |
568 | } | 568 | } |
569 | ); | 569 | ); |
570 | modalInstanceDomicilio.result.then( | 570 | modalInstanceDomicilio.result.then( |
571 | function(domicilio) { | 571 | function(domicilio) { |
572 | $scope.remito.domicilio = domicilio; | 572 | $scope.remito.domicilio = domicilio; |
573 | $scope.remito.cliente = { | 573 | $scope.remito.cliente = { |
574 | COD: cliente.cod, | 574 | COD: cliente.cod, |
575 | CUIT: cliente.cuit, | 575 | CUIT: cliente.cuit, |
576 | NOM: cliente.nom, | 576 | NOM: cliente.nom, |
577 | MAIL: cliente.mail, | 577 | MAIL: cliente.mail, |
578 | MOD: cliente.mod | 578 | MOD: cliente.mod |
579 | }; | 579 | }; |
580 | 580 | ||
581 | 581 | var domicilioStamp = | |
582 | var domicilioStamp = | 582 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
583 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 583 | domicilio.Localidad + ', ' + domicilio.Provincia; |
584 | domicilio.Localidad + ', ' + domicilio.Provincia; | 584 | $scope.remito.domicilioStamp = domicilioStamp; |
585 | $scope.remito.domicilioStamp = domicilioStamp; | 585 | $scope.$broadcast('addCabecera',{ |
586 | |||
587 | $scope.$broadcast('addCabecera',{ | 586 | label: 'Cliente:', |
588 | label: 'Cliente:', | 587 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom |
589 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + ' - ' + cliente.nom | 588 | }); |
590 | }); | 589 | $scope.$broadcast('addCabecera',{ |
591 | $scope.$broadcast('addCabecera',{ | ||
592 | label: 'Domicilio:', | 590 | label: 'Domicilio:', |
593 | valor: domicilioStamp | 591 | valor: domicilioStamp |
594 | }); | 592 | }); |
595 | 593 | ||
596 | if (domicilio.verPuntos) { | 594 | if (domicilio.verPuntos) { |
597 | delete $scope.remito.domicilio.verPuntos; | 595 | delete $scope.remito.domicilio.verPuntos; |
598 | $scope.seleccionarPuntosDeDescarga(); | 596 | $scope.seleccionarPuntosDeDescarga(); |
599 | }else { | 597 | } else { |
600 | crearRemitoService | 598 | crearRemitoService |
601 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | 599 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
602 | .then(function(res) { | 600 | .then(function(res) { |
603 | if (res.data.length) $scope.seleccionarPuntosDeDescarga(); | 601 | if (res.data.length) $scope.seleccionarPuntosDeDescarga(); |
604 | }); | 602 | }); |
605 | } | 603 | } |
606 | }, function() { | 604 | }, function() { |
607 | $scope.seleccionarCliente(true); | 605 | $scope.seleccionarCliente(true); |
608 | return; | 606 | return; |
609 | } | 607 | } |
610 | ); | 608 | ); |
611 | }; | 609 | }; |
612 | 610 | ||
613 | $scope.getTotal = function() { | 611 | $scope.getTotal = function() { |
614 | var total = 0; | 612 | var total = 0; |
615 | var arrayTempArticulos = $scope.remito.articulosRemito; | 613 | var arrayTempArticulos = $scope.articulosFiltro(); |
616 | for(var i = 0; i < arrayTempArticulos.length; i++) { | 614 | for(var i = 0; i < arrayTempArticulos.length; i++) { |
617 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 615 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
618 | } | ||
619 | return parseFloat(total.toFixed(2)); | ||
620 | }; | ||
621 | |||
622 | $scope.getSubTotal = function() { | ||
623 | if ($scope.articuloACargar) { | ||
624 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | ||
625 | } | ||
626 | }; | ||
627 | |||
628 | $scope.seleccionarPreciosYCondiciones = function() { | ||
629 | if (!$scope.remito.cliente.COD) { | 616 | } |
630 | focaModalService.alert('Primero seleccione un cliente'); | 617 | return parseFloat(total.toFixed(2)); |
631 | return; | 618 | }; |
632 | } | 619 | |
633 | if (varlidarRemitoFacturado()) { | 620 | $scope.getSubTotal = function() { |
634 | var modalInstance = $uibModal.open( | 621 | if ($scope.articuloACargar) { |
635 | { | 622 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
636 | ariaLabelledBy: 'Busqueda de Precio Condición', | 623 | } |
637 | templateUrl: 'modal-precio-condicion.html', | 624 | }; |
638 | controller: 'focaModalPrecioCondicionController', | 625 | |
639 | size: 'lg', | 626 | $scope.seleccionarPreciosYCondiciones = function() { |
640 | resolve: { | 627 | if (!$scope.remito.cliente.COD) { |
641 | idListaPrecio: function() { | 628 | focaModalService.alert('Primero seleccione un cliente'); |
642 | return $scope.remito.cliente.MOD || null; | 629 | return; |
643 | } | 630 | } |
644 | } | 631 | if (varlidarRemitoFacturado()) { |
645 | } | 632 | var modalInstance = $uibModal.open( |
646 | ); | 633 | { |
647 | modalInstance.result.then( | 634 | ariaLabelledBy: 'Busqueda de Precio Condición', |
648 | function(precioCondicion) { | 635 | templateUrl: 'modal-precio-condicion.html', |
649 | var cabecera = ''; | 636 | controller: 'focaModalPrecioCondicionController', |
650 | var plazosConcat = ''; | 637 | size: 'lg', |
651 | if (!Array.isArray(precioCondicion)) { | 638 | resolve: { |
652 | $scope.remito.idPrecioCondicion = precioCondicion.id; | 639 | idListaPrecio: function() { |
653 | $scope.remito.remitoPlazo = precioCondicion.plazoPago; | 640 | return $scope.remito.cliente.MOD || null; |
654 | $scope.idLista = precioCondicion.idListaPrecio; | 641 | } |
655 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 642 | } |
656 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 643 | } |
657 | } | 644 | ); |
658 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + | 645 | modalInstance.result.then( |
659 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); | 646 | function(precioCondicion) { |
660 | }else { //Cuando se ingresan los plazos manualmente | 647 | var cabecera = ''; |
661 | $scope.remito.idPrecioCondicion = 0; | 648 | var plazosConcat = ''; |
662 | //-1, el modal productos busca todos los productos | 649 | if (!Array.isArray(precioCondicion)) { |
663 | $scope.idLista = -1; | 650 | $scope.remito.idPrecioCondicion = precioCondicion.id; |
664 | $scope.remito.remitoPlazo = precioCondicion; | 651 | $scope.remito.remitoPlazo = precioCondicion.plazoPago; |
665 | for(var j = 0; j < precioCondicion.length; j++) { | 652 | $scope.idLista = precioCondicion.idListaPrecio; |
666 | plazosConcat += precioCondicion[j].dias + ' '; | 653 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
667 | } | 654 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
668 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 655 | } |
669 | } | 656 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + |
670 | $scope.remito.articulosRemito = []; | 657 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); |
671 | $scope.$broadcast('addCabecera',{ | 658 | } else { //Cuando se ingresan los plazos manualmente |
672 | label: 'Precios y condiciones:', | 659 | $scope.remito.idPrecioCondicion = 0; |
673 | valor: cabecera | 660 | //-1, el modal productos busca todos los productos |
674 | }); | 661 | $scope.idLista = -1; |
675 | 662 | $scope.remito.remitoPlazo = precioCondicion; | |
676 | $scope.remito.precioCondicion = precioCondicion; | 663 | for(var j = 0; j < precioCondicion.length; j++) { |
677 | }, function() { | 664 | plazosConcat += precioCondicion[j].dias + ' '; |
678 | 665 | } | |
679 | } | 666 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
680 | ); | 667 | } |
681 | } | 668 | $scope.remito.articulosRemito = []; |
682 | }; | 669 | $scope.$broadcast('addCabecera',{ |
683 | 670 | label: 'Precios y condiciones:', | |
684 | $scope.seleccionarTransportista = function() { | 671 | valor: cabecera |
685 | $scope.seleccionarProveedor(function() { | 672 | }); |
686 | if (varlidarRemitoFacturado()) { | 673 | $scope.remito.precioCondicion = precioCondicion; |
687 | var modalInstance = $uibModal.open( | 674 | }, function() { |
688 | { | 675 | |
689 | ariaLabelledBy: 'Busqueda de Flete', | 676 | } |
690 | templateUrl: 'modal-flete.html', | 677 | ); |
691 | controller: 'focaModalFleteController', | ||
692 | size: 'lg', | 678 | } |
693 | resolve: { | 679 | }; |
694 | parametrosFlete: | 680 | |
695 | function() { | 681 | $scope.seleccionarFlete = function(proveedor) { |
696 | return { | 682 | if (varlidarRemitoFacturado()) { |
697 | flete: $scope.remito.flete ? '1' : | 683 | var modalInstance = $uibModal.open( |
698 | ($scope.remito.fob ? 'FOB' : | 684 | { |
699 | ($scope.remito.flete === undefined ? | 685 | ariaLabelledBy: 'Busqueda de Flete', |
700 | null : '0')), | 686 | templateUrl: 'modal-flete.html', |
701 | bomba: $scope.remito.bomba ? '1' : | 687 | controller: 'focaModalFleteController', |
702 | ($scope.remito.bomba === undefined ? | 688 | size: 'lg', |
703 | null : '0'), | 689 | resolve: { |
704 | kilometros: $scope.remito.kilometros | 690 | parametrosFlete: |
705 | }; | 691 | function() { |
706 | } | 692 | return { |
707 | } | 693 | flete: $scope.remito.flete ? '1' : |
708 | } | 694 | ($scope.remito.fob ? 'FOB' : |
709 | ); | 695 | ($scope.remito.flete === undefined ? |
710 | modalInstance.result.then( | 696 | null : '0')), |
711 | function(datos) { | 697 | bomba: $scope.remito.bomba ? '1' : |
712 | $scope.remito.flete = datos.flete; | 698 | ($scope.remito.bomba === undefined ? |
713 | $scope.remito.fob = datos.FOB; | 699 | null : '0'), |
714 | $scope.remito.bomba = datos.bomba; | 700 | kilometros: $scope.remito.kilometros |
715 | $scope.remito.kilometros = datos.kilometros; | 701 | }; |
716 | 702 | } | |
717 | $scope.$broadcast('addCabecera',{ | 703 | } |
718 | label: 'Flete:', | 704 | } |
719 | valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') | 705 | ); |
720 | }); | 706 | modalInstance.result.then( |
721 | if (datos.flete) { | 707 | function(datos) { |
722 | $scope.$broadcast('addCabecera',{ | ||
723 | label: 'Bomba:', | ||
724 | valor: datos.bomba ? 'Si' : 'No' | 708 | |
725 | }); | 709 | $scope.remito.proveedor = proveedor; |
726 | $scope.$broadcast('addCabecera',{ | 710 | $scope.remito.idProveedor = proveedor.COD; |
727 | label: 'Kilometros:', | 711 | $scope.$broadcast('addCabecera',{ |
728 | valor: datos.kilometros | 712 | label: 'Proveedor:', |
729 | }); | 713 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
730 | } else { | 714 | proveedor.NOM |
731 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 715 | }); |
732 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 716 | |
717 | $scope.remito.flete = datos.flete; | ||
718 | $scope.remito.fob = datos.FOB; | ||
719 | $scope.remito.bomba = datos.bomba; | ||
720 | $scope.remito.kilometros = datos.kilometros; | ||
721 | |||
722 | $scope.$broadcast('addCabecera',{ | ||
723 | label: 'Flete:', | ||
724 | valor: datos.flete ? 'Si' : ($scope.remito.fob ? 'FOB' : 'No') | ||
725 | }); | ||
726 | if (datos.flete) { | ||
727 | $scope.$broadcast('addCabecera',{ | ||
728 | label: 'Bomba:', | ||
729 | valor: datos.bomba ? 'Si' : 'No' | ||
730 | }); | ||
731 | $scope.$broadcast('addCabecera',{ | ||
733 | $scope.remito.fob = false; | 732 | label: 'Kilometros:', |
734 | $scope.remito.bomba = false; | 733 | valor: datos.kilometros |
735 | $scope.remito.kilometros = null; | 734 | }); |
736 | } | 735 | } else { |
737 | }, function() { | 736 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
738 | $scope.seleccionarTransportista(); | 737 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
739 | } | 738 | $scope.remito.bomba = false; |
740 | ); | 739 | $scope.remito.kilometros = null; |
741 | } | 740 | } |
742 | }); | 741 | }, function() { |
743 | }; | 742 | $scope.seleccionarTransportista(); |
744 | 743 | } | |
745 | $scope.seleccionarMoneda = function() { | 744 | ); |
746 | if (varlidarRemitoFacturado()) { | ||
747 | var parametrosModal = { | ||
748 | titulo: 'Búsqueda de monedas', | ||
749 | query: '/moneda', | ||
750 | columnas: [ | ||
751 | { | ||
752 | propiedad: 'DETALLE', | ||
753 | nombre: 'Nombre' | ||
754 | }, | ||
755 | { | 745 | } |
756 | propiedad: 'SIMBOLO', | 746 | }; |
757 | nombre: 'Símbolo' | 747 | |
758 | } | 748 | $scope.seleccionarMoneda = function() { |
749 | if (varlidarRemitoFacturado()) { | ||
750 | var parametrosModal = { | ||
759 | ], | 751 | titulo: 'Búsqueda de monedas', |
760 | size: 'md' | 752 | query: '/moneda', |
761 | }; | 753 | columnas: [ |
762 | focaModalService.modal(parametrosModal).then( | 754 | { |
763 | function(moneda) { | 755 | propiedad: 'DETALLE', |
764 | $scope.abrirModalCotizacion(moneda); | 756 | nombre: 'Nombre' |
765 | }, function() { | 757 | }, |
766 | 758 | { | |
767 | } | 759 | propiedad: 'SIMBOLO', |
768 | ); | 760 | nombre: 'Símbolo' |
769 | } | 761 | } |
770 | }; | 762 | ], |
771 | 763 | size: 'md' | |
772 | $scope.seleccionarObservaciones = function() { | 764 | }; |
773 | focaModalService | 765 | focaModalService.modal(parametrosModal).then( |
774 | .prompt({ | 766 | function(moneda) { |
775 | titulo: 'Observaciones', | 767 | $scope.abrirModalCotizacion(moneda); |
776 | value: $scope.remito.observaciones, | 768 | }, function() { |
777 | textarea: true, | 769 | |
778 | readonly: true | 770 | } |
779 | }) | 771 | ); |
780 | .then(function(observaciones) { | 772 | } |
781 | $scope.remito.observaciones = observaciones; | 773 | }; |
782 | }); | 774 | |
783 | }; | 775 | $scope.seleccionarObservaciones = function() { |
784 | 776 | focaModalService | |
785 | $scope.abrirModalCotizacion = function(moneda) { | 777 | .prompt({ |
786 | var modalInstance = $uibModal.open( | 778 | titulo: 'Observaciones', |
787 | { | 779 | value: $scope.remito.observaciones, |
788 | ariaLabelledBy: 'Busqueda de Cotización', | 780 | textarea: true, |
789 | templateUrl: 'modal-cotizacion.html', | 781 | readonly: true |
790 | controller: 'focaModalCotizacionController', | 782 | }) |
791 | size: 'lg', | 783 | .then(function(observaciones) { |
792 | resolve: {idMoneda: function() {return moneda.ID;}} | 784 | $scope.remito.observaciones = observaciones; |
793 | } | 785 | }); |
794 | ); | 786 | }; |
795 | modalInstance.result.then( | 787 | |
796 | function(cotizacion) { | 788 | $scope.abrirModalCotizacion = function(moneda) { |
797 | var articulosTablaTemp = $scope.remito.articulosRemito; | 789 | var modalInstance = $uibModal.open( |
798 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 790 | { |
799 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 791 | ariaLabelledBy: 'Busqueda de Cotización', |
800 | $scope.remito.cotizacion.COTIZACION; | 792 | templateUrl: 'modal-cotizacion.html', |
801 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 793 | controller: 'focaModalCotizacionController', |
802 | cotizacion.COTIZACION; | 794 | size: 'lg', |
803 | } | 795 | resolve: {idMoneda: function() {return moneda.ID;}} |
804 | $scope.remito.articulosRemito = articulosTablaTemp; | 796 | } |
805 | $scope.remito.cotizacion.moneda = moneda; | 797 | ); |
806 | $scope.remito.cotizacion = cotizacion; | 798 | modalInstance.result.then( |
807 | if (moneda.DETALLE === 'PESOS ARGENTINOS') { | 799 | function(cotizacion) { |
808 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 800 | var articulosTablaTemp = $scope.remito.articulosRemito; |
809 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 801 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
810 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 802 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
811 | }else { | 803 | $scope.remito.cotizacion.VENDEDOR; |
812 | $scope.$broadcast('addCabecera',{ | 804 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
813 | label: 'Moneda:', | 805 | cotizacion.VENDEDOR; |
814 | valor: moneda.DETALLE | 806 | } |
815 | }); | 807 | $scope.remito.articulosRemito = articulosTablaTemp; |
816 | $scope.$broadcast('addCabecera',{ | 808 | $scope.remito.cotizacion = cotizacion; |
817 | label: 'Fecha cotizacion:', | 809 | $scope.remito.cotizacion.moneda = moneda; |
818 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 810 | if (moneda.DETALLE === 'PESOS ARGENTINOS') { |
819 | }); | 811 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
820 | $scope.$broadcast('addCabecera',{ | 812 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
821 | label: 'Cotizacion:', | ||
822 | valor: $filter('number')(cotizacion.COTIZACION, '2') | 813 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
814 | } else { | ||
823 | }); | 815 | $scope.$broadcast('addCabecera',{ |
824 | } | 816 | label: 'Moneda:', |
825 | }, function() { | 817 | valor: moneda.DETALLE |
826 | 818 | }); | |
827 | } | 819 | $scope.$broadcast('addCabecera',{ |
828 | ); | 820 | label: 'Fecha cotizacion:', |
829 | }; | 821 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
830 | 822 | }); | |
831 | $scope.agregarATabla = function(key) { | 823 | $scope.$broadcast('addCabecera',{ |
832 | if (key === 13) { | 824 | label: 'Cotizacion:', |
833 | if ($scope.articuloACargar.cantidad === undefined || | 825 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
834 | $scope.articuloACargar.cantidad === 0 || | 826 | }); |
835 | $scope.articuloACargar.cantidad === null ) { | 827 | } |
836 | focaModalService.alert('El valor debe ser al menos 1'); | 828 | }, function() { |
837 | return; | 829 | |
838 | } | 830 | } |
839 | delete $scope.articuloACargar.sectorCodigo; | 831 | ); |
840 | $scope.remito.articulosRemito.push($scope.articuloACargar); | 832 | }; |
841 | $scope.cargando = true; | 833 | |
842 | } | 834 | $scope.agregarATabla = function(key) { |
843 | }; | 835 | if (key === 13) { |
844 | 836 | if ($scope.articuloACargar.cantidad === undefined || | |
845 | $scope.quitarArticulo = function(key) { | 837 | $scope.articuloACargar.cantidad === 0 || |
846 | $scope.remito.articulosRemito.splice(key, 1); | 838 | $scope.articuloACargar.cantidad === null ) { |
847 | }; | 839 | focaModalService.alert('El valor debe ser al menos 1'); |
848 | 840 | return; | |
849 | $scope.editarArticulo = function(key, articulo, tmpCantidad, tmpPrecio) { | 841 | } |
850 | if (key === 13) { | 842 | delete $scope.articuloACargar.sectorCodigo; |
851 | if (!articulo.cantidad || !articulo.precio) { | 843 | $scope.remito.articulosRemito.push($scope.articuloACargar); |
852 | focaModalService.alert('Los valores deben ser al menos 1'); | 844 | $scope.cargando = true; |
853 | return; | 845 | } |
854 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { | 846 | }; |
855 | focaModalService.alert('Los valores no pueden ser negativos'); | 847 | |
856 | return; | 848 | $scope.quitarArticulo = function(articulo) { |
857 | } | 849 | articulo.idRemito = -1; |
858 | articulo.cantidad = tmpCantidad; | 850 | }; |
859 | articulo.precio = tmpPrecio; | 851 | |
860 | $scope.getTotal(); | 852 | $scope.articulosFiltro = function() { |
861 | articulo.editCantidad = articulo.editPrecio = false; | 853 | |
862 | } | 854 | var result = $scope.remito.articulosRemito.filter(function(articulo) { |
855 | return articulo.idRemito >= 0; | ||
856 | }); | ||
857 | return result; | ||
858 | }; | ||
859 | |||
860 | $scope.editarArticulo = function(key, articulo, tmpCantidad, tmpPrecio) { | ||
861 | if (key === 13) { | ||
862 | if (!articulo.cantidad || !articulo.precio) { | ||
863 | }; | 863 | focaModalService.alert('Los valores deben ser al menos 1'); |
864 | 864 | return; | |
865 | $scope.cancelarEditar = function(articulo) { | 865 | } else if (articulo.cantidad < 0 || articulo.precio < 0) { |
866 | $scope.tmpCantidad = articulo.cantidad; | 866 | focaModalService.alert('Los valores no pueden ser negativos'); |
867 | $scope.tmpPrecio = articulo.precio; | 867 | return; |
868 | articulo.editCantidad = articulo.editPrecio = false; | 868 | } |
869 | }; | 869 | articulo.cantidad = tmpCantidad; |
870 | 870 | articulo.precio = tmpPrecio; | |
871 | $scope.cambioEdit = function(articulo, propiedad) { | 871 | $scope.getTotal(); |
872 | if (propiedad === 'cantidad') { | 872 | articulo.editCantidad = articulo.editPrecio = false; |
873 | articulo.editCantidad = true; | 873 | } |
874 | } else if (propiedad === 'precio') { | 874 | }; |
875 | articulo.editPrecio = true; | 875 | |
876 | } | 876 | $scope.cancelarEditar = function(articulo) { |
877 | }; | 877 | $scope.tmpCantidad = articulo.cantidad; |
878 | 878 | $scope.tmpPrecio = articulo.precio; | |
879 | $scope.resetFilter = function() { | 879 | articulo.editCantidad = articulo.editPrecio = false; |
880 | $scope.articuloACargar = {}; | 880 | }; |
881 | $scope.cargando = true; | 881 | |
882 | }; | 882 | $scope.cambioEdit = function(articulo, propiedad) { |
883 | //Recibe aviso si el teclado está en uso | 883 | if (propiedad === 'cantidad') { |
884 | $rootScope.$on('usarTeclado', function(event, data) { | 884 | articulo.editCantidad = true; |
885 | if (data) { | 885 | } else if (propiedad === 'precio') { |
886 | $scope.mostrarTeclado = true; | ||
887 | return; | ||
888 | } | ||
889 | $scope.mostrarTeclado = false; | ||
890 | }); | ||
891 | |||
892 | $scope.selectFocus = function($event) { | ||
893 | // Si el teclado esta en uso no selecciona el valor | ||
894 | if ($scope.mostrarTeclado) { | ||
895 | return; | ||
896 | } | ||
897 | $event.target.select(); | ||
898 | }; | ||
899 | |||
900 | function addArrayCabecera(array) { | ||
901 | for (var i = 0; i < array.length; i++) { | ||
902 | $scope.$broadcast('addCabecera',{ | ||
903 | label: array[i].label, | ||
904 | valor: array[i].valor | ||
905 | }); | ||
906 | } | ||
907 | } | ||
908 | 886 | articulo.editPrecio = true; | |
909 | function rellenar(relleno, longitud) { | 887 | } |
910 | relleno = '' + relleno; | 888 | }; |
911 | while (relleno.length < longitud) { | 889 | |
912 | relleno = '0' + relleno; | 890 | $scope.resetFilter = function() { |
913 | } | 891 | $scope.articuloACargar = {}; |
914 | 892 | $scope.cargando = true; | |
915 | return relleno; | 893 | }; |
916 | } | 894 | //Recibe aviso si el teclado está en uso |
917 | 895 | $rootScope.$on('usarTeclado', function(event, data) { | |
918 | function varlidarRemitoFacturado() { | 896 | if (data) { |
919 | if ($scope.remito.estado !== 5) { | 897 | $scope.mostrarTeclado = true; |
920 | return true; | 898 | return; |
921 | } else { | 899 | } |
922 | focaModalService.alert('No se puede editar un remito facturado'); | 900 | $scope.mostrarTeclado = false; |
923 | return false(); | 901 | }); |
924 | } | 902 | |
925 | } | 903 | $scope.selectFocus = function($event) { |
926 | 904 | // Si el teclado esta en uso no selecciona el valor | |
927 | function salir() { | 905 | if ($scope.mostrarTeclado) { |
928 | var confirmacion = false; | 906 | return; |
929 | 907 | } | |
930 | if (!angular.equals($scope.remito, $scope.inicial)) { | 908 | $event.target.select(); |
931 | confirmacion = true; | 909 | }; |
932 | } | 910 | |
933 | 911 | function addArrayCabecera(array) { | |
934 | if (confirmacion) { | 912 | for (var i = 0; i < array.length; i++) { |
935 | focaModalService.confirm( | 913 | $scope.$broadcast('addCabecera',{ |
936 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 914 | label: array[i].label, |
937 | ).then(function(data) { | 915 | valor: array[i].valor |
938 | if (data) { | 916 | }); |
939 | $location.path('/'); | 917 | } |
940 | } | 918 | } |
941 | }); | 919 | |
942 | } else { | 920 | function rellenar(relleno, longitud) { |
943 | $location.path('/'); | ||
944 | } | 921 | relleno = '' + relleno; |
945 | } | 922 | while (relleno.length < longitud) { |
946 | 923 | relleno = '0' + relleno; | |
947 | function enableObservaciones(val) { | 924 | } |
948 | var boton = $scope.botonera.filter(function(botonObs) { | 925 | return relleno; |
949 | return botonObs.label === 'Observaciones'; | 926 | } |
950 | }); | 927 | |
951 | 928 | function varlidarRemitoFacturado() { | |
952 | boton[0].disable = !val; | 929 | if ($scope.remito.estado !== 5) { |
953 | } | 930 | return true; |
954 | 931 | } else { | |
955 | function setearRemito(remito) { | 932 | focaModalService.alert('No se puede editar un remito facturado'); |
956 | //añado cabeceras | 933 | return false(); |
957 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 934 | } |
958 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 935 | } |
959 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 936 | |
960 | 937 | function salir() { | |
961 | var cabeceras = []; | 938 | var confirmacion = false; |
962 | 939 | ||
963 | if (remito.cotizacion.ID) { | 940 | if (!angular.equals($scope.remito, $scope.inicial)) { |
964 | cabeceras.push({ | 941 | confirmacion = true; |
965 | label: 'Moneda:', | 942 | } |
966 | valor: remito.cotizacion.moneda.DETALLE | 943 | |
967 | }); | 944 | if (confirmacion) { |
968 | cabeceras.push({ | 945 | focaModalService.confirm( |
969 | label: 'Fecha cotizacion:', | 946 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
970 | valor: $filter('date')(remito.cotizacion.FECHA, | 947 | ).then(function(data) { |
971 | 'dd/MM/yyyy') | 948 | if (data) { |
972 | }); | 949 | $location.path('/'); |
973 | cabeceras.push({ | 950 | } |
974 | label: 'Cotizacion:', | 951 | }); |
975 | valor: $filter('number')(remito.cotizacion.VENDEDOR, | 952 | } else { |
976 | '2') | 953 | $location.path('/'); |
977 | }); | 954 | } |
978 | } | 955 | } |
979 | if (remito.cliente.COD) { | 956 | |
980 | cabeceras.push({ | ||
981 | label: 'Cliente:', | 957 | function enableObservaciones(val) { |
982 | valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + | 958 | var boton = $scope.botonera.filter(function(botonObs) { |
983 | remito.cliente.NOM | 959 | return botonObs.label === 'Observaciones'; |
984 | }); | 960 | }); |
985 | cabeceras.push({ | 961 | boton[0].disable = !val; |
986 | label: 'Domicilio:', | 962 | } |
987 | valor: remito.domicilioStamp | 963 | |
988 | }); | 964 | function setearRemito(remito) { |
989 | } | 965 | //añado cabeceras |
990 | if (remito.vendedor.NUM) { | 966 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
991 | cabeceras.push({ | 967 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
992 | label: 'Vendedor:', | 968 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
993 | valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + | 969 | |
994 | ' - ' + remito.vendedor.NOM | 970 | var cabeceras = []; |
995 | }); | 971 | |
996 | } | 972 | if (remito.cotizacion.moneda.CODIGO_AFIP !== 'PES') { |
997 | if (remito.proveedor.COD) { | 973 | cabeceras.push({ |
998 | cabeceras.push({ | 974 | label: 'Moneda:', |
999 | label: 'Proveedor:', | 975 | valor: remito.cotizacion.moneda.DETALLE |
1000 | valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + | 976 | }); |
1001 | ' - ' + remito.proveedor.NOM | 977 | cabeceras.push({ |
1002 | }); | 978 | label: 'Fecha cotizacion:', |
1003 | } | 979 | valor: $filter('date')(remito.cotizacion.FECHA, |
1004 | if (remito.flete !== undefined) { | 980 | 'dd/MM/yyyy') |
1005 | cabeceras.push({ | 981 | }); |
1006 | label: 'Flete:', | 982 | cabeceras.push({ |
1007 | valor: remito.fob === 1 ? 'FOB' : ( | 983 | label: 'Cotizacion:', |
1008 | remito.flete === 1 ? 'Si' : 'No') | 984 | valor: $filter('number')(remito.cotizacion.VENDEDOR, |
1009 | }); | 985 | '2') |
1010 | } | 986 | }); |
1011 | if (remito.remitoPlazo) { | 987 | } |
1012 | cabeceras.push({ | 988 | if (remito.cliente.COD) { |
1013 | label: 'Precio condicion:', | 989 | cabeceras.push({ |
1014 | valor: valorPrecioCondicion() + ' ' + | 990 | label: 'Cliente:', |
1015 | remitoBusinessService.plazoToString(remito.remitoPlazo) | 991 | valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + |
1016 | }); | 992 | remito.cliente.NOM |
1017 | } | 993 | }); |
1018 | 994 | cabeceras.push({ | |
1019 | function valorPrecioCondicion() { | 995 | label: 'Domicilio:', |
1020 | if (remito.idPrecioCondicion > 0) { | 996 | valor: remito.domicilioStamp |
1021 | return remito.precioCondicion.nombre; | 997 | }); |
1022 | } else { | 998 | } |
1023 | return 'Ingreso Manual'; | 999 | if (remito.vendedor.NUM) { |
1024 | } | 1000 | cabeceras.push({ |
1025 | } | 1001 | label: 'Vendedor:', |
1026 | 1002 | valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + | |
1027 | if (remito.flete === 1) { | 1003 | ' - ' + remito.vendedor.NOM |
1028 | var cabeceraBomba = { | 1004 | }); |
1029 | label: 'Bomba', | 1005 | } |
1030 | valor: remito.bomba === 1 ? 'Si' : 'No' | 1006 | if (remito.proveedor.COD) { |
1031 | }; | 1007 | cabeceras.push({ |
1032 | if (remito.kilometros) { | 1008 | label: 'Proveedor:', |
1033 | var cabeceraKilometros = { | 1009 | valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + |
1034 | label: 'Kilometros', | 1010 | ' - ' + remito.proveedor.NOM |
1035 | valor: remito.kilometros | 1011 | }); |
1036 | }; | 1012 | } |
1037 | cabeceras.push(cabeceraKilometros); | 1013 | if (remito.flete !== undefined && remito.fob !== undefined) { |
1038 | } | 1014 | cabeceras.push({ |
1039 | cabeceras.push(cabeceraBomba); | 1015 | label: 'Flete:', |
1040 | } | 1016 | valor: remito.fob ? 'FOB' : ( |
1041 | $scope.remito.articulosRemito = remito.articulosRemito; | 1017 | remito.flete ? 'Si' : 'No') |
1042 | remitoBusinessService.calcularArticulos($scope.remito.articulosRemito, | 1018 | }); |
1043 | remito.cotizacion.VENDEDOR); | 1019 | } |
1044 | if (remito.idPrecioCondicion > 0) { | 1020 | if (remito.remitoPlazo) { |
1045 | $scope.idLista = remito.precioCondicion.idListaPrecio; | 1021 | cabeceras.push({ |
1046 | } else { | 1022 | label: 'Precio condicion:', |
1047 | $scope.idLista = -1; | ||
1048 | } | 1023 | valor: valorPrecioCondicion() + ' ' + |
1049 | $scope.puntoVenta = rellenar(remito.sucursal, 4); | 1024 | remitoBusinessService.plazoToString(remito.remitoPlazo) |
1050 | $scope.comprobante = rellenar(remito.numeroRemito, 8); | 1025 | }); |
1051 | $scope.remito = remito; | 1026 | } |
1052 | if ($scope.remito.puntosDescarga) { | 1027 | function valorPrecioCondicion() { |
1053 | var puntosDescarga = $scope.remito.puntosDescarga; | 1028 | if (remito.idPrecioCondicion > 0) { |
1054 | cabeceras.push({ | 1029 | return remito.precioCondicion.nombre; |
1055 | label: 'Puntos de descarga: ', | ||
1056 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntosDescarga)) | 1030 | } else { |
1057 | }); | 1031 | return 'Ingreso Manual'; |
1058 | } | 1032 | } |
1059 | addArrayCabecera(cabeceras); | 1033 | } |
1060 | } | 1034 | if (remito.flete === 1) { |
1061 | 1035 | var cabeceraBomba = { | |
1062 | function getLSRemito() { | 1036 | label: 'Bomba', |
1063 | var remito = JSON.parse($localStorage.remito || null); | 1037 | valor: remito.bomba === 1 ? 'Si' : 'No' |
1064 | if (remito) { | 1038 | }; |
1065 | setearRemito(remito); | 1039 | if (remito.kilometros) { |
1066 | delete $localStorage.remito; | 1040 | var cabeceraKilometros = { |
1067 | } | 1041 | label: 'Kilometros', |
1068 | } | 1042 | valor: remito.kilometros |
1069 | 1043 | }; | |
1070 | function deleteCliente() { | 1044 | cabeceras.push(cabeceraKilometros); |
1071 | delete $scope.remito.domicilioStamp; | ||
1072 | delete $scope.remito.puntosDescarga; |
src/js/service.js
1 | angular.module('focaCrearRemito') | 1 | angular.module('focaCrearRemito') |
2 | .service('crearRemitoService', ['$http', 'API_ENDPOINT', | 2 | .service('crearRemitoService', ['$http', 'API_ENDPOINT', |
3 | function($http, API_ENDPOINT) { | 3 | function($http, API_ENDPOINT) { |
4 | var route = API_ENDPOINT.URL; | 4 | var route = API_ENDPOINT.URL; |
5 | return { | 5 | return { |
6 | crearRemito: function(remito) { | 6 | crearRemito: function(remito) { |
7 | // TODO: Cambiar para usar el servicio /remito | 7 | // TODO: Cambiar para usar el servicio /remito |
8 | return $http.post(route + '/remito', remito); | 8 | return $http.post(route + '/remito', remito); |
9 | }, | 9 | }, |
10 | getRemitoById: function(id) { | 10 | getRemitoById: function(id) { |
11 | return $http.get(route + '/remito/obtener/' + id); | 11 | return $http.get(route + '/remito/obtener/' + id); |
12 | }, | 12 | }, |
13 | obtenerRemito: function() { | 13 | obtenerRemito: function() { |
14 | return $http.get(route +'/nota-pedido'); | 14 | return $http.get(route +'/nota-pedido'); |
15 | }, | 15 | }, |
16 | setRemito: function(remito) { | 16 | setRemito: function(remito) { |
17 | this.remito = remito; | 17 | this.remito = remito; |
18 | }, | 18 | }, |
19 | clearRemito: function() { | 19 | clearRemito: function() { |
20 | this.remito = undefined; | 20 | this.remito = undefined; |
21 | }, | 21 | }, |
22 | getRemito: function() { | 22 | getRemito: function() { |
23 | return this.remito; | 23 | return this.remito; |
24 | }, | 24 | }, |
25 | getArticulosByIdRemito: function(id) { | 25 | getArticulosByIdRemito: function(id) { |
26 | return $http.get(route+'/articulos/nota-pedido/'+id); | 26 | return $http.get(route+'/articulos/nota-pedido/'+id); |
27 | }, | 27 | }, |
28 | crearArticulosParaRemito: function(articuloRemito) { | 28 | crearArticulosParaRemito: function(articuloRemito) { |
29 | return $http.post(route + '/articulos/remito', | 29 | return $http.post(route + '/articulos/remito', |
30 | {articuloRemito: articuloRemito}); | 30 | {articuloRemito: articuloRemito}); |
31 | }, | 31 | }, |
32 | getDomiciliosByIdRemito: function(id) { | 32 | getDomiciliosByIdRemito: function(id) { |
33 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); | 33 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); |
34 | }, | 34 | }, |
35 | getDomiciliosByIdCliente: function(id) { | 35 | getDomiciliosByIdCliente: function(id) { |
36 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) | 36 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) |
37 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); | 37 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); |
38 | }, | 38 | }, |
39 | getPrecioCondicion: function() { | 39 | getPrecioCondicion: function() { |
40 | return $http.get(route + '/precio-condicion'); | 40 | return $http.get(route + '/precio-condicion'); |
41 | }, | 41 | }, |
42 | getPrecioCondicionById: function(id) { | 42 | getPrecioCondicionById: function(id) { |
43 | return $http.get(route + '/precio-condicion/' + id); | 43 | return $http.get(route + '/precio-condicion/' + id); |
44 | }, | 44 | }, |
45 | getPlazoPagoByPrecioCondicion: function(id) { | 45 | getPlazoPagoByPrecioCondicion: function(id) { |
46 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); | 46 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); |
47 | }, | 47 | }, |
48 | crearFlete: function(flete) { | 48 | crearFlete: function(flete) { |
49 | return $http.post(route + '/flete', {flete : flete}); | 49 | return $http.post(route + '/flete', {flete : flete}); |
50 | }, | 50 | }, |
51 | crearPlazosParaRemito: function(plazos) { | 51 | crearPlazosParaRemito: function(plazos) { |
52 | return $http.post(route + '/plazo-pago/remito', plazos); | 52 | return $http.post(route + '/plazo-pago/remito', plazos); |
53 | }, | 53 | }, |
54 | getCotizacionByIdMoneda: function(id) { | 54 | getCotizacionByIdMoneda: function(id) { |
55 | return $http.get(route + '/moneda/' + id); | 55 | return $http.get(route + '/moneda/' + id); |
56 | }, | 56 | }, |
57 | crearEstadoParaRemito: function(estado) { | 57 | crearEstadoParaRemito: function(estado) { |
58 | return $http.post(route + '/estado', {estado: estado}); | 58 | return $http.post(route + '/estado', {estado: estado}); |
59 | }, | 59 | }, |
60 | getNumeroRemito: function() { | 60 | getNumeroRemito: function() { |
61 | return $http.get(route + '/remito/numero-siguiente'); | 61 | return $http.get(route + '/remito/numero-siguiente'); |
62 | }, | 62 | }, |
63 | imprimirRemitoByIdRemito: function(idRemito) { | 63 | imprimirRemitoByIdRemito: function(idRemito) { |
64 | return $http.get(route + '/remito/comprobante/' + idRemito , { | 64 | return $http.get(route + '/remito/comprobante/' + idRemito , { |
65 | responseType: 'arraybuffer' | 65 | responseType: 'arraybuffer' |
66 | }); | 66 | }); |
67 | }, | 67 | }, |
68 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { | 68 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { |
69 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + | 69 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + |
70 | idDomicilio + '/' + idCliente); | 70 | idDomicilio + '/' + idCliente); |
71 | }, | 71 | }, |
72 | enviarCorreo: function(options) { | 72 | enviarCorreo: function(options) { |
73 | return $http.post(API_ENDPOINT.URL + '/remito/mail', options); | 73 | return $http.post(API_ENDPOINT.URL + '/remito/mail', options); |
74 | }, | 74 | }, |
75 | getBotonera: function() { | 75 | getBotonera: function() { |
76 | return [ | 76 | return [ |
77 | { | 77 | { |
78 | label: 'Nota pedido', | 78 | label: 'Nota pedido', |
79 | image: 'notaDePedido.png' | 79 | image: 'notaDePedido.png' |
80 | }, | 80 | }, |
81 | { | 81 | { |
82 | label: 'Cliente', | 82 | label: 'Cliente', |
83 | image: 'cliente.png' | 83 | image: 'cliente.png' |
84 | }, | 84 | }, |
85 | { | 85 | { |
86 | label: 'Transportista', | 86 | label: 'Proveedor', |
87 | image: 'proveedor.png' | 87 | image: 'proveedor.png' |
88 | }, | 88 | }, |
89 | { | 89 | { |
90 | label: 'Moneda', | 90 | label: 'Moneda', |
91 | image: 'moneda.png' | 91 | image: 'moneda.png' |
92 | }, | 92 | }, |
93 | { | 93 | { |
94 | label: 'Precios y condiciones', | 94 | label: 'Precios y condiciones', |
95 | image: 'precios-condiciones.png' | 95 | image: 'precios-condiciones.png' |
96 | }, | 96 | }, |
97 | { | 97 | { |
98 | label: 'Productos', | 98 | label: 'Productos', |
99 | image: 'productos.png' | 99 | image: 'productos.png' |
100 | }, | 100 | }, |
101 | { | 101 | { |
102 | label: 'Observaciones', | 102 | label: 'Observaciones', |
103 | image: 'botonObservaciones.png', | 103 | image: 'botonObservaciones.png', |
104 | disable: true | 104 | disable: true |
105 | } | 105 | } |
106 | ]; | 106 | ]; |
107 | } | 107 | } |
108 | }; | 108 | }; |
109 | }]); | 109 | }]); |
110 | 110 |
src/views/remito.html
1 | <div class="crear-nota-remito foca-crear row"> | 1 | <div class="crear-nota-remito foca-crear row"> |
2 | <foca-cabecera-facturador | 2 | <foca-cabecera-facturador |
3 | titulo="'Remito'" | 3 | titulo="'Remito'" |
4 | numero="puntoVenta + '-' + comprobante" | 4 | numero="puntoVenta + '-' + comprobante" |
5 | fecha="now" | 5 | fecha="now" |
6 | class="mb-0 col-lg-12" | 6 | class="mb-0 col-lg-12" |
7 | busqueda="seleccionarRemito" | 7 | busqueda="seleccionarRemito" |
8 | ></foca-cabecera-facturador> | 8 | ></foca-cabecera-facturador> |
9 | <marquee | ||
10 | bgcolor="#FF9900" | ||
11 | behavior="scroll" | ||
12 | direction="left" | ||
13 | ng-bind="remito.observaciones" | ||
14 | ></marquee> | ||
9 | <div class="col-lg-12"> | 15 | <div class="col-lg-12"> |
10 | <div class="row mt-4"> | 16 | <div class="row mt-4"> |
11 | <div class="col-12 col-md-10 col-lg-10 border border-light rounded"> | 17 | <div class="col-12 col-md-10 col-lg-10 border border-light rounded"> |
12 | <div class="row p-1 botonera-secundaria px-5 py-2"> | 18 | <div class="row p-1 botonera-secundaria px-5 py-2"> |
13 | <div class="col-12"> | 19 | <div class="col-12"> |
14 | <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador> | 20 | <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador> |
15 | </div> | 21 | </div> |
16 | </div> | 22 | </div> |
17 | <!-- PC --> | 23 | <!-- PC --> |
18 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> | 24 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> |
19 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> | 25 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> |
20 | <thead> | 26 | <thead> |
21 | <tr class="d-flex"> | 27 | <tr class="d-flex"> |
22 | <th class="">#</th> | 28 | <th class="">#</th> |
23 | <th class="col">Código</th> | 29 | <th class="col">Código</th> |
24 | <th class="col-4">Descripción</th> | 30 | <th class="col-4">Descripción</th> |
25 | <th class="col text-right">Cantidad</th> | 31 | <th class="col text-right">Cantidad</th> |
26 | <th class="col text-right">Precio Unitario</th> | 32 | <th class="col text-right">Precio Unitario</th> |
27 | <th class="col text-right">SubTotal</th> | 33 | <th class="col text-right">SubTotal</th> |
28 | <th class="text-right"> | 34 | <th class="text-right"> |
29 | <button | 35 | <button |
30 | class="btn btn-outline-light selectable" | 36 | class="btn btn-outline-light selectable" |
31 | ng-click="show = !show; masMenos()" | 37 | ng-click="show = !show; masMenos()" |
32 | > | 38 | > |
33 | <i | 39 | <i |
34 | class="fa fa-chevron-down" | 40 | class="fa fa-chevron-down" |
35 | ng-show="show" | 41 | ng-show="show" |
36 | aria-hidden="true" | 42 | aria-hidden="true" |
37 | > | 43 | > |
38 | </i> | 44 | </i> |
39 | <i | 45 | <i |
40 | class="fa fa-chevron-up" | 46 | class="fa fa-chevron-up" |
41 | ng-hide="show" | 47 | ng-hide="show" |
42 | aria-hidden="true"> | 48 | aria-hidden="true"> |
43 | </i> | 49 | </i> |
44 | </button> | 50 | </button> |
45 | </th> | 51 | </th> |
46 | </tr> | 52 | </tr> |
47 | </thead> | 53 | </thead> |
48 | <tbody class="tabla-articulo-body"> | 54 | <tbody class="tabla-articulo-body"> |
49 | <tr | 55 | <tr |
50 | ng-repeat="(key, articulo) in remito.articulosRemito" | 56 | ng-repeat="(key, articulo) in articulosFiltro()" |
51 | ng-show="show || key == (remito.articulosRemito.length - 1)" | 57 | ng-show="show || key == (articulosFiltro().length - 1)" |
52 | class="d-flex" | 58 | class="d-flex" |
53 | > | 59 | > |
54 | <td ng-bind="key + 1"></td> | 60 | <td ng-bind="key + 1"></td> |
55 | <td | 61 | <td |
56 | class="col" | 62 | class="col" |
57 | ng-bind="articulo.sector + '-' + articulo.codigo" | 63 | ng-bind="articulo.sector + '-' + articulo.codigo" |
58 | ></td> | 64 | ></td> |
59 | <td | 65 | <td |
60 | class="col-4" | 66 | class="col-4" |
61 | ng-bind="articulo.descripcion" | 67 | ng-bind="articulo.descripcion" |
62 | ></td> | 68 | ></td> |
63 | <td class="col text-right"> | 69 | <td class="col text-right"> |
64 | <input | 70 | <input |
65 | ng-show="articulo.editCantidad" | 71 | ng-show="articulo.editCantidad" |
66 | ng-model="tmpCantidad" | 72 | ng-model="tmpCantidad" |
67 | class="form-control" | 73 | class="form-control" |
68 | foca-tipo-input | 74 | foca-tipo-input |
69 | min="1" | 75 | min="1" |
70 | foca-focus="articulo.editCantidad" | 76 | foca-focus="articulo.editCantidad" |
71 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" | 77 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" |
72 | esc-key="cancelarEditar(articulo)" | 78 | esc-key="cancelarEditar(articulo)" |
73 | ng-focus="selectFocus($event); | 79 | ng-focus="selectFocus($event); |
74 | tmpCantidad = articulo.cantidad; | 80 | tmpCantidad = articulo.cantidad; |
75 | tmpPrecio = articulo.precio" | 81 | tmpPrecio = articulo.precio" |
76 | teclado-virtual | 82 | teclado-virtual |
77 | > | 83 | > |
78 | <i | 84 | <i |
79 | class="selectable" | 85 | class="selectable" |
80 | ng-click="cambioEdit(articulo, 'cantidad')" | 86 | ng-click="cambioEdit(articulo, 'cantidad')" |
81 | ng-hide="articulo.editCantidad" | 87 | ng-hide="articulo.editCantidad" |
82 | ng-bind="articulo.cantidad"> | 88 | ng-bind="articulo.cantidad"> |
83 | </i> | 89 | </i> |
84 | </td> | 90 | </td> |
85 | <td class="col text-right"> | 91 | <td class="col text-right"> |
86 | <input | 92 | <input |
87 | ng-show="articulo.editPrecio" | 93 | ng-show="articulo.editPrecio" |
88 | ng-model="tmpPrecio" | 94 | ng-model="tmpPrecio" |
89 | class="form-control" | 95 | class="form-control" |
90 | foca-tipo-input | 96 | foca-tipo-input |
91 | min="1" | 97 | min="1" |
92 | step="0.0001" | 98 | step="0.0001" |
93 | foca-focus="articulo.editPrecio" | 99 | foca-focus="articulo.editPrecio" |
94 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" | 100 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" |
95 | esc-key="cancelarEditar(articulo)" | 101 | esc-key="cancelarEditar(articulo)" |
96 | ng-focus="selectFocus($event); | 102 | ng-focus="selectFocus($event); |
97 | tmpCantidad = articulo.cantidad; | 103 | tmpCantidad = articulo.cantidad; |
98 | tmpPrecio = articulo.precio" | 104 | tmpPrecio = articulo.precio" |
99 | teclado-virtual | 105 | teclado-virtual |
100 | > | 106 | > |
101 | <i | 107 | <i |
102 | class="selectable" | 108 | class="selectable" |
103 | ng-click="cambioEdit(articulo, 'precio')" | 109 | ng-click="cambioEdit(articulo, 'precio')" |
104 | ng-hide="articulo.editPrecio" | 110 | ng-hide="articulo.editPrecio" |
105 | ng-bind="articulo.precio | number: 4"> | 111 | ng-bind="articulo.precio | number: 4"> |
106 | </i> | 112 | </i> |
107 | </td> | 113 | </td> |
108 | <td | 114 | <td |
109 | class="col text-right" | 115 | class="col text-right" |
110 | ng-bind="(articulo.precio * articulo.cantidad) | number: 2"> | 116 | ng-bind="(articulo.precio * articulo.cantidad) | number: 2"> |
111 | </td> | 117 | </td> |
112 | <td class="text-center"> | 118 | <td class="text-center"> |
113 | <button | 119 | <button |
114 | class="btn btn-outline-light" | 120 | class="btn btn-outline-light" |
115 | ng-click="quitarArticulo(key)" | 121 | ng-click="quitarArticulo(articulo)" |
116 | > | 122 | > |
117 | <i class="fa fa-trash"></i> | 123 | <i class="fa fa-trash"></i> |
118 | </button> | 124 | </button> |
119 | <button | 125 | <button |
120 | class="btn btn-outline-light" | 126 | class="btn btn-outline-light" |
121 | ng-click="editarArticulo(13, articulo)" | 127 | ng-click="editarArticulo(13, articulo)" |
122 | ng-show="articulo.editCantidad || articulo.editPrecio" | 128 | ng-show="articulo.editCantidad || articulo.editPrecio" |
123 | > | 129 | > |
124 | <i class="fa fa-save"></i> | 130 | <i class="fa fa-save"></i> |
125 | </button> | 131 | </button> |
126 | </td> | 132 | </td> |
127 | </tr> | 133 | </tr> |
128 | </tbody> | 134 | </tbody> |
129 | <tfoot> | 135 | <tfoot> |
130 | <tr ng-show="!cargando" class="d-flex"> | 136 | <tr ng-show="!cargando" class="d-flex"> |
131 | <td | 137 | <td |
132 | class="align-middle" | 138 | class="align-middle" |
133 | ng-bind="remito.articulosRemito.length + 1" | 139 | ng-bind="articulosFiltro().length + 1" |
134 | ></td> | 140 | ></td> |
135 | <td class="col"> | 141 | <td class="col"> |
136 | <input | 142 | <input |
137 | class="form-control" | 143 | class="form-control" |
138 | ng-model="articuloACargar.sectorCodigo" | 144 | ng-model="articuloACargar.sectorCodigo" |
139 | readonly | 145 | readonly |
140 | > | 146 | > |
141 | </td> | 147 | </td> |
142 | <td class="col-4 tabla-articulo-descripcion"> | 148 | <td class="col-4 tabla-articulo-descripcion"> |
143 | <input | 149 | <input |
144 | class="form-control" | 150 | class="form-control" |
145 | ng-model="articuloACargar.descripcion" | 151 | ng-model="articuloACargar.descripcion" |
146 | readonly | 152 | readonly |
147 | > | 153 | > |
148 | </td> | 154 | </td> |
149 | <td class="col text-right"> | 155 | <td class="col text-right"> |
150 | <input | 156 | <input |
151 | class="form-control" | 157 | class="form-control" |
152 | foca-tipo-input | 158 | foca-tipo-input |
153 | min="1" | 159 | min="1" |
154 | ng-model="articuloACargar.cantidad" | 160 | ng-model="articuloACargar.cantidad" |
155 | foca-focus="!cargando" | 161 | foca-focus="!cargando" |
156 | esc-key="resetFilter()" | 162 | esc-key="resetFilter()" |
157 | ng-keypress="agregarATabla($event.keyCode)" | 163 | ng-keypress="agregarATabla($event.keyCode)" |
158 | teclado-virtual | 164 | teclado-virtual |
159 | > | 165 | > |
160 | </td> | 166 | </td> |
161 | <td class="col text-right"> | 167 | <td class="col text-right"> |
162 | <input | 168 | <input |
163 | class="form-control" | 169 | class="form-control" |
164 | ng-model="articuloACargar.precio" | 170 | ng-model="articuloACargar.precio" |
165 | ng-show="idLista != -1" | 171 | ng-show="idLista != -1" |
166 | ng-keypress="agregarATabla($event.keyCode)" | 172 | ng-keypress="agregarATabla($event.keyCode)" |
167 | > | 173 | > |
168 | <input | 174 | <input |
169 | class="form-control" | 175 | class="form-control" |
170 | foca-tipo-input | 176 | foca-tipo-input |
171 | step="0.0001" | 177 | step="0.0001" |
172 | ng-model="articuloACargar.precio" | 178 | ng-model="articuloACargar.precio" |
173 | esc-key="resetFilter()" | 179 | esc-key="resetFilter()" |
174 | ng-keypress="agregarATabla($event.keyCode)" | 180 | ng-keypress="agregarATabla($event.keyCode)" |
175 | ng-show="idLista == -1" | 181 | ng-show="idLista == -1" |
176 | teclado-virtual | 182 | teclado-virtual |
177 | > | 183 | > |
178 | </td> | 184 | </td> |
179 | <td class="col text-right"> | 185 | <td class="col text-right"> |
180 | <input | 186 | <input |
181 | class="form-control" | 187 | class="form-control" |
182 | ng-value="getSubTotal() | number: 2" | 188 | ng-value="getSubTotal() | number: 2" |
183 | readonly | 189 | readonly |
184 | ></td> | 190 | ></td> |
185 | <td class="text-center align-middle"> | 191 | <td class="text-center align-middle"> |
186 | <button | 192 | <button |
187 | class="btn btn-outline-light" | 193 | class="btn btn-outline-light" |
188 | ng-click="agregarATabla(13)" | 194 | ng-click="agregarATabla(13)" |
189 | > | 195 | > |
190 | <i class="fa fa-save"></i> | 196 | <i class="fa fa-save"></i> |
191 | </button> | 197 | </button> |
192 | </td> | 198 | </td> |
193 | </tr> | 199 | </tr> |
194 | 200 | ||
195 | <tr class="d-flex"> | 201 | <tr class="d-flex"> |
196 | <td colspan="4" class="no-border-top"> | 202 | <td colspan="4" class="no-border-top"> |
197 | <strong>Items:</strong> | 203 | <strong>Items:</strong> |
198 | <a ng-bind="remito.articulosRemito.length"></a> | 204 | <a ng-bind="articulosFiltro().length"></a> |
199 | </td> | 205 | </td> |
200 | <td class="text-right ml-auto table-celda-total no-border-top"> | 206 | <td class="text-right ml-auto table-celda-total no-border-top"> |
201 | <h3>Total:</h3> | 207 | <h3>Total:</h3> |
202 | </td> | 208 | </td> |
203 | <td class="table-celda-total text-right no-border-top" colspan="1"> | 209 | <td class="table-celda-total text-right no-border-top" colspan="1"> |
204 | <h3>{{getTotal() | currency: remito.moneda.SIMBOLO}}</h3> | 210 | <h3>{{getTotal() | currency: remito.cotizacion.moneda.SIMBOLO}}</h3> |
205 | </td> | 211 | </td> |
206 | <td class="text-right no-border-top"> | 212 | <td class="text-right no-border-top"> |
207 | <button | 213 | <button |
208 | type="button" | 214 | type="button" |
209 | class="btn btn-default btn-sm" | 215 | class="btn btn-default btn-sm" |
210 | > | 216 | > |
211 | Totales | 217 | Totales |
212 | </button> | ||
213 | </td> | ||
214 | </tr> | ||
215 | </tfoot> | ||
216 | </table> | ||
217 | </div> | ||
218 | |||
219 | <!-- MOBILE --> | ||
220 | <div class="row d-sm-none"> | ||
221 | <table class="table table-sm table-striped tabla-articulo margin-bottom-mobile"> | ||
222 | <thead> | ||
223 | <tr class="d-flex"> | ||
224 | <th class="">#</th> | ||
225 | <th class="col px-0"> | ||
226 | <div class="d-flex"> | ||
227 | <div class="col-4 px-1">Código</div> | ||
228 | <div class="col-8 px-1">Descripción</div> | ||
229 | </div> | ||
230 | <div class="d-flex"> | ||
231 | <div class="col-3 px-1">Cantidad</div> | ||
232 | <div class="col px-1 text-right">P. Uni.</div> | ||
233 | <div class="col px-1 text-right">Subtotal</div> | ||
234 | </div> | ||
235 | </th> | ||
236 | <th class="text-center tamaño-boton"> | ||
237 | | ||
238 | </th> | ||
239 | </tr> | ||
240 | </thead> | ||
241 | <tbody> | ||
242 | <tr | ||
243 | ng-repeat="(key, articulo) in remito.articulosRemito" | ||
244 | ng-show="show || key == remito.articulosRemito.length - 1" | ||
245 | > | ||
246 | <td class="w-100 align-middle d-flex p-0"> | ||
247 | <div class="align-middle p-1"> | ||
248 | <span ng-bind="key+1" class="align-middle"></span> | ||
249 | </div> | ||
250 | <div class="col px-0"> | ||
251 | <div class="d-flex"> | ||
252 | <div class="col-4 px-1"> | ||
253 | <span | ||
254 | ng-bind="articulo.sector + '-' + articulo.codigo" | ||
255 | ></span> | ||
256 | </div> | ||
257 | <div class="col-8 px-1"> | ||
258 | <span | ||
259 | ng-bind="'x' + articulo.cantidad" | ||
260 | ng-hide="articulo.editCantidad" | ||
261 | ></span> | ||
262 | <i | ||
263 | class="fa fa-pencil text-white-50" | ||
264 | aria-hidden="true" | ||
265 | ng-hide="articulo.editCantidad" | ||
266 | ng-click="articulo.editCantidad = true" | ||
267 | ></i> | ||
268 | <input | ||
269 | ng-show="articulo.editCantidad" | ||
270 | ng-model="articulo.cantidad" | ||
271 | class="form-control" | ||
272 | foca-tipo-input | ||
273 | min="1" | ||
274 | step="0.001" | ||
275 | foca-focus="articulo.editCantidad" | ||
276 | ng-keypress="editarArticulo($event.keyCode, articulo)" | ||
277 | ng-focus="selectFocus($event)" | ||
278 | > | ||
279 | </div> | ||
280 | </div> | ||
281 | <div class="d-flex"> | ||
282 | <div class="col-3 px-1"> | ||
283 | <span ng-bind="'x' + articulo.cantidad"></span> | ||
284 | </div> | ||
285 | <div class="col px-1 text-right"> | ||
286 | <span ng-bind="articulo.precio | currency: remito.moneda.SIMBOLO : 4"></span> | ||
287 | </div> | ||
288 | <div class="col px-1 text-right"> | ||
289 | <span | ||
290 | ng-bind="(articulo.precio * articulo.cantidad) | currency: remito.moneda.SIMBOLO" | ||
291 | > | ||
292 | </span> | ||
293 | </div> | ||
294 | </div> | ||
295 | </div> | ||
296 | <div class="align-middle p-1"> | ||
297 | <button | ||
298 | class="btn btn-outline-light" | ||
299 | ng-click="quitarArticulo(key)" | ||
300 | > | ||
301 | <i class="fa fa-trash"></i> | ||
302 | </button> | ||
303 | </div> | ||
304 | </td> | ||
305 | </tr> | ||
306 | </tbody> | ||
307 | <tfoot> | ||
308 | <!-- CARGANDO ITEM --> | ||
309 | <tr ng-show="!cargando" class="d-flex"> | ||
310 | <td | ||
311 | class="align-middle p-1" | ||
312 | ng-bind="remito.articulosRemito.length + 1" | ||
313 | ></td> | ||
314 | <td class="col p-0"> | ||
315 | <div class="d-flex"> | ||
316 | <div class="col-4 px-1"> | ||
317 | <span | ||
318 | ng-bind="articuloACargar.sectorCodigo" | ||
319 | ></span> | ||
320 | </div> | ||
321 | <div class="col-8 px-1"> | ||
322 | <span ng-bind="articuloACargar.descripcion"></span> | ||
323 | </div> | ||
324 | </div> | ||
325 | <div class="d-flex"> | ||
326 | <div class="col-3 px-1 m-1"> | ||
327 | <input | ||
328 | class="form-control p-1" | ||
329 | foca-tipo-input | ||
330 | min="1" | ||
331 | ng-model="articuloACargar.cantidad" | ||
332 | foca-focus="!cargando" | ||
333 | ng-keypress="agregarATabla($event.keyCode)" | ||
334 | style="height: auto; line-height: 1.1em" | ||
335 | > | ||
336 | </div> | ||
337 | <div class="col px-1 text-right"> | ||
338 | <span ng-bind="articuloACargar.precio | currency: remito.moneda.SIMBOLO : 4"></span> | ||
339 | </div> | ||
340 | <div class="col px-1 text-right"> | ||
341 | <span | ||
342 | ng-bind="getSubTotal() | currency: remito.moneda.SIMBOLO" | ||
343 | > | ||
344 | </span> | ||
345 | </div> | ||
346 | </div> | ||
347 | </td> | ||
348 | <td class="text-center align-middle"> | ||
349 | <button | ||
350 | class="btn btn-outline-light" | ||
351 | ng-click="agregarATabla(13)" | ||
352 | > | ||
353 | <i class="fa fa-save"></i> | ||
354 | </button> | ||
355 | </td> | ||
356 | </tr> | ||
357 | <!-- TOOGLE EXPANDIR --> | ||
358 | <tr> | ||
359 | <td class="col"> | ||
360 | <button | ||
361 | class="btn btn-outline-light selectable w-100" | ||
362 | ng-click="show = !show; masMenos()" | ||
363 | ng-show="remito.articulosRemito.length > 0" | ||
364 | > | ||
365 | <i | ||
366 | class="fa fa-chevron-down" | ||
367 | ng-hide="show" | ||
368 | aria-hidden="true" | ||
369 | > | ||
370 | </i> | ||
371 | <i | ||
372 | class="fa fa-chevron-up" | ||
373 | ng-show="show" | ||
374 | aria-hidden="true"> | ||
375 | </i> | ||
376 | </button> | ||
377 | </td> | ||
378 | </tr> | ||
379 | <!-- FOOTER --> | ||
380 | <tr class="d-flex"> | ||
381 | <td class="align-middle no-border-top" colspan="2"> | ||
382 | <strong>Cantidad Items:</strong> | ||
383 | <a ng-bind="remito.articulosRemito.length"></a> | ||
384 | </td> | ||
385 | <td class="text-right ml-auto table-celda-total no-border-top"> | ||
386 | <h3>Total:</h3> | ||
387 | </td> | ||
388 | <td class="table-celda-total text-right no-border-top"> | ||
389 | <h3>{{getTotal() | currency: remito.moneda.SIMBOLO}}</h3> | 218 | </button> |
390 | </td> | 219 | </td> |
391 | </tr> | 220 | </tr> |
392 | </tfoot> | 221 | </tfoot> |
393 | </table> | 222 | </table> |
394 | </div> | 223 | </div> |
395 | </div> | 224 | </div> |
396 | </div> | 225 | </div> |
397 | </div> | 226 | </div> |
398 | <div class="row d-md-none fixed-bottom"> | 227 | <div class="row d-md-none fixed-bottom"> |
399 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> | 228 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> |
400 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> | 229 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> |
401 | <span | 230 | <span |
402 | class="mr-3 ml-auto" | 231 | class="mr-3 ml-auto" |
403 | ng-class="saveLoading ? 'text-muted' : ''" | 232 | ng-class="saveLoading ? 'text-muted' : ''" |
404 | ng-click="crearRemito()" | 233 | ng-click="crearRemito()" |
405 | ladda="saveLoading" | 234 | ladda="saveLoading" |