From 8aee8c1f53aced39de8fd825580a920a81ca2586 Mon Sep 17 00:00:00 2001 From: Luigi Date: Mon, 6 May 2019 15:43:56 -0300 Subject: [PATCH] Cotizacion pesos argentinos (modal) --- src/js/controller.js | 53 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/src/js/controller.js b/src/js/controller.js index 0172b9d..44948d6 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -9,6 +9,8 @@ angular.module('focaCrearRemito') .controller('remitoController', { config(); + var cotizacionPArgentino = {}; + function config() { $scope.tmpCantidad = Number; $scope.tmpPrecio = Number; @@ -813,7 +815,16 @@ angular.module('focaCrearRemito') .controller('remitoController', }; focaModalService.modal(parametrosModal).then( function(moneda) { - $scope.abrirModalCotizacion(moneda); + if (moneda.ID !== 1) { + $scope.abrirModalCotizacion(moneda); + } + crearRemitoService.getCotizacionByIdMoneda(1) + .then(function (res){ + cotizacionPArgentino = res.data[0]; + $scope.remito.cotizacion = cotizacionPArgentino; + $scope.remito.cotizacion.moneda = moneda; + actualizarCabeceraMoneda(cotizacionPArgentino); + }); }, function() { } @@ -856,30 +867,34 @@ angular.module('focaCrearRemito') .controller('remitoController', $scope.remito.articulosRemito = articulosTablaTemp; $scope.remito.cotizacion = cotizacion; $scope.remito.cotizacion.moneda = moneda; - if (moneda.DETALLE === 'PESOS ARGENTINOS') { - $scope.$broadcast('removeCabecera', 'Moneda:'); - $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); - $scope.$broadcast('removeCabecera', 'Cotizacion:'); - } else { - $scope.$broadcast('addCabecera',{ - label: 'Moneda:', - valor: moneda.DETALLE - }); - $scope.$broadcast('addCabecera',{ - label: 'Fecha cotizacion:', - valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') - }); - $scope.$broadcast('addCabecera',{ - label: 'Cotizacion:', - valor: $filter('number')(cotizacion.VENDEDOR, '2') - }); - } + actualizarCabeceraMoneda(cotizacion); }, function() { } ); }; + function actualizarCabeceraMoneda (cotizacion) { + if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { + $scope.$broadcast('removeCabecera', 'Moneda:'); + $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); + $scope.$broadcast('removeCabecera', 'Cotizacion:'); + } else { + $scope.$broadcast('addCabecera', { + label: 'Moneda:', + valor: cotizacion.moneda.DETALLE + }); + $scope.$broadcast('addCabecera', { + label: 'Fecha cotizacion:', + valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') + }); + $scope.$broadcast('addCabecera', { + label: 'Cotizacion:', + valor: $filter('number')(cotizacion.VENDEDOR, '2') + }); + } + } + $scope.agregarATabla = function(key) { if (key === 13) { if ($scope.articuloACargar.cantidad === undefined || -- 1.9.1