Commit af3ab502a34c23e03c957fad4b3fd6ed028f3f03
Exists in
master
and in
1 other branch
Merge branch 'master' into 'develop'
Master See merge request !54
Showing
4 changed files
Show diff stats
spec/controllerSpec.js
... | ... | @@ -652,58 +652,6 @@ describe('Controladores módulo crear nota de pedido', function() { |
652 | 652 | }); |
653 | 653 | }); |
654 | 654 | |
655 | - it('función seleccionarCliente abre alerta cuando no se elije vendedor', function() { | |
656 | - //arrange | |
657 | - var scope = { | |
658 | - $watch: function() { }, | |
659 | - $broadcast: function() { } | |
660 | - }; | |
661 | - var focaModalService = { | |
662 | - alert: function() { } | |
663 | - }; | |
664 | - | |
665 | - $controler('notaPedidoCtrl', { | |
666 | - $scope: scope, | |
667 | - $uibModal: {}, | |
668 | - $location: {}, | |
669 | - $filter: filter, | |
670 | - $timeout: timeout, | |
671 | - crearNotaPedidoService: { | |
672 | - getNumeroNotaPedido: function() { | |
673 | - return { | |
674 | - then: function() { } | |
675 | - }; | |
676 | - }, | |
677 | - getBotonera: function() { }, | |
678 | - getCotizacionByIdMoneda: function() { | |
679 | - return { | |
680 | - then: function() { } | |
681 | - }; | |
682 | - } | |
683 | - }, | |
684 | - focaBotoneraLateralService: {}, | |
685 | - focaModalService: focaModalService, | |
686 | - notaPedidoBusinessService: {}, | |
687 | - $rootScope: { | |
688 | - $on: function() { } | |
689 | - }, | |
690 | - focaSeguimientoService: {}, | |
691 | - APP: {}, | |
692 | - focaLoginService: {}, | |
693 | - $localStorage: {} | |
694 | - }); | |
695 | - scope.notaPedido = { | |
696 | - vendedor: { NUM: false } | |
697 | - }; | |
698 | - | |
699 | - //act | |
700 | - spyOn(focaModalService, 'alert'); | |
701 | - scope.seleccionarCliente(); | |
702 | - | |
703 | - //assert | |
704 | - expect(focaModalService.alert).toHaveBeenCalledWith('Primero seleccione un vendedor'); | |
705 | - }); | |
706 | - | |
707 | 655 | it('función seleccionarCliente abre modal', function() { |
708 | 656 | //arrange |
709 | 657 | var scope = { |
... | ... | @@ -731,17 +679,34 @@ describe('Controladores módulo crear nota de pedido', function() { |
731 | 679 | return { |
732 | 680 | then: function() { } |
733 | 681 | }; |
682 | + }, | |
683 | + getVendedorById: function() { | |
684 | + return { | |
685 | + then: function() { } | |
686 | + }; | |
734 | 687 | } |
735 | 688 | }, |
736 | 689 | focaBotoneraLateralService: {}, |
737 | - focaModalService: {}, | |
690 | + focaModalService: { | |
691 | + modal: function() { | |
692 | + return { | |
693 | + then: function() {} | |
694 | + }; | |
695 | + } | |
696 | + }, | |
738 | 697 | notaPedidoBusinessService: {}, |
739 | 698 | $rootScope: { |
740 | 699 | $on: function() { } |
741 | 700 | }, |
742 | 701 | focaSeguimientoService: {}, |
743 | - APP: {}, | |
744 | - focaLoginService: {}, | |
702 | + APP: 'distribuidor', | |
703 | + focaLoginService: { | |
704 | + getLoginData: function() { | |
705 | + return { | |
706 | + vendedorCorbrador: true | |
707 | + }; | |
708 | + } | |
709 | + }, | |
745 | 710 | $localStorage: {} |
746 | 711 | }); |
747 | 712 | scope.notaPedido = { |
... | ... | @@ -763,7 +728,9 @@ describe('Controladores módulo crear nota de pedido', function() { |
763 | 728 | //arrange |
764 | 729 | var scope = { |
765 | 730 | $watch: function() { }, |
766 | - $broadcast: function() { } | |
731 | + $broadcast: function() { }, | |
732 | + seleccionarVendedor: function() { }, | |
733 | + notaPedido: {} | |
767 | 734 | }; |
768 | 735 | var uibModal = { |
769 | 736 | open: function() { } |
... | ... | @@ -786,17 +753,34 @@ describe('Controladores módulo crear nota de pedido', function() { |
786 | 753 | return { |
787 | 754 | then: function() { } |
788 | 755 | }; |
756 | + }, | |
757 | + getVendedorById : function() { | |
758 | + return { | |
759 | + then: function() { } | |
760 | + }; | |
789 | 761 | } |
790 | 762 | }, |
791 | 763 | focaBotoneraLateralService: {}, |
792 | - focaModalService: {}, | |
764 | + focaModalService: { | |
765 | + modal: function() { | |
766 | + return { | |
767 | + then: function() { } | |
768 | + }; | |
769 | + } | |
770 | + }, | |
793 | 771 | notaPedidoBusinessService: {}, |
794 | 772 | $rootScope: { |
795 | 773 | $on: function() { } |
796 | 774 | }, |
797 | 775 | focaSeguimientoService: {}, |
798 | - APP: {}, | |
799 | - focaLoginService: {}, | |
776 | + APP: 'distribuidor', | |
777 | + focaLoginService: { | |
778 | + getLoginData: function() { | |
779 | + return { | |
780 | + vendedorCorbrador: true | |
781 | + }; | |
782 | + } | |
783 | + }, | |
800 | 784 | $localStorage: {} |
801 | 785 | }); |
802 | 786 | scope.idLista = true; |
... | ... | @@ -1163,126 +1147,6 @@ describe('Controladores módulo crear nota de pedido', function() { |
1163 | 1147 | }); |
1164 | 1148 | }); |
1165 | 1149 | |
1166 | - it('función seleccionarFlete abre modal', function() { | |
1167 | - | |
1168 | - //arrange | |
1169 | - var scope = { | |
1170 | - $watch: function() { }, | |
1171 | - $broadcast: function() { } | |
1172 | - }; | |
1173 | - var uibModal = { | |
1174 | - open: function() { } | |
1175 | - }; | |
1176 | - | |
1177 | - $controler('notaPedidoCtrl', { | |
1178 | - $scope: scope, | |
1179 | - $uibModal: uibModal, | |
1180 | - $location: {}, | |
1181 | - $filter: filter, | |
1182 | - $timeout: timeout, | |
1183 | - crearNotaPedidoService: { | |
1184 | - getNumeroNotaPedido: function() { | |
1185 | - return { | |
1186 | - then: function() { } | |
1187 | - }; | |
1188 | - }, | |
1189 | - getBotonera: function() { }, | |
1190 | - getCotizacionByIdMoneda: function() { | |
1191 | - return { | |
1192 | - then: function() { } | |
1193 | - }; | |
1194 | - } | |
1195 | - }, | |
1196 | - focaBotoneraLateralService: {}, | |
1197 | - focaModalService: {}, | |
1198 | - notaPedidoBusinessService: {}, | |
1199 | - $rootScope: { | |
1200 | - $on: function() { } | |
1201 | - }, | |
1202 | - focaSeguimientoService: {}, | |
1203 | - APP: {}, | |
1204 | - focaLoginService: {}, | |
1205 | - $localStorage: {} | |
1206 | - }); | |
1207 | - | |
1208 | - scope.notaPedido = {}; | |
1209 | - | |
1210 | - var respuesta = { result: {then: function() { } } }; | |
1211 | - | |
1212 | - //act | |
1213 | - spyOn(uibModal, 'open').and.returnValue(respuesta); | |
1214 | - scope.seleccionarFlete(); | |
1215 | - | |
1216 | - //assert | |
1217 | - expect(uibModal.open).toHaveBeenCalled(); | |
1218 | - }); | |
1219 | - | |
1220 | - it('función seleccionarFlete setea flete y cabecera', function(done) { | |
1221 | - | |
1222 | - //arrange | |
1223 | - var scope = { | |
1224 | - $watch: function() { }, | |
1225 | - $broadcast: function() { } | |
1226 | - }; | |
1227 | - var uibModal = { | |
1228 | - open: function() { } | |
1229 | - }; | |
1230 | - | |
1231 | - $controler('notaPedidoCtrl', { | |
1232 | - $scope: scope, | |
1233 | - $uibModal: uibModal, | |
1234 | - $location: {}, | |
1235 | - $filter: filter, | |
1236 | - $timeout: timeout, | |
1237 | - crearNotaPedidoService: { | |
1238 | - getNumeroNotaPedido: function() { | |
1239 | - return { | |
1240 | - then: function() { } | |
1241 | - }; | |
1242 | - }, | |
1243 | - getBotonera: function() { }, | |
1244 | - getCotizacionByIdMoneda: function() { | |
1245 | - return { | |
1246 | - then: function() { } | |
1247 | - }; | |
1248 | - } | |
1249 | - }, | |
1250 | - focaBotoneraLateralService: {}, | |
1251 | - focaModalService: {}, | |
1252 | - notaPedidoBusinessService: {}, | |
1253 | - $rootScope: { | |
1254 | - $on: function() { } | |
1255 | - }, | |
1256 | - focaSeguimientoService: {}, | |
1257 | - APP: {}, | |
1258 | - focaLoginService: {}, | |
1259 | - $localStorage: {} | |
1260 | - }); | |
1261 | - scope.idLista = true; | |
1262 | - scope.notaPedido = { | |
1263 | - vendedor: { NUM: true } | |
1264 | - }; | |
1265 | - var respuesta = { flete: 1, FOB: 2, bomba: 3, kilometros: 4 }; | |
1266 | - var promesaRespuesta = { result: Promise.resolve(respuesta) }; | |
1267 | - scope.$broadcast = function() { }; | |
1268 | - | |
1269 | - //act | |
1270 | - spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); | |
1271 | - spyOn(scope, '$broadcast'); | |
1272 | - scope.seleccionarFlete(); | |
1273 | - | |
1274 | - //assert | |
1275 | - | |
1276 | - promesaRespuesta.result.then(function() { | |
1277 | - expect(scope.notaPedido.flete).toEqual(respuesta.flete); | |
1278 | - expect(scope.notaPedido.fob).toEqual(respuesta.FOB); | |
1279 | - expect(scope.notaPedido.bomba).toEqual(respuesta.bomba); | |
1280 | - expect(scope.notaPedido.kilometros).toEqual(respuesta.kilometros); | |
1281 | - expect(scope.$broadcast).toHaveBeenCalled(); | |
1282 | - done(); | |
1283 | - }); | |
1284 | - }); | |
1285 | - | |
1286 | 1150 | it('función seleccionarMoneda abre modal', function() { |
1287 | 1151 | //arrange |
1288 | 1152 | var scope = { |
spec/controllerSpecCrearPedido.js
... | ... | @@ -64,63 +64,6 @@ describe('Controladores módulo crear nota de pedido', function() { |
64 | 64 | expect(typeof controlador).toEqual('object'); |
65 | 65 | }); |
66 | 66 | |
67 | - it('la funcion $scope.crearNotaPedido muestra alerta cuando vendedor es null', function() { | |
68 | - | |
69 | - //arrange | |
70 | - var scope = { | |
71 | - $watch: function() { }, | |
72 | - $broadcast: function() {} | |
73 | - }; | |
74 | - var focaModalService = { | |
75 | - alert: function() { } | |
76 | - }; | |
77 | - | |
78 | - $controler('notaPedidoCtrl', { | |
79 | - $scope: scope, | |
80 | - $uibModal: {}, | |
81 | - $location: {}, | |
82 | - $filter: filter, | |
83 | - $timeout: timeout, | |
84 | - crearNotaPedidoService: { | |
85 | - getNumeroNotaPedido: function() { | |
86 | - return { | |
87 | - then: function() { } | |
88 | - }; | |
89 | - }, | |
90 | - getBotonera: function() { }, | |
91 | - getCotizacionByIdMoneda: function() { | |
92 | - return { | |
93 | - then: function() {} | |
94 | - }; | |
95 | - } | |
96 | - }, | |
97 | - focaBotoneraLateralService: {}, | |
98 | - focaModalService: focaModalService, | |
99 | - notaPedidoBusinessService: {}, | |
100 | - $rootScope: { | |
101 | - $on: function() { } | |
102 | - }, | |
103 | - focaSeguimientoService: {}, | |
104 | - APP: {}, | |
105 | - focaLoginService: {}, | |
106 | - $localStorage: {}, | |
107 | - $watch: function() { }, | |
108 | - $broadcast: function() {} | |
109 | - }); | |
110 | - | |
111 | - //act | |
112 | - scope.notaPedido = { | |
113 | - vendedor: { | |
114 | - id: null | |
115 | - } | |
116 | - }; | |
117 | - spyOn(focaModalService, 'alert'); | |
118 | - scope.crearNotaPedido(); | |
119 | - | |
120 | - //expect | |
121 | - expect(focaModalService.alert).toHaveBeenCalledWith('Ingrese Vendedor'); | |
122 | - }); | |
123 | - | |
124 | 67 | it('la funcion $scope.crearNotaPedido muestra alerta cuando cliente es null', function() { |
125 | 68 | |
126 | 69 | //arrange |
src/js/controller.js
... | ... | @@ -341,6 +341,65 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
341 | 341 | } |
342 | 342 | }; |
343 | 343 | |
344 | + $scope.seleccionarTransportista = function() { | |
345 | + $scope.seleccionarProveedor(function() { | |
346 | + if (validarNotaRemitada()) { | |
347 | + var modalInstance = $uibModal.open( | |
348 | + { | |
349 | + ariaLabelledBy: 'Busqueda de Flete', | |
350 | + templateUrl: 'modal-flete.html', | |
351 | + controller: 'focaModalFleteController', | |
352 | + size: 'lg', | |
353 | + resolve: { | |
354 | + parametrosFlete: | |
355 | + function() { | |
356 | + return { | |
357 | + flete: $scope.notaPedido.fob ? 'FOB' : | |
358 | + ( $scope.notaPedido.flete ? '1' : | |
359 | + ($scope.notaPedido.flete === undefined ? | |
360 | + null : '0')), | |
361 | + bomba: $scope.notaPedido.bomba ? '1' : | |
362 | + ($scope.notaPedido.bomba === undefined ? | |
363 | + null : '0'), | |
364 | + kilometros: $scope.notaPedido.kilometros | |
365 | + }; | |
366 | + } | |
367 | + } | |
368 | + } | |
369 | + ); | |
370 | + modalInstance.result.then( | |
371 | + function(datos) { | |
372 | + $scope.notaPedido.flete = datos.flete; | |
373 | + $scope.notaPedido.fob = datos.FOB; | |
374 | + $scope.notaPedido.bomba = datos.bomba; | |
375 | + $scope.notaPedido.kilometros = datos.kilometros; | |
376 | + $scope.$broadcast('addCabecera', { | |
377 | + label: 'Flete:', | |
378 | + valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') | |
379 | + }); | |
380 | + if (datos.flete) { | |
381 | + $scope.$broadcast('addCabecera', { | |
382 | + label: 'Bomba:', | |
383 | + valor: datos.bomba ? 'Si' : 'No' | |
384 | + }); | |
385 | + $scope.$broadcast('addCabecera', { | |
386 | + label: 'Kilometros:', | |
387 | + valor: datos.kilometros | |
388 | + }); | |
389 | + } else { | |
390 | + $scope.$broadcast('removeCabecera', 'Bomba:'); | |
391 | + $scope.$broadcast('removeCabecera', 'Kilometros:'); | |
392 | + $scope.notaPedido.bomba = false; | |
393 | + $scope.notaPedido.kilometros = null; | |
394 | + } | |
395 | + }, function() { | |
396 | + $scope.seleccionarTransportista(); | |
397 | + } | |
398 | + ); | |
399 | + } | |
400 | + }); | |
401 | + }; | |
402 | + | |
344 | 403 | $scope.seleccionarVendedor = function(callback, ocultarVendedor) { |
345 | 404 | if (APP === 'distribuidor' || ocultarVendedor) { |
346 | 405 | callback(); |
... | ... | @@ -384,10 +443,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
384 | 443 | |
385 | 444 | $scope.seleccionarCliente = function(ocultarVendedor) { |
386 | 445 | $scope.seleccionarVendedor(function() { |
387 | - if (!$scope.notaPedido.vendedor.NUM) { | |
388 | - focaModalService.alert('Primero seleccione un vendedor'); | |
389 | - return; | |
390 | - } | |
391 | 446 | if (validarNotaRemitada()) { |
392 | 447 | var modalInstance = $uibModal.open( |
393 | 448 | { |
... | ... | @@ -413,7 +468,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
413 | 468 | }, ocultarVendedor); |
414 | 469 | }; |
415 | 470 | |
416 | - $scope.seleccionarProveedor = function() { | |
471 | + $scope.seleccionarProveedor = function(callback) { | |
417 | 472 | if(validarNotaRemitada()) { |
418 | 473 | var parametrosModal = { |
419 | 474 | titulo: 'Búsqueda de Proveedor', |
... | ... | @@ -447,6 +502,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
447 | 502 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
448 | 503 | proveedor.NOM |
449 | 504 | }); |
505 | + callback(); | |
450 | 506 | }, function() { |
451 | 507 | |
452 | 508 | } |
... | ... | @@ -571,63 +627,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
571 | 627 | } |
572 | 628 | }; |
573 | 629 | |
574 | - $scope.seleccionarFlete = function() { | |
575 | - if(validarNotaRemitada()) { | |
576 | - var modalInstance = $uibModal.open( | |
577 | - { | |
578 | - ariaLabelledBy: 'Busqueda de Flete', | |
579 | - templateUrl: 'modal-flete.html', | |
580 | - controller: 'focaModalFleteController', | |
581 | - size: 'lg', | |
582 | - resolve: { | |
583 | - parametrosFlete: | |
584 | - function() { | |
585 | - return { | |
586 | - flete: $scope.notaPedido.fob ? 'FOB' : | |
587 | - ( $scope.notaPedido.flete ? '1' : | |
588 | - ($scope.notaPedido.flete === undefined ? | |
589 | - null : '0')), | |
590 | - bomba: $scope.notaPedido.bomba ? '1' : | |
591 | - ($scope.notaPedido.bomba === undefined ? | |
592 | - null : '0'), | |
593 | - kilometros: $scope.notaPedido.kilometros | |
594 | - }; | |
595 | - } | |
596 | - } | |
597 | - } | |
598 | - ); | |
599 | - modalInstance.result.then( | |
600 | - function(datos) { | |
601 | - $scope.notaPedido.flete = datos.flete; | |
602 | - $scope.notaPedido.fob = datos.FOB; | |
603 | - $scope.notaPedido.bomba = datos.bomba; | |
604 | - $scope.notaPedido.kilometros = datos.kilometros; | |
605 | - $scope.$broadcast('addCabecera', { | |
606 | - label: 'Flete:', | |
607 | - valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') | |
608 | - }); | |
609 | - if(datos.flete) { | |
610 | - $scope.$broadcast('addCabecera', { | |
611 | - label: 'Bomba:', | |
612 | - valor: datos.bomba ? 'Si' : 'No' | |
613 | - }); | |
614 | - $scope.$broadcast('addCabecera', { | |
615 | - label: 'Kilometros:', | |
616 | - valor: datos.kilometros | |
617 | - }); | |
618 | - } else { | |
619 | - $scope.$broadcast('removeCabecera', 'Bomba:'); | |
620 | - $scope.$broadcast('removeCabecera', 'Kilometros:'); | |
621 | - $scope.notaPedido.bomba = false; | |
622 | - $scope.notaPedido.kilometros = null; | |
623 | - } | |
624 | - }, function() { | |
625 | - | |
626 | - } | |
627 | - ); | |
628 | - } | |
629 | - }; | |
630 | - | |
631 | 630 | $scope.seleccionarMoneda = function() { |
632 | 631 | if(validarNotaRemitada()) { |
633 | 632 | var parametrosModal = { |
src/js/service.js
... | ... | @@ -62,7 +62,7 @@ angular.module('focaCrearNotaPedido') |
62 | 62 | image: 'cliente.png' |
63 | 63 | }, |
64 | 64 | { |
65 | - label: 'Proveedor', | |
65 | + label: 'Transportista', | |
66 | 66 | image: 'proveedor.png' |
67 | 67 | }, |
68 | 68 | { |
... | ... | @@ -74,10 +74,6 @@ angular.module('focaCrearNotaPedido') |
74 | 74 | image: 'precios-condiciones.png' |
75 | 75 | }, |
76 | 76 | { |
77 | - label: 'Flete', | |
78 | - image: 'flete.png' | |
79 | - }, | |
80 | - { | |
81 | 77 | label: 'Productos', |
82 | 78 | image: 'productos.png' |
83 | 79 | }, |