Commit 49f819a76e26c2bdc4d1689bca160925a45e2ca8
1 parent
e40d9b0906
Exists in
master
Validar nota remitada
Showing
2 changed files
with
80 additions
and
70 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -29,6 +29,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 29 | 29 | $scope.isNumber = angular.isNumber; |
| 30 | 30 | $scope.datepickerAbierto = false; |
| 31 | 31 | $scope.show = false; |
| 32 | + $scope.validar = true; | |
| 32 | 33 | $scope.cargando = true; |
| 33 | 34 | $scope.botonera = crearNotaPedidoService.getBotonera(); |
| 34 | 35 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
| ... | ... | @@ -153,77 +154,78 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 153 | 154 | } else if ($scope.notaPedido.articulosNotaPedido.length === 0) { |
| 154 | 155 | focaModalService.alert('Debe cargar al menos un articulo'); |
| 155 | 156 | return; |
| 156 | - } | |
| 157 | - focaBotoneraLateralService.startGuardar(); | |
| 158 | - $scope.saveLoading = true; | |
| 159 | - var notaPedido = { | |
| 160 | - id: $scope.notaPedido.id, | |
| 161 | - fechaCarga: new Date($scope.notaPedido.fechaCarga) | |
| 162 | - .toISOString().slice(0, 19).replace('T', ' '), | |
| 163 | - idVendedor: $scope.notaPedido.vendedor.id, | |
| 164 | - idCliente: $scope.notaPedido.cliente.COD, | |
| 165 | - nombreCliente: $scope.notaPedido.cliente.NOM, | |
| 166 | - cuitCliente: $scope.notaPedido.cliente.CUIT, | |
| 167 | - idProveedor: $scope.notaPedido.proveedor.COD, | |
| 168 | - idDomicilio: $scope.notaPedido.domicilio.id, | |
| 169 | - idCotizacion: $scope.notaPedido.cotizacion.ID, | |
| 170 | - idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, | |
| 171 | - cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | |
| 172 | - flete: $scope.notaPedido.flete, | |
| 173 | - fob: $scope.notaPedido.fob, | |
| 174 | - bomba: $scope.notaPedido.bomba, | |
| 175 | - kilometros: $scope.notaPedido.kilometros, | |
| 176 | - domicilioStamp: $scope.notaPedido.domicilioStamp, | |
| 177 | - observaciones: $scope.notaPedido.observaciones, | |
| 178 | - estado: 0, | |
| 179 | - total: $scope.getTotal() | |
| 180 | - }; | |
| 181 | - crearNotaPedidoService.crearNotaPedido(notaPedido).then( | |
| 182 | - function(data) { | |
| 183 | - // Al guardar los datos de la nota de pedido logueamos la | |
| 184 | - // actividad para su seguimiento. | |
| 185 | - //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? | |
| 186 | - focaSeguimientoService.guardarPosicion( | |
| 187 | - 'Nota de pedido', | |
| 188 | - data.data.id, | |
| 189 | - '' | |
| 190 | - ); | |
| 191 | - notaPedidoBusinessService.addArticulos( | |
| 192 | - $scope.notaPedido.articulosNotaPedido, | |
| 193 | - data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); | |
| 194 | - | |
| 195 | - if ($scope.notaPedido.notaPedidoPuntoDescarga) { | |
| 196 | - notaPedidoBusinessService.addPuntosDescarga(data.data.id, | |
| 197 | - $scope.notaPedido.notaPedidoPuntoDescarga); | |
| 198 | - } | |
| 157 | + } else if (validarNotaRemitada()) { | |
| 158 | + focaBotoneraLateralService.startGuardar(); | |
| 159 | + $scope.saveLoading = true; | |
| 160 | + var notaPedido = { | |
| 161 | + id: $scope.notaPedido.id, | |
| 162 | + fechaCarga: new Date($scope.notaPedido.fechaCarga) | |
| 163 | + .toISOString().slice(0, 19).replace('T', ' '), | |
| 164 | + idVendedor: $scope.notaPedido.vendedor.id, | |
| 165 | + idCliente: $scope.notaPedido.cliente.COD, | |
| 166 | + nombreCliente: $scope.notaPedido.cliente.NOM, | |
| 167 | + cuitCliente: $scope.notaPedido.cliente.CUIT, | |
| 168 | + idProveedor: $scope.notaPedido.proveedor.COD, | |
| 169 | + idDomicilio: $scope.notaPedido.domicilio.id, | |
| 170 | + idCotizacion: $scope.notaPedido.cotizacion.ID, | |
| 171 | + idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, | |
| 172 | + cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | |
| 173 | + flete: $scope.notaPedido.flete, | |
| 174 | + fob: $scope.notaPedido.fob, | |
| 175 | + bomba: $scope.notaPedido.bomba, | |
| 176 | + kilometros: $scope.notaPedido.kilometros, | |
| 177 | + domicilioStamp: $scope.notaPedido.domicilioStamp, | |
| 178 | + observaciones: $scope.notaPedido.observaciones, | |
| 179 | + estado: 0, | |
| 180 | + total: $scope.getTotal() | |
| 181 | + }; | |
| 182 | + crearNotaPedidoService.crearNotaPedido(notaPedido).then( | |
| 183 | + function(data) { | |
| 184 | + // Al guardar los datos de la nota de pedido logueamos la | |
| 185 | + // actividad para su seguimiento. | |
| 186 | + //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? | |
| 187 | + focaSeguimientoService.guardarPosicion( | |
| 188 | + 'Nota de pedido', | |
| 189 | + data.data.id, | |
| 190 | + '' | |
| 191 | + ); | |
| 192 | + notaPedidoBusinessService.addArticulos( | |
| 193 | + $scope.notaPedido.articulosNotaPedido, | |
| 194 | + data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); | |
| 195 | + | |
| 196 | + if ($scope.notaPedido.notaPedidoPuntoDescarga) { | |
| 197 | + notaPedidoBusinessService.addPuntosDescarga(data.data.id, | |
| 198 | + $scope.notaPedido.notaPedidoPuntoDescarga); | |
| 199 | + } | |
| 199 | 200 | |
| 200 | - var plazos = $scope.notaPedido.notaPedidoPlazo; | |
| 201 | - var plazosACrear = []; | |
| 202 | - plazos.forEach(function(plazo) { | |
| 203 | - plazosACrear.push({ | |
| 204 | - idNotaPedido: data.data.id, | |
| 205 | - dias: plazo.dias | |
| 201 | + var plazos = $scope.notaPedido.notaPedidoPlazo; | |
| 202 | + var plazosACrear = []; | |
| 203 | + plazos.forEach(function(plazo) { | |
| 204 | + plazosACrear.push({ | |
| 205 | + idNotaPedido: data.data.id, | |
| 206 | + dias: plazo.dias | |
| 207 | + }); | |
| 206 | 208 | }); |
| 207 | - }); | |
| 208 | 209 | |
| 209 | - if (plazosACrear.length) { | |
| 210 | - crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); | |
| 211 | - } | |
| 210 | + if (plazosACrear.length) { | |
| 211 | + crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); | |
| 212 | + } | |
| 212 | 213 | |
| 213 | - notaPedidoBusinessService.addEstado(data.data.id, | |
| 214 | - $scope.notaPedido.vendedor.id); | |
| 214 | + notaPedidoBusinessService.addEstado(data.data.id, | |
| 215 | + $scope.notaPedido.vendedor.id); | |
| 215 | 216 | |
| 216 | - focaBotoneraLateralService.endGuardar(true); | |
| 217 | - $scope.saveLoading = false; | |
| 217 | + focaBotoneraLateralService.endGuardar(true); | |
| 218 | + $scope.saveLoading = false; | |
| 218 | 219 | |
| 219 | - init(); | |
| 220 | - }, function(error) { | |
| 221 | - focaModalService.alert('Hubo un error al crear la nota de pedido'); | |
| 222 | - focaBotoneraLateralService.endGuardar(); | |
| 223 | - $scope.saveLoading = false; | |
| 224 | - console.info(error); | |
| 225 | - } | |
| 226 | - ); | |
| 220 | + init(); | |
| 221 | + }, function(error) { | |
| 222 | + focaModalService.alert('Hubo un error al crear la nota de pedido'); | |
| 223 | + focaBotoneraLateralService.endGuardar(); | |
| 224 | + $scope.saveLoading = false; | |
| 225 | + console.info(error); | |
| 226 | + } | |
| 227 | + ); | |
| 228 | + } | |
| 227 | 229 | }; |
| 228 | 230 | |
| 229 | 231 | $scope.seleccionarNotaPedido = function() { |
| ... | ... | @@ -816,6 +818,13 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 816 | 818 | |
| 817 | 819 | function setearNotaPedido(notaPedido) { |
| 818 | 820 | //añado cabeceras |
| 821 | + | |
| 822 | + if (notaPedido.idRemito == null) { | |
| 823 | + $scope.validar = true; | |
| 824 | + } else { | |
| 825 | + $scope.validar = false; | |
| 826 | + } | |
| 827 | + | |
| 819 | 828 | $scope.notaPedido = notaPedido; |
| 820 | 829 | if (!$scope.notaPedido.domicilio) { |
| 821 | 830 | $scope.notaPedido.domicilio = { |
src/views/nota-pedido.html
| ... | ... | @@ -68,7 +68,7 @@ |
| 68 | 68 | ></td> |
| 69 | 69 | <td class="col text-right"> |
| 70 | 70 | <input |
| 71 | - ng-show="articulo.editCantidad" | |
| 71 | + ng-show="articulo.editCantidad && validar" | |
| 72 | 72 | ng-model="tmpCantidad" |
| 73 | 73 | class="form-control" |
| 74 | 74 | foca-tipo-input |
| ... | ... | @@ -84,13 +84,13 @@ |
| 84 | 84 | <i |
| 85 | 85 | class="selectable" |
| 86 | 86 | ng-click="cambioEdit(articulo, 'cantidad')" |
| 87 | - ng-hide="articulo.editCantidad" | |
| 87 | + ng-hide="articulo.editCantidad && validar" | |
| 88 | 88 | ng-bind="articulo.cantidad"> |
| 89 | 89 | </i> |
| 90 | 90 | </td> |
| 91 | 91 | <td class="col text-right"> |
| 92 | 92 | <input |
| 93 | - ng-show="articulo.editPrecio" | |
| 93 | + ng-show="articulo.editPrecio && validar" | |
| 94 | 94 | ng-model="tmpPrecio" |
| 95 | 95 | class="form-control" |
| 96 | 96 | foca-tipo-input |
| ... | ... | @@ -107,8 +107,9 @@ |
| 107 | 107 | <i |
| 108 | 108 | class="selectable" |
| 109 | 109 | ng-click="cambioEdit(articulo, 'precio')" |
| 110 | - ng-hide="articulo.editPrecio" | |
| 111 | - ng-bind="articulo.precio | number: 4"> | |
| 110 | + ng-hide="articulo.editPrecio && validar" | |
| 111 | + ng-bind="articulo.precio | number: 4" | |
| 112 | + > | |
| 112 | 113 | </i> |
| 113 | 114 | </td> |
| 114 | 115 | <td |