Commit cd6e32a184e023becdcaaf9db8e8172ddd29f461
Exists in
master
and in
1 other branch
Merge branch 'develop' into 'master'
Develop See merge request !71
Showing
6 changed files
Show diff stats
gulpfile.js
... | ... | @@ -21,7 +21,9 @@ var paths = { |
21 | 21 | dist: 'dist/' |
22 | 22 | }; |
23 | 23 | |
24 | -gulp.task('uglify', gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')); | |
24 | +gulp.task('uglify', function(callback) { | |
25 | + gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')(callback); | |
26 | +}); | |
25 | 27 | |
26 | 28 | gulp.task('templates', function() { |
27 | 29 | return pump( |
spec/controllerSpec.js
... | ... | @@ -211,7 +211,7 @@ describe('Controladores módulo crear nota de pedido', function() { |
211 | 211 | $filter: filter, |
212 | 212 | $timeout: timeout, |
213 | 213 | crearNotaPedidoService: { |
214 | - getNumeroNotaPedido: function() { | |
214 | + getNumeroNotaPedido: function() { | |
215 | 215 | return { |
216 | 216 | then: function() { } |
217 | 217 | }; |
... | ... | @@ -255,7 +255,7 @@ describe('Controladores módulo crear nota de pedido', function() { |
255 | 255 | 'undefined', function() |
256 | 256 | { |
257 | 257 | //arrange |
258 | - var scope = { | |
258 | + var scope = { | |
259 | 259 | $watch: function() { }, |
260 | 260 | $broadcast: function() { } |
261 | 261 | }; |
... | ... | @@ -379,7 +379,7 @@ describe('Controladores módulo crear nota de pedido', function() { |
379 | 379 | $filter: filter, |
380 | 380 | $timeout: timeout, |
381 | 381 | crearNotaPedidoService: { |
382 | - getNumeroNotaPedido: function() { | |
382 | + getNumeroNotaPedido: function() { | |
383 | 383 | return { |
384 | 384 | then: function() { } |
385 | 385 | }; |
... | ... | @@ -910,16 +910,18 @@ describe('Controladores módulo crear nota de pedido', function() { |
910 | 910 | var cliente = { |
911 | 911 | COD: undefined, |
912 | 912 | CUIT: undefined, |
913 | - NOM: undefined | |
913 | + NOM: undefined, | |
914 | + MOD: undefined | |
914 | 915 | }; |
915 | 916 | |
916 | 917 | //act |
917 | 918 | spyOn(uibModal, 'open').and.returnValue(promesaRespuesta); |
918 | 919 | spyOn(scope, '$broadcast'); |
919 | - scope.abrirModalDomicilios({ }); | |
920 | + scope.abrirModalDomicilios(cliente); | |
920 | 921 | |
921 | 922 | //assert |
922 | 923 | promesaRespuesta.result.then(function() { |
924 | + //scope.notaPedido.domicilio sea vacio | |
923 | 925 | expect(scope.notaPedido.domicilio).toEqual(respuesta); |
924 | 926 | expect(scope.notaPedido.cliente).toEqual(cliente); |
925 | 927 | expect(scope.$broadcast).toHaveBeenCalled(); |
... | ... | @@ -1073,7 +1075,9 @@ describe('Controladores módulo crear nota de pedido', function() { |
1073 | 1075 | $localStorage: {} |
1074 | 1076 | }); |
1075 | 1077 | |
1076 | - scope.notaPedido = {}; | |
1078 | + scope.notaPedido = { | |
1079 | + cliente: { COD: true } | |
1080 | + }; | |
1077 | 1081 | |
1078 | 1082 | var respuesta = { result: {then: function() { } } }; |
1079 | 1083 | |
... | ... | @@ -1128,7 +1132,8 @@ describe('Controladores módulo crear nota de pedido', function() { |
1128 | 1132 | }); |
1129 | 1133 | scope.idLista = true; |
1130 | 1134 | scope.notaPedido = { |
1131 | - vendedor: { NUM: true } | |
1135 | + vendedor: { NUM: true }, | |
1136 | + cliente: { COD: true } | |
1132 | 1137 | }; |
1133 | 1138 | var respuesta = { plazoPago: { } }; |
1134 | 1139 | var promesaRespuesta = { result: Promise.resolve(respuesta) }; |
src/js/businessService.js
... | ... | @@ -24,22 +24,15 @@ angular.module('focaCrearNotaPedido') |
24 | 24 | crearNotaPedidoService.crearEstadoParaNotaPedido(estado); |
25 | 25 | }, |
26 | 26 | addPuntosDescarga: function(idNotaPedido, puntosDescarga) { |
27 | + | |
27 | 28 | var puntos = []; |
28 | 29 | |
29 | - if (puntosDescarga && puntosDescarga.length > 0) { | |
30 | - puntosDescarga.forEach(function(punto) { | |
31 | - if (puntos.articulosAgregados && puntos.articulosAgregados.length > 0) { | |
32 | - punto.articulosAgregados.forEach(function(articulo) { | |
33 | - puntos.push({ | |
34 | - idPuntoDescarga: punto.id, | |
35 | - idNotaPedido: idNotaPedido, | |
36 | - idProducto: articulo.id, | |
37 | - cantidad: articulo.cantidad | |
38 | - }); | |
39 | - }); | |
40 | - } | |
30 | + puntosDescarga.forEach(function(punto) { | |
31 | + puntos.push({ | |
32 | + idPuntoDescarga: punto.id, | |
33 | + idNotaPedido: idNotaPedido, | |
41 | 34 | }); |
42 | - } | |
35 | + }); | |
43 | 36 | |
44 | 37 | return crearNotaPedidoService.crearPuntosDescarga(puntos); |
45 | 38 | }, |
src/js/controller.js
... | ... | @@ -48,20 +48,20 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
48 | 48 | if (APP === 'distribuidor') { |
49 | 49 | $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; |
50 | 50 | } |
51 | - | |
51 | + | |
52 | 52 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
53 | 53 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { |
54 | 54 | var monedaPorDefecto = res.data[0]; |
55 | - | |
56 | 55 | $scope.notaPedido.cotizacion = Object.assign( |
57 | 56 | {moneda: monedaPorDefecto}, |
58 | 57 | monedaPorDefecto.cotizaciones[0] |
59 | 58 | ); |
60 | 59 | $scope.inicial.cotizacion = $scope.notaPedido.cotizacion; |
60 | + $timeout(function() {getLSNotaPedido();}); | |
61 | 61 | }); |
62 | 62 | |
63 | 63 | init(); |
64 | - $timeout(function() {getLSNotaPedido();}); | |
64 | + | |
65 | 65 | } |
66 | 66 | |
67 | 67 | function init() { |
... | ... | @@ -107,7 +107,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
107 | 107 | }); |
108 | 108 | |
109 | 109 | $scope.notaPedido.vendedor = vendedor; |
110 | - $scope.inicial.notaPedido.vendedor =$scope.notaPedido.vendedor; | |
111 | 110 | } |
112 | 111 | ); |
113 | 112 | } |
... | ... | @@ -314,7 +313,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
314 | 313 | idDomicilio: $scope.notaPedido.domicilio.id, |
315 | 314 | idCliente: $scope.notaPedido.cliente.COD, |
316 | 315 | articulos: $scope.notaPedido.articulosNotaPedido, |
317 | - puntosDescarga: $scope.notaPedido.notaPedidoPuntoDescarga | |
316 | + puntosDescarga: $scope.notaPedido.notaPedidoPuntoDescarga, | |
317 | + domicilio: $scope.notaPedido.domicilio | |
318 | 318 | } |
319 | 319 | } |
320 | 320 | } |
... | ... | @@ -323,16 +323,9 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
323 | 323 | function(puntosDescarga) { |
324 | 324 | $scope.notaPedido.notaPedidoPuntoDescarga = puntosDescarga; |
325 | 325 | |
326 | - //AGREGO PUNTOS DE DESCARGA A CABECERA | |
327 | - var puntosStamp = ''; | |
328 | - puntosDescarga.forEach(function(punto, idx, arr) { | |
329 | - puntosStamp += punto.descripcion; | |
330 | - if ((idx + 1) !== arr.length) puntosStamp += ', '; | |
331 | - }); | |
332 | - | |
333 | 326 | $scope.$broadcast('addCabecera', { |
334 | 327 | label: 'Puntos de descarga:', |
335 | - valor: puntosStamp | |
328 | + valor: getCabeceraPuntoDescarga(puntosDescarga) | |
336 | 329 | }); |
337 | 330 | }, function() { |
338 | 331 | $scope.abrirModalDomicilios($scope.cliente); |
... | ... | @@ -341,8 +334,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
341 | 334 | } |
342 | 335 | }; |
343 | 336 | |
344 | - $scope.seleccionarTransportista = function() { | |
345 | - $scope.seleccionarProveedor(function() { | |
337 | + $scope.seleccionarProveedor = function() { | |
338 | + $scope.abrirModalProveedores(function() { | |
346 | 339 | if (validarNotaRemitada()) { |
347 | 340 | var modalInstance = $uibModal.open( |
348 | 341 | { |
... | ... | @@ -468,7 +461,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
468 | 461 | }, ocultarVendedor); |
469 | 462 | }; |
470 | 463 | |
471 | - $scope.seleccionarProveedor = function(callback) { | |
464 | + $scope.abrirModalProveedores = function(callback) { | |
472 | 465 | if (validarNotaRemitada()) { |
473 | 466 | var parametrosModal = { |
474 | 467 | titulo: 'Búsqueda de Proveedor', |
... | ... | @@ -572,7 +565,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
572 | 565 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
573 | 566 | } |
574 | 567 | } |
575 | - | |
576 | 568 | return parseFloat(total.toFixed(2)); |
577 | 569 | }; |
578 | 570 | |
... | ... | @@ -587,7 +579,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
587 | 579 | focaModalService.alert('Primero seleccione un cliente'); |
588 | 580 | return; |
589 | 581 | } |
590 | - if(validarNotaRemitada()) { | |
582 | + if (validarNotaRemitada()) { | |
591 | 583 | var modalInstance = $uibModal.open( |
592 | 584 | { |
593 | 585 | ariaLabelledBy: 'Busqueda de Precio Condición', |
... | ... | @@ -675,10 +667,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
675 | 667 | focaModalService |
676 | 668 | .prompt(observacion) |
677 | 669 | .then(function(observaciones) { |
678 | - $scope.$broadcast('addCabecera', { | |
679 | - label: 'Observaciones:', | |
680 | - valor: observaciones | |
681 | - }); | |
682 | 670 | $scope.notaPedido.observaciones = observaciones; |
683 | 671 | }); |
684 | 672 | }; |
... | ... | @@ -804,19 +792,25 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
804 | 792 | function setearNotaPedido(notaPedido) { |
805 | 793 | //añado cabeceras |
806 | 794 | $scope.notaPedido = notaPedido; |
795 | + if (!$scope.notaPedido.domicilio) { | |
796 | + $scope.notaPedido.domicilio = { | |
797 | + id: $scope.notaPedido.idDomicilio | |
798 | + }; | |
799 | + } | |
807 | 800 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
808 | 801 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
802 | + $scope.$broadcast('cleanCabecera'); | |
809 | 803 | |
810 | 804 | var cabeceras = []; |
811 | 805 | |
812 | - if (notaPedido.cotizacion) { | |
806 | + if (notaPedido.cotizacion.moneda.CODIGO_AFIP !== 'PES') { | |
813 | 807 | cabeceras.push({ |
814 | 808 | label: 'Moneda:', |
815 | 809 | valor: notaPedido.cotizacion.moneda.DETALLE |
816 | 810 | }); |
817 | 811 | cabeceras.push({ |
818 | 812 | label: 'Fecha cotizacion:', |
819 | - valor: $filter('date')(notaPedido.cotizacion.FECHA, | |
813 | + valor: $filter('date')(notaPedido.cotizacion.FECHA, | |
820 | 814 | 'dd/MM/yyyy') |
821 | 815 | }); |
822 | 816 | cabeceras.push({ |
... | ... | @@ -826,6 +820,14 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
826 | 820 | }); |
827 | 821 | } |
828 | 822 | |
823 | + if (notaPedido.vendedor.NUM) { | |
824 | + cabeceras.push({ | |
825 | + label: 'Vendedor:', | |
826 | + valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + | |
827 | + ' - ' + notaPedido.vendedor.NOM | |
828 | + }); | |
829 | + } | |
830 | + | |
829 | 831 | if (notaPedido.cliente.COD) { |
830 | 832 | cabeceras.push({ |
831 | 833 | label: 'Cliente:', |
... | ... | @@ -836,14 +838,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
836 | 838 | valor: notaPedido.domicilioStamp |
837 | 839 | }); |
838 | 840 | } |
839 | - | |
840 | - if (notaPedido.vendedor.NUM) { | |
841 | - cabeceras.push({ | |
842 | - label: 'Vendedor:', | |
843 | - valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + | |
844 | - ' - ' + notaPedido.vendedor.NOM | |
845 | - }); | |
846 | - } | |
847 | 841 | |
848 | 842 | if (notaPedido.proveedor.COD) { |
849 | 843 | cabeceras.push({ |
... | ... | @@ -892,29 +886,41 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
892 | 886 | } |
893 | 887 | cabeceras.push(cabeceraBomba); |
894 | 888 | } |
895 | - | |
896 | - notaPedidoBusinessService.calcularArticulos($scope.notaPedido.articulosNotaPedido, | |
897 | - notaPedido.cotizacion.VENDEDOR); | |
898 | - | |
889 | + | |
899 | 890 | if (notaPedido.idPrecioCondicion > 0) { |
900 | 891 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; |
901 | 892 | } else { |
902 | 893 | $scope.idLista = -1; |
903 | 894 | } |
904 | - | |
895 | + | |
905 | 896 | $scope.puntoVenta = $filter('rellenarDigitos')( |
906 | 897 | notaPedido.sucursal, 4 |
907 | 898 | ); |
908 | - | |
899 | + | |
909 | 900 | $scope.comprobante = $filter('rellenarDigitos')( |
910 | 901 | notaPedido.numeroNotaPedido, 8 |
911 | 902 | ); |
912 | - | |
913 | - $scope.notaPedido.notaPedidoPuntoDescarga = | |
914 | - formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga || []); | |
903 | + | |
904 | + if (notaPedido.notaPedidoPuntoDescarga) { | |
905 | + var puntosDescarga = notaPedido.notaPedidoPuntoDescarga | |
906 | + cabeceras.push({ | |
907 | + label: 'Puntos de descarga: ', | |
908 | + valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntosDescarga)) | |
909 | + }); | |
910 | + } | |
911 | + | |
915 | 912 | addArrayCabecera(cabeceras); |
916 | 913 | } |
917 | 914 | |
915 | + function getCabeceraPuntoDescarga(puntosDescarga){ | |
916 | + var puntosStamp = ''; | |
917 | + puntosDescarga.forEach(function(punto, idx, arr) { | |
918 | + puntosStamp += punto.descripcion; | |
919 | + if ((idx + 1) !== arr.length) puntosStamp += ', '; | |
920 | + }); | |
921 | + return puntosStamp; | |
922 | + } | |
923 | + | |
918 | 924 | function addArrayCabecera(array) { |
919 | 925 | for (var i = 0; i < array.length; i++) { |
920 | 926 | $scope.$broadcast('addCabecera', { |
... | ... | @@ -933,41 +939,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
933 | 939 | } |
934 | 940 | } |
935 | 941 | |
936 | - function formatearPuntosDescarga(puntosDescarga) { | |
937 | - var result = []; | |
938 | - | |
939 | - puntosDescarga.forEach(function(el) { | |
940 | - var puntoDescarga = result.filter(function(resultPunto) { | |
941 | - return resultPunto.id === el.idPuntoDescarga; | |
942 | - }); | |
943 | - | |
944 | - if (puntoDescarga.length) { | |
945 | - puntoDescarga[0].articulosAgregados.push({ | |
946 | - cantidad: el.cantidad, | |
947 | - descripcion: el.producto.descripcion, | |
948 | - id: el.producto.id | |
949 | - }); | |
950 | - } else { | |
951 | - result.push({ | |
952 | - id: el.puntoDescarga.id, | |
953 | - id_cliente: el.puntoDescarga.id_cliente, | |
954 | - id_da_config_0: el.puntoDescarga.id_da_config_0, | |
955 | - latitud: el.puntoDescarga.latitud, | |
956 | - longitud: el.puntoDescarga.longitud, | |
957 | - descripcion: el.puntoDescarga.descripcion, | |
958 | - articulosAgregados: [ | |
959 | - { | |
960 | - cantidad: el.cantidad, | |
961 | - descripcion: el.producto.descripcion, | |
962 | - id: el.producto.id | |
963 | - } | |
964 | - ] | |
965 | - }); | |
966 | - } | |
967 | - }); | |
968 | - return result; | |
969 | - } | |
970 | - | |
971 | 942 | function salir() { |
972 | 943 | var confirmacion = false; |
973 | 944 | |
... | ... | @@ -991,8 +962,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
991 | 962 | function getLSNotaPedido() { |
992 | 963 | var notaPedido = JSON.parse($localStorage.notaPedido || null); |
993 | 964 | if (notaPedido) { |
994 | - setearNotaPedido(notaPedido); | |
995 | 965 | delete $localStorage.notaPedido; |
966 | + setearNotaPedido(notaPedido); | |
996 | 967 | } |
997 | 968 | } |
998 | 969 |
src/js/service.js
src/views/nota-pedido.html
... | ... | @@ -6,6 +6,12 @@ |
6 | 6 | class="mb-0 col-lg-12" |
7 | 7 | busqueda="seleccionarNotaPedido" |
8 | 8 | ></foca-cabecera-facturador> |
9 | + <marquee | |
10 | + bgcolor="#FF9900" | |
11 | + behavior="scroll" | |
12 | + direction="left" | |
13 | + ng-bind="notaPedido.observaciones" | |
14 | + ></marquee> | |
9 | 15 | <div class="col-lg-12"> |
10 | 16 | <div class="row"> |
11 | 17 | <div class="col-12 col-md-10 col-lg-10 border border-light rounded"> |
... | ... | @@ -199,7 +205,7 @@ |
199 | 205 | <h3>Total:</h3> |
200 | 206 | </td> |
201 | 207 | <td class="table-celda-total text-right no-border-top" colspan="1"> |
202 | - <h3>{{getTotal() | currency: notaPedido.moneda.SIMBOLO}}</h3> | |
208 | + <h3>{{getTotal() | currency: notaPedido.cotizacion.moneda.SIMBOLO}}</h3> | |
203 | 209 | </td> |
204 | 210 | <td class="text-right no-border-top"> |
205 | 211 | <button |
... | ... | @@ -389,7 +395,7 @@ |
389 | 395 | <h3>Total:</h3> |
390 | 396 | </td> |
391 | 397 | <td class="table-celda-total text-right no-border-top"> |
392 | - <h3>{{getTotal() | currency: notaPedido.moneda.SIMBOLO}}</h3> | |
398 | + <h3>{{getTotal() | currency: notaPedido.cotizacion.moneda.SIMBOLO}}</h3> | |
393 | 399 | </td> |
394 | 400 | </tr> |
395 | 401 | </tfoot> |