Commit 7ab856b37f0b37e98e2d4f8a358c7181397d5824
Exists in
master
and in
1 other branch
Merge branch 'master' into 'develop'
Master(efernandez) See merge request !87
Showing
1 changed file
Show diff stats
src/js/controller.js
| ... | ... | @@ -685,16 +685,21 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 685 | 685 | }; |
| 686 | 686 | focaModalService.modal(parametrosModal).then( |
| 687 | 687 | function(moneda) { |
| 688 | + | |
| 688 | 689 | if (moneda.ID !== 1) { |
| 689 | 690 | $scope.abrirModalCotizacion(moneda); |
| 691 | + return; | |
| 690 | 692 | } |
| 693 | + | |
| 691 | 694 | crearNotaPedidoService.getCotizacionByIdMoneda(1) |
| 692 | - .then(function (res){ | |
| 693 | - cotizacionPArgentino = res.data[0]; | |
| 694 | - $scope.notaPedido.cotizacion = cotizacionPArgentino; | |
| 695 | - $scope.notaPedido.cotizacion.moneda = moneda; | |
| 696 | - actualizarCabeceraMoneda(cotizacionPArgentino); | |
| 697 | - }); | |
| 695 | + .then(function (res) { | |
| 696 | + | |
| 697 | + cotizacionPArgentino = res.data[0].cotizaciones[0]; | |
| 698 | + cotizacionPArgentino.moneda = moneda; | |
| 699 | + | |
| 700 | + actualizarCabeceraMoneda(cotizacionPArgentino); | |
| 701 | + $scope.notaPedido.cotizacion = cotizacionPArgentino; | |
| 702 | + }); | |
| 698 | 703 | } |
| 699 | 704 | ); |
| 700 | 705 | } |
| ... | ... | @@ -731,18 +736,11 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 731 | 736 | ); |
| 732 | 737 | modalInstance.result.then( |
| 733 | 738 | function(cotizacion) { |
| 734 | - var articulosTablaTemp = $scope.notaPedido.articulosNotaPedido || []; | |
| 735 | - for (var i = 0; i < articulosTablaTemp.length; i++) { | |
| 736 | - articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | |
| 737 | - $scope.notaPedido.cotizacion.VENDEDOR; | |
| 738 | - articulosTablaTemp[i].precio = (articulosTablaTemp[i].precio / | |
| 739 | - cotizacion.VENDEDOR).toFixed(4); | |
| 740 | - } | |
| 741 | - $scope.notaPedido.articulosNotaPedido = articulosTablaTemp; | |
| 742 | - $scope.notaPedido.cotizacion = cotizacion; | |
| 743 | - $scope.notaPedido.cotizacion.moneda = moneda; | |
| 739 | + | |
| 740 | + cotizacion.moneda = moneda; | |
| 744 | 741 | actualizarCabeceraMoneda(cotizacion); |
| 745 | 742 | |
| 743 | + $scope.notaPedido.cotizacion = cotizacion; | |
| 746 | 744 | $filter('filter')($scope.botonera, { label: 'Moneda'})[0].checked = true; |
| 747 | 745 | }, function() { |
| 748 | 746 | |
| ... | ... | @@ -751,6 +749,12 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 751 | 749 | }; |
| 752 | 750 | |
| 753 | 751 | function actualizarCabeceraMoneda (cotizacion) { |
| 752 | + | |
| 753 | + $scope.notaPedido.articulosNotaPedido.forEach(function(art) { | |
| 754 | + art.precio = (art.precio * $scope.notaPedido.cotizacion.VENDEDOR).toFixed(4); | |
| 755 | + art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4); | |
| 756 | + }); | |
| 757 | + | |
| 754 | 758 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { |
| 755 | 759 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
| 756 | 760 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
| ... | ... | @@ -935,7 +939,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 935 | 939 | }); |
| 936 | 940 | |
| 937 | 941 | $filter('filter')($scope.botonera, |
| 938 | - { label: 'Precios y Condiciones'})[0].checked = true; | |
| 942 | + { label: 'Precios y condiciones'})[0].checked = true; | |
| 939 | 943 | } |
| 940 | 944 | |
| 941 | 945 | if (notaPedido.flete !== undefined) { |