Commit 94d630a24e38a87e13ae769d00a2fc053dd6c1d9
1 parent
6afee148bf
Exists in
master
and in
2 other branches
change money
Showing
1 changed file
with
36 additions
and
20 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -219,10 +219,12 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 219 | 219 | $scope.remito.id = 0; |
| 220 | 220 | $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; |
| 221 | 221 | |
| 222 | - for(var i = notaPedido.articulosNotaPedido.length - 1; i >= 0; i--) { | |
| 223 | - notaPedido.articulosNotaPedido[i].id = 0; | |
| 224 | - notaPedido.articulosNotaPedido[i].idRemito = 0; | |
| 225 | - } | |
| 222 | + notaPedido.articulosNotaPedido.forEach(function (articulo) { | |
| 223 | + articulo.id = 0; | |
| 224 | + articulo.idRemito = 0; | |
| 225 | + articulo.precio = | |
| 226 | + (articulo.precio / notaPedido.cotizacion.VENDEDOR).toFixed(4); | |
| 227 | + }); | |
| 226 | 228 | |
| 227 | 229 | $scope.remito.articulosRemito = notaPedido.articulosNotaPedido; |
| 228 | 230 | |
| ... | ... | @@ -816,16 +818,22 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 816 | 818 | }; |
| 817 | 819 | focaModalService.modal(parametrosModal).then( |
| 818 | 820 | function(moneda) { |
| 821 | + | |
| 819 | 822 | if (moneda.ID !== 1) { |
| 820 | 823 | $scope.abrirModalCotizacion(moneda); |
| 824 | + return; | |
| 821 | 825 | } |
| 826 | + | |
| 822 | 827 | crearRemitoService.getCotizacionByIdMoneda(1) |
| 823 | - .then(function (res){ | |
| 824 | - cotizacionPArgentino = res.data[0]; | |
| 825 | - $scope.remito.cotizacion = cotizacionPArgentino; | |
| 826 | - $scope.remito.cotizacion.moneda = moneda; | |
| 827 | - actualizarCabeceraMoneda(cotizacionPArgentino); | |
| 828 | - }); | |
| 828 | + .then(function (res) { | |
| 829 | + | |
| 830 | + cotizacionPArgentino = res.data[0].cotizaciones[0]; | |
| 831 | + cotizacionPArgentino.moneda = moneda; | |
| 832 | + | |
| 833 | + actualizarCabeceraMoneda(cotizacionPArgentino); | |
| 834 | + | |
| 835 | + $scope.remito.cotizacion = cotizacionPArgentino; | |
| 836 | + }); | |
| 829 | 837 | }, function() { |
| 830 | 838 | |
| 831 | 839 | } |
| ... | ... | @@ -858,17 +866,11 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 858 | 866 | ); |
| 859 | 867 | modalInstance.result.then( |
| 860 | 868 | function(cotizacion) { |
| 861 | - var articulosTablaTemp = $scope.remito.articulosRemito; | |
| 862 | - for(var i = 0; i < articulosTablaTemp.length; i++) { | |
| 863 | - articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | |
| 864 | - $scope.remito.cotizacion.VENDEDOR; | |
| 865 | - articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | |
| 866 | - cotizacion.VENDEDOR; | |
| 867 | - } | |
| 868 | - $scope.remito.articulosRemito = articulosTablaTemp; | |
| 869 | - $scope.remito.cotizacion = cotizacion; | |
| 870 | - $scope.remito.cotizacion.moneda = moneda; | |
| 869 | + | |
| 870 | + cotizacion.moneda = moneda; | |
| 871 | + | |
| 871 | 872 | actualizarCabeceraMoneda(cotizacion); |
| 873 | + $scope.remito.cotizacion = cotizacion; | |
| 872 | 874 | }, function() { |
| 873 | 875 | |
| 874 | 876 | } |
| ... | ... | @@ -876,6 +878,12 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 876 | 878 | }; |
| 877 | 879 | |
| 878 | 880 | function actualizarCabeceraMoneda (cotizacion) { |
| 881 | + | |
| 882 | + $scope.remito.articulosRemito.forEach(function(art) { | |
| 883 | + art.precio = (art.precio * $scope.remito.cotizacion.VENDEDOR).toFixed(4); | |
| 884 | + art.precio = (art.precio / cotizacion.VENDEDOR).toFixed(4); | |
| 885 | + }); | |
| 886 | + | |
| 879 | 887 | if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { |
| 880 | 888 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
| 881 | 889 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
| ... | ... | @@ -1145,6 +1153,14 @@ angular.module('focaCrearRemito') .controller('remitoController', |
| 1145 | 1153 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntosDescarga)) |
| 1146 | 1154 | }); |
| 1147 | 1155 | } |
| 1156 | + | |
| 1157 | + if ($scope.remito.articulosRemito.length) { | |
| 1158 | + $scope.remito.articulosRemito.forEach(function (articulo) { | |
| 1159 | + articulo.precio = | |
| 1160 | + (articulo.precio / $scope.remito.cotizacion.VENDEDOR).toFixed(4); | |
| 1161 | + }); | |
| 1162 | + } | |
| 1163 | + | |
| 1148 | 1164 | addArrayCabecera(cabeceras); |
| 1149 | 1165 | } |
| 1150 | 1166 |