Commit 28a0de6a8c590504e1c1e616f3609d532dffc7a4
Exists in
master
and in
1 other branch
Merge branch 'develop' into 'master'
Develop See merge request !58
Showing
5 changed files
Show diff stats
package.json
... | ... | @@ -28,10 +28,7 @@ |
28 | 28 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", |
29 | 29 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", |
30 | 30 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", |
31 | - "foca-modal-moneda": "git+http://git.focasoftware.com/npm/foca-modal-moneda.git", | |
32 | 31 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", |
33 | - "foca-modal-proveedor": "git+http://git.focasoftware.com/npm/foca-modal-proveedor.git", | |
34 | - "foca-modal-vendedores": "git+http://git.focasoftware.com/npm/foca-modal-vendedores.git", | |
35 | 32 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git" |
36 | 33 | }, |
37 | 34 | "devDependencies": { |
... | ... | @@ -47,10 +44,7 @@ |
47 | 44 | "foca-modal-cotizacion": "git+http://git.focasoftware.com/npm/foca-modal-cotizacion.git", |
48 | 45 | "foca-modal-domicilio": "git+http://git.focasoftware.com/npm/foca-modal-domicilio.git", |
49 | 46 | "foca-modal-flete": "git+http://git.focasoftware.com/npm/foca-modal-flete.git", |
50 | - "foca-modal-moneda": "git+http://git.focasoftware.com/npm/foca-modal-moneda.git", | |
51 | 47 | "foca-modal-precio-condiciones": "git+http://git.focasoftware.com/npm/foca-modal-precio-condiciones.git", |
52 | - "foca-modal-proveedor": "git+http://git.focasoftware.com/npm/foca-modal-proveedor.git", | |
53 | - "foca-modal-vendedores": "git+http://git.focasoftware.com/npm/foca-modal-vendedores.git", | |
54 | 48 | "foca-seguimiento": "git+http://git.focasoftware.com/npm/foca-seguimiento.git", |
55 | 49 | "font-awesome": "^4.7.0", |
56 | 50 | "gulp": "^3.9.1", |
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
... | ... | @@ -28,6 +28,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
28 | 28 | $scope.datepickerAbierto = false; |
29 | 29 | $scope.show = false; |
30 | 30 | $scope.cargando = true; |
31 | + $scope.botonera = crearNotaPedidoService.getBotonera(); | |
31 | 32 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
32 | 33 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
33 | 34 | $scope.dateOptions = { |
... | ... | @@ -46,9 +47,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
46 | 47 | // SETEA BOTONERA DE FACTURADOR TENIENDO EN CUENTA SI ESTA SETEADO EL VENDEDOR |
47 | 48 | if (APP === 'distribuidor') { |
48 | 49 | $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; |
49 | - $scope.botonera = crearNotaPedidoService.getBotonera($scope.idVendedor); | |
50 | - } else { | |
51 | - $scope.botonera = crearNotaPedidoService.getBotonera(); | |
52 | 50 | } |
53 | 51 | |
54 | 52 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
... | ... | @@ -117,7 +115,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
117 | 115 | $scope.inicial = angular.copy($scope.notaPedido); |
118 | 116 | } |
119 | 117 | |
120 | - $scope.$watch('notaPedido', function(newValue, oldValue) { | |
118 | + $scope.$watch('notaPedido', function(newValue) { | |
121 | 119 | focaBotoneraLateralService.setPausarData({ |
122 | 120 | label: 'notaPedido', |
123 | 121 | val: newValue |
... | ... | @@ -125,10 +123,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
125 | 123 | }, true); |
126 | 124 | |
127 | 125 | $scope.crearNotaPedido = function() { |
128 | - if (!$scope.notaPedido.vendedor.id) { | |
129 | - focaModalService.alert('Ingrese Vendedor'); | |
130 | - return; | |
131 | - } else if (!$scope.notaPedido.cliente.COD) { | |
126 | + if (!$scope.notaPedido.cliente.COD) { | |
132 | 127 | focaModalService.alert('Ingrese Cliente'); |
133 | 128 | return; |
134 | 129 | } else if (!$scope.notaPedido.proveedor.COD) { |
... | ... | @@ -159,7 +154,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
159 | 154 | $scope.saveLoading = true; |
160 | 155 | var notaPedido = { |
161 | 156 | id: $scope.notaPedido.id, |
162 | - fechaCarga: new Date($scope.notaPedido.fechaCarga).toISOString().slice(0, 19).replace('T', ' '), | |
157 | + fechaCarga: new Date($scope.notaPedido.fechaCarga) | |
158 | + .toISOString().slice(0, 19).replace('T', ' '), | |
163 | 159 | idVendedor: $scope.notaPedido.vendedor.id, |
164 | 160 | idCliente: $scope.notaPedido.cliente.COD, |
165 | 161 | nombreCliente: $scope.notaPedido.cliente.NOM, |
... | ... | @@ -236,7 +232,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
236 | 232 | resolve: { |
237 | 233 | usadoPor: function() {return 'notaPedido';}, |
238 | 234 | idVendedor: function() { |
239 | - if(APP === 'distribuidor') | |
235 | + if (APP === 'distribuidor') | |
240 | 236 | return $scope.notaPedido.vendedor.id; |
241 | 237 | else |
242 | 238 | return null; |
... | ... | @@ -303,10 +299,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
303 | 299 | }; |
304 | 300 | |
305 | 301 | $scope.seleccionarPuntosDeDescarga = function() { |
306 | - if(!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { | |
302 | + if (!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { | |
307 | 303 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
308 | 304 | return; |
309 | - }else { | |
305 | + } else { | |
310 | 306 | var modalInstance = $uibModal.open( |
311 | 307 | { |
312 | 308 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
... | ... | @@ -331,7 +327,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
331 | 327 | var puntosStamp = ''; |
332 | 328 | puntosDescarga.forEach(function(punto, idx, arr) { |
333 | 329 | puntosStamp += punto.descripcion; |
334 | - if((idx + 1) !== arr.length) puntosStamp += ', '; | |
330 | + if ((idx + 1) !== arr.length) puntosStamp += ', '; | |
335 | 331 | }); |
336 | 332 | |
337 | 333 | $scope.$broadcast('addCabecera', { |
... | ... | @@ -345,8 +341,72 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
345 | 341 | } |
346 | 342 | }; |
347 | 343 | |
348 | - $scope.seleccionarVendedor = function() { | |
349 | - if(validarNotaRemitada()) { | |
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 | + | |
403 | + $scope.seleccionarVendedor = function(callback, ocultarVendedor) { | |
404 | + if (APP === 'distribuidor' || ocultarVendedor) { | |
405 | + callback(); | |
406 | + return; | |
407 | + } | |
408 | + | |
409 | + if (validarNotaRemitada()) { | |
350 | 410 | var parametrosModal = { |
351 | 411 | titulo: 'Búsqueda vendedores', |
352 | 412 | query: '/vendedor', |
... | ... | @@ -374,15 +434,42 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
374 | 434 | vendedor.NOM |
375 | 435 | }); |
376 | 436 | $scope.notaPedido.vendedor = vendedor; |
377 | - }, function() { | |
378 | - | |
379 | - } | |
437 | + deleteCliente(); | |
438 | + callback(); | |
439 | + }, function() {} | |
380 | 440 | ); |
381 | 441 | } |
382 | 442 | }; |
383 | 443 | |
384 | - $scope.seleccionarProveedor = function() { | |
385 | - if(validarNotaRemitada()) { | |
444 | + $scope.seleccionarCliente = function(ocultarVendedor) { | |
445 | + $scope.seleccionarVendedor(function() { | |
446 | + if (validarNotaRemitada()) { | |
447 | + var modalInstance = $uibModal.open( | |
448 | + { | |
449 | + ariaLabelledBy: 'Busqueda de Cliente', | |
450 | + templateUrl: 'foca-busqueda-cliente-modal.html', | |
451 | + controller: 'focaBusquedaClienteModalController', | |
452 | + resolve: { | |
453 | + vendedor: function() { return $scope.notaPedido.vendedor; }, | |
454 | + cobrador: function() { return null; } | |
455 | + }, | |
456 | + size: 'lg' | |
457 | + } | |
458 | + ); | |
459 | + modalInstance.result.then( | |
460 | + function(cliente) { | |
461 | + $scope.abrirModalDomicilios(cliente); | |
462 | + $scope.cliente = cliente; | |
463 | + }, function() { | |
464 | + if (APP !== 'distribuidor') $scope.seleccionarCliente(); | |
465 | + } | |
466 | + ); | |
467 | + } | |
468 | + }, ocultarVendedor); | |
469 | + }; | |
470 | + | |
471 | + $scope.seleccionarProveedor = function(callback) { | |
472 | + if (validarNotaRemitada()) { | |
386 | 473 | var parametrosModal = { |
387 | 474 | titulo: 'Búsqueda de Proveedor', |
388 | 475 | query: '/proveedor', |
... | ... | @@ -415,6 +502,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
415 | 502 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
416 | 503 | proveedor.NOM |
417 | 504 | }); |
505 | + callback(); | |
418 | 506 | }, function() { |
419 | 507 | |
420 | 508 | } |
... | ... | @@ -422,32 +510,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
422 | 510 | } |
423 | 511 | }; |
424 | 512 | |
425 | - $scope.seleccionarCliente = function() { | |
426 | - if(!$scope.notaPedido.vendedor.NUM) { | |
427 | - focaModalService.alert('Primero seleccione un vendedor'); | |
428 | - return; | |
429 | - } | |
430 | - if(validarNotaRemitada()) { | |
431 | - var modalInstance = $uibModal.open( | |
432 | - { | |
433 | - ariaLabelledBy: 'Busqueda de Cliente', | |
434 | - templateUrl: 'foca-busqueda-cliente-modal.html', | |
435 | - controller: 'focaBusquedaClienteModalController', | |
436 | - resolve: { | |
437 | - vendedor: function() { return $scope.notaPedido.vendedor; } | |
438 | - }, | |
439 | - size: 'lg' | |
440 | - } | |
441 | - ); | |
442 | - modalInstance.result.then( | |
443 | - function(cliente) { | |
444 | - $scope.abrirModalDomicilios(cliente); | |
445 | - $scope.cliente = cliente; | |
446 | - }, function() {} | |
447 | - ); | |
448 | - } | |
449 | - }; | |
450 | - | |
451 | 513 | $scope.abrirModalDomicilios = function(cliente) { |
452 | 514 | var modalInstanceDomicilio = $uibModal.open( |
453 | 515 | { |
... | ... | @@ -467,7 +529,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
467 | 529 | $scope.notaPedido.cliente = { |
468 | 530 | COD: cliente.cod, |
469 | 531 | CUIT: cliente.cuit, |
470 | - NOM: cliente.nom | |
532 | + NOM: cliente.nom, | |
533 | + MOD: cliente.mod | |
471 | 534 | }; |
472 | 535 | var domicilioStamp = |
473 | 536 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
... | ... | @@ -484,18 +547,18 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
484 | 547 | label: 'Domicilio:', |
485 | 548 | valor: domicilioStamp |
486 | 549 | }); |
487 | - if(domicilio.verPuntos) { | |
550 | + if (domicilio.verPuntos) { | |
488 | 551 | delete $scope.notaPedido.domicilio.verPuntos; |
489 | 552 | $scope.seleccionarPuntosDeDescarga(); |
490 | - }else { | |
553 | + } else { | |
491 | 554 | crearNotaPedidoService |
492 | 555 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
493 | 556 | .then(function(res) { |
494 | - if(res.data.length) $scope.seleccionarPuntosDeDescarga(); | |
557 | + if (res.data.length) $scope.seleccionarPuntosDeDescarga(); | |
495 | 558 | }); |
496 | 559 | } |
497 | 560 | }, function() { |
498 | - $scope.seleccionarCliente(); | |
561 | + $scope.seleccionarCliente(true); | |
499 | 562 | return; |
500 | 563 | } |
501 | 564 | ); |
... | ... | @@ -514,31 +577,40 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
514 | 577 | }; |
515 | 578 | |
516 | 579 | $scope.getSubTotal = function() { |
517 | - if($scope.articuloACargar) { | |
580 | + if ($scope.articuloACargar) { | |
518 | 581 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
519 | 582 | } |
520 | 583 | }; |
521 | 584 | |
522 | 585 | $scope.seleccionarPreciosYCondiciones = function() { |
586 | + if (!$scope.notaPedido.cliente.COD) { | |
587 | + focaModalService.alert('Primero seleccione un cliente'); | |
588 | + return; | |
589 | + } | |
523 | 590 | if(validarNotaRemitada()) { |
524 | 591 | var modalInstance = $uibModal.open( |
525 | 592 | { |
526 | 593 | ariaLabelledBy: 'Busqueda de Precio Condición', |
527 | 594 | templateUrl: 'modal-precio-condicion.html', |
528 | 595 | controller: 'focaModalPrecioCondicionController', |
529 | - size: 'lg' | |
596 | + size: 'lg', | |
597 | + resolve: { | |
598 | + idListaPrecio: function() { | |
599 | + return $scope.notaPedido.cliente.MOD || null; | |
600 | + } | |
601 | + } | |
530 | 602 | } |
531 | 603 | ); |
532 | 604 | modalInstance.result.then( |
533 | 605 | function(precioCondicion) { |
534 | 606 | var cabecera = ''; |
535 | 607 | var plazosConcat = ''; |
536 | - if(!Array.isArray(precioCondicion)) { | |
608 | + if (!Array.isArray(precioCondicion)) { | |
537 | 609 | $scope.notaPedido.notaPedidoPlazo = precioCondicion.plazoPago; |
538 | 610 | $scope.notaPedido.precioCondicion = precioCondicion; |
539 | 611 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; |
540 | 612 | $scope.idLista = precioCondicion.idListaPrecio; |
541 | - for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | |
613 | + for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | |
542 | 614 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
543 | 615 | } |
544 | 616 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + |
... | ... | @@ -548,7 +620,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
548 | 620 | //-1, el modal productos busca todos los productos |
549 | 621 | $scope.idLista = -1; |
550 | 622 | $scope.notaPedido.notaPedidoPlazo = precioCondicion; |
551 | - for(var j = 0; j < precioCondicion.length; j++) { | |
623 | + for (var j = 0; j < precioCondicion.length; j++) { | |
552 | 624 | plazosConcat += precioCondicion[j].dias + ' '; |
553 | 625 | } |
554 | 626 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
... | ... | @@ -565,65 +637,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
565 | 637 | } |
566 | 638 | }; |
567 | 639 | |
568 | - $scope.seleccionarFlete = function() { | |
569 | - if(validarNotaRemitada()) { | |
570 | - var modalInstance = $uibModal.open( | |
571 | - { | |
572 | - ariaLabelledBy: 'Busqueda de Flete', | |
573 | - templateUrl: 'modal-flete.html', | |
574 | - controller: 'focaModalFleteController', | |
575 | - size: 'lg', | |
576 | - resolve: { | |
577 | - parametrosFlete: | |
578 | - function() { | |
579 | - return { | |
580 | - flete: $scope.notaPedido.fob ? 'FOB' : | |
581 | - ( $scope.notaPedido.flete ? '1' : | |
582 | - ($scope.notaPedido.flete === undefined ? | |
583 | - null : '0')), | |
584 | - bomba: $scope.notaPedido.bomba ? '1' : | |
585 | - ($scope.notaPedido.bomba === undefined ? | |
586 | - null : '0'), | |
587 | - kilometros: $scope.notaPedido.kilometros | |
588 | - }; | |
589 | - } | |
590 | - } | |
591 | - } | |
592 | - ); | |
593 | - modalInstance.result.then( | |
594 | - function(datos) { | |
595 | - $scope.notaPedido.flete = datos.flete; | |
596 | - $scope.notaPedido.fob = datos.FOB; | |
597 | - $scope.notaPedido.bomba = datos.bomba; | |
598 | - $scope.notaPedido.kilometros = datos.kilometros; | |
599 | - $scope.$broadcast('addCabecera', { | |
600 | - label: 'Flete:', | |
601 | - valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') | |
602 | - }); | |
603 | - if(datos.flete) { | |
604 | - $scope.$broadcast('addCabecera', { | |
605 | - label: 'Bomba:', | |
606 | - valor: datos.bomba ? 'Si' : 'No' | |
607 | - }); | |
608 | - $scope.$broadcast('addCabecera', { | |
609 | - label: 'Kilometros:', | |
610 | - valor: datos.kilometros | |
611 | - }); | |
612 | - } else { | |
613 | - $scope.$broadcast('removeCabecera', 'Bomba:'); | |
614 | - $scope.$broadcast('removeCabecera', 'Kilometros:'); | |
615 | - $scope.notaPedido.bomba = false; | |
616 | - $scope.notaPedido.kilometros = null; | |
617 | - } | |
618 | - }, function() { | |
619 | - | |
620 | - } | |
621 | - ); | |
622 | - } | |
623 | - }; | |
624 | - | |
625 | 640 | $scope.seleccionarMoneda = function() { |
626 | - if(validarNotaRemitada()) { | |
641 | + if (validarNotaRemitada()) { | |
627 | 642 | var parametrosModal = { |
628 | 643 | titulo: 'Búsqueda de monedas', |
629 | 644 | query: '/moneda', |
... | ... | @@ -650,9 +665,20 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
650 | 665 | }; |
651 | 666 | |
652 | 667 | $scope.seleccionarObservaciones = function() { |
668 | + var observacion = { | |
669 | + titulo: 'Ingrese Observaciones', | |
670 | + value: $scope.notaPedido.observaciones, | |
671 | + maxlength: 155, | |
672 | + textarea: true | |
673 | + }; | |
674 | + | |
653 | 675 | focaModalService |
654 | - .prompt('Ingrese observaciones', $scope.notaPedido.observaciones, true) | |
676 | + .prompt(observacion) | |
655 | 677 | .then(function(observaciones) { |
678 | + $scope.$broadcast('addCabecera', { | |
679 | + label: 'Observaciones:', | |
680 | + valor: observaciones | |
681 | + }); | |
656 | 682 | $scope.notaPedido.observaciones = observaciones; |
657 | 683 | }); |
658 | 684 | }; |
... | ... | @@ -674,7 +700,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
674 | 700 | modalInstance.result.then( |
675 | 701 | function(cotizacion) { |
676 | 702 | var articulosTablaTemp = $scope.notaPedido.articulosNotaPedido || []; |
677 | - for(var i = 0; i < articulosTablaTemp.length; i++) { | |
703 | + for (var i = 0; i < articulosTablaTemp.length; i++) { | |
678 | 704 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
679 | 705 | $scope.notaPedido.cotizacion.VENDEDOR; |
680 | 706 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
... | ... | @@ -683,7 +709,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
683 | 709 | $scope.notaPedido.articulosNotaPedido = articulosTablaTemp; |
684 | 710 | $scope.notaPedido.cotizacion = cotizacion; |
685 | 711 | $scope.notaPedido.cotizacion.moneda = moneda; |
686 | - if(moneda.DETALLE === 'PESOS ARGENTINOS') { | |
712 | + if (moneda.DETALLE === 'PESOS ARGENTINOS') { | |
687 | 713 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
688 | 714 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
689 | 715 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
... | ... | @@ -708,8 +734,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
708 | 734 | }; |
709 | 735 | |
710 | 736 | $scope.agregarATabla = function(key) { |
711 | - if(key === 13) { | |
712 | - if($scope.articuloACargar.cantidad === undefined || | |
737 | + if (key === 13) { | |
738 | + if ($scope.articuloACargar.cantidad === undefined || | |
713 | 739 | $scope.articuloACargar.cantidad === 0 || |
714 | 740 | $scope.articuloACargar.cantidad === null ) { |
715 | 741 | focaModalService.alert('El valor debe ser al menos 1'); |
... | ... | @@ -726,8 +752,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
726 | 752 | }; |
727 | 753 | |
728 | 754 | $scope.editarArticulo = function(key, articulo) { |
729 | - if(key === 13) { | |
730 | - if(articulo.cantidad === null || articulo.cantidad === 0 || | |
755 | + if (key === 13) { | |
756 | + if (articulo.cantidad === null || articulo.cantidad === 0 || | |
731 | 757 | articulo.cantidad === undefined) { |
732 | 758 | focaModalService.alert('El valor debe ser al menos 1'); |
733 | 759 | return; |
... | ... | @@ -738,9 +764,9 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
738 | 764 | }; |
739 | 765 | |
740 | 766 | $scope.cambioEdit = function(articulo, propiedad) { |
741 | - if(propiedad === 'cantidad') { | |
767 | + if (propiedad === 'cantidad') { | |
742 | 768 | articulo.editCantidad = true; |
743 | - } else if(propiedad === 'precio') { | |
769 | + } else if (propiedad === 'precio') { | |
744 | 770 | articulo.editPrecio = true; |
745 | 771 | } |
746 | 772 | }; |
... | ... | @@ -751,7 +777,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
751 | 777 | }; |
752 | 778 | //Recibe aviso si el teclado está en uso |
753 | 779 | $rootScope.$on('usarTeclado', function(event, data) { |
754 | - if(data) { | |
780 | + if (data) { | |
755 | 781 | $scope.mostrarTeclado = true; |
756 | 782 | return; |
757 | 783 | } |
... | ... | @@ -760,7 +786,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
760 | 786 | |
761 | 787 | $scope.selectFocus = function($event) { |
762 | 788 | // Si el teclado esta en uso no selecciona el valor |
763 | - if($scope.mostrarTeclado) { | |
789 | + if ($scope.mostrarTeclado) { | |
764 | 790 | return; |
765 | 791 | } |
766 | 792 | $event.target.select(); |
... | ... | @@ -799,6 +825,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
799 | 825 | '2') |
800 | 826 | }); |
801 | 827 | } |
828 | + | |
802 | 829 | if (notaPedido.cliente.COD) { |
803 | 830 | cabeceras.push({ |
804 | 831 | label: 'Cliente:', |
... | ... | @@ -809,6 +836,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
809 | 836 | valor: notaPedido.domicilioStamp |
810 | 837 | }); |
811 | 838 | } |
839 | + | |
812 | 840 | if (notaPedido.vendedor.NUM) { |
813 | 841 | cabeceras.push({ |
814 | 842 | label: 'Vendedor:', |
... | ... | @@ -816,6 +844,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
816 | 844 | ' - ' + notaPedido.vendedor.NOM |
817 | 845 | }); |
818 | 846 | } |
847 | + | |
819 | 848 | if (notaPedido.proveedor.COD) { |
820 | 849 | cabeceras.push({ |
821 | 850 | label: 'Proveedor:', |
... | ... | @@ -823,6 +852,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
823 | 852 | ' - ' + notaPedido.proveedor.NOM |
824 | 853 | }); |
825 | 854 | } |
855 | + | |
826 | 856 | if (notaPedido.notaPedidoPlazo.length) { |
827 | 857 | cabeceras.push({ |
828 | 858 | label: 'Precios y condiciones:', |
... | ... | @@ -831,6 +861,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
831 | 861 | .plazoToString(notaPedido.notaPedidoPlazo) |
832 | 862 | }); |
833 | 863 | } |
864 | + | |
834 | 865 | if (notaPedido.flete !== undefined) { |
835 | 866 | cabeceras.push({ |
836 | 867 | label: 'Flete:', |
... | ... | @@ -839,7 +870,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
839 | 870 | }); |
840 | 871 | } |
841 | 872 | |
842 | - | |
843 | 873 | function valorPrecioCondicion() { |
844 | 874 | if (notaPedido.idPrecioCondicion > 0) { |
845 | 875 | return notaPedido.precioCondicion.nombre; |
... | ... | @@ -886,7 +916,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
886 | 916 | } |
887 | 917 | |
888 | 918 | function addArrayCabecera(array) { |
889 | - for(var i = 0; i < array.length; i++) { | |
919 | + for (var i = 0; i < array.length; i++) { | |
890 | 920 | $scope.$broadcast('addCabecera', { |
891 | 921 | label: array[i].label, |
892 | 922 | valor: array[i].valor |
... | ... | @@ -895,9 +925,9 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
895 | 925 | } |
896 | 926 | |
897 | 927 | function validarNotaRemitada() { |
898 | - if(!$scope.notaPedido.idRemito) { | |
928 | + if (!$scope.notaPedido.idRemito) { | |
899 | 929 | return true; |
900 | - }else{ | |
930 | + } else { | |
901 | 931 | focaModalService.alert('No se puede editar una nota de pedido remitada'); |
902 | 932 | return false; |
903 | 933 | } |
... | ... | @@ -965,5 +995,15 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
965 | 995 | delete $localStorage.notaPedido; |
966 | 996 | } |
967 | 997 | } |
998 | + | |
999 | + function deleteCliente() { | |
1000 | + delete $scope.notaPedido.domicilioStamp; | |
1001 | + delete $scope.notaPedido.notaPedidoPuntoDescarga; | |
1002 | + $scope.notaPedido.domicilio = {dom: ''}; | |
1003 | + $scope.notaPedido.cliente = {}; | |
1004 | + $scope.$broadcast('removeCabecera', 'Cliente:'); | |
1005 | + $scope.$broadcast('removeCabecera', 'Domicilio:'); | |
1006 | + $scope.$broadcast('removeCabecera', 'Puntos de descarga:'); | |
1007 | + } | |
968 | 1008 | } |
969 | 1009 | ]); |
src/js/service.js
... | ... | @@ -55,14 +55,14 @@ angular.module('focaCrearNotaPedido') |
55 | 55 | getNumeroNotaPedido: function() { |
56 | 56 | return $http.get(route + '/nota-pedido/numero-siguiente'); |
57 | 57 | }, |
58 | - getBotonera: function(vendedor) { | |
58 | + getBotonera: function() { | |
59 | 59 | var result = [ |
60 | 60 | { |
61 | 61 | label: 'Cliente', |
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,28 +74,14 @@ 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 | }, |
84 | 80 | { |
85 | 81 | label: 'Observaciones', |
86 | - image: 'productos.png' | |
82 | + image: 'botonObservaciones.png' | |
87 | 83 | } |
88 | 84 | ]; |
89 | - | |
90 | - if(!vendedor) { | |
91 | - var botonVendedor = { | |
92 | - label: 'Vendedor', | |
93 | - image: 'vendedor.png' | |
94 | - }; | |
95 | - | |
96 | - result.unshift(botonVendedor); | |
97 | - } | |
98 | - | |
99 | 85 | return result; |
100 | 86 | }, |
101 | 87 | crearPuntosDescarga: function(puntosDescarga) { |