Commit 6215e17d29b828c52107f690a574001703556fef

Authored by Jose Pinto
Exists in master and in 1 other branch develop

Merge branch 'master' into 'master'

Master

See merge request !49
... ... @@ -4,3 +4,4 @@ package-lock\.json
4 4 /src/etc/develop.js
5 5  
6 6 tmp/
  7 +debug.log
... ... @@ -11,6 +11,7 @@ const replace = require('gulp-replace');
11 11 const connect = require('gulp-connect');
12 12 const header = require('gulp-header');
13 13 const footer = require('gulp-footer');
  14 +const gulpSequence = require('gulp-sequence');
14 15  
15 16 var paths = {
16 17 srcJS: 'src/js/*.js',
... ... @@ -20,7 +21,9 @@ var paths = {
20 21 dist: 'dist/'
21 22 };
22 23  
23   -gulp.task('templates', ['clean'], function() {
  24 +gulp.task('uglify', gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app'));
  25 +
  26 +gulp.task('templates', function() {
24 27 return pump(
25 28 [
26 29 gulp.src(paths.srcViews),
... ... @@ -34,7 +37,7 @@ gulp.task('templates', ['clean'], function() {
34 37 );
35 38 });
36 39  
37   -gulp.task('uglify', ['templates', 'uglify-spec'], function() {
  40 +gulp.task('uglify-app', function() {
38 41 return pump(
39 42 [
40 43 gulp.src([
... ... @@ -69,6 +69,7 @@
69 69 "jquery": "^3.3.1",
70 70 "jshint": "^2.9.6",
71 71 "ladda": "1.0.6",
  72 + "ngstorage": "^0.3.11",
72 73 "pre-commit": "^1.2.2",
73 74 "pump": "^3.0.0",
74 75 "ui-bootstrap4": "^3.0.5"
spec/controllerSpec.js
... ... @@ -25,7 +25,10 @@ describe('Controladores módulo crear nota de pedido', function() {
25 25  
26 26 it('La función seleccionarNotaPedido levanta modal', function() {
27 27 //arrange
28   - var scope = {};
  28 + var scope = {
  29 + $watch: function() { },
  30 + $broadcast: function() { }
  31 + };
29 32 var uibModal = {
30 33 open: function() { }
31 34 };
... ... @@ -37,6 +40,11 @@ describe('Controladores módulo crear nota de pedido', function() {
37 40 $filter: filter,
38 41 $timeout: timeout,
39 42 crearNotaPedidoService: {
  43 + getNumeroNotaPedido: function() {
  44 + return {
  45 + then: function() { }
  46 + };
  47 + },
40 48 getBotonera: function() { },
41 49 getCotizacionByIdMoneda: function() {
42 50 return {
... ... @@ -52,7 +60,8 @@ describe('Controladores módulo crear nota de pedido', function() {
52 60 },
53 61 focaSeguimientoService: {},
54 62 APP: {},
55   - focaLoginService: {}
  63 + focaLoginService: {},
  64 + $localStorage: {}
56 65 });
57 66 var respuesta = { result: { then: function() { } } };
58 67  
... ... @@ -66,7 +75,10 @@ describe('Controladores módulo crear nota de pedido', function() {
66 75  
67 76 it('La función seleccionarNotaPedido llama a broadCast en promesa', function(done) {
68 77 //arrange
69   - var scope = {};
  78 + var scope = {
  79 + $watch: function() { },
  80 + $broadcast: function() { }
  81 + };
70 82 var uibModal = {
71 83 open: function() { }
72 84 };
... ... @@ -78,6 +90,11 @@ describe('Controladores módulo crear nota de pedido', function() {
78 90 $filter: filter,
79 91 $timeout: timeout,
80 92 crearNotaPedidoService: {
  93 + getNumeroNotaPedido: function() {
  94 + return {
  95 + then: function() { }
  96 + };
  97 + },
81 98 getBotonera: function() { },
82 99 getCotizacionByIdMoneda: function() {
83 100 return {
... ... @@ -96,7 +113,8 @@ describe('Controladores módulo crear nota de pedido', function() {
96 113 },
97 114 focaSeguimientoService: {},
98 115 APP: {},
99   - focaLoginService: {}
  116 + focaLoginService: {},
  117 + $localStorage: {}
100 118 });
101 119 var notaPedido = {
102 120 cotizacion: {
... ... @@ -105,7 +123,7 @@ describe('Controladores módulo crear nota de pedido', function() {
105 123 cliente: {},
106 124 vendedor: {},
107 125 proveedor: {},
108   - notaPedidoPlazo: {},
  126 + notaPedidoPlazo: [],
109 127 notaPedidoPuntoDescarga: []
110 128 };
111 129 var respuesta = { result: Promise.resolve(notaPedido) };
... ... @@ -127,7 +145,10 @@ describe('Controladores módulo crear nota de pedido', function() {
127 145  
128 146 it('función seleccionarProductos muestra alerta cuando idLista undefined', function() {
129 147 //arrange
130   - var scope = {};
  148 + var scope = {
  149 + $watch: function() { },
  150 + $broadcast: function() { }
  151 + };
131 152 var focaModalService = {
132 153 alert: function() { }
133 154 };
... ... @@ -139,6 +160,11 @@ describe('Controladores módulo crear nota de pedido', function() {
139 160 $filter: filter,
140 161 $timeout: timeout,
141 162 crearNotaPedidoService: {
  163 + getNumeroNotaPedido: function() {
  164 + return {
  165 + then: function() { }
  166 + };
  167 + },
142 168 getBotonera: function() { },
143 169 getCotizacionByIdMoneda: function() {
144 170 return {
... ... @@ -154,7 +180,8 @@ describe('Controladores módulo crear nota de pedido', function() {
154 180 },
155 181 focaSeguimientoService: {},
156 182 APP: {},
157   - focaLoginService: {}
  183 + focaLoginService: {},
  184 + $localStorage: {}
158 185 });
159 186  
160 187 //act
... ... @@ -169,7 +196,10 @@ describe('Controladores módulo crear nota de pedido', function() {
169 196  
170 197 it('función seleccionarProductos abre modal', function() {
171 198 //arrange
172   - var scope = {};
  199 + var scope = {
  200 + $watch: function() { },
  201 + $broadcast: function() { }
  202 + };
173 203 var uibModal = {
174 204 open: function() { }
175 205 };
... ... @@ -181,6 +211,11 @@ describe('Controladores módulo crear nota de pedido', function() {
181 211 $filter: filter,
182 212 $timeout: timeout,
183 213 crearNotaPedidoService: {
  214 + getNumeroNotaPedido: function() {
  215 + return {
  216 + then: function() { }
  217 + };
  218 + },
184 219 getBotonera: function() { },
185 220 getCotizacionByIdMoneda: function() {
186 221 return {
... ... @@ -196,12 +231,15 @@ describe('Controladores módulo crear nota de pedido', function() {
196 231 },
197 232 focaSeguimientoService: {},
198 233 APP: {},
199   - focaLoginService: {}
  234 + focaLoginService: {},
  235 + $localStorage: {}
200 236 });
201 237 scope.idLista = true;
202 238 scope.notaPedido = {
203   - cotizacion: {},
204   - moneda: {}
  239 + cotizacion: {
  240 + moneda: {}
  241 + },
  242 +
205 243 };
206 244 var respuesta = { result: {then: function() { } } };
207 245  
... ... @@ -217,7 +255,10 @@ describe('Controladores módulo crear nota de pedido', function() {
217 255 'undefined', function()
218 256 {
219 257 //arrange
220   - var scope = {};
  258 + var scope = {
  259 + $watch: function() { },
  260 + $broadcast: function() { }
  261 + };
221 262 var focaModalService = {
222 263 alert: function() { }
223 264 };
... ... @@ -229,6 +270,11 @@ describe('Controladores módulo crear nota de pedido', function() {
229 270 $filter: filter,
230 271 $timeout: timeout,
231 272 crearNotaPedidoService: {
  273 + getNumeroNotaPedido: function() {
  274 + return {
  275 + then: function() { }
  276 + };
  277 + },
232 278 getBotonera: function() { },
233 279 getCotizacionByIdMoneda: function() {
234 280 return {
... ... @@ -244,7 +290,8 @@ describe('Controladores módulo crear nota de pedido', function() {
244 290 },
245 291 focaSeguimientoService: {},
246 292 APP: {},
247   - focaLoginService: {}
  293 + focaLoginService: {},
  294 + $localStorage: {}
248 295 });
249 296 scope.idLista = true;
250 297 scope.notaPedido = {
... ... @@ -262,7 +309,10 @@ describe('Controladores módulo crear nota de pedido', function() {
262 309  
263 310 it('función seleccionarPuntosDeDescarga abre modal', function() {
264 311 //arrange
265   - var scope = {};
  312 + var scope = {
  313 + $watch: function() { },
  314 + $broadcast: function() { }
  315 + };
266 316 var uibModal = {
267 317 open: function() { }
268 318 };
... ... @@ -274,6 +324,11 @@ describe('Controladores módulo crear nota de pedido', function() {
274 324 $filter: filter,
275 325 $timeout: timeout,
276 326 crearNotaPedidoService: {
  327 + getNumeroNotaPedido: function() {
  328 + return {
  329 + then: function() { }
  330 + };
  331 + },
277 332 getBotonera: function() { },
278 333 getCotizacionByIdMoneda: function() {
279 334 return {
... ... @@ -289,7 +344,8 @@ describe('Controladores módulo crear nota de pedido', function() {
289 344 },
290 345 focaSeguimientoService: {},
291 346 APP: {},
292   - focaLoginService: {}
  347 + focaLoginService: {},
  348 + $localStorage: {}
293 349 });
294 350 scope.idLista = true;
295 351 scope.notaPedido = {
... ... @@ -308,7 +364,10 @@ describe('Controladores módulo crear nota de pedido', function() {
308 364  
309 365 it('función seleccionarPuntosDeDescarga setea punto elegido', function(done) {
310 366 //arrange
311   - var scope = {};
  367 + var scope = {
  368 + $watch: function() { },
  369 + $broadcast: function() { }
  370 + };
312 371 var uibModal = {
313 372 open: function() { }
314 373 };
... ... @@ -320,6 +379,11 @@ describe('Controladores módulo crear nota de pedido', function() {
320 379 $filter: filter,
321 380 $timeout: timeout,
322 381 crearNotaPedidoService: {
  382 + getNumeroNotaPedido: function() {
  383 + return {
  384 + then: function() { }
  385 + };
  386 + },
323 387 getBotonera: function() { },
324 388 getCotizacionByIdMoneda: function() {
325 389 return {
... ... @@ -335,12 +399,14 @@ describe('Controladores módulo crear nota de pedido', function() {
335 399 },
336 400 focaSeguimientoService: {},
337 401 APP: {},
338   - focaLoginService: {}
  402 + focaLoginService: {},
  403 + $localStorage: {}
339 404 });
340 405 scope.idLista = true;
341 406 scope.notaPedido = {
342 407 cliente: { COD: true },
343   - domicilio: { id: true }
  408 + domicilio: { id: true },
  409 + puntosDescarga: []
344 410 };
345 411 var respuesta = [];
346 412 var promiseRespuesta = { result: Promise.resolve(respuesta) };
... ... @@ -359,7 +425,10 @@ describe('Controladores módulo crear nota de pedido', function() {
359 425  
360 426 it('función seleccionarVendedor abre modal', function() {
361 427 //arrange
362   - var scope = {};
  428 + var scope = {
  429 + $watch: function() { },
  430 + $broadcast: function() { }
  431 + };
363 432 var focaModalService = {
364 433 modal: function() { }
365 434 };
... ... @@ -371,6 +440,11 @@ describe('Controladores módulo crear nota de pedido', function() {
371 440 $filter: filter,
372 441 $timeout: timeout,
373 442 crearNotaPedidoService: {
  443 + getNumeroNotaPedido: function() {
  444 + return {
  445 + then: function() { }
  446 + };
  447 + },
374 448 getBotonera: function() { },
375 449 getCotizacionByIdMoneda: function() {
376 450 return {
... ... @@ -386,7 +460,8 @@ describe('Controladores módulo crear nota de pedido', function() {
386 460 },
387 461 focaSeguimientoService: {},
388 462 APP: {},
389   - focaLoginService: {}
  463 + focaLoginService: {},
  464 + $localStorage: {}
390 465 });
391 466 scope.idLista = true;
392 467 scope.notaPedido = {
... ... @@ -406,7 +481,10 @@ describe('Controladores módulo crear nota de pedido', function() {
406 481  
407 482 it('función seleccionarVendedor setea vendedor y cabecera', function(done) {
408 483 //arrange
409   - var scope = {};
  484 + var scope = {
  485 + $watch: function() { },
  486 + $broadcast: function() { }
  487 + };
410 488 var focaModalService = {
411 489 modal: function() { }
412 490 };
... ... @@ -418,6 +496,11 @@ describe('Controladores módulo crear nota de pedido', function() {
418 496 $filter: filter,
419 497 $timeout: timeout,
420 498 crearNotaPedidoService: {
  499 + getNumeroNotaPedido: function() {
  500 + return {
  501 + then: function() { }
  502 + };
  503 + },
421 504 getBotonera: function() { },
422 505 getCotizacionByIdMoneda: function() {
423 506 return {
... ... @@ -433,7 +516,8 @@ describe('Controladores módulo crear nota de pedido', function() {
433 516 },
434 517 focaSeguimientoService: {},
435 518 APP: {},
436   - focaLoginService: {}
  519 + focaLoginService: {},
  520 + $localStorage: {}
437 521 });
438 522 scope.idLista = true;
439 523 scope.notaPedido = {
... ... @@ -459,7 +543,10 @@ describe('Controladores módulo crear nota de pedido', function() {
459 543  
460 544 it('función seleccionarProveedor abre modal', function() {
461 545 //arrange
462   - var scope = {};
  546 + var scope = {
  547 + $watch: function() { },
  548 + $broadcast: function() { }
  549 + };
463 550 var focaModalService = {
464 551 modal: function() { }
465 552 };
... ... @@ -471,6 +558,11 @@ describe('Controladores módulo crear nota de pedido', function() {
471 558 $filter: filter,
472 559 $timeout: timeout,
473 560 crearNotaPedidoService: {
  561 + getNumeroNotaPedido: function() {
  562 + return {
  563 + then: function() { }
  564 + };
  565 + },
474 566 getBotonera: function() { },
475 567 getCotizacionByIdMoneda: function() {
476 568 return {
... ... @@ -486,7 +578,8 @@ describe('Controladores módulo crear nota de pedido', function() {
486 578 },
487 579 focaSeguimientoService: {},
488 580 APP: {},
489   - focaLoginService: {}
  581 + focaLoginService: {},
  582 + $localStorage: {}
490 583 });
491 584 scope.notaPedido = {};
492 585  
... ... @@ -502,7 +595,10 @@ describe('Controladores módulo crear nota de pedido', function() {
502 595  
503 596 it('función seleccionarProveedor setea vendedor y cabecera', function(done) {
504 597 //arrange
505   - var scope = {};
  598 + var scope = {
  599 + $watch: function() { },
  600 + $broadcast: function() { }
  601 + };
506 602 var focaModalService = {
507 603 modal: function() { }
508 604 };
... ... @@ -514,6 +610,11 @@ describe('Controladores módulo crear nota de pedido', function() {
514 610 $filter: filter,
515 611 $timeout: timeout,
516 612 crearNotaPedidoService: {
  613 + getNumeroNotaPedido: function() {
  614 + return {
  615 + then: function() { }
  616 + };
  617 + },
517 618 getBotonera: function() { },
518 619 getCotizacionByIdMoneda: function() {
519 620 return {
... ... @@ -529,7 +630,8 @@ describe('Controladores módulo crear nota de pedido', function() {
529 630 },
530 631 focaSeguimientoService: {},
531 632 APP: {},
532   - focaLoginService: {}
  633 + focaLoginService: {},
  634 + $localStorage: {}
533 635 });
534 636  
535 637 scope.notaPedido = {};
... ... @@ -552,7 +654,10 @@ describe('Controladores módulo crear nota de pedido', function() {
552 654  
553 655 it('función seleccionarCliente abre alerta cuando no se elije vendedor', function() {
554 656 //arrange
555   - var scope = {};
  657 + var scope = {
  658 + $watch: function() { },
  659 + $broadcast: function() { }
  660 + };
556 661 var focaModalService = {
557 662 alert: function() { }
558 663 };
... ... @@ -564,6 +669,11 @@ describe('Controladores módulo crear nota de pedido', function() {
564 669 $filter: filter,
565 670 $timeout: timeout,
566 671 crearNotaPedidoService: {
  672 + getNumeroNotaPedido: function() {
  673 + return {
  674 + then: function() { }
  675 + };
  676 + },
567 677 getBotonera: function() { },
568 678 getCotizacionByIdMoneda: function() {
569 679 return {
... ... @@ -579,7 +689,8 @@ describe('Controladores módulo crear nota de pedido', function() {
579 689 },
580 690 focaSeguimientoService: {},
581 691 APP: {},
582   - focaLoginService: {}
  692 + focaLoginService: {},
  693 + $localStorage: {}
583 694 });
584 695 scope.notaPedido = {
585 696 vendedor: { NUM: false }
... ... @@ -595,7 +706,10 @@ describe('Controladores módulo crear nota de pedido', function() {
595 706  
596 707 it('función seleccionarCliente abre modal', function() {
597 708 //arrange
598   - var scope = {};
  709 + var scope = {
  710 + $watch: function() { },
  711 + $broadcast: function() { }
  712 + };
599 713 var uibModal = {
600 714 open: function() { }
601 715 };
... ... @@ -607,6 +721,11 @@ describe('Controladores módulo crear nota de pedido', function() {
607 721 $filter: filter,
608 722 $timeout: timeout,
609 723 crearNotaPedidoService: {
  724 + getNumeroNotaPedido: function() {
  725 + return {
  726 + then: function() { }
  727 + };
  728 + },
610 729 getBotonera: function() { },
611 730 getCotizacionByIdMoneda: function() {
612 731 return {
... ... @@ -622,7 +741,8 @@ describe('Controladores módulo crear nota de pedido', function() {
622 741 },
623 742 focaSeguimientoService: {},
624 743 APP: {},
625   - focaLoginService: {}
  744 + focaLoginService: {},
  745 + $localStorage: {}
626 746 });
627 747 scope.notaPedido = {
628 748 vendedor: { NUM: true }
... ... @@ -641,7 +761,10 @@ describe('Controladores módulo crear nota de pedido', function() {
641 761 it('función seleccionarCliente setea vendedor y llama a domicilios', function(done) {
642 762  
643 763 //arrange
644   - var scope = {};
  764 + var scope = {
  765 + $watch: function() { },
  766 + $broadcast: function() { }
  767 + };
645 768 var uibModal = {
646 769 open: function() { }
647 770 };
... ... @@ -653,6 +776,11 @@ describe('Controladores módulo crear nota de pedido', function() {
653 776 $filter: filter,
654 777 $timeout: timeout,
655 778 crearNotaPedidoService: {
  779 + getNumeroNotaPedido: function() {
  780 + return {
  781 + then: function() { }
  782 + };
  783 + },
656 784 getBotonera: function() { },
657 785 getCotizacionByIdMoneda: function() {
658 786 return {
... ... @@ -668,7 +796,8 @@ describe('Controladores módulo crear nota de pedido', function() {
668 796 },
669 797 focaSeguimientoService: {},
670 798 APP: {},
671   - focaLoginService: {}
  799 + focaLoginService: {},
  800 + $localStorage: {}
672 801 });
673 802 scope.idLista = true;
674 803 scope.notaPedido = {
... ... @@ -692,7 +821,10 @@ describe('Controladores módulo crear nota de pedido', function() {
692 821  
693 822 it('función abrirModalDomicilios abre modal', function() {
694 823 //arrange
695   - var scope = {};
  824 + var scope = {
  825 + $watch: function() { },
  826 + $broadcast: function() { }
  827 + };
696 828 var uibModal = {
697 829 open: function() { }
698 830 };
... ... @@ -704,6 +836,11 @@ describe('Controladores módulo crear nota de pedido', function() {
704 836 $filter: filter,
705 837 $timeout: timeout,
706 838 crearNotaPedidoService: {
  839 + getNumeroNotaPedido: function() {
  840 + return {
  841 + then: function() { }
  842 + };
  843 + },
707 844 getBotonera: function() { },
708 845 getCotizacionByIdMoneda: function() {
709 846 return {
... ... @@ -719,7 +856,8 @@ describe('Controladores módulo crear nota de pedido', function() {
719 856 },
720 857 focaSeguimientoService: {},
721 858 APP: {},
722   - focaLoginService: {}
  859 + focaLoginService: {},
  860 + $localStorage: {}
723 861 });
724 862  
725 863 var respuesta = { result: {then: function() { } } };
... ... @@ -735,7 +873,10 @@ describe('Controladores módulo crear nota de pedido', function() {
735 873 it('función abrirModalDomicilios setea domicilio, cliente y cabeceras', function(done) {
736 874  
737 875 //arrange
738   - var scope = {};
  876 + var scope = {
  877 + $watch: function() { },
  878 + $broadcast: function() { }
  879 + };
739 880 var uibModal = {
740 881 open: function() { }
741 882 };
... ... @@ -747,6 +888,11 @@ describe('Controladores módulo crear nota de pedido', function() {
747 888 $filter: filter,
748 889 $timeout: timeout,
749 890 crearNotaPedidoService: {
  891 + getNumeroNotaPedido: function() {
  892 + return {
  893 + then: function() { }
  894 + };
  895 + },
750 896 getBotonera: function() { },
751 897 getCotizacionByIdMoneda: function() {
752 898 return {
... ... @@ -767,7 +913,8 @@ describe('Controladores módulo crear nota de pedido', function() {
767 913 },
768 914 focaSeguimientoService: {},
769 915 APP: {},
770   - focaLoginService: {}
  916 + focaLoginService: {},
  917 + $localStorage: {}
771 918 });
772 919 scope.idLista = true;
773 920 scope.notaPedido = {
... ... @@ -799,7 +946,10 @@ describe('Controladores módulo crear nota de pedido', function() {
799 946 it('función getTotal devulve correctamente', function() {
800 947  
801 948 //arrange
802   - var scope = {};
  949 + var scope = {
  950 + $watch: function() { },
  951 + $broadcast: function() { }
  952 + };
803 953  
804 954 $controler('notaPedidoCtrl', {
805 955 $scope: scope,
... ... @@ -808,6 +958,11 @@ describe('Controladores módulo crear nota de pedido', function() {
808 958 $filter: filter,
809 959 $timeout: timeout,
810 960 crearNotaPedidoService: {
  961 + getNumeroNotaPedido: function() {
  962 + return {
  963 + then: function() { }
  964 + };
  965 + },
811 966 getBotonera: function() { },
812 967 getCotizacionByIdMoneda: function() {
813 968 return {
... ... @@ -823,7 +978,8 @@ describe('Controladores módulo crear nota de pedido', function() {
823 978 },
824 979 focaSeguimientoService: {},
825 980 APP: {},
826   - focaLoginService: {}
  981 + focaLoginService: {},
  982 + $localStorage: {}
827 983 });
828 984 scope.idLista = true;
829 985 scope.notaPedido = {
... ... @@ -831,7 +987,7 @@ describe('Controladores módulo crear nota de pedido', function() {
831 987 };
832 988  
833 989 //act
834   - scope.articulosTabla = [{ precio: 2, cantidad: 1}];
  990 + scope.notaPedido.articulosNotaPedido = [{ precio: 2, cantidad: 1}];
835 991 var esperado = 2;
836 992 var resultado = scope.getTotal();
837 993  
... ... @@ -842,7 +998,10 @@ describe('Controladores módulo crear nota de pedido', function() {
842 998 it('función getSubTotal devulve correctamente', function() {
843 999  
844 1000 //arrange
845   - var scope = {};
  1001 + var scope = {
  1002 + $watch: function() { },
  1003 + $broadcast: function() { }
  1004 + };
846 1005  
847 1006 $controler('notaPedidoCtrl', {
848 1007 $scope: scope,
... ... @@ -851,6 +1010,11 @@ describe('Controladores módulo crear nota de pedido', function() {
851 1010 $filter: filter,
852 1011 $timeout: timeout,
853 1012 crearNotaPedidoService: {
  1013 + getNumeroNotaPedido: function() {
  1014 + return {
  1015 + then: function() { }
  1016 + };
  1017 + },
854 1018 getBotonera: function() { },
855 1019 getCotizacionByIdMoneda: function() {
856 1020 return {
... ... @@ -866,7 +1030,8 @@ describe('Controladores módulo crear nota de pedido', function() {
866 1030 },
867 1031 focaSeguimientoService: {},
868 1032 APP: {},
869   - focaLoginService: {}
  1033 + focaLoginService: {},
  1034 + $localStorage: {}
870 1035 });
871 1036 scope.idLista = true;
872 1037 scope.notaPedido = {
... ... @@ -885,7 +1050,10 @@ describe('Controladores módulo crear nota de pedido', function() {
885 1050 it('función seleccionarPreciosYCondiciones abre modal', function() {
886 1051  
887 1052 //arrange
888   - var scope = {};
  1053 + var scope = {
  1054 + $watch: function() { },
  1055 + $broadcast: function() { }
  1056 + };
889 1057 var uibModal = {
890 1058 open: function() { }
891 1059 };
... ... @@ -897,6 +1065,11 @@ describe('Controladores módulo crear nota de pedido', function() {
897 1065 $filter: filter,
898 1066 $timeout: timeout,
899 1067 crearNotaPedidoService: {
  1068 + getNumeroNotaPedido: function() {
  1069 + return {
  1070 + then: function() { }
  1071 + };
  1072 + },
900 1073 getBotonera: function() { },
901 1074 getCotizacionByIdMoneda: function() {
902 1075 return {
... ... @@ -912,7 +1085,8 @@ describe('Controladores módulo crear nota de pedido', function() {
912 1085 },
913 1086 focaSeguimientoService: {},
914 1087 APP: {},
915   - focaLoginService: {}
  1088 + focaLoginService: {},
  1089 + $localStorage: {}
916 1090 });
917 1091  
918 1092 scope.notaPedido = {};
... ... @@ -930,7 +1104,10 @@ describe('Controladores módulo crear nota de pedido', function() {
930 1104 it('función seleccionarPreciosYCondiciones setea articulos y cabecera', function(done) {
931 1105  
932 1106 //arrange
933   - var scope = {};
  1107 + var scope = {
  1108 + $watch: function() { },
  1109 + $broadcast: function() { }
  1110 + };
934 1111 var uibModal = {
935 1112 open: function() { }
936 1113 };
... ... @@ -942,6 +1119,11 @@ describe('Controladores módulo crear nota de pedido', function() {
942 1119 $filter: filter,
943 1120 $timeout: timeout,
944 1121 crearNotaPedidoService: {
  1122 + getNumeroNotaPedido: function() {
  1123 + return {
  1124 + then: function() { }
  1125 + };
  1126 + },
945 1127 getBotonera: function() { },
946 1128 getCotizacionByIdMoneda: function() {
947 1129 return {
... ... @@ -957,7 +1139,8 @@ describe('Controladores módulo crear nota de pedido', function() {
957 1139 },
958 1140 focaSeguimientoService: {},
959 1141 APP: {},
960   - focaLoginService: {}
  1142 + focaLoginService: {},
  1143 + $localStorage: {}
961 1144 });
962 1145 scope.idLista = true;
963 1146 scope.notaPedido = {
... ... @@ -974,7 +1157,7 @@ describe('Controladores módulo crear nota de pedido', function() {
974 1157  
975 1158 //assert
976 1159 promesaRespuesta.result.then(function() {
977   - expect(scope.articulosTabla.length).toEqual(0);
  1160 + expect(scope.notaPedido.articulosNotaPedido.length).toEqual(0);
978 1161 expect(scope.$broadcast).toHaveBeenCalled();
979 1162 done();
980 1163 });
... ... @@ -983,7 +1166,10 @@ describe('Controladores módulo crear nota de pedido', function() {
983 1166 it('función seleccionarFlete abre modal', function() {
984 1167  
985 1168 //arrange
986   - var scope = {};
  1169 + var scope = {
  1170 + $watch: function() { },
  1171 + $broadcast: function() { }
  1172 + };
987 1173 var uibModal = {
988 1174 open: function() { }
989 1175 };
... ... @@ -995,6 +1181,11 @@ describe('Controladores módulo crear nota de pedido', function() {
995 1181 $filter: filter,
996 1182 $timeout: timeout,
997 1183 crearNotaPedidoService: {
  1184 + getNumeroNotaPedido: function() {
  1185 + return {
  1186 + then: function() { }
  1187 + };
  1188 + },
998 1189 getBotonera: function() { },
999 1190 getCotizacionByIdMoneda: function() {
1000 1191 return {
... ... @@ -1010,7 +1201,8 @@ describe('Controladores módulo crear nota de pedido', function() {
1010 1201 },
1011 1202 focaSeguimientoService: {},
1012 1203 APP: {},
1013   - focaLoginService: {}
  1204 + focaLoginService: {},
  1205 + $localStorage: {}
1014 1206 });
1015 1207  
1016 1208 scope.notaPedido = {};
... ... @@ -1028,7 +1220,10 @@ describe('Controladores módulo crear nota de pedido', function() {
1028 1220 it('función seleccionarFlete setea flete y cabecera', function(done) {
1029 1221  
1030 1222 //arrange
1031   - var scope = {};
  1223 + var scope = {
  1224 + $watch: function() { },
  1225 + $broadcast: function() { }
  1226 + };
1032 1227 var uibModal = {
1033 1228 open: function() { }
1034 1229 };
... ... @@ -1040,6 +1235,11 @@ describe('Controladores módulo crear nota de pedido', function() {
1040 1235 $filter: filter,
1041 1236 $timeout: timeout,
1042 1237 crearNotaPedidoService: {
  1238 + getNumeroNotaPedido: function() {
  1239 + return {
  1240 + then: function() { }
  1241 + };
  1242 + },
1043 1243 getBotonera: function() { },
1044 1244 getCotizacionByIdMoneda: function() {
1045 1245 return {
... ... @@ -1055,7 +1255,8 @@ describe('Controladores módulo crear nota de pedido', function() {
1055 1255 },
1056 1256 focaSeguimientoService: {},
1057 1257 APP: {},
1058   - focaLoginService: {}
  1258 + focaLoginService: {},
  1259 + $localStorage: {}
1059 1260 });
1060 1261 scope.idLista = true;
1061 1262 scope.notaPedido = {
... ... @@ -1084,7 +1285,10 @@ describe('Controladores módulo crear nota de pedido', function() {
1084 1285  
1085 1286 it('función seleccionarMoneda abre modal', function() {
1086 1287 //arrange
1087   - var scope = {};
  1288 + var scope = {
  1289 + $watch: function() { },
  1290 + $broadcast: function() { }
  1291 + };
1088 1292 var focaModalService = {
1089 1293 modal: function() { }
1090 1294 };
... ... @@ -1096,6 +1300,11 @@ describe('Controladores módulo crear nota de pedido', function() {
1096 1300 $filter: filter,
1097 1301 $timeout: timeout,
1098 1302 crearNotaPedidoService: {
  1303 + getNumeroNotaPedido: function() {
  1304 + return {
  1305 + then: function() { }
  1306 + };
  1307 + },
1099 1308 getBotonera: function() { },
1100 1309 getCotizacionByIdMoneda: function() {
1101 1310 return {
... ... @@ -1111,7 +1320,8 @@ describe('Controladores módulo crear nota de pedido', function() {
1111 1320 },
1112 1321 focaSeguimientoService: {},
1113 1322 APP: {},
1114   - focaLoginService: {}
  1323 + focaLoginService: {},
  1324 + $localStorage: {}
1115 1325 });
1116 1326 scope.notaPedido = {};
1117 1327  
... ... @@ -1127,7 +1337,10 @@ describe('Controladores módulo crear nota de pedido', function() {
1127 1337  
1128 1338 it('función seleccionarMoneda llama Modal Cotizacion', function(done) {
1129 1339 //arrange
1130   - var scope = {};
  1340 + var scope = {
  1341 + $watch: function() { },
  1342 + $broadcast: function() { }
  1343 + };
1131 1344 var focaModalService = {
1132 1345 modal: function() { }
1133 1346 };
... ... @@ -1139,6 +1352,11 @@ describe('Controladores módulo crear nota de pedido', function() {
1139 1352 $filter: filter,
1140 1353 $timeout: timeout,
1141 1354 crearNotaPedidoService: {
  1355 + getNumeroNotaPedido: function() {
  1356 + return {
  1357 + then: function() { }
  1358 + };
  1359 + },
1142 1360 getBotonera: function() { },
1143 1361 getCotizacionByIdMoneda: function() {
1144 1362 return {
... ... @@ -1154,7 +1372,8 @@ describe('Controladores módulo crear nota de pedido', function() {
1154 1372 },
1155 1373 focaSeguimientoService: {},
1156 1374 APP: {},
1157   - focaLoginService: {}
  1375 + focaLoginService: {},
  1376 + $localStorage: {}
1158 1377 });
1159 1378  
1160 1379 scope.notaPedido = {};
... ... @@ -1176,7 +1395,10 @@ describe('Controladores módulo crear nota de pedido', function() {
1176 1395 it('función seleccionarObservaciones llama a prompt', function() {
1177 1396  
1178 1397 //arrange
1179   - var scope = {};
  1398 + var scope = {
  1399 + $watch: function() { },
  1400 + $broadcast: function() { }
  1401 + };
1180 1402 var focaModalService = {
1181 1403 prompt: function() { }
1182 1404 };
... ... @@ -1188,6 +1410,11 @@ describe('Controladores módulo crear nota de pedido', function() {
1188 1410 $filter: filter,
1189 1411 $timeout: timeout,
1190 1412 crearNotaPedidoService: {
  1413 + getNumeroNotaPedido: function() {
  1414 + return {
  1415 + then: function() { }
  1416 + };
  1417 + },
1191 1418 getBotonera: function() { },
1192 1419 getCotizacionByIdMoneda: function() {
1193 1420 return {
... ... @@ -1203,7 +1430,8 @@ describe('Controladores módulo crear nota de pedido', function() {
1203 1430 },
1204 1431 focaSeguimientoService: {},
1205 1432 APP: {},
1206   - focaLoginService: {}
  1433 + focaLoginService: {},
  1434 + $localStorage: {}
1207 1435 });
1208 1436 var respuesta = { then: function() { } };
1209 1437 scope.notaPedido = {};
... ... @@ -1219,7 +1447,10 @@ describe('Controladores módulo crear nota de pedido', function() {
1219 1447 it('función seleccionarObservaciones setea observaciones', function(done) {
1220 1448  
1221 1449 //arrange
1222   - var scope = {};
  1450 + var scope = {
  1451 + $watch: function() { },
  1452 + $broadcast: function() { }
  1453 + };
1223 1454 var focaModalService = {
1224 1455 prompt: function() { }
1225 1456 };
... ... @@ -1231,6 +1462,11 @@ describe('Controladores módulo crear nota de pedido', function() {
1231 1462 $filter: filter,
1232 1463 $timeout: timeout,
1233 1464 crearNotaPedidoService: {
  1465 + getNumeroNotaPedido: function() {
  1466 + return {
  1467 + then: function() { }
  1468 + };
  1469 + },
1234 1470 getBotonera: function() { },
1235 1471 getCotizacionByIdMoneda: function() {
1236 1472 return {
... ... @@ -1246,7 +1482,8 @@ describe('Controladores módulo crear nota de pedido', function() {
1246 1482 },
1247 1483 focaSeguimientoService: {},
1248 1484 APP: {},
1249   - focaLoginService: {}
  1485 + focaLoginService: {},
  1486 + $localStorage: {}
1250 1487 });
1251 1488 var respuesta = 'unit test';
1252 1489 var promesa = Promise.resolve(respuesta);
... ... @@ -1266,7 +1503,10 @@ describe('Controladores módulo crear nota de pedido', function() {
1266 1503 it('función abrirModalCotizacion abre modal', function() {
1267 1504  
1268 1505 //arrange
1269   - var scope = {};
  1506 + var scope = {
  1507 + $watch: function() { },
  1508 + $broadcast: function() { }
  1509 + };
1270 1510 var uibModal = {
1271 1511 open: function() { }
1272 1512 };
... ... @@ -1278,6 +1518,11 @@ describe('Controladores módulo crear nota de pedido', function() {
1278 1518 $filter: filter,
1279 1519 $timeout: timeout,
1280 1520 crearNotaPedidoService: {
  1521 + getNumeroNotaPedido: function() {
  1522 + return {
  1523 + then: function() { }
  1524 + };
  1525 + },
1281 1526 getBotonera: function() { },
1282 1527 getCotizacionByIdMoneda: function() {
1283 1528 return {
... ... @@ -1293,7 +1538,8 @@ describe('Controladores módulo crear nota de pedido', function() {
1293 1538 },
1294 1539 focaSeguimientoService: {},
1295 1540 APP: {},
1296   - focaLoginService: {}
  1541 + focaLoginService: {},
  1542 + $localStorage: {}
1297 1543 });
1298 1544  
1299 1545 scope.notaPedido = {};
... ... @@ -1310,7 +1556,10 @@ describe('Controladores módulo crear nota de pedido', function() {
1310 1556  
1311 1557 it('función abrirModalCotizacion setea datos y cabecera', function(done) {
1312 1558 //arrange
1313   - var scope = {};
  1559 + var scope = {
  1560 + $watch: function() { },
  1561 + $broadcast: function() { }
  1562 + };
1314 1563 var uibModal = {
1315 1564 open: function() { }
1316 1565 };
... ... @@ -1322,6 +1571,11 @@ describe('Controladores módulo crear nota de pedido', function() {
1322 1571 $filter: filter,
1323 1572 $timeout: timeout,
1324 1573 crearNotaPedidoService: {
  1574 + getNumeroNotaPedido: function() {
  1575 + return {
  1576 + then: function() { }
  1577 + };
  1578 + },
1325 1579 getBotonera: function() { },
1326 1580 getCotizacionByIdMoneda: function() {
1327 1581 return {
... ... @@ -1337,7 +1591,9 @@ describe('Controladores módulo crear nota de pedido', function() {
1337 1591 },
1338 1592 focaSeguimientoService: {},
1339 1593 APP: {},
1340   - focaLoginService: {}
  1594 + focaLoginService: {},
  1595 + $localStorage: {},
  1596 + articulosNotaPedido: []
1341 1597 });
1342 1598  
1343 1599 scope.notaPedido = {};
... ... @@ -1356,9 +1612,6 @@ describe('Controladores módulo crear nota de pedido', function() {
1356 1612 promesaRespuesta.result.then(function() {
1357 1613  
1358 1614 expect(scope.$broadcast).toHaveBeenCalled();
1359   - expect(scope.notaPedido.moneda).toEqual(moneda);
1360   - expect(scope.monedaDefecto).toEqual(moneda);
1361   - expect(scope.cotizacionDefecto).toEqual(cotizacion);
1362 1615 expect(scope.notaPedido.cotizacion).toEqual(cotizacion);
1363 1616 done();
1364 1617 });
... ... @@ -1367,7 +1620,10 @@ describe('Controladores módulo crear nota de pedido', function() {
1367 1620 it('función agregarATabla muestra alerta cuando a cargar undefined', function() {
1368 1621  
1369 1622 //arrange
1370   - var scope = {};
  1623 + var scope = {
  1624 + $watch: function() { },
  1625 + $broadcast: function() { }
  1626 + };
1371 1627 var focaModalService = {
1372 1628 alert: function() { }
1373 1629 };
... ... @@ -1379,6 +1635,11 @@ describe('Controladores módulo crear nota de pedido', function() {
1379 1635 $filter: filter,
1380 1636 $timeout: timeout,
1381 1637 crearNotaPedidoService: {
  1638 + getNumeroNotaPedido: function() {
  1639 + return {
  1640 + then: function() { }
  1641 + };
  1642 + },
1382 1643 getBotonera: function() { },
1383 1644 getCotizacionByIdMoneda: function() {
1384 1645 return {
... ... @@ -1394,7 +1655,8 @@ describe('Controladores módulo crear nota de pedido', function() {
1394 1655 },
1395 1656 focaSeguimientoService: {},
1396 1657 APP: {},
1397   - focaLoginService: {}
  1658 + focaLoginService: {},
  1659 + $localStorage: {}
1398 1660 });
1399 1661 scope.articuloACargar = {};
1400 1662  
... ... @@ -1409,7 +1671,10 @@ describe('Controladores módulo crear nota de pedido', function() {
1409 1671 it('función editarArticulo muestra alerta cuando a cargar es undefined', function() {
1410 1672  
1411 1673 //arrange
1412   - var scope = {};
  1674 + var scope = {
  1675 + $watch: function() { },
  1676 + $broadcast: function() { }
  1677 + };
1413 1678 var focaModalService = {
1414 1679 alert: function() { }
1415 1680 };
... ... @@ -1421,6 +1686,11 @@ describe('Controladores módulo crear nota de pedido', function() {
1421 1686 $filter: filter,
1422 1687 $timeout: timeout,
1423 1688 crearNotaPedidoService: {
  1689 + getNumeroNotaPedido: function() {
  1690 + return {
  1691 + then: function() { }
  1692 + };
  1693 + },
1424 1694 getBotonera: function() { },
1425 1695 getCotizacionByIdMoneda: function() {
1426 1696 return {
... ... @@ -1436,7 +1706,8 @@ describe('Controladores módulo crear nota de pedido', function() {
1436 1706 },
1437 1707 focaSeguimientoService: {},
1438 1708 APP: {},
1439   - focaLoginService: {}
  1709 + focaLoginService: {},
  1710 + $localStorage: {}
1440 1711 });
1441 1712 scope.articuloACargar = {};
1442 1713  
... ... @@ -1453,7 +1724,10 @@ describe('Controladores módulo crear nota de pedido', function() {
1453 1724 inject(function($location) {
1454 1725  
1455 1726 //arrange
1456   - var scope = {};
  1727 + var scope = {
  1728 + $watch: function() { },
  1729 + $broadcast: function() { }
  1730 + };
1457 1731  
1458 1732 $controler('notaPedidoCtrl', {
1459 1733 $scope: scope,
... ... @@ -1462,6 +1736,11 @@ describe('Controladores módulo crear nota de pedido', function() {
1462 1736 $filter: filter,
1463 1737 $timeout: timeout,
1464 1738 crearNotaPedidoService: {
  1739 + getNumeroNotaPedido: function() {
  1740 + return {
  1741 + then: function() { }
  1742 + };
  1743 + },
1465 1744 getBotonera: function() { },
1466 1745 getCotizacionByIdMoneda: function() {
1467 1746 return {
... ... @@ -1477,7 +1756,8 @@ describe('Controladores módulo crear nota de pedido', function() {
1477 1756 },
1478 1757 focaSeguimientoService: {},
1479 1758 APP: {},
1480   - focaLoginService: {}
  1759 + focaLoginService: {},
  1760 + $localStorage: {},
1481 1761 });
1482 1762  
1483 1763 //act
spec/controllerSpecCrearPedido.js
... ... @@ -27,12 +27,20 @@ describe('Controladores módulo crear nota de pedido', function() {
27 27  
28 28 //act
29 29 var controlador = $controler('notaPedidoCtrl', {
30   - $scope: {},
  30 + $scope: {
  31 + $watch: function() { },
  32 + $broadcast: function() {}
  33 + },
31 34 $uibModal: {},
32 35 $location: {},
33 36 $filter: filter,
34 37 $timeout: timeout,
35 38 crearNotaPedidoService: {
  39 + getNumeroNotaPedido: function() {
  40 + return {
  41 + then: function() { }
  42 + };
  43 + },
36 44 getBotonera: function() { },
37 45 getCotizacionByIdMoneda: function() {
38 46 return {
... ... @@ -48,7 +56,8 @@ describe('Controladores módulo crear nota de pedido', function() {
48 56 },
49 57 focaSeguimientoService: {},
50 58 APP: {},
51   - focaLoginService: {}
  59 + focaLoginService: {},
  60 + $localStorage: {}
52 61 });
53 62  
54 63 //expect
... ... @@ -58,7 +67,10 @@ describe('Controladores módulo crear nota de pedido', function() {
58 67 it('la funcion $scope.crearNotaPedido muestra alerta cuando vendedor es null', function() {
59 68  
60 69 //arrange
61   - var scope = {};
  70 + var scope = {
  71 + $watch: function() { },
  72 + $broadcast: function() {}
  73 + };
62 74 var focaModalService = {
63 75 alert: function() { }
64 76 };
... ... @@ -70,6 +82,11 @@ describe('Controladores módulo crear nota de pedido', function() {
70 82 $filter: filter,
71 83 $timeout: timeout,
72 84 crearNotaPedidoService: {
  85 + getNumeroNotaPedido: function() {
  86 + return {
  87 + then: function() { }
  88 + };
  89 + },
73 90 getBotonera: function() { },
74 91 getCotizacionByIdMoneda: function() {
75 92 return {
... ... @@ -85,7 +102,10 @@ describe('Controladores módulo crear nota de pedido', function() {
85 102 },
86 103 focaSeguimientoService: {},
87 104 APP: {},
88   - focaLoginService: {}
  105 + focaLoginService: {},
  106 + $localStorage: {},
  107 + $watch: function() { },
  108 + $broadcast: function() {}
89 109 });
90 110  
91 111 //act
... ... @@ -104,7 +124,10 @@ describe('Controladores módulo crear nota de pedido', function() {
104 124 it('la funcion $scope.crearNotaPedido muestra alerta cuando cliente es null', function() {
105 125  
106 126 //arrange
107   - var scope = {};
  127 + var scope = {
  128 + $watch: function() { },
  129 + $broadcast: function() {}
  130 + };
108 131 var focaModalService = {
109 132 alert: function() { }
110 133 };
... ... @@ -116,6 +139,11 @@ describe('Controladores módulo crear nota de pedido', function() {
116 139 $filter: filter,
117 140 $timeout: timeout,
118 141 crearNotaPedidoService: {
  142 + getNumeroNotaPedido: function() {
  143 + return {
  144 + then: function() { }
  145 + };
  146 + },
119 147 getBotonera: function() { },
120 148 getCotizacionByIdMoneda: function() {
121 149 return {
... ... @@ -131,7 +159,10 @@ describe('Controladores módulo crear nota de pedido', function() {
131 159 },
132 160 focaSeguimientoService: {},
133 161 APP: {},
134   - focaLoginService: {}
  162 + focaLoginService: {},
  163 + $localStorage: {},
  164 + $watch: function() { },
  165 + $broadcast: function() {}
135 166 });
136 167  
137 168 scope.notaPedido = {
... ... @@ -154,7 +185,10 @@ describe('Controladores módulo crear nota de pedido', function() {
154 185 it('funcion $scope.crearNotaPedido muestra alerta cuando proveedor es null', function() {
155 186  
156 187 //arrange
157   - var scope = {};
  188 + var scope = {
  189 + $watch: function() { },
  190 + $broadcast: function() {}
  191 + };
158 192 var focaModalService = {
159 193 alert: function() { }
160 194 };
... ... @@ -166,6 +200,11 @@ describe('Controladores módulo crear nota de pedido', function() {
166 200 $filter: filter,
167 201 $timeout: timeout,
168 202 crearNotaPedidoService: {
  203 + getNumeroNotaPedido: function() {
  204 + return {
  205 + then: function() { }
  206 + };
  207 + },
169 208 getBotonera: function() { },
170 209 getCotizacionByIdMoneda: function() {
171 210 return {
... ... @@ -181,7 +220,10 @@ describe('Controladores módulo crear nota de pedido', function() {
181 220 },
182 221 focaSeguimientoService: {},
183 222 APP: {},
184   - focaLoginService: {}
  223 + focaLoginService: {},
  224 + $localStorage: {},
  225 + $watch: function() { },
  226 + $broadcast: function() {}
185 227 });
186 228  
187 229 scope.notaPedido = {
... ... @@ -207,7 +249,10 @@ describe('Controladores módulo crear nota de pedido', function() {
207 249 it('funcion $scope.crearNotaPedido muestra alerta cuando Moneda es null', function() {
208 250  
209 251 //arrange
210   - var scope = {};
  252 + var scope = {
  253 + $watch: function() { },
  254 + $broadcast: function() {}
  255 + };
211 256 var focaModalService = {
212 257 alert: function() { }
213 258 };
... ... @@ -219,6 +264,11 @@ describe('Controladores módulo crear nota de pedido', function() {
219 264 $filter: filter,
220 265 $timeout: timeout,
221 266 crearNotaPedidoService: {
  267 + getNumeroNotaPedido: function() {
  268 + return {
  269 + then: function() { }
  270 + };
  271 + },
222 272 getBotonera: function() { },
223 273 getCotizacionByIdMoneda: function() {
224 274 return {
... ... @@ -234,7 +284,10 @@ describe('Controladores módulo crear nota de pedido', function() {
234 284 },
235 285 focaSeguimientoService: {},
236 286 APP: {},
237   - focaLoginService: {}
  287 + focaLoginService: {},
  288 + $localStorage: {},
  289 + $watch: function() { },
  290 + $broadcast: function() {}
238 291 });
239 292  
240 293 scope.notaPedido = {
... ... @@ -247,8 +300,11 @@ describe('Controladores módulo crear nota de pedido', function() {
247 300 proveedor:{
248 301 COD: true
249 302 },
250   - moneda:{
251   - ID: null
  303 + cotizacion: {
  304 + ID: true,
  305 + moneda:{
  306 + ID: null
  307 + }
252 308 }
253 309 };
254 310  
... ... @@ -263,7 +319,10 @@ describe('Controladores módulo crear nota de pedido', function() {
263 319 it('funcion $scope.crearNotaPedido muestra alerta cuando cotizacion es null', function() {
264 320  
265 321 //arrange
266   - var scope = {};
  322 + var scope = {
  323 + $watch: function() { },
  324 + $broadcast: function() {}
  325 + };
267 326 var focaModalService = {
268 327 alert: function() { }
269 328 };
... ... @@ -275,6 +334,11 @@ describe('Controladores módulo crear nota de pedido', function() {
275 334 $filter: filter,
276 335 $timeout: timeout,
277 336 crearNotaPedidoService: {
  337 + getNumeroNotaPedido: function() {
  338 + return {
  339 + then: function() { }
  340 + };
  341 + },
278 342 getBotonera: function() { },
279 343 getCotizacionByIdMoneda: function() {
280 344 return {
... ... @@ -290,7 +354,10 @@ describe('Controladores módulo crear nota de pedido', function() {
290 354 },
291 355 focaSeguimientoService: {},
292 356 APP: {},
293   - focaLoginService: {}
  357 + focaLoginService: {},
  358 + $localStorage: {},
  359 + $watch: function() { },
  360 + $broadcast: function() {}
294 361 });
295 362  
296 363 scope.notaPedido = {
... ... @@ -303,11 +370,11 @@ describe('Controladores módulo crear nota de pedido', function() {
303 370 proveedor:{
304 371 COD: true
305 372 },
306   - moneda:{
307   - ID: true
308   - },
309 373 cotizacion:{
310   - ID: null
  374 + ID: null,
  375 + moneda: {
  376 + ID: true
  377 + }
311 378 }
312 379 };
313 380  
... ... @@ -322,7 +389,10 @@ describe('Controladores módulo crear nota de pedido', function() {
322 389 it('funcion $scope.crearNotaPedido muestra alerta cuando plazos es null', function() {
323 390  
324 391 //arrange
325   - var scope = {};
  392 + var scope = {
  393 + $watch: function() { },
  394 + $broadcast: function() {}
  395 + };
326 396 var focaModalService = {
327 397 alert: function() { }
328 398 };
... ... @@ -334,6 +404,11 @@ describe('Controladores módulo crear nota de pedido', function() {
334 404 $filter: filter,
335 405 $timeout: timeout,
336 406 crearNotaPedidoService: {
  407 + getNumeroNotaPedido: function() {
  408 + return {
  409 + then: function() { }
  410 + };
  411 + },
337 412 getBotonera: function() { },
338 413 getCotizacionByIdMoneda: function() {
339 414 return {
... ... @@ -349,7 +424,10 @@ describe('Controladores módulo crear nota de pedido', function() {
349 424 },
350 425 focaSeguimientoService: {},
351 426 APP: {},
352   - focaLoginService: {}
  427 + focaLoginService: {},
  428 + $localStorage: {},
  429 + $watch: function() { },
  430 + $broadcast: function() {}
353 431 });
354 432  
355 433 scope.notaPedido = {
... ... @@ -362,11 +440,11 @@ describe('Controladores módulo crear nota de pedido', function() {
362 440 proveedor:{
363 441 COD: true
364 442 },
365   - moneda:{
366   - ID: true
367   - },
368 443 cotizacion:{
369   - ID: true
  444 + ID: true,
  445 + moneda:{
  446 + ID: true
  447 + }
370 448 }
371 449 };
372 450  
... ... @@ -383,7 +461,10 @@ describe('Controladores módulo crear nota de pedido', function() {
383 461 it('funcion $scope.crearNotaPedido muestra alerta cuando flete es null', function() {
384 462  
385 463 //arrange
386   - var scope = {};
  464 + var scope = {
  465 + $watch: function() { },
  466 + $broadcast: function() {}
  467 + };
387 468 var focaModalService = {
388 469 alert: function() { }
389 470 };
... ... @@ -395,6 +476,11 @@ describe('Controladores módulo crear nota de pedido', function() {
395 476 $filter: filter,
396 477 $timeout: timeout,
397 478 crearNotaPedidoService: {
  479 + getNumeroNotaPedido: function() {
  480 + return {
  481 + then: function() { }
  482 + };
  483 + },
398 484 getBotonera: function() { },
399 485 getCotizacionByIdMoneda: function() {
400 486 return {
... ... @@ -410,7 +496,10 @@ describe('Controladores módulo crear nota de pedido', function() {
410 496 },
411 497 focaSeguimientoService: {},
412 498 APP: {},
413   - focaLoginService: {}
  499 + focaLoginService: {},
  500 + $localStorage: {},
  501 + $watch: function() { },
  502 + $broadcast: function() {}
414 503 });
415 504  
416 505 scope.notaPedido = {
... ... @@ -423,13 +512,14 @@ describe('Controladores módulo crear nota de pedido', function() {
423 512 proveedor:{
424 513 COD: true
425 514 },
426   - moneda:{
427   - ID: true
428   - },
429 515 cotizacion:{
430   - ID: true
  516 + ID: true,
  517 + moneda:{
  518 + ID: true
  519 + }
431 520 },
432   - flete: null
  521 + flete: null,
  522 + notaPedidoPlazo: []
433 523 };
434 524  
435 525 scope.plazosPagos = true;
... ... @@ -445,7 +535,10 @@ describe('Controladores módulo crear nota de pedido', function() {
445 535 it('funcion $scope.crearNotaPedido muestra alerta cuando domicilio es null', function() {
446 536  
447 537 //arrange
448   - var scope = {};
  538 + var scope = {
  539 + $watch: function() { },
  540 + $broadcast: function() {}
  541 + };
449 542 var focaModalService = {
450 543 alert: function() { }
451 544 };
... ... @@ -457,6 +550,11 @@ describe('Controladores módulo crear nota de pedido', function() {
457 550 $filter: filter,
458 551 $timeout: timeout,
459 552 crearNotaPedidoService: {
  553 + getNumeroNotaPedido: function() {
  554 + return {
  555 + then: function() { }
  556 + };
  557 + },
460 558 getBotonera: function() { },
461 559 getCotizacionByIdMoneda: function() {
462 560 return {
... ... @@ -472,7 +570,10 @@ describe('Controladores módulo crear nota de pedido', function() {
472 570 },
473 571 focaSeguimientoService: {},
474 572 APP: {},
475   - focaLoginService: {}
  573 + focaLoginService: {},
  574 + $localStorage: {},
  575 + $watch: function() { },
  576 + $broadcast: function() {}
476 577 });
477 578  
478 579 scope.notaPedido = {
... ... @@ -485,14 +586,15 @@ describe('Controladores módulo crear nota de pedido', function() {
485 586 proveedor:{
486 587 COD: true
487 588 },
488   - moneda:{
489   - ID: true
490   - },
491 589 cotizacion:{
492   - ID: true
  590 + ID: true,
  591 + moneda:{
  592 + ID: true
  593 + }
493 594 },
494 595 flete: true,
495   - domicilioStamp: null
  596 + domicilioStamp: null,
  597 + notaPedidoPlazo: []
496 598 };
497 599  
498 600 scope.plazosPagos = true;
... ... @@ -510,7 +612,10 @@ describe('Controladores módulo crear nota de pedido', function() {
510 612 {
511 613  
512 614 //arrange
513   - var scope = {};
  615 + var scope = {
  616 + $watch: function() { },
  617 + $broadcast: function() {}
  618 + };
514 619 var focaModalService = {
515 620 alert: function() { }
516 621 };
... ... @@ -522,14 +627,26 @@ describe('Controladores módulo crear nota de pedido', function() {
522 627 $filter: filter,
523 628 $timeout: timeout,
524 629 crearNotaPedidoService: {
  630 + getNumeroNotaPedido: function() {
  631 + return {
  632 + then: function() {}
  633 + };
  634 + },
525 635 getBotonera: function() { },
526 636 getCotizacionByIdMoneda: function() {
527 637 return {
528 638 then: function() {}
529 639 };
  640 + },
  641 + crearNotaPedido: function() {
  642 + return {
  643 + then: function() { }
  644 + };
530 645 }
531 646 },
532   - focaBotoneraLateralService: {},
  647 + focaBotoneraLateralService: {
  648 + startGuardar: function() {}
  649 + },
533 650 focaModalService: focaModalService,
534 651 notaPedidoBusinessService: {},
535 652 $rootScope: {
... ... @@ -537,7 +654,10 @@ describe('Controladores módulo crear nota de pedido', function() {
537 654 },
538 655 focaSeguimientoService: {},
539 656 APP: {},
540   - focaLoginService: {}
  657 + focaLoginService: {},
  658 + $localStorage: {},
  659 + $watch: function() { },
  660 + $broadcast: function() {}
541 661 });
542 662  
543 663 scope.notaPedido = {
... ... @@ -550,17 +670,25 @@ describe('Controladores módulo crear nota de pedido', function() {
550 670 proveedor:{
551 671 COD: true
552 672 },
553   - moneda:{
554   - ID: true
555   - },
556 673 cotizacion:{
557   - ID: true
  674 + ID: true,
  675 + moneda:{
  676 + ID: true
  677 + }
  678 + },
  679 + precioCondicion: {
  680 + id: true
  681 + },
  682 + domicilio: {
  683 + id: true
558 684 },
559 685 flete: true,
560 686 domicilioStamp: true,
  687 + notaPedidoPlazo: [],
  688 + articulosNotaPedido: [],
  689 + fechaCarga: true
561 690 };
562 691  
563   - scope.plazosPagos = true;
564 692 scope.articulosTabla = [];
565 693  
566 694 //act
... ... @@ -575,7 +703,10 @@ describe('Controladores módulo crear nota de pedido', function() {
575 703 it('funcion $scope.crearNotaPedido llama startGuardar', function() {
576 704  
577 705 //arrange
578   - var scope = {};
  706 + var scope = {
  707 + $watch: function() { },
  708 + $broadcast: function() {}
  709 + };
579 710 var focaBotoneraLateralService = {
580 711 startGuardar: function() { }
581 712 };
... ... @@ -587,6 +718,11 @@ describe('Controladores módulo crear nota de pedido', function() {
587 718 $filter: filter,
588 719 $timeout: timeout,
589 720 crearNotaPedidoService: {
  721 + getNumeroNotaPedido: function() {
  722 + return {
  723 + then: function() { }
  724 + };
  725 + },
590 726 getBotonera: function() { },
591 727 getCotizacionByIdMoneda: function() {
592 728 return {
... ... @@ -600,14 +736,19 @@ describe('Controladores módulo crear nota de pedido', function() {
600 736 }
601 737 },
602 738 focaBotoneraLateralService: focaBotoneraLateralService,
603   - focaModalService: {},
  739 + focaModalService: {
  740 + alert: function() {}
  741 + },
604 742 notaPedidoBusinessService: {},
605 743 $rootScope: {
606 744 $on: function() { }
607 745 },
608 746 focaSeguimientoService: {},
609 747 APP: {},
610   - focaLoginService: {}
  748 + focaLoginService: {},
  749 + $localStorage: {},
  750 + $watch: function() { },
  751 + $broadcast: function() {}
611 752 });
612 753  
613 754 scope.notaPedido = {
... ... @@ -620,17 +761,20 @@ describe('Controladores módulo crear nota de pedido', function() {
620 761 proveedor:{
621 762 COD: true
622 763 },
623   - moneda:{
624   - ID: true
625   - },
626 764 cotizacion:{
627   - ID: true
  765 + ID: true,
  766 + moneda:{
  767 + ID: true
  768 + }
628 769 },
629 770 flete: true,
630 771 domicilioStamp: true,
631 772 domicilio: {
632 773 id: true
633   - }
  774 + },
  775 + notaPedidoPlazo: [],
  776 + articulosNotaPedido: true,
  777 + fechaCarga: true
634 778 };
635 779  
636 780 scope.plazosPagos = true;
... ... @@ -638,7 +782,7 @@ describe('Controladores módulo crear nota de pedido', function() {
638 782  
639 783 //act
640 784 spyOn(focaBotoneraLateralService, 'startGuardar');
641   - scope.crearNotaPedido();
  785 + scope.crearNotaPedido(scope.notaPedido);
642 786  
643 787 //expect
644 788 expect(focaBotoneraLateralService.startGuardar).toHaveBeenCalled();
... ... @@ -647,7 +791,10 @@ describe('Controladores módulo crear nota de pedido', function() {
647 791 it('funcion $scope.crearNotaPedido llama funciones al guardar', function(done) {
648 792  
649 793 //arrange
650   - var scope = {};
  794 + var scope = {
  795 + $watch: function() { },
  796 + $broadcast: function() {}
  797 + };
651 798 var focaBotoneraLateralService = {
652 799 startGuardar: function() { },
653 800 endGuardar: function() { }
... ... @@ -666,7 +813,11 @@ describe('Controladores módulo crear nota de pedido', function() {
666 813 then: function() {}
667 814 };
668 815 },
669   - crearNotaPedido: function() { },
  816 + crearNotaPedido: function() {
  817 + return {
  818 + then: function() { }
  819 + };
  820 + },
670 821 getNumeroNotaPedido: function() {
671 822 return {
672 823 then: function() { }
... ... @@ -682,14 +833,19 @@ describe('Controladores módulo crear nota de pedido', function() {
682 833 $timeout: timeout,
683 834 crearNotaPedidoService: crearNotaPedidoService,
684 835 focaBotoneraLateralService: focaBotoneraLateralService,
685   - focaModalService: {},
  836 + focaModalService: {
  837 + alert: function() {}
  838 + },
686 839 notaPedidoBusinessService: notaPedidoBusinessService,
687 840 $rootScope: {
688 841 $on: function() { }
689 842 },
690 843 focaSeguimientoService: focaSeguimientoService,
691 844 APP: {},
692   - focaLoginService: {}
  845 + focaLoginService: {},
  846 + $localStorage: {},
  847 + $watch: function() { },
  848 + $broadcast: function() {}
693 849 });
694 850  
695 851 scope.notaPedido = {
... ... @@ -702,17 +858,20 @@ describe('Controladores módulo crear nota de pedido', function() {
702 858 proveedor:{
703 859 COD: true
704 860 },
705   - moneda:{
706   - ID: true
707   - },
708 861 cotizacion:{
709   - ID: true
  862 + ID: true,
  863 + moneda:{
  864 + ID: true
  865 + }
710 866 },
711 867 flete: true,
712 868 domicilioStamp: true,
713 869 domicilio: {
714 870 id: true
715   - }
  871 + },
  872 + notaPedidoPlazo: [],
  873 + articulosNotaPedido: [1],
  874 + fechaCarga: true
716 875 };
717 876  
718 877 scope.plazosPagos = [];
... ... @@ -726,13 +885,14 @@ describe('Controladores módulo crear nota de pedido', function() {
726 885 spyOn(focaSeguimientoService, 'guardarPosicion');
727 886 spyOn(notaPedidoBusinessService, 'addArticulos');
728 887 scope.crearNotaPedido();
729   -
730 888 //expect
  889 +
731 890 promesa.then(function() {
732 891 expect(focaSeguimientoService.guardarPosicion).toHaveBeenCalled();
733 892 expect(notaPedidoBusinessService.addArticulos).toHaveBeenCalled();
734 893 done();
735 894 });
  895 +
736 896 });
737 897 });
738 898 });
src/js/controller.js
... ... @@ -13,20 +13,21 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
13 13 'focaSeguimientoService',
14 14 'APP',
15 15 'focaLoginService',
  16 + '$localStorage',
16 17 function(
17 18 $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService,
18 19 focaBotoneraLateralService, focaModalService, notaPedidoBusinessService,
19   - $rootScope, focaSeguimientoService, APP, focaLoginService)
20   - {
  20 + $rootScope, focaSeguimientoService, APP, focaLoginService, $localStorage)
  21 + {
21 22 config();
22 23  
23 24 function config() {
24 25 // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA
  26 + $scope.notaPedido = {};
25 27 $scope.isNumber = angular.isNumber;
26 28 $scope.datepickerAbierto = false;
27 29 $scope.show = false;
28 30 $scope.cargando = true;
29   - $scope.now = new Date();
30 31 $scope.puntoVenta = $filter('rellenarDigitos')(0, 4);
31 32 $scope.comprobante = $filter('rellenarDigitos')(0, 8);
32 33 $scope.dateOptions = {
... ... @@ -49,14 +50,20 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
49 50 } else {
50 51 $scope.botonera = crearNotaPedidoService.getBotonera();
51 52 }
52   -
  53 +
53 54 //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]'
54 55 crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) {
55   - $scope.monedaDefecto = res.data[0];
56   - $scope.cotizacionDefecto = $scope.monedaDefecto.cotizaciones[0];
  56 + var monedaPorDefecto = res.data[0];
57 57  
58   - init();
  58 + $scope.notaPedido.cotizacion = Object.assign(
  59 + {moneda: monedaPorDefecto},
  60 + monedaPorDefecto.cotizaciones[0]
  61 + );
  62 + $scope.inicial.cotizacion = $scope.notaPedido.cotizacion;
59 63 });
  64 +
  65 + init();
  66 + $timeout(function() {getLSNotaPedido();});
60 67 }
61 68  
62 69 function init() {
... ... @@ -68,11 +75,11 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
68 75 proveedor: {},
69 76 domicilio: {dom: ''},
70 77 vendedor: {},
71   - moneda: $scope.monedaDefecto,
72   - cotizacion: $scope.cotizacionDefecto
  78 + fechaCarga: new Date(),
  79 + cotizacion: {},
  80 + articulosNotaPedido: [],
  81 + notaPedidoPlazo: []
73 82 };
74   -
75   - $scope.articulosTabla = [];
76 83 $scope.idLista = undefined;
77 84  
78 85 crearNotaPedidoService.getNumeroNotaPedido().then(
... ... @@ -107,41 +114,44 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
107 114 );
108 115 }
109 116  
110   - $scope.inicial = {
111   - notaPedido: angular.copy($scope.notaPedido),
112   - articulosTabla: angular.copy($scope.articulosTabla),
113   - idLista: angular.copy($scope.idLista)
114   - };
  117 + $scope.inicial = angular.copy($scope.notaPedido);
115 118 }
116 119  
  120 + $scope.$watch('notaPedido', function(newValue, oldValue) {
  121 + focaBotoneraLateralService.setPausarData({
  122 + label: 'notaPedido',
  123 + val: newValue
  124 + });
  125 + }, true);
  126 +
117 127 $scope.crearNotaPedido = function() {
118   - if(!$scope.notaPedido.vendedor.id) {
  128 + if (!$scope.notaPedido.vendedor.id) {
119 129 focaModalService.alert('Ingrese Vendedor');
120 130 return;
121   - } else if(!$scope.notaPedido.cliente.COD) {
  131 + } else if (!$scope.notaPedido.cliente.COD) {
122 132 focaModalService.alert('Ingrese Cliente');
123 133 return;
124   - } else if(!$scope.notaPedido.proveedor.COD) {
  134 + } else if (!$scope.notaPedido.proveedor.COD) {
125 135 focaModalService.alert('Ingrese Proveedor');
126 136 return;
127   - } else if(!$scope.notaPedido.moneda.ID) {
128   - focaModalService.alert('Ingrese Moneda');
129   - return;
130   - } else if(!$scope.notaPedido.cotizacion.ID) {
  137 + } else if (!$scope.notaPedido.cotizacion.ID) {
131 138 focaModalService.alert('Ingrese Cotización');
132 139 return;
133   - } else if(!$scope.plazosPagos) {
  140 + } else if (!$scope.notaPedido.cotizacion.moneda.ID) {
  141 + focaModalService.alert('Ingrese Moneda');
  142 + return;
  143 + } else if (!$scope.notaPedido.notaPedidoPlazo) {
134 144 focaModalService.alert('Ingrese Precios y Condiciones');
135 145 return;
136   - } else if(
  146 + } else if (
137 147 $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null)
138 148 {
139 149 focaModalService.alert('Ingrese Flete');
140 150 return;
141   - } else if(!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto
  151 + } else if (!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto
142 152 focaModalService.alert('Ingrese Domicilio');
143 153 return;
144   - } else if($scope.articulosTabla.length === 0) {
  154 + } else if ($scope.notaPedido.articulosNotaPedido.length === 0) {
145 155 focaModalService.alert('Debe cargar al menos un articulo');
146 156 return;
147 157 }
... ... @@ -149,7 +159,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
149 159 $scope.saveLoading = true;
150 160 var notaPedido = {
151 161 id: $scope.notaPedido.id,
152   - fechaCarga: $scope.now.toISOString().slice(0, 19).replace('T', ' '),
  162 + fechaCarga: new Date($scope.notaPedido.fechaCarga).toISOString().slice(0, 19).replace('T', ' '),
153 163 idVendedor: $scope.notaPedido.vendedor.id,
154 164 idCliente: $scope.notaPedido.cliente.COD,
155 165 nombreCliente: $scope.notaPedido.cliente.NOM,
... ... @@ -178,15 +188,16 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
178 188 data.data.id,
179 189 ''
180 190 );
181   - notaPedidoBusinessService.addArticulos($scope.articulosTabla,
  191 + notaPedidoBusinessService.addArticulos(
  192 + $scope.notaPedido.articulosNotaPedido,
182 193 data.data.id, $scope.notaPedido.cotizacion.VENDEDOR);
183 194  
184   - if($scope.notaPedido.puntosDescarga) {
  195 + if ($scope.notaPedido.notaPedidoPuntoDescarga) {
185 196 notaPedidoBusinessService.addPuntosDescarga(data.data.id,
186   - $scope.notaPedido.puntosDescarga);
  197 + $scope.notaPedido.notaPedidoPuntoDescarga);
187 198 }
188 199  
189   - var plazos = $scope.plazosPagos;
  200 + var plazos = $scope.notaPedido.notaPedidoPlazo;
190 201 var plazosACrear = [];
191 202 plazos.forEach(function(plazo) {
192 203 plazosACrear.push({
... ... @@ -233,111 +244,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
233 244 }
234 245 }
235 246 );
236   - modalInstance.result.then(
237   - function(notaPedido) {
238   - $scope.now = new Date(notaPedido.fechaCarga);
239   - //añado cabeceras
240   - $scope.notaPedido.id = notaPedido.id;
241   - $scope.$broadcast('removeCabecera', 'Bomba:');
242   - $scope.$broadcast('removeCabecera', 'Kilometros:');
243   - var cabeceras = [
244   - {
245   - label: 'Moneda:',
246   - valor: notaPedido.cotizacion.moneda.DETALLE
247   - },
248   - {
249   - label: 'Fecha cotizacion:',
250   - valor: $filter('date')(notaPedido.cotizacion.FECHA,
251   - 'dd/MM/yyyy')
252   - },
253   - {
254   - label: 'Cotizacion:',
255   - valor: $filter('number')(notaPedido.cotizacion.VENDEDOR,
256   - '2')
257   - },
258   - {
259   - label: 'Cliente:',
260   - valor: notaPedido.cliente.NOM
261   - },
262   - {
263   - label: 'Domicilio:',
264   - valor: notaPedido.domicilioStamp
265   - },
266   - {
267   - label: 'Vendedor:',
268   - valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) +
269   - ' - ' + notaPedido.vendedor.NOM
270   - },
271   - {
272   - label: 'Proveedor:',
273   - valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) +
274   - ' - ' + notaPedido.proveedor.NOM
275   - },
276   - {
277   - label: 'Precios y condiciones:',
278   - valor: valorPrecioCondicion() + ' ' +
279   - notaPedidoBusinessService
280   - .plazoToString(notaPedido.notaPedidoPlazo)
281   - },
282   - {
283   - label: 'Flete:',
284   - valor: notaPedido.fob === 1 ? 'FOB' : (
285   - notaPedido.flete === 1 ? 'Si' : 'No')
286   - }
287   - ];
288   -
289   - function valorPrecioCondicion() {
290   - if(notaPedido.idPrecioCondicion > 0) {
291   - return notaPedido.precioCondicion.nombre;
292   - } else {
293   - return 'Ingreso Manual';
294   - }
295   - }
296   -
297   - if(notaPedido.flete === 1) {
298   - var cabeceraBomba = {
299   - label: 'Bomba:',
300   - valor: notaPedido.bomba === 1 ? 'Si' : 'No'
301   - };
302   - if(notaPedido.kilometros) {
303   - var cabeceraKilometros = {
304   - label: 'Kilometros:',
305   - valor: notaPedido.kilometros
306   - };
307   - cabeceras.push(cabeceraKilometros);
308   - }
309   - cabeceras.push(cabeceraBomba);
310   - }
311   -
312   - $scope.articulosTabla = notaPedido.articulosNotaPedido;
313   - notaPedidoBusinessService.calcularArticulos($scope.articulosTabla,
314   - notaPedido.cotizacion.VENDEDOR);
315   -
316   - if(notaPedido.idPrecioCondicion > 0) {
317   - $scope.idLista = notaPedido.precioCondicion.idListaPrecio;
318   - } else {
319   - $scope.idLista = -1;
320   - }
321   -
322   - $scope.puntoVenta = $filter('rellenarDigitos')(
323   - notaPedido.sucursal, 4
324   - );
325   -
326   - $scope.comprobante = $filter('rellenarDigitos')(
327   - notaPedido.numeroNotaPedido, 8
328   - );
329   -
330   - $scope.notaPedido = notaPedido;
331   - $scope.notaPedido.moneda = notaPedido.cotizacion.moneda;
332   - $scope.plazosPagos = notaPedido.notaPedidoPlazo;
333   - $scope.notaPedido.puntosDescarga =
334   - formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga);
335   - addArrayCabecera(cabeceras);
336   -
337   - }, function() {
338   - // funcion ejecutada cuando se cancela el modal
339   - }
340   - );
  247 + modalInstance.result.then(setearNotaPedido);
341 248 };
342 249  
343 250 $scope.seleccionarProductos = function() {
... ... @@ -355,7 +262,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
355 262 parametroProducto: {
356 263 idLista: $scope.idLista,
357 264 cotizacion: $scope.notaPedido.cotizacion.VENDEDOR,
358   - simbolo: $scope.notaPedido.moneda.SIMBOLO
  265 + simbolo: $scope.notaPedido.cotizacion.moneda.SIMBOLO
359 266 }
360 267 },
361 268 size: 'lg'
... ... @@ -370,7 +277,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
370 277 sector: producto.sector,
371 278 sectorCodigo: producto.sector + '-' + producto.codigo,
372 279 descripcion: producto.descripcion,
373   - item: $scope.articulosTabla.length + 1,
  280 + item: $scope.notaPedido.articulosNotaPedido.length + 1,
374 281 nombre: producto.descripcion,
375 282 precio: parseFloat(producto.precio.toFixed(4)),
376 283 costoUnitario: producto.costo,
... ... @@ -410,15 +317,15 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
410 317 filters: {
411 318 idDomicilio: $scope.notaPedido.domicilio.id,
412 319 idCliente: $scope.notaPedido.cliente.COD,
413   - articulos: $scope.articulosTabla,
414   - puntosDescarga: $scope.notaPedido.puntosDescarga
  320 + articulos: $scope.notaPedido.articulosNotaPedido,
  321 + puntosDescarga: $scope.notaPedido.notaPedidoPuntoDescarga
415 322 }
416 323 }
417 324 }
418 325 );
419 326 modalInstance.result.then(
420 327 function(puntosDescarga) {
421   - $scope.notaPedido.puntosDescarga = puntosDescarga;
  328 + $scope.notaPedido.notaPedidoPuntoDescarga = puntosDescarga;
422 329  
423 330 //AGREGO PUNTOS DE DESCARGA A CABECERA
424 331 var puntosStamp = '';
... ... @@ -567,7 +474,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
567 474 domicilio.Localidad + ', ' + domicilio.Provincia;
568 475 $scope.notaPedido.domicilioStamp = domicilioStamp;
569 476  
570   - $scope.notaPedido.puntosDescarga = domicilio.puntosDescarga;
  477 + $scope.notaPedido.notaPedidoPuntoDescarga = domicilio.puntosDescarga;
571 478  
572 479 $scope.$broadcast('addCabecera', {
573 480 label: 'Cliente:',
... ... @@ -596,9 +503,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
596 503  
597 504 $scope.getTotal = function() {
598 505 var total = 0;
599   -
600   - if ($scope.articulosTabla) {
601   - var arrayTempArticulos = $scope.articulosTabla;
  506 + if ($scope.notaPedido.articulosNotaPedido) {
  507 + var arrayTempArticulos = $scope.notaPedido.articulosNotaPedido;
602 508 for (var i = 0; i < arrayTempArticulos.length; i++) {
603 509 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
604 510 }
... ... @@ -628,8 +534,9 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
628 534 var cabecera = '';
629 535 var plazosConcat = '';
630 536 if(!Array.isArray(precioCondicion)) {
  537 + $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago;
  538 + $scope.notaPedido.precioCondicion = precioCondicion;
631 539 $scope.notaPedido.idPrecioCondicion = precioCondicion.id;
632   - $scope.plazosPagos = precioCondicion.plazoPago;
633 540 $scope.idLista = precioCondicion.idListaPrecio;
634 541 for(var i = 0; i < precioCondicion.plazoPago.length; i++) {
635 542 plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
... ... @@ -640,13 +547,13 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
640 547 $scope.notaPedido.idPrecioCondicion = 0;
641 548 //-1, el modal productos busca todos los productos
642 549 $scope.idLista = -1;
643   - $scope.plazosPagos = precioCondicion;
  550 + $scope.notaPedido.notaPedidoPlazo = precioCondicion;
644 551 for(var j = 0; j < precioCondicion.length; j++) {
645 552 plazosConcat += precioCondicion[j].dias + ' ';
646 553 }
647 554 cabecera = 'Ingreso manual ' + plazosConcat.trim();
648 555 }
649   - $scope.articulosTabla = [];
  556 + $scope.notaPedido.articulosNotaPedido = [];
650 557 $scope.$broadcast('addCabecera', {
651 558 label: 'Precios y condiciones:',
652 559 valor: cabecera
... ... @@ -766,21 +673,16 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
766 673 );
767 674 modalInstance.result.then(
768 675 function(cotizacion) {
769   - var articulosTablaTemp = $scope.articulosTabla;
770   -
  676 + var articulosTablaTemp = $scope.notaPedido.articulosNotaPedido || [];
771 677 for(var i = 0; i < articulosTablaTemp.length; i++) {
772 678 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
773 679 $scope.notaPedido.cotizacion.VENDEDOR;
774 680 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio /
775 681 cotizacion.VENDEDOR;
776 682 }
777   -
778   - $scope.articulosTabla = articulosTablaTemp;
779   - $scope.notaPedido.moneda = moneda;
780   - $scope.monedaDefecto = moneda;
781   - $scope.cotizacionDefecto = cotizacion;
  683 + $scope.notaPedido.articulosNotaPedido = articulosTablaTemp;
782 684 $scope.notaPedido.cotizacion = cotizacion;
783   -
  685 + $scope.notaPedido.cotizacion.moneda = moneda;
784 686 if(moneda.DETALLE === 'PESOS ARGENTINOS') {
785 687 $scope.$broadcast('removeCabecera', 'Moneda:');
786 688 $scope.$broadcast('removeCabecera', 'Fecha cotizacion:');
... ... @@ -814,13 +716,13 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
814 716 return;
815 717 }
816 718 delete $scope.articuloACargar.sectorCodigo;
817   - $scope.articulosTabla.push($scope.articuloACargar);
  719 + $scope.notaPedido.articulosNotaPedido.push($scope.articuloACargar);
818 720 $scope.cargando = true;
819 721 }
820 722 };
821 723  
822 724 $scope.quitarArticulo = function(key) {
823   - $scope.articulosTabla.splice(key, 1);
  725 + $scope.notaPedido.articulosNotaPedido.splice(key, 1);
824 726 };
825 727  
826 728 $scope.editarArticulo = function(key, articulo) {
... ... @@ -873,6 +775,116 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
873 775 articulo.precio = parseFloat(articulo.precio);
874 776 };
875 777  
  778 + function setearNotaPedido(notaPedido) {
  779 + //añado cabeceras
  780 + $scope.notaPedido = notaPedido;
  781 + $scope.$broadcast('removeCabecera', 'Bomba:');
  782 + $scope.$broadcast('removeCabecera', 'Kilometros:');
  783 +
  784 + var cabeceras = [];
  785 +
  786 + if (notaPedido.cotizacion) {
  787 + cabeceras.push({
  788 + label: 'Moneda:',
  789 + valor: notaPedido.cotizacion.moneda.DETALLE
  790 + });
  791 + cabeceras.push({
  792 + label: 'Fecha cotizacion:',
  793 + valor: $filter('date')(notaPedido.cotizacion.FECHA,
  794 + 'dd/MM/yyyy')
  795 + });
  796 + cabeceras.push({
  797 + label: 'Cotizacion:',
  798 + valor: $filter('number')(notaPedido.cotizacion.VENDEDOR,
  799 + '2')
  800 + });
  801 + }
  802 + if (notaPedido.cliente.COD) {
  803 + cabeceras.push({
  804 + label: 'Cliente:',
  805 + valor: notaPedido.cliente.NOM
  806 + });
  807 + cabeceras.push({
  808 + label: 'Domicilio:',
  809 + valor: notaPedido.domicilioStamp
  810 + });
  811 + }
  812 + if (notaPedido.vendedor.NUM) {
  813 + cabeceras.push({
  814 + label: 'Vendedor:',
  815 + valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) +
  816 + ' - ' + notaPedido.vendedor.NOM
  817 + });
  818 + }
  819 + if (notaPedido.proveedor.COD) {
  820 + cabeceras.push({
  821 + label: 'Proveedor:',
  822 + valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) +
  823 + ' - ' + notaPedido.proveedor.NOM
  824 + });
  825 + }
  826 + if (notaPedido.notaPedidoPlazo.length) {
  827 + cabeceras.push({
  828 + label: 'Precios y condiciones:',
  829 + valor: valorPrecioCondicion() + ' ' +
  830 + notaPedidoBusinessService
  831 + .plazoToString(notaPedido.notaPedidoPlazo)
  832 + });
  833 + }
  834 + if (notaPedido.flete !== undefined) {
  835 + cabeceras.push({
  836 + label: 'Flete:',
  837 + valor: notaPedido.fob === 1 ? 'FOB' : (
  838 + notaPedido.flete === 1 ? 'Si' : 'No')
  839 + });
  840 + }
  841 +
  842 +
  843 + function valorPrecioCondicion() {
  844 + if (notaPedido.idPrecioCondicion > 0) {
  845 + return notaPedido.precioCondicion.nombre;
  846 + } else {
  847 + return 'Ingreso Manual';
  848 + }
  849 + }
  850 +
  851 + if (notaPedido.flete === 1) {
  852 + var cabeceraBomba = {
  853 + label: 'Bomba:',
  854 + valor: notaPedido.bomba === 1 ? 'Si' : 'No'
  855 + };
  856 + if (notaPedido.kilometros) {
  857 + var cabeceraKilometros = {
  858 + label: 'Kilometros:',
  859 + valor: notaPedido.kilometros
  860 + };
  861 + cabeceras.push(cabeceraKilometros);
  862 + }
  863 + cabeceras.push(cabeceraBomba);
  864 + }
  865 +
  866 + notaPedidoBusinessService.calcularArticulos($scope.notaPedido.articulosNotaPedido,
  867 + notaPedido.cotizacion.VENDEDOR);
  868 +
  869 + if (notaPedido.idPrecioCondicion > 0) {
  870 + $scope.idLista = notaPedido.precioCondicion.idListaPrecio;
  871 + } else {
  872 + $scope.idLista = -1;
  873 + }
  874 +
  875 + $scope.puntoVenta = $filter('rellenarDigitos')(
  876 + notaPedido.sucursal, 4
  877 + );
  878 +
  879 + $scope.comprobante = $filter('rellenarDigitos')(
  880 + notaPedido.numeroNotaPedido, 8
  881 + );
  882 +
  883 + $scope.notaPedido.notaPedidoPuntoDescarga =
  884 + formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga || []);
  885 + addArrayCabecera(cabeceras);
  886 + }
  887 +
876 888 function addArrayCabecera(array) {
877 889 for(var i = 0; i < array.length; i++) {
878 890 $scope.$broadcast('addCabecera', {
... ... @@ -899,13 +911,13 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
899 911 return resultPunto.id === el.idPuntoDescarga;
900 912 });
901 913  
902   - if(puntoDescarga.length) {
  914 + if (puntoDescarga.length) {
903 915 puntoDescarga[0].articulosAgregados.push({
904 916 cantidad: el.cantidad,
905 917 descripcion: el.producto.descripcion,
906 918 id: el.producto.id
907 919 });
908   - }else {
  920 + } else {
909 921 result.push({
910 922 id: el.puntoDescarga.id,
911 923 id_cliente: el.puntoDescarga.id_cliente,
... ... @@ -929,11 +941,9 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
929 941 function salir() {
930 942 var confirmacion = false;
931 943  
932   - angular.forEach($scope.inicial, function(valor, key) {
933   - if (!angular.equals($scope[key], $scope.inicial[key])) {
934   - confirmacion = true;
935   - }
936   - });
  944 + if (!angular.equals($scope.notaPedido, $scope.inicial)) {
  945 + confirmacion = true;
  946 + }
937 947  
938 948 if (confirmacion) {
939 949 focaModalService.confirm(
... ... @@ -947,5 +957,13 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
947 957 $location.path('/');
948 958 }
949 959 }
  960 +
  961 + function getLSNotaPedido() {
  962 + var notaPedido = JSON.parse($localStorage.notaPedido || null);
  963 + if (notaPedido) {
  964 + setearNotaPedido(notaPedido);
  965 + delete $localStorage.notaPedido;
  966 + }
  967 + }
950 968 }
951 969 ]);
src/views/nota-pedido.html
... ... @@ -2,7 +2,7 @@
2 2 <foca-cabecera-facturador
3 3 titulo="'Nota de pedido'"
4 4 numero="puntoVenta + '-' + comprobante"
5   - fecha="now"
  5 + fecha="notaPedido.fechaCarga"
6 6 class="mb-0 col-lg-12"
7 7 busqueda="seleccionarNotaPedido"
8 8 ></foca-cabecera-facturador>
... ... @@ -47,8 +47,8 @@
47 47 </thead>
48 48 <tbody class="tabla-articulo-body">
49 49 <tr
50   - ng-repeat="(key, articulo) in articulosTabla"
51   - ng-show="show || key == (articulosTabla.length - 1)"
  50 + ng-repeat="(key, articulo) in notaPedido.articulosNotaPedido"
  51 + ng-show="show || key == (notaPedido.articulosNotaPedido.length - 1)"
52 52 class="d-flex"
53 53 >
54 54 <td ng-bind="key + 1"></td>
... ... @@ -127,7 +127,7 @@
127 127 <tr ng-show="!cargando" class="d-flex">
128 128 <td
129 129 class="align-middle"
130   - ng-bind="articulosTabla.length + 1"
  130 + ng-bind="notaPedido.articulosNotaPedido.length + 1"
131 131 ></td>
132 132 <td class="col">
133 133 <input
... ... @@ -193,7 +193,7 @@
193 193 <tr class="d-flex">
194 194 <td colspan="4" class="no-border-top">
195 195 <strong>Items:</strong>
196   - <a ng-bind="articulosTabla.length"></a>
  196 + <a ng-bind="notaPedido.articulosNotaPedido.length"></a>
197 197 </td>
198 198 <td class="text-right ml-auto table-celda-total no-border-top">
199 199 <h3>Total:</h3>
... ... @@ -237,8 +237,8 @@
237 237 </thead>
238 238 <tbody>
239 239 <tr
240   - ng-repeat="(key, articulo) in articulosTabla"
241   - ng-show="show || key == articulosTabla.length - 1"
  240 + ng-repeat="(key, articulo) in notaPedido.articulosNotaPedido"
  241 + ng-show="show || key == notaPedido.articulosNotaPedido.length - 1"
242 242 >
243 243 <td class="w-100 align-middle d-flex p-0">
244 244 <div class="align-middle p-1">
... ... @@ -309,7 +309,7 @@
309 309 <tr ng-show="!cargando" class="d-flex">
310 310 <td
311 311 class="align-middle p-1"
312   - ng-bind="articulosTabla.length + 1"
  312 + ng-bind="notaPedido.articulosNotaPedido.length + 1"
313 313 ></td>
314 314 <td class="col p-0">
315 315 <div class="d-flex">
... ... @@ -363,7 +363,7 @@
363 363 <button
364 364 class="btn btn-outline-light selectable w-100"
365 365 ng-click="show = !show; masMenos()"
366   - ng-show="articulosTabla.length > 0"
  366 + ng-show="notaPedido.articulosNotaPedido.length > 0"
367 367 >
368 368 <i
369 369 class="fa fa-chevron-down"
... ... @@ -383,7 +383,7 @@
383 383 <tr class="d-flex">
384 384 <td class="align-middle no-border-top" colspan="2">
385 385 <strong>Cantidad Items:</strong>
386   - <a ng-bind="articulosTabla.length"></a>
  386 + <a ng-bind="notaPedido.articulosNotaPedido.length"></a>
387 387 </td>
388 388 <td class="text-right ml-auto table-celda-total no-border-top">
389 389 <h3>Total:</h3>