Commit 4d0f692eed11226d3d392c28c9a8f4e97bd6bead
Exists in
master
and in
1 other branch
Merge branch 'master' into 'develop'
Master(efernandez) See merge request !78
Showing
3 changed files
Show diff stats
src/js/businessService.js
| ... | ... | @@ -36,6 +36,19 @@ angular.module('focaCrearRemito') |
| 36 | 36 | result += plazos[i].dias + ' '; |
| 37 | 37 | } |
| 38 | 38 | return result.trim(); |
| 39 | + }, | |
| 40 | + addPuntosDescarga: function(idRemito, puntosDescarga) { | |
| 41 | + | |
| 42 | + var puntos = []; | |
| 43 | + | |
| 44 | + puntosDescarga.forEach(function(punto) { | |
| 45 | + puntos.push({ | |
| 46 | + idPuntoDescarga: punto.puntoDescarga.id, | |
| 47 | + idRemito: idRemito, | |
| 48 | + }); | |
| 49 | + }); | |
| 50 | + | |
| 51 | + return crearRemitoService.crearPuntosDescarga(puntos); | |
| 39 | 52 | } |
| 40 | 53 | }; |
| 41 | 54 | }]); |
src/js/controller.js
| ... | ... | @@ -64,7 +64,8 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 64 | 64 | domicilio: { dom: '' }, |
| 65 | 65 | moneda: {}, |
| 66 | 66 | cotizacion: $scope.cotizacionPorDefecto || {}, |
| 67 | - articulosRemito: [] | |
| 67 | + articulosRemito: [], | |
| 68 | + remitoPuntoDescarga: [] | |
| 68 | 69 | }; |
| 69 | 70 | |
| 70 | 71 | $scope.notaPedido = { |
| ... | ... | @@ -218,6 +219,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 218 | 219 | $scope.remito = notaPedido; |
| 219 | 220 | $scope.remito.id = 0; |
| 220 | 221 | $scope.remito.remitoPlazo = notaPedido.notaPedidoPlazo; |
| 222 | + $scope.remito.remitoPuntoDescarga = notaPedido.notaPedidoPuntoDescarga; | |
| 221 | 223 | |
| 222 | 224 | notaPedido.articulosNotaPedido.forEach(function (articulo) { |
| 223 | 225 | articulo.id = 0; |
| ... | ... | @@ -246,12 +248,12 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 246 | 248 | |
| 247 | 249 | $scope.seleccionarRemito = function () { |
| 248 | 250 | if ($scope.remitoIsDirty) { |
| 249 | - focaModalService.confirm("¿Desea continuar? Se perderan los cambios") | |
| 251 | + focaModalService.confirm('¿Desea continuar? Se perderan los cambios') | |
| 250 | 252 | .then(function () { |
| 251 | 253 | $scope.getRemitoModal(); |
| 252 | 254 | }); |
| 253 | 255 | } else { |
| 254 | - $scope.getRemitoModal() | |
| 256 | + $scope.getRemitoModal(); | |
| 255 | 257 | } |
| 256 | 258 | }; |
| 257 | 259 | $scope.getRemitoModal = function () { |
| ... | ... | @@ -269,7 +271,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 269 | 271 | // funcion ejecutada cuando se cancela el modal |
| 270 | 272 | } |
| 271 | 273 | ); |
| 272 | - } | |
| 274 | + }; | |
| 273 | 275 | //validacion por domicilio y por plazo pago |
| 274 | 276 | $scope.crearRemito = function () { |
| 275 | 277 | if (!$scope.remito.vendedor.NUM) { |
| ... | ... | @@ -278,7 +280,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 278 | 280 | } else if (!$scope.remito.cliente.COD) { |
| 279 | 281 | focaModalService.alert('Ingrese Cliente'); |
| 280 | 282 | return; |
| 281 | - } else if (!$scope.remito.proveedor) { | |
| 283 | + } else if (!$scope.remito.proveedor.COD) { | |
| 282 | 284 | focaModalService.alert('Ingrese Proveedor'); |
| 283 | 285 | return; |
| 284 | 286 | } else if (!$scope.remito.cotizacion.moneda.id && |
| ... | ... | @@ -307,8 +309,8 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 307 | 309 | total: $scope.getTotal() * $scope.remito.cotizacion.VENDEDOR, |
| 308 | 310 | numeroNotaPedido: $scope.remito.numeroNotaPedido, |
| 309 | 311 | idVendedor: $scope.remito.idVendedor, |
| 310 | - idProveedor: $scope.remito.idProveedor, | |
| 311 | - idDomicilio: $scope.remito.idDomicilio, | |
| 312 | + idProveedor: $scope.remito.proveedor.COD, | |
| 313 | + idDomicilio: $scope.remito.idDomicilio || $scope.remito.domicilio.id, | |
| 312 | 314 | idCotizacion: $scope.remito.cotizacion.ID, |
| 313 | 315 | idPrecioCondicion: $scope.remito.idPrecioCondicion, |
| 314 | 316 | flete: $scope.remito.flete, |
| ... | ... | @@ -356,6 +358,11 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 356 | 358 | $scope.remito.id = data.data.id; |
| 357 | 359 | $scope.remito.numeroRemito = data.data.numero; |
| 358 | 360 | |
| 361 | + if ($scope.remito.remitoPuntoDescarga.length) { | |
| 362 | + remitoBusinessService.addPuntosDescarga(data.data.id, | |
| 363 | + $scope.remito.remitoPuntoDescarga); | |
| 364 | + } | |
| 365 | + | |
| 359 | 366 | remitoBusinessService.addArticulos($scope.remito.articulosRemito, |
| 360 | 367 | $scope.remito.id, $scope.remito.cotizacion.VENDEDOR); |
| 361 | 368 | |
| ... | ... | @@ -467,20 +474,26 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 467 | 474 | idDomicilio: $scope.remito.domicilio.id, |
| 468 | 475 | idCliente: $scope.remito.cliente.COD, |
| 469 | 476 | articulos: $scope.remito.articulosRemito, |
| 470 | - puntosDescarga: $scope.remito.domicilio.puntosDescarga, | |
| 477 | + puntosDescarga: $scope.remito.remitoPuntoDescarga, | |
| 471 | 478 | domicilio: $scope.remito.domicilio |
| 472 | 479 | } |
| 473 | 480 | } |
| 474 | 481 | } |
| 475 | 482 | ); |
| 476 | 483 | modalInstance.result.then( |
| 477 | - function (puntosDescarga) { | |
| 478 | - $scope.remito.domicilio.puntosDescarga = puntosDescarga; | |
| 484 | + function(puntosDescarga) { | |
| 485 | + | |
| 486 | + puntosDescarga.forEach(function(punto) { | |
| 487 | + $scope.remito.remitoPuntoDescarga.push( | |
| 488 | + { | |
| 489 | + puntoDescarga: punto | |
| 490 | + } | |
| 491 | + ); | |
| 492 | + }); | |
| 479 | 493 | |
| 480 | 494 | $scope.$broadcast('addCabecera', { |
| 481 | 495 | label: 'Puntos de descarga:', |
| 482 | - valor: getCabeceraPuntoDescarga( | |
| 483 | - $scope.remito.domicilio.puntosDescarga) | |
| 496 | + valor: getCabeceraPuntoDescarga(puntosDescarga) | |
| 484 | 497 | }); |
| 485 | 498 | }, function () { |
| 486 | 499 | $scope.abrirModalDomicilios($scope.cliente); |
| ... | ... | @@ -638,12 +651,6 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 638 | 651 | if (domicilio.verPuntos) { |
| 639 | 652 | delete $scope.remito.domicilio.verPuntos; |
| 640 | 653 | $scope.seleccionarPuntosDeDescarga(); |
| 641 | - } else { | |
| 642 | - crearRemitoService | |
| 643 | - .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | |
| 644 | - .then(function (res) { | |
| 645 | - if (res.data.length) $scope.seleccionarPuntosDeDescarga(); | |
| 646 | - }); | |
| 647 | 654 | } |
| 648 | 655 | |
| 649 | 656 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; |
| ... | ... | @@ -1155,11 +1162,16 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 1155 | 1162 | $scope.puntoVenta = rellenar(remito.sucursal, 4); |
| 1156 | 1163 | $scope.comprobante = rellenar(remito.numeroRemito, 8); |
| 1157 | 1164 | $scope.remito = remito; |
| 1158 | - if ($scope.remito.puntosDescarga) { | |
| 1159 | - var puntosDescarga = $scope.remito.puntosDescarga; | |
| 1165 | + if ($scope.remito.remitoPuntoDescarga.length) { | |
| 1166 | + var puntoDescarga = []; | |
| 1167 | + | |
| 1168 | + $scope.remito.remitoPuntoDescarga.forEach(function(remitoPuntoDescarga) { | |
| 1169 | + puntoDescarga.push(remitoPuntoDescarga.puntoDescarga); | |
| 1170 | + }); | |
| 1171 | + | |
| 1160 | 1172 | cabeceras.push({ |
| 1161 | 1173 | label: 'Puntos de descarga: ', |
| 1162 | - valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntosDescarga)) | |
| 1174 | + valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntoDescarga)) | |
| 1163 | 1175 | }); |
| 1164 | 1176 | } |
| 1165 | 1177 | $scope.remitoIsDirty = false; |
| ... | ... | @@ -1183,13 +1195,14 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 1183 | 1195 | } |
| 1184 | 1196 | |
| 1185 | 1197 | function deleteCliente() { |
| 1186 | - delete $scope.remito.domicilioStamp; | |
| 1187 | - delete $scope.remito.puntosDescarga; | |
| 1198 | + $scope.remito.domicilioStamp = ''; | |
| 1199 | + $scope.remito.remitoPuntoDescarga = []; | |
| 1188 | 1200 | $scope.remito.domicilio = { dom: '' }; |
| 1189 | 1201 | $scope.remito.cliente = {}; |
| 1190 | 1202 | $scope.$broadcast('removeCabecera', 'Cliente:'); |
| 1191 | 1203 | $scope.$broadcast('removeCabecera', 'Domicilio:'); |
| 1192 | 1204 | $scope.$broadcast('removeCabecera', 'Puntos de descarga:'); |
| 1205 | + $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = false; | |
| 1193 | 1206 | } |
| 1194 | 1207 | |
| 1195 | 1208 | function getCabeceraPuntoDescarga(puntosDescarga) { |
src/js/service.js
| ... | ... | @@ -78,6 +78,10 @@ angular.module('focaCrearRemito') |
| 78 | 78 | getParametros: function() { |
| 79 | 79 | return $http.get(API_ENDPOINT.URL + '/parametros/remito'); |
| 80 | 80 | }, |
| 81 | + crearPuntosDescarga: function(puntosDescarga) { | |
| 82 | + return $http.post(route + '/puntos-descarga/remito', | |
| 83 | + {puntosDescarga: puntosDescarga}); | |
| 84 | + }, | |
| 81 | 85 | getBotonera: function() { |
| 82 | 86 | return [ |
| 83 | 87 | { |