Commit 976b325c51bb3215456f7ea525f4540eca99a763
Exists in
master
Merge branch 'develop' of git.focasoftware.com:npm/foca-crear-remito
# Conflicts: # src/js/controller.js
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 | |
... | ... | @@ -434,15 +441,20 @@ angular.module('focaCrearRemito').controller('remitoController', |
434 | 441 | editCantidad: false, |
435 | 442 | editPrecio: false, |
436 | 443 | rubro: producto.CodRub, |
437 | - exentoUnitario: producto.precio, | |
438 | 444 | ivaUnitario: producto.IMPIVA, |
439 | 445 | impuestoInternoUnitario: producto.ImpInt, |
440 | 446 | impuestoInterno1Unitario: producto.ImpInt2, |
441 | 447 | impuestoInterno2Unitario: producto.ImpInt3, |
442 | 448 | precioLista: producto.precio, |
443 | 449 | combustible: 1, |
444 | - facturado: 0 | |
450 | + facturado: 0, | |
451 | + idArticulo: producto.id, | |
452 | + tasaIva: producto.tasaIVA | |
445 | 453 | }; |
454 | + | |
455 | + newArt.exentoUnitario = newArt.ivaUnitario ? 0 : producto.neto; | |
456 | + newArt.netoUnitario = newArt.ivaUnitario ? producto.neto : 0; | |
457 | + | |
446 | 458 | $scope.articuloACargar = newArt; |
447 | 459 | $scope.cargando = false; |
448 | 460 | }, function () { |
... | ... | @@ -467,20 +479,26 @@ angular.module('focaCrearRemito').controller('remitoController', |
467 | 479 | idDomicilio: $scope.remito.domicilio.id, |
468 | 480 | idCliente: $scope.remito.cliente.COD, |
469 | 481 | articulos: $scope.remito.articulosRemito, |
470 | - puntosDescarga: $scope.remito.domicilio.puntosDescarga, | |
482 | + puntosDescarga: $scope.remito.remitoPuntoDescarga, | |
471 | 483 | domicilio: $scope.remito.domicilio |
472 | 484 | } |
473 | 485 | } |
474 | 486 | } |
475 | 487 | ); |
476 | 488 | modalInstance.result.then( |
477 | - function (puntosDescarga) { | |
478 | - $scope.remito.domicilio.puntosDescarga = puntosDescarga; | |
489 | + function(puntosDescarga) { | |
490 | + | |
491 | + puntosDescarga.forEach(function(punto) { | |
492 | + $scope.remito.remitoPuntoDescarga.push( | |
493 | + { | |
494 | + puntoDescarga: punto | |
495 | + } | |
496 | + ); | |
497 | + }); | |
479 | 498 | |
480 | 499 | $scope.$broadcast('addCabecera', { |
481 | 500 | label: 'Puntos de descarga:', |
482 | - valor: getCabeceraPuntoDescarga( | |
483 | - $scope.remito.domicilio.puntosDescarga) | |
501 | + valor: getCabeceraPuntoDescarga(puntosDescarga) | |
484 | 502 | }); |
485 | 503 | }, function () { |
486 | 504 | $scope.abrirModalDomicilios($scope.cliente); |
... | ... | @@ -638,12 +656,6 @@ angular.module('focaCrearRemito').controller('remitoController', |
638 | 656 | if (domicilio.verPuntos) { |
639 | 657 | delete $scope.remito.domicilio.verPuntos; |
640 | 658 | $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 | 659 | } |
648 | 660 | |
649 | 661 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; |
... | ... | @@ -1155,11 +1167,16 @@ angular.module('focaCrearRemito').controller('remitoController', |
1155 | 1167 | $scope.puntoVenta = rellenar(remito.sucursal, 4); |
1156 | 1168 | $scope.comprobante = rellenar(remito.numeroRemito, 8); |
1157 | 1169 | $scope.remito = remito; |
1158 | - if ($scope.remito.puntosDescarga) { | |
1159 | - var puntosDescarga = $scope.remito.puntosDescarga; | |
1170 | + if ($scope.remito.remitoPuntoDescarga.length) { | |
1171 | + var puntoDescarga = []; | |
1172 | + | |
1173 | + $scope.remito.remitoPuntoDescarga.forEach(function(remitoPuntoDescarga) { | |
1174 | + puntoDescarga.push(remitoPuntoDescarga.puntoDescarga); | |
1175 | + }); | |
1176 | + | |
1160 | 1177 | cabeceras.push({ |
1161 | 1178 | label: 'Puntos de descarga: ', |
1162 | - valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntosDescarga)) | |
1179 | + valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntoDescarga)) | |
1163 | 1180 | }); |
1164 | 1181 | } |
1165 | 1182 | $scope.remitoIsDirty = false; |
... | ... | @@ -1183,13 +1200,14 @@ angular.module('focaCrearRemito').controller('remitoController', |
1183 | 1200 | } |
1184 | 1201 | |
1185 | 1202 | function deleteCliente() { |
1186 | - delete $scope.remito.domicilioStamp; | |
1187 | - delete $scope.remito.puntosDescarga; | |
1203 | + $scope.remito.domicilioStamp = ''; | |
1204 | + $scope.remito.remitoPuntoDescarga = []; | |
1188 | 1205 | $scope.remito.domicilio = { dom: '' }; |
1189 | 1206 | $scope.remito.cliente = {}; |
1190 | 1207 | $scope.$broadcast('removeCabecera', 'Cliente:'); |
1191 | 1208 | $scope.$broadcast('removeCabecera', 'Domicilio:'); |
1192 | 1209 | $scope.$broadcast('removeCabecera', 'Puntos de descarga:'); |
1210 | + $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = false; | |
1193 | 1211 | } |
1194 | 1212 | |
1195 | 1213 | 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 | { |