Commit 59681a9dabc0a5704c8a81362f2ea055037a3b2e
1 parent
3b8f25490c
Exists in
master
ok specs
Showing
3 changed files
with
183 additions
and
76 deletions
Show diff stats
.gitignore
spec/controllerSpec.js
... | ... | @@ -25,7 +25,8 @@ describe('controladores módulo crear cobranza', function() { |
25 | 25 | //act |
26 | 26 | var controlador = $controller('cobranzaController', { |
27 | 27 | $scope: { |
28 | - $broadcast: function() { } | |
28 | + $broadcast: function() { }, | |
29 | + $watch: function() { } | |
29 | 30 | }, |
30 | 31 | $timeout: $timeout, |
31 | 32 | $uibModal: {}, |
... | ... | @@ -48,7 +49,8 @@ describe('controladores módulo crear cobranza', function() { |
48 | 49 | focaSeguimientoService: {}, |
49 | 50 | focaBotoneraLateralService: {}, |
50 | 51 | APP: {}, |
51 | - focaLoginService: {} | |
52 | + focaLoginService: {}, | |
53 | + $localStorage: true | |
52 | 54 | }); |
53 | 55 | |
54 | 56 | //assert |
... | ... | @@ -59,7 +61,8 @@ describe('controladores módulo crear cobranza', function() { |
59 | 61 | |
60 | 62 | //arrange |
61 | 63 | var scope = { |
62 | - $broadcast: function() { } | |
64 | + $broadcast: function() { }, | |
65 | + $watch: function() { } | |
63 | 66 | }; |
64 | 67 | var focaModalService = { |
65 | 68 | alert: function() { } |
... | ... | @@ -88,7 +91,8 @@ describe('controladores módulo crear cobranza', function() { |
88 | 91 | focaSeguimientoService: {}, |
89 | 92 | focaBotoneraLateralService: {}, |
90 | 93 | APP: {}, |
91 | - focaLoginService: {} | |
94 | + focaLoginService: {}, | |
95 | + $localStorage: true | |
92 | 96 | }); |
93 | 97 | |
94 | 98 | //act |
... | ... | @@ -103,7 +107,8 @@ describe('controladores módulo crear cobranza', function() { |
103 | 107 | |
104 | 108 | //arrange |
105 | 109 | var scope = { |
106 | - $broadcast: function() { } | |
110 | + $broadcast: function() { }, | |
111 | + $watch: function() { } | |
107 | 112 | }; |
108 | 113 | var focaModalService = { |
109 | 114 | alert: function() { } |
... | ... | @@ -132,10 +137,14 @@ describe('controladores módulo crear cobranza', function() { |
132 | 137 | focaSeguimientoService: {}, |
133 | 138 | focaBotoneraLateralService: {}, |
134 | 139 | APP: {}, |
135 | - focaLoginService: {} | |
140 | + focaLoginService: {}, | |
141 | + $localStorage: true | |
136 | 142 | }); |
137 | 143 | scope.cobranza = { |
138 | - cliente: { } | |
144 | + cliente: { | |
145 | + COD: true | |
146 | + }, | |
147 | + cobrador: {} | |
139 | 148 | }; |
140 | 149 | |
141 | 150 | //act |
... | ... | @@ -150,7 +159,8 @@ describe('controladores módulo crear cobranza', function() { |
150 | 159 | |
151 | 160 | //arrange |
152 | 161 | var scope = { |
153 | - $broadcast: function() { } | |
162 | + $broadcast: function() { }, | |
163 | + $watch: function() { } | |
154 | 164 | }; |
155 | 165 | var focaModalService = { |
156 | 166 | alert: function() { } |
... | ... | @@ -179,11 +189,17 @@ describe('controladores módulo crear cobranza', function() { |
179 | 189 | focaSeguimientoService: {}, |
180 | 190 | focaBotoneraLateralService: {}, |
181 | 191 | APP: {}, |
182 | - focaLoginService: {} | |
192 | + focaLoginService: {}, | |
193 | + $localStorage: true | |
183 | 194 | }); |
184 | 195 | scope.cobranza = { |
185 | - cliente: { }, | |
186 | - cobrador: { } | |
196 | + cliente: { | |
197 | + COD: true | |
198 | + }, | |
199 | + cobrador: { | |
200 | + NUM: true | |
201 | + }, | |
202 | + facturas: [] | |
187 | 203 | }; |
188 | 204 | |
189 | 205 | //act |
... | ... | @@ -198,7 +214,8 @@ describe('controladores módulo crear cobranza', function() { |
198 | 214 | |
199 | 215 | //arrange |
200 | 216 | var scope = { |
201 | - $broadcast: function() { } | |
217 | + $broadcast: function() { }, | |
218 | + $watch: function() { } | |
202 | 219 | }; |
203 | 220 | var focaModalService = { |
204 | 221 | alert: function() { } |
... | ... | @@ -227,12 +244,20 @@ describe('controladores módulo crear cobranza', function() { |
227 | 244 | focaSeguimientoService: {}, |
228 | 245 | focaBotoneraLateralService: {}, |
229 | 246 | APP: {}, |
230 | - focaLoginService: {} | |
247 | + focaLoginService: {}, | |
248 | + $localStorage: true | |
231 | 249 | }); |
232 | 250 | scope.cobranza = { |
233 | - cliente: {}, | |
234 | - cobrador: {}, | |
235 | - moneda: { SIMBOLO: '' } | |
251 | + cliente: { | |
252 | + COD: true | |
253 | + }, | |
254 | + cobrador: { | |
255 | + NUM: true | |
256 | + }, | |
257 | + cotizacion: { | |
258 | + moneda: { SIMBOLO: '' }, | |
259 | + }, | |
260 | + facturas: [1] | |
236 | 261 | }; |
237 | 262 | scope.facturaTabla = [1]; |
238 | 263 | |
... | ... | @@ -250,7 +275,8 @@ describe('controladores módulo crear cobranza', function() { |
250 | 275 | |
251 | 276 | //arrange |
252 | 277 | var scope = { |
253 | - $broadcast: function() { } | |
278 | + $broadcast: function() { }, | |
279 | + $watch: function() { } | |
254 | 280 | }; |
255 | 281 | var focaBotoneraLateralService = { |
256 | 282 | startGuardar: function() { } |
... | ... | @@ -276,20 +302,48 @@ describe('controladores módulo crear cobranza', function() { |
276 | 302 | $uibModal: {}, |
277 | 303 | $location: {}, |
278 | 304 | focaCrearCobranzaService: focaCrearCobranzaService, |
279 | - focaModalService: {}, | |
305 | + focaModalService: { | |
306 | + alert: function() {} | |
307 | + }, | |
280 | 308 | $filter: $filter, |
281 | 309 | focaSeguimientoService: {}, |
282 | 310 | focaBotoneraLateralService: focaBotoneraLateralService, |
283 | 311 | APP: {}, |
284 | - focaLoginService: {} | |
312 | + focaLoginService: {}, | |
313 | + $localStorage: true | |
285 | 314 | }); |
286 | 315 | scope.cobranza = { |
287 | - cliente: {}, | |
288 | - cobrador: {}, | |
289 | - moneda: { SIMBOLO: '' }, | |
290 | - cotizacion: {} | |
316 | + cliente: { | |
317 | + COD: true | |
318 | + }, | |
319 | + cobrador: { | |
320 | + NUM: true | |
321 | + }, | |
322 | + cotizacion: { | |
323 | + moneda: { | |
324 | + ID: true, | |
325 | + SIMBOLO: '' | |
326 | + } | |
327 | + }, | |
328 | + facturas: [1], | |
329 | + cobros: [{ | |
330 | + fecha: new Date(), | |
331 | + fechaPresentacion: new Date(), | |
332 | + fechaEmision: new Date(), | |
333 | + tipo: true, | |
334 | + banco: { | |
335 | + ID: true | |
336 | + }, | |
337 | + localidad: { | |
338 | + ID: true, | |
339 | + NOMBRE: true | |
340 | + }, | |
341 | + provincia: { | |
342 | + ID: true | |
343 | + } | |
344 | + }], | |
345 | + fecha: new Date() | |
291 | 346 | }; |
292 | - scope.facturaTabla = [1]; | |
293 | 347 | |
294 | 348 | //act |
295 | 349 | spyOn(focaBotoneraLateralService, 'startGuardar'); |
... | ... | @@ -308,7 +362,8 @@ describe('controladores módulo crear cobranza', function() { |
308 | 362 | |
309 | 363 | //arrange |
310 | 364 | var scope = { |
311 | - $broadcast: function() { } | |
365 | + $broadcast: function() { }, | |
366 | + $watch: function() { } | |
312 | 367 | }; |
313 | 368 | |
314 | 369 | $controller('cobranzaController', { |
... | ... | @@ -334,7 +389,8 @@ describe('controladores módulo crear cobranza', function() { |
334 | 389 | focaSeguimientoService: {}, |
335 | 390 | focaBotoneraLateralService: {}, |
336 | 391 | APP: {}, |
337 | - focaLoginService: {} | |
392 | + focaLoginService: {}, | |
393 | + $localStorage: true | |
338 | 394 | }); |
339 | 395 | |
340 | 396 | //act |
... | ... | @@ -348,7 +404,8 @@ describe('controladores módulo crear cobranza', function() { |
348 | 404 | |
349 | 405 | //arrange |
350 | 406 | var scope = { |
351 | - $broadcast: function() { } | |
407 | + $broadcast: function() { }, | |
408 | + $watch: function() { } | |
352 | 409 | }; |
353 | 410 | |
354 | 411 | $controller('cobranzaController', { |
... | ... | @@ -374,7 +431,8 @@ describe('controladores módulo crear cobranza', function() { |
374 | 431 | focaSeguimientoService: {}, |
375 | 432 | focaBotoneraLateralService: {}, |
376 | 433 | APP: {}, |
377 | - focaLoginService: {} | |
434 | + focaLoginService: {}, | |
435 | + $localStorage: true | |
378 | 436 | }); |
379 | 437 | |
380 | 438 | //act |
... | ... | @@ -388,7 +446,8 @@ describe('controladores módulo crear cobranza', function() { |
388 | 446 | |
389 | 447 | //arrange |
390 | 448 | var scope = { |
391 | - $broadcast: function() { } | |
449 | + $broadcast: function() { }, | |
450 | + $watch: function() { } | |
392 | 451 | }; |
393 | 452 | var uibModal = { |
394 | 453 | open: function() { } |
... | ... | @@ -417,7 +476,8 @@ describe('controladores módulo crear cobranza', function() { |
417 | 476 | focaSeguimientoService: {}, |
418 | 477 | focaBotoneraLateralService: {}, |
419 | 478 | APP: {}, |
420 | - focaLoginService: {} | |
479 | + focaLoginService: {}, | |
480 | + $localStorage: true | |
421 | 481 | }); |
422 | 482 | var respuesta = { facturas: 1, cobros: 2, cliente: { } }; |
423 | 483 | var promesa = { result: Promise.resolve(respuesta) }; |
... | ... | @@ -431,8 +491,8 @@ describe('controladores módulo crear cobranza', function() { |
431 | 491 | promesa.result.then(function() { |
432 | 492 | expect(uibModal.open).toHaveBeenCalled(); |
433 | 493 | expect(scope.$broadcast).toHaveBeenCalledWith('cleanCabecera'); |
434 | - expect(scope.facturaTabla).toEqual(respuesta.facturas); | |
435 | - expect(scope.cobrosTabla).toEqual(respuesta.cobros); | |
494 | + expect(scope.cobranza.facturas).toEqual(respuesta.facturas); | |
495 | + expect(scope.cobranza.cobros).toEqual(respuesta.cobros); | |
436 | 496 | done(); |
437 | 497 | }); |
438 | 498 | }); |
... | ... | @@ -441,7 +501,8 @@ describe('controladores módulo crear cobranza', function() { |
441 | 501 | |
442 | 502 | //arrange |
443 | 503 | var scope = { |
444 | - $broadcast: function() { } | |
504 | + $broadcast: function() { }, | |
505 | + $watch: function() { } | |
445 | 506 | }; |
446 | 507 | var uibModal = { |
447 | 508 | open: function() { } |
... | ... | @@ -470,7 +531,8 @@ describe('controladores módulo crear cobranza', function() { |
470 | 531 | focaSeguimientoService: {}, |
471 | 532 | focaBotoneraLateralService: {}, |
472 | 533 | APP: {}, |
473 | - focaLoginService: {} | |
534 | + focaLoginService: {}, | |
535 | + $localStorage: true | |
474 | 536 | }); |
475 | 537 | scope.cobranza = { |
476 | 538 | cobrador: {} |
... | ... | @@ -495,7 +557,8 @@ describe('controladores módulo crear cobranza', function() { |
495 | 557 | |
496 | 558 | //arrange |
497 | 559 | var scope = { |
498 | - $broadcast: function() { } | |
560 | + $broadcast: function() { }, | |
561 | + $watch: function() { } | |
499 | 562 | }; |
500 | 563 | var focaModalService = { |
501 | 564 | alert: function() { } |
... | ... | @@ -504,7 +567,15 @@ describe('controladores módulo crear cobranza', function() { |
504 | 567 | $controller('cobranzaController', { |
505 | 568 | $scope: scope, |
506 | 569 | $timeout: $timeout, |
507 | - $uibModal: {}, | |
570 | + $uibModal: { | |
571 | + open: function() { | |
572 | + return { | |
573 | + result: { | |
574 | + then: function() { } | |
575 | + } | |
576 | + }; | |
577 | + } | |
578 | + }, | |
508 | 579 | $location: {}, |
509 | 580 | focaCrearCobranzaService: { |
510 | 581 | getCotizacionByIdMoneda: function() { |
... | ... | @@ -524,7 +595,8 @@ describe('controladores módulo crear cobranza', function() { |
524 | 595 | focaSeguimientoService: {}, |
525 | 596 | focaBotoneraLateralService: {}, |
526 | 597 | APP: {}, |
527 | - focaLoginService: {} | |
598 | + focaLoginService: {}, | |
599 | + $localStorage: true | |
528 | 600 | }); |
529 | 601 | |
530 | 602 | //act |
... | ... | @@ -539,7 +611,8 @@ describe('controladores módulo crear cobranza', function() { |
539 | 611 | |
540 | 612 | //arrange |
541 | 613 | var scope = { |
542 | - $broadcast: function() { } | |
614 | + $broadcast: function() { }, | |
615 | + $watch: function() { } | |
543 | 616 | }; |
544 | 617 | var uibModal = { |
545 | 618 | open: function() { } |
... | ... | @@ -563,15 +636,20 @@ describe('controladores módulo crear cobranza', function() { |
563 | 636 | }; |
564 | 637 | } |
565 | 638 | }, |
566 | - focaModalService: {}, | |
639 | + focaModalService: { | |
640 | + alert: function() {} | |
641 | + }, | |
567 | 642 | $filter: $filter, |
568 | 643 | focaSeguimientoService: {}, |
569 | 644 | focaBotoneraLateralService: {}, |
570 | 645 | APP: {}, |
571 | - focaLoginService: {} | |
646 | + focaLoginService: {}, | |
647 | + $localStorage: true | |
572 | 648 | }); |
573 | 649 | scope.cobranza = { |
574 | - cliente: { } | |
650 | + cliente: { | |
651 | + COD: true | |
652 | + } | |
575 | 653 | }; |
576 | 654 | |
577 | 655 | var respuesta = { result: { then: function() { } } }; |
... | ... | @@ -588,7 +666,8 @@ describe('controladores módulo crear cobranza', function() { |
588 | 666 | |
589 | 667 | //arrange |
590 | 668 | var scope = { |
591 | - $broadcast: function() { } | |
669 | + $broadcast: function() { }, | |
670 | + $watch: function() { } | |
592 | 671 | }; |
593 | 672 | var uibModal = { |
594 | 673 | open: function() { } |
... | ... | @@ -617,7 +696,8 @@ describe('controladores módulo crear cobranza', function() { |
617 | 696 | focaSeguimientoService: {}, |
618 | 697 | focaBotoneraLateralService: {}, |
619 | 698 | APP: {}, |
620 | - focaLoginService: {} | |
699 | + focaLoginService: {}, | |
700 | + $localStorage: true | |
621 | 701 | }); |
622 | 702 | scope.cobranza = { |
623 | 703 | cliente: { } |
... | ... | @@ -637,7 +717,8 @@ describe('controladores módulo crear cobranza', function() { |
637 | 717 | |
638 | 718 | //arrange |
639 | 719 | var scope = { |
640 | - $broadcast: function() { } | |
720 | + $broadcast: function() { }, | |
721 | + $watch: function() { } | |
641 | 722 | }; |
642 | 723 | var uibModal = { |
643 | 724 | open: function() { } |
... | ... | @@ -666,7 +747,8 @@ describe('controladores módulo crear cobranza', function() { |
666 | 747 | focaSeguimientoService: {}, |
667 | 748 | focaBotoneraLateralService: {}, |
668 | 749 | APP: {}, |
669 | - focaLoginService: {} | |
750 | + focaLoginService: {}, | |
751 | + $localStorage: true | |
670 | 752 | }); |
671 | 753 | scope.cobranza = { |
672 | 754 | cliente: { } |
... | ... | @@ -686,7 +768,8 @@ describe('controladores módulo crear cobranza', function() { |
686 | 768 | |
687 | 769 | //arrange |
688 | 770 | var scope = { |
689 | - $broadcast: function() { } | |
771 | + $broadcast: function() { }, | |
772 | + $watch: function() { } | |
690 | 773 | }; |
691 | 774 | var uibModal = { |
692 | 775 | open: function() { } |
... | ... | @@ -715,7 +798,8 @@ describe('controladores módulo crear cobranza', function() { |
715 | 798 | focaSeguimientoService: {}, |
716 | 799 | focaBotoneraLateralService: {}, |
717 | 800 | APP: {}, |
718 | - focaLoginService: {} | |
801 | + focaLoginService: {}, | |
802 | + $localStorage: true | |
719 | 803 | }); |
720 | 804 | scope.cobranza = { |
721 | 805 | cliente: { } |
... | ... | @@ -735,7 +819,8 @@ describe('controladores módulo crear cobranza', function() { |
735 | 819 | |
736 | 820 | //arrange |
737 | 821 | var scope = { |
738 | - $broadcast: function() { } | |
822 | + $broadcast: function() { }, | |
823 | + $watch: function() { } | |
739 | 824 | }; |
740 | 825 | var focaModalService = { |
741 | 826 | modal: function() { } |
... | ... | @@ -764,7 +849,8 @@ describe('controladores módulo crear cobranza', function() { |
764 | 849 | focaSeguimientoService: {}, |
765 | 850 | focaBotoneraLateralService: {}, |
766 | 851 | APP: {}, |
767 | - focaLoginService: {} | |
852 | + focaLoginService: {}, | |
853 | + $localStorage: true | |
768 | 854 | }); |
769 | 855 | |
770 | 856 | var respuesta = 1; |
... | ... | @@ -787,7 +873,8 @@ describe('controladores módulo crear cobranza', function() { |
787 | 873 | |
788 | 874 | //arrange |
789 | 875 | var scope = { |
790 | - $broadcast: function() { } | |
876 | + $broadcast: function() { }, | |
877 | + $watch: function() { } | |
791 | 878 | }; |
792 | 879 | var uibModal = { |
793 | 880 | open: function() { } |
... | ... | @@ -816,7 +903,8 @@ describe('controladores módulo crear cobranza', function() { |
816 | 903 | focaSeguimientoService: {}, |
817 | 904 | focaBotoneraLateralService: {}, |
818 | 905 | APP: {}, |
819 | - focaLoginService: {} | |
906 | + focaLoginService: {}, | |
907 | + $localStorage: true | |
820 | 908 | }); |
821 | 909 | |
822 | 910 | var respuesta = 1; |
... | ... | @@ -840,7 +928,8 @@ describe('controladores módulo crear cobranza', function() { |
840 | 928 | |
841 | 929 | //arrange |
842 | 930 | var scope = { |
843 | - $broadcast: function() { } | |
931 | + $broadcast: function() { }, | |
932 | + $watch: function() { } | |
844 | 933 | }; |
845 | 934 | var focaModalService = { |
846 | 935 | modal: function() { } |
... | ... | @@ -869,7 +958,8 @@ describe('controladores módulo crear cobranza', function() { |
869 | 958 | focaSeguimientoService: {}, |
870 | 959 | focaBotoneraLateralService: {}, |
871 | 960 | APP: {}, |
872 | - focaLoginService: {} | |
961 | + focaLoginService: {}, | |
962 | + $localStorage: true | |
873 | 963 | }); |
874 | 964 | |
875 | 965 | var respuesta = 1; |
... | ... | @@ -893,7 +983,8 @@ describe('controladores módulo crear cobranza', function() { |
893 | 983 | |
894 | 984 | //arrange |
895 | 985 | var scope = { |
896 | - $broadcast: function() { } | |
986 | + $broadcast: function() { }, | |
987 | + $watch: function() { } | |
897 | 988 | }; |
898 | 989 | |
899 | 990 | $controller('cobranzaController', { |
... | ... | @@ -919,9 +1010,12 @@ describe('controladores módulo crear cobranza', function() { |
919 | 1010 | focaSeguimientoService: {}, |
920 | 1011 | focaBotoneraLateralService: {}, |
921 | 1012 | APP: {}, |
922 | - focaLoginService: {} | |
1013 | + focaLoginService: {}, | |
1014 | + $localStorage: true | |
923 | 1015 | }); |
924 | - scope.facturaTabla = [{ IPA: 1 }]; | |
1016 | + scope.cobranza = { | |
1017 | + facturas: [{ IPA: 1 }] | |
1018 | + }; | |
925 | 1019 | |
926 | 1020 | //act |
927 | 1021 | var esperado = 1; |
... | ... | @@ -935,7 +1029,8 @@ describe('controladores módulo crear cobranza', function() { |
935 | 1029 | |
936 | 1030 | //arrange |
937 | 1031 | var scope = { |
938 | - $broadcast: function() { } | |
1032 | + $broadcast: function() { }, | |
1033 | + $watch: function() { } | |
939 | 1034 | }; |
940 | 1035 | |
941 | 1036 | $controller('cobranzaController', { |
... | ... | @@ -961,9 +1056,12 @@ describe('controladores módulo crear cobranza', function() { |
961 | 1056 | focaSeguimientoService: {}, |
962 | 1057 | focaBotoneraLateralService: {}, |
963 | 1058 | APP: {}, |
964 | - focaLoginService: {} | |
1059 | + focaLoginService: {}, | |
1060 | + $localStorage: true | |
965 | 1061 | }); |
966 | - scope.cobrosTabla = [{ importe: 1 }]; | |
1062 | + scope.cobranza = { | |
1063 | + cobros: [{ importe: 1 }] | |
1064 | + }; | |
967 | 1065 | |
968 | 1066 | //act |
969 | 1067 | var esperado = 1; |
... | ... | @@ -977,7 +1075,8 @@ describe('controladores módulo crear cobranza', function() { |
977 | 1075 | |
978 | 1076 | //arrange |
979 | 1077 | var scope = { |
980 | - $broadcast: function() { } | |
1078 | + $broadcast: function() { }, | |
1079 | + $watch: function() { } | |
981 | 1080 | }; |
982 | 1081 | |
983 | 1082 | $controller('cobranzaController', { |
... | ... | @@ -1003,7 +1102,8 @@ describe('controladores módulo crear cobranza', function() { |
1003 | 1102 | focaSeguimientoService: {}, |
1004 | 1103 | focaBotoneraLateralService: {}, |
1005 | 1104 | APP: {}, |
1006 | - focaLoginService: {} | |
1105 | + focaLoginService: {}, | |
1106 | + $localStorage: true | |
1007 | 1107 | }); |
1008 | 1108 | scope.articuloACargar = { |
1009 | 1109 | precio: 2, |
... | ... | @@ -1024,7 +1124,8 @@ describe('controladores módulo crear cobranza', function() { |
1024 | 1124 | |
1025 | 1125 | //arrange |
1026 | 1126 | var scope = { |
1027 | - $broadcast: function() { } | |
1127 | + $broadcast: function() { }, | |
1128 | + $watch: function() { } | |
1028 | 1129 | }; |
1029 | 1130 | |
1030 | 1131 | $controller('cobranzaController', { |
... | ... | @@ -1050,7 +1151,8 @@ describe('controladores módulo crear cobranza', function() { |
1050 | 1151 | focaSeguimientoService: {}, |
1051 | 1152 | focaBotoneraLateralService: {}, |
1052 | 1153 | APP: {}, |
1053 | - focaLoginService: {} | |
1154 | + focaLoginService: {}, | |
1155 | + $localStorage: true | |
1054 | 1156 | }); |
1055 | 1157 | |
1056 | 1158 | //act |
... | ... | @@ -1065,7 +1167,8 @@ describe('controladores módulo crear cobranza', function() { |
1065 | 1167 | |
1066 | 1168 | //arrange |
1067 | 1169 | var scope = { |
1068 | - $broadcast: function() { } | |
1170 | + $broadcast: function() { }, | |
1171 | + $watch: function() { } | |
1069 | 1172 | }; |
1070 | 1173 | |
1071 | 1174 | $controller('cobranzaController', { |
... | ... | @@ -1091,7 +1194,8 @@ describe('controladores módulo crear cobranza', function() { |
1091 | 1194 | focaSeguimientoService: {}, |
1092 | 1195 | focaBotoneraLateralService: {}, |
1093 | 1196 | APP: {}, |
1094 | - focaLoginService: {} | |
1197 | + focaLoginService: {}, | |
1198 | + $localStorage: true | |
1095 | 1199 | }); |
1096 | 1200 | |
1097 | 1201 | var parametro = { |
src/js/controller.js
... | ... | @@ -57,9 +57,11 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
57 | 57 | |
58 | 58 | $scope.cobranza = { |
59 | 59 | fecha: new Date(), |
60 | - cotizacion: $scope.cotizacionPorDefecto, | |
60 | + cotizacion: {}, | |
61 | 61 | facturas: [], |
62 | - cobros: [] | |
62 | + cobros: [], | |
63 | + cliente: {}, | |
64 | + cobrador: {} | |
63 | 65 | }; |
64 | 66 | |
65 | 67 | if (APP === 'cobranza') { |
... | ... | @@ -108,19 +110,19 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
108 | 110 | }, true); |
109 | 111 | |
110 | 112 | $scope.crearCobranza = function() { |
111 | - if(!$scope.cobranza.cliente) { | |
113 | + if (!$scope.cobranza.cliente.COD) { | |
112 | 114 | focaModalService.alert('Ingrese Cliente'); |
113 | 115 | return; |
114 | 116 | } |
115 | - if(!$scope.cobranza.cobrador) { | |
117 | + if (!$scope.cobranza.cobrador.NUM) { | |
116 | 118 | focaModalService.alert('Ingrese Cobrador'); |
117 | 119 | return; |
118 | 120 | } |
119 | - if($scope.cobranza.facturas.length < 1) { | |
121 | + if ($scope.cobranza.facturas.length < 1) { | |
120 | 122 | focaModalService.alert('Ingrese al menos una factura'); |
121 | 123 | return; |
122 | 124 | } |
123 | - if($scope.getTotalCobrado() + $scope.getTotalDeuda() !== 0) { | |
125 | + if ($scope.getTotalCobrado() + $scope.getTotalDeuda() !== 0) { | |
124 | 126 | focaModalService.alert('La diferencia debe ser ' + |
125 | 127 | $scope.cobranza.cotizacion.moneda.SIMBOLO + '0,00'); |
126 | 128 | return; |
... | ... | @@ -391,7 +393,7 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
391 | 393 | }; |
392 | 394 | |
393 | 395 | $scope.seleccionarFactura = function() { |
394 | - if(!$scope.cobranza.cliente) { | |
396 | + if(!$scope.cobranza.cliente.COD) { | |
395 | 397 | focaModalService.alert('Seleccione primero un cliente'); |
396 | 398 | return; |
397 | 399 | } |
... | ... | @@ -573,11 +575,11 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
573 | 575 | function(cotizacion) { |
574 | 576 | $scope.cobranza.cotizacion.moneda = moneda; |
575 | 577 | $scope.cobranza.cotizacion = cotizacion; |
576 | - if(moneda.DETALLE === 'PESOS ARGENTINOS') { | |
578 | + if (moneda.DETALLE === 'PESOS ARGENTINOS') { | |
577 | 579 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
578 | 580 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
579 | 581 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
580 | - }else { | |
582 | + } else { | |
581 | 583 | $scope.$broadcast('addCabecera', { |
582 | 584 | label: 'Moneda:', |
583 | 585 | valor: moneda.DETALLE |
... | ... | @@ -708,14 +710,14 @@ angular.module('focaCrearCobranza') .controller('cobranzaController', |
708 | 710 | $scope.editando = true; |
709 | 711 | $scope.$broadcast('cleanCabecera'); |
710 | 712 | |
711 | - if(cobranza.cliente) { | |
713 | + if (cobranza.cliente) { | |
712 | 714 | $scope.$broadcast('addCabecera', { |
713 | 715 | label: 'Cliente:', |
714 | 716 | valor: $filter('rellenarDigitos')(cobranza.cliente.COD, 5) + ' - ' + |
715 | 717 | cobranza.cliente.NOM |
716 | 718 | }); |
717 | 719 | } |
718 | - if(cobranza.cobrador.NUM) { | |
720 | + if (cobranza.cobrador && cobranza.cobrador.NUM) { | |
719 | 721 | $scope.$broadcast('addCabecera', { |
720 | 722 | label: 'Cobrador:', |
721 | 723 | valor: (cobranza.cobrador.NUM) ? |