Commit a785aa919fe2e4275b9badab1797b2e31bd7fcae
Exists in
master
Merge branch 'master' into 'develop'
Master See merge request !83
Showing
1 changed file
Show diff stats
src/js/controller.js
... | ... | @@ -20,6 +20,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
20 | 20 | $rootScope, focaSeguimientoService, APP, focaLoginService, $localStorage) |
21 | 21 | { |
22 | 22 | config(); |
23 | + var cotizacionPArgentino = {}; | |
23 | 24 | |
24 | 25 | function config() { |
25 | 26 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA |
... | ... | @@ -37,7 +38,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
37 | 38 | maxDate: new Date(), |
38 | 39 | minDate: new Date(2010, 0, 1) |
39 | 40 | }; |
40 | - | |
41 | + | |
41 | 42 | //SETEO BOTONERA LATERAL |
42 | 43 | $timeout(function() { |
43 | 44 | focaBotoneraLateralService.showSalir(false); |
... | ... | @@ -684,9 +685,16 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
684 | 685 | }; |
685 | 686 | focaModalService.modal(parametrosModal).then( |
686 | 687 | function(moneda) { |
687 | - $scope.abrirModalCotizacion(moneda); | |
688 | - }, function() { | |
689 | - | |
688 | + if (moneda.ID !== 1) { | |
689 | + $scope.abrirModalCotizacion(moneda); | |
690 | + } | |
691 | + 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 | + }); | |
690 | 698 | } |
691 | 699 | ); |
692 | 700 | } |
... | ... | @@ -733,24 +741,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
733 | 741 | $scope.notaPedido.articulosNotaPedido = articulosTablaTemp; |
734 | 742 | $scope.notaPedido.cotizacion = cotizacion; |
735 | 743 | $scope.notaPedido.cotizacion.moneda = moneda; |
736 | - if (moneda.DETALLE === 'PESOS ARGENTINOS') { | |
737 | - $scope.$broadcast('removeCabecera', 'Moneda:'); | |
738 | - $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | |
739 | - $scope.$broadcast('removeCabecera', 'Cotizacion:'); | |
740 | - } else { | |
741 | - $scope.$broadcast('addCabecera', { | |
742 | - label: 'Moneda:', | |
743 | - valor: moneda.DETALLE | |
744 | - }); | |
745 | - $scope.$broadcast('addCabecera', { | |
746 | - label: 'Fecha cotizacion:', | |
747 | - valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | |
748 | - }); | |
749 | - $scope.$broadcast('addCabecera', { | |
750 | - label: 'Cotizacion:', | |
751 | - valor: $filter('number')(cotizacion.VENDEDOR, '2') | |
752 | - }); | |
753 | - } | |
744 | + actualizarCabeceraMoneda(cotizacion); | |
754 | 745 | |
755 | 746 | $filter('filter')($scope.botonera, { label: 'Moneda'})[0].checked = true; |
756 | 747 | }, function() { |
... | ... | @@ -759,6 +750,27 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
759 | 750 | ); |
760 | 751 | }; |
761 | 752 | |
753 | + function actualizarCabeceraMoneda (cotizacion) { | |
754 | + if (cotizacion.moneda.DETALLE === 'PESOS ARGENTINOS') { | |
755 | + $scope.$broadcast('removeCabecera', 'Moneda:'); | |
756 | + $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | |
757 | + $scope.$broadcast('removeCabecera', 'Cotizacion:'); | |
758 | + } else { | |
759 | + $scope.$broadcast('addCabecera', { | |
760 | + label: 'Moneda:', | |
761 | + valor: cotizacion.moneda.DETALLE | |
762 | + }); | |
763 | + $scope.$broadcast('addCabecera', { | |
764 | + label: 'Fecha cotizacion:', | |
765 | + valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | |
766 | + }); | |
767 | + $scope.$broadcast('addCabecera', { | |
768 | + label: 'Cotizacion:', | |
769 | + valor: $filter('number')(cotizacion.VENDEDOR, '2') | |
770 | + }); | |
771 | + } | |
772 | + } | |
773 | + | |
762 | 774 | $scope.agregarATabla = function(key) { |
763 | 775 | if (key === 13) { |
764 | 776 | if ($scope.articuloACargar.cantidad === undefined || |