Compare View
Commits (11)
-
Master See merge request !42
-
Master See merge request !43
-
Master See merge request !44
-
Master See merge request !45
-
This reverts commit 0ed74d25c8a6ebbd6e783d226e737c0520353971.
-
Master See merge request !46
Showing
2 changed files
Show diff stats
src/js/controller.js
| ... | ... | @@ -34,18 +34,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 34 | 34 | minDate: new Date(2010, 0, 1) |
| 35 | 35 | }; |
| 36 | 36 | |
| 37 | - //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | |
| 38 | - var monedaPorDefecto; | |
| 39 | - crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | |
| 40 | - monedaPorDefecto = res.data[0]; | |
| 41 | - | |
| 42 | - $scope.notaPedido.moneda = monedaPorDefecto; | |
| 43 | - $scope.inicial.notaPedido.moneda = $scope.notaPedido.moneda; | |
| 44 | - | |
| 45 | - $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; | |
| 46 | - $scope.inicial.notaPedido.cotizacion = $scope.notaPedido.cotizacion; | |
| 47 | - }); | |
| 48 | - | |
| 49 | 37 | //SETEO BOTONERA LATERAL |
| 50 | 38 | $timeout(function() { |
| 51 | 39 | focaBotoneraLateralService.showSalir(false); |
| ... | ... | @@ -61,8 +49,14 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 61 | 49 | } else { |
| 62 | 50 | $scope.botonera = crearNotaPedidoService.getBotonera(); |
| 63 | 51 | } |
| 64 | - | |
| 65 | - init(); | |
| 52 | + | |
| 53 | + //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | |
| 54 | + crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | |
| 55 | + $scope.monedaDefecto = res.data[0]; | |
| 56 | + $scope.cotizacionDefecto = $scope.monedaDefecto.cotizaciones[0]; | |
| 57 | + | |
| 58 | + init(); | |
| 59 | + }); | |
| 66 | 60 | } |
| 67 | 61 | |
| 68 | 62 | function init() { |
| ... | ... | @@ -73,7 +67,9 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 73 | 67 | cliente: {}, |
| 74 | 68 | proveedor: {}, |
| 75 | 69 | domicilio: {dom: ''}, |
| 76 | - vendedor: {} | |
| 70 | + vendedor: {}, | |
| 71 | + moneda: $scope.monedaDefecto, | |
| 72 | + cotizacion: $scope.cotizacionDefecto | |
| 77 | 73 | }; |
| 78 | 74 | |
| 79 | 75 | $scope.articulosTabla = []; |
| ... | ... | @@ -159,7 +155,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 159 | 155 | nombreCliente: $scope.notaPedido.cliente.NOM, |
| 160 | 156 | cuitCliente: $scope.notaPedido.cliente.CUIT, |
| 161 | 157 | idProveedor: $scope.notaPedido.proveedor.COD, |
| 162 | - //idDomicilio: $scope.notaPedido.domicilio.id,TODO GUARDAR DOMICILIO ID | |
| 158 | + idDomicilio: $scope.notaPedido.domicilio.id, | |
| 163 | 159 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
| 164 | 160 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, |
| 165 | 161 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
| ... | ... | @@ -168,6 +164,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 168 | 164 | bomba: $scope.notaPedido.bomba, |
| 169 | 165 | kilometros: $scope.notaPedido.kilometros, |
| 170 | 166 | domicilioStamp: $scope.notaPedido.domicilioStamp, |
| 167 | + observaciones: $scope.notaPedido.observaciones, | |
| 171 | 168 | estado: 0, |
| 172 | 169 | total: $scope.getTotal() |
| 173 | 170 | }; |
| ... | ... | @@ -411,8 +408,6 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 411 | 408 | size: 'lg', |
| 412 | 409 | resolve: { |
| 413 | 410 | filters: { |
| 414 | - /*TODO: al traer nota de pedido ya creada | |
| 415 | - obtener idDomicilio correctamente*/ | |
| 416 | 411 | idDomicilio: $scope.notaPedido.domicilio.id, |
| 417 | 412 | idCliente: $scope.notaPedido.cliente.COD, |
| 418 | 413 | articulos: $scope.articulosTabla, |
| ... | ... | @@ -601,10 +596,14 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 601 | 596 | |
| 602 | 597 | $scope.getTotal = function() { |
| 603 | 598 | var total = 0; |
| 604 | - var arrayTempArticulos = $scope.articulosTabla; | |
| 605 | - for (var i = 0; i < arrayTempArticulos.length; i++) { | |
| 606 | - total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | |
| 599 | + | |
| 600 | + if ($scope.articulosTabla) { | |
| 601 | + var arrayTempArticulos = $scope.articulosTabla; | |
| 602 | + for (var i = 0; i < arrayTempArticulos.length; i++) { | |
| 603 | + total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | |
| 604 | + } | |
| 607 | 605 | } |
| 606 | + | |
| 608 | 607 | return parseFloat(total.toFixed(2)); |
| 609 | 608 | }; |
| 610 | 609 | |
| ... | ... | @@ -743,6 +742,14 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 743 | 742 | } |
| 744 | 743 | }; |
| 745 | 744 | |
| 745 | + $scope.seleccionarObservaciones = function() { | |
| 746 | + focaModalService | |
| 747 | + .prompt('Ingrese observaciones', $scope.notaPedido.observaciones, true) | |
| 748 | + .then(function(observaciones) { | |
| 749 | + $scope.notaPedido.observaciones = observaciones; | |
| 750 | + }); | |
| 751 | + }; | |
| 752 | + | |
| 746 | 753 | $scope.abrirModalCotizacion = function(moneda) { |
| 747 | 754 | var modalInstance = $uibModal.open( |
| 748 | 755 | { |
| ... | ... | @@ -750,26 +757,35 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 750 | 757 | templateUrl: 'modal-cotizacion.html', |
| 751 | 758 | controller: 'focaModalCotizacionController', |
| 752 | 759 | size: 'lg', |
| 753 | - resolve: {idMoneda: function() {return moneda.ID;}} | |
| 760 | + resolve: { | |
| 761 | + idMoneda: function() { | |
| 762 | + return moneda.ID; | |
| 763 | + } | |
| 764 | + } | |
| 754 | 765 | } |
| 755 | 766 | ); |
| 756 | 767 | modalInstance.result.then( |
| 757 | 768 | function(cotizacion) { |
| 758 | 769 | var articulosTablaTemp = $scope.articulosTabla; |
| 770 | + | |
| 759 | 771 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
| 760 | 772 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
| 761 | 773 | $scope.notaPedido.cotizacion.VENDEDOR; |
| 762 | 774 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
| 763 | 775 | cotizacion.VENDEDOR; |
| 764 | 776 | } |
| 777 | + | |
| 765 | 778 | $scope.articulosTabla = articulosTablaTemp; |
| 766 | 779 | $scope.notaPedido.moneda = moneda; |
| 780 | + $scope.monedaDefecto = moneda; | |
| 781 | + $scope.cotizacionDefecto = cotizacion; | |
| 767 | 782 | $scope.notaPedido.cotizacion = cotizacion; |
| 783 | + | |
| 768 | 784 | if(moneda.DETALLE === 'PESOS ARGENTINOS') { |
| 769 | 785 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
| 770 | 786 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
| 771 | 787 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
| 772 | - }else { | |
| 788 | + } else { | |
| 773 | 789 | $scope.$broadcast('addCabecera', { |
| 774 | 790 | label: 'Moneda:', |
| 775 | 791 | valor: moneda.DETALLE |