diff --git a/src/js/controller.js b/src/js/controller.js index 694467c..0cd9d9b 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -21,6 +21,27 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', { config(); + var cotizacionPArgentino = { + COTIZACION: 1, + C_HD: '', + E_HD: '', + FECHA: new Date(), + ID: 20, + ID_MONEDA: 1, + VENDEDOR: 1, + moneda: { + ALIAS_CC: 1091, + CODIGO_AFIP: 'PES', + COTIZACION: 0, + C_HD: '', + DETALLE: 'PESOS ARGENTINOS', + E_HD: '', + FECHA_ULT_COT: new Date(), + ID: 1, + SIMBOLO: '$' + } + }; + function config() { // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA $scope.tmpCantidad = Number; @@ -37,7 +58,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', maxDate: new Date(), minDate: new Date(2010, 0, 1) }; - + //SETEO BOTONERA LATERAL $timeout(function() { focaBotoneraLateralService.showSalir(false); @@ -672,7 +693,13 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', }; focaModalService.modal(parametrosModal).then( function(moneda) { - $scope.abrirModalCotizacion(moneda); + if (moneda.ID !== 1) { + $scope.abrirModalCotizacion(moneda); + } + moneda = cotizacionPArgentino; + $scope.notaPedido.cotizacion = cotizacionPArgentino; + $scope.notaPedido.cotizacion.moneda = cotizacionPArgentino.moneda; + actualizarCabeceraMoneda(cotizacionPArgentino); }, function() { } @@ -721,30 +748,34 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', $scope.notaPedido.articulosNotaPedido = articulosTablaTemp; $scope.notaPedido.cotizacion = cotizacion; $scope.notaPedido.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 ||