Commit d0d33876d9cbcf8785ae23d3a558248ba6005cc2
Exists in
master
Merge branch 'master' into 'master'
Master(mpuebla) See merge request !3
Showing
1 changed file
Show diff stats
src/js/controller.js
| ... | ... | @@ -15,13 +15,13 @@ angular.module('focaModalDescarga') |
| 15 | 15 | focaModalDetalleHojaRutaService, focaSeguimientoService) { |
| 16 | 16 | |
| 17 | 17 | //#region variables |
| 18 | + console.log(remito); | |
| 18 | 19 | $scope.remito = {}; |
| 19 | 20 | $scope.remito = remito; |
| 20 | 21 | $scope.nroRecibo = 0; |
| 21 | 22 | $scope.cisternas = remito.cisternas; |
| 22 | 23 | $scope.nroRemito = "00" + remito.sucursal + "-000000000" + remito.numeroRemito; |
| 23 | - | |
| 24 | - console.log(remito); | |
| 24 | + $scope.articulos = []; | |
| 25 | 25 | //#endregion |
| 26 | 26 | |
| 27 | 27 | $scope.crearRemito = function () { |
| ... | ... | @@ -48,7 +48,7 @@ angular.module('focaModalDescarga') |
| 48 | 48 | numeroNotaPedido: $scope.remito.numeroNotaPedido, |
| 49 | 49 | idVendedor: $scope.remito.vendedor.NUM, |
| 50 | 50 | idProveedor: $scope.remito.proveedor.COD, |
| 51 | - idDomicilio: $scope.remito.idDomicilio || $scope.remito.domicilio.id, | |
| 51 | + idDomicilio: 0, | |
| 52 | 52 | idCotizacion: $scope.remito.cotizacion.ID, |
| 53 | 53 | idListaPrecio: $scope.remito.cliente.mod, |
| 54 | 54 | flete: $scope.remito.flete, |
| ... | ... | @@ -86,14 +86,15 @@ angular.module('focaModalDescarga') |
| 86 | 86 | idHojaRuta: $scope.remito.idHojaRuta |
| 87 | 87 | } |
| 88 | 88 | //#endregionc |
| 89 | - focaModalDescargasService.crearRemito({remito: remito, notaPedido: {id:0}}) | |
| 89 | + focaModalDescargasService.crearRemito({ remito: remito, notaPedido: { id: 0 } }) | |
| 90 | 90 | .then(function (res) { |
| 91 | 91 | console.log(res); |
| 92 | 92 | remitoId = res.data.id |
| 93 | 93 | descargar(remitoId); |
| 94 | - focaModalDescargasService.addArticulos($scope.remito.articulosRemito, remitoId, 1); | |
| 94 | + focaModalDescargasService. | |
| 95 | + addArticulos($scope.articulos, remitoId, 1); | |
| 95 | 96 | focaModalService.alert("Descarga realizada") |
| 96 | - .then(function(){ | |
| 97 | + .then(function () { | |
| 97 | 98 | $uibModalInstance.dismiss(); |
| 98 | 99 | }) |
| 99 | 100 | }) |
| ... | ... | @@ -102,10 +103,13 @@ angular.module('focaModalDescarga') |
| 102 | 103 | }; |
| 103 | 104 | $scope.getTotal = function () { |
| 104 | 105 | var total = 0; |
| 105 | - var arrayTempArticulos = $scope.remito.articulosRemito; | |
| 106 | - for (var i = 0; i < arrayTempArticulos.length; i++) { | |
| 107 | - total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | |
| 108 | - } | |
| 106 | + $scope.cisternas.forEach(function (cisterna) { | |
| 107 | + $scope.articulos.push(cisterna.cisternaCarga.articulo); | |
| 108 | + total += cisterna.cisternaCarga.articulo.PreVen * cisterna.cisternaCarga.descargar; | |
| 109 | + }); | |
| 110 | + // for (var i = 0; i < articulos.length; i++) { | |
| 111 | + // total += articulos[i].PreVen * articulos[i].cantidad; | |
| 112 | + // } | |
| 109 | 113 | return parseFloat(total.toFixed(2)); |
| 110 | 114 | }; |
| 111 | 115 | function descargar(idRemito) { |
| ... | ... | @@ -152,7 +156,7 @@ angular.module('focaModalDescarga') |
| 152 | 156 | focaModalDetalleHojaRutaService |
| 153 | 157 | .postMovimientoHojaRuta(save) |
| 154 | 158 | .then(guardarSeguimiento) |
| 155 | - .catch(function() {}); | |
| 159 | + .catch(function () { }); | |
| 156 | 160 | function guardarSeguimiento(res) { |
| 157 | 161 | focaSeguimientoService |
| 158 | 162 | .guardarPosicion( |
| ... | ... | @@ -164,16 +168,12 @@ angular.module('focaModalDescarga') |
| 164 | 168 | }; |
| 165 | 169 | function getImporte(propiedad) { |
| 166 | 170 | var importe = 0; |
| 167 | - | |
| 168 | 171 | $scope.remito.articulosRemito.forEach(function (articulo) { |
| 169 | - | |
| 170 | 172 | if (articulo[propiedad]) { |
| 171 | 173 | importe += articulo[propiedad] * articulo.cantidad; |
| 172 | 174 | } |
| 173 | 175 | return; |
| 174 | - | |
| 175 | 176 | }); |
| 176 | - | |
| 177 | 177 | return importe; |
| 178 | 178 | }; |
| 179 | 179 | function validarDescarga() { |