Commit 97cd35be9ae79e3c3e5f5a913b3782a45bbd2640

Authored by Marcelo
Exists in master and in 1 other branch develop

Merge branch 'develop' of git.focasoftware.com:npm/foca-crear-nota-pedido

... ... @@ -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 }
... ... @@ -341,8 +341,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
341 341 }
342 342 };
343 343  
344   - $scope.seleccionarTransportista = function() {
345   - $scope.seleccionarProveedor(function() {
  344 + $scope.seleccionarProveedor = function() {
  345 + $scope.abrirModalProveedores(function() {
346 346 if (validarNotaRemitada()) {
347 347 var modalInstance = $uibModal.open(
348 348 {
... ... @@ -468,7 +468,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
468 468 }, ocultarVendedor);
469 469 };
470 470  
471   - $scope.seleccionarProveedor = function(callback) {
  471 + $scope.abrirModalProveedores = function(callback) {
472 472 if (validarNotaRemitada()) {
473 473 var parametrosModal = {
474 474 titulo: 'Búsqueda de Proveedor',
... ... @@ -572,7 +572,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
572 572 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
573 573 }
574 574 }
575   -
576 575 return parseFloat(total.toFixed(2));
577 576 };
578 577  
... ... @@ -587,7 +586,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
587 586 focaModalService.alert('Primero seleccione un cliente');
588 587 return;
589 588 }
590   - if(validarNotaRemitada()) {
  589 + if (validarNotaRemitada()) {
591 590 var modalInstance = $uibModal.open(
592 591 {
593 592 ariaLabelledBy: 'Busqueda de Precio Condición',
... ... @@ -675,10 +674,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
675 674 focaModalService
676 675 .prompt(observacion)
677 676 .then(function(observaciones) {
678   - $scope.$broadcast('addCabecera', {
679   - label: 'Observaciones:',
680   - valor: observaciones
681   - });
682 677 $scope.notaPedido.observaciones = observaciones;
683 678 });
684 679 };
... ... @@ -811,17 +806,18 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
811 806 }
812 807 $scope.$broadcast('removeCabecera', 'Bomba:');
813 808 $scope.$broadcast('removeCabecera', 'Kilometros:');
  809 + $scope.$broadcast('cleanCabecera');
814 810  
815 811 var cabeceras = [];
816 812  
817   - if (notaPedido.cotizacion) {
  813 + if (notaPedido.cotizacion.moneda.CODIGO_AFIP !== 'PES') {
818 814 cabeceras.push({
819 815 label: 'Moneda:',
820 816 valor: notaPedido.cotizacion.moneda.DETALLE
821 817 });
822 818 cabeceras.push({
823 819 label: 'Fecha cotizacion:',
824   - valor: $filter('date')(notaPedido.cotizacion.FECHA,
  820 + valor: $filter('date')(notaPedido.cotizacion.FECHA,
825 821 'dd/MM/yyyy')
826 822 });
827 823 cabeceras.push({
... ... @@ -841,7 +837,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
841 837 valor: notaPedido.domicilioStamp
842 838 });
843 839 }
844   -
  840 +
845 841 if (notaPedido.vendedor.NUM) {
846 842 cabeceras.push({
847 843 label: 'Vendedor:',
... ... @@ -897,26 +893,21 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
897 893 }
898 894 cabeceras.push(cabeceraBomba);
899 895 }
900   -
901   - notaPedidoBusinessService.calcularArticulos($scope.notaPedido.articulosNotaPedido,
902   - notaPedido.cotizacion.VENDEDOR);
903   -
  896 +
904 897 if (notaPedido.idPrecioCondicion > 0) {
905 898 $scope.idLista = notaPedido.precioCondicion.idListaPrecio;
906 899 } else {
907 900 $scope.idLista = -1;
908 901 }
909   -
  902 +
910 903 $scope.puntoVenta = $filter('rellenarDigitos')(
911 904 notaPedido.sucursal, 4
912 905 );
913   -
  906 +
914 907 $scope.comprobante = $filter('rellenarDigitos')(
915 908 notaPedido.numeroNotaPedido, 8
916 909 );
917   -
918   - $scope.notaPedido.notaPedidoPuntoDescarga =
919   - formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga || []);
  910 +
920 911 addArrayCabecera(cabeceras);
921 912 }
922 913  
... ... @@ -938,41 +929,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
938 929 }
939 930 }
940 931  
941   - function formatearPuntosDescarga(puntosDescarga) {
942   - var result = [];
943   -
944   - puntosDescarga.forEach(function(el) {
945   - var puntoDescarga = result.filter(function(resultPunto) {
946   - return resultPunto.id === el.idPuntoDescarga;
947   - });
948   -
949   - if (puntoDescarga.length) {
950   - puntoDescarga[0].articulosAgregados.push({
951   - cantidad: el.cantidad,
952   - descripcion: el.producto.descripcion,
953   - id: el.producto.id
954   - });
955   - } else {
956   - result.push({
957   - id: el.puntoDescarga.id,
958   - id_cliente: el.puntoDescarga.id_cliente,
959   - id_da_config_0: el.puntoDescarga.id_da_config_0,
960   - latitud: el.puntoDescarga.latitud,
961   - longitud: el.puntoDescarga.longitud,
962   - descripcion: el.puntoDescarga.descripcion,
963   - articulosAgregados: [
964   - {
965   - cantidad: el.cantidad,
966   - descripcion: el.producto.descripcion,
967   - id: el.producto.id
968   - }
969   - ]
970   - });
971   - }
972   - });
973   - return result;
974   - }
975   -
976 932 function salir() {
977 933 var confirmacion = false;
978 934  
... ... @@ -996,14 +952,14 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
996 952 function getLSNotaPedido() {
997 953 var notaPedido = JSON.parse($localStorage.notaPedido || null);
998 954 if (notaPedido) {
999   - setearNotaPedido(notaPedido);
1000 955 delete $localStorage.notaPedido;
  956 + setearNotaPedido(notaPedido);
1001 957 }
1002 958 }
1003 959  
1004 960 function deleteCliente() {
1005 961 delete $scope.notaPedido.domicilioStamp;
1006   - delete $scope.notaPedido.notaPedidoPuntoDescarga;
  962 + delete $scope.notaPedido.notaPedidoPuntosDescarga;
1007 963 $scope.notaPedido.domicilio = {dom: ''};
1008 964 $scope.notaPedido.cliente = {};
1009 965 $scope.$broadcast('removeCabecera', 'Cliente:');
... ... @@ -62,7 +62,7 @@ angular.module('focaCrearNotaPedido')
62 62 image: 'cliente.png'
63 63 },
64 64 {
65   - label: 'Transportista',
  65 + label: 'Proveedor',
66 66 image: 'proveedor.png'
67 67 },
68 68 {
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>