Commit 9231617cb28cd067ec95d1116b3449b97399c0a5
Exists in
master
Merge branch 'develop' of git.focasoftware.com:npm/foca-crear-remito
Showing
2 changed files
Show diff stats
src/js/controller.js
| ... | ... | @@ -25,7 +25,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 25 | 25 | maxDate: new Date(), |
| 26 | 26 | minDate: new Date(2010, 0, 1) |
| 27 | 27 | }; |
| 28 | - | |
| 28 | + $scope.cabeceras = []; | |
| 29 | 29 | crearRemitoService.getParametros().then(function (res) { |
| 30 | 30 | var parametros = JSON.parse(res.data[0].jsonText); |
| 31 | 31 | if ($localStorage.remito) { |
| ... | ... | @@ -65,7 +65,6 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 65 | 65 | articulosRemito: [], |
| 66 | 66 | remitoPuntoDescarga: [] |
| 67 | 67 | }; |
| 68 | - | |
| 69 | 68 | $scope.notaPedido = { |
| 70 | 69 | id: 0 |
| 71 | 70 | }; |
| ... | ... | @@ -131,7 +130,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 131 | 130 | notaPedido.notaPedidoPuntoDescarga.forEach(function (notaPedido) { |
| 132 | 131 | puntosDescarga.push(notaPedido.puntoDescarga); |
| 133 | 132 | }); |
| 134 | - var cabeceras = [ | |
| 133 | + $scope.cabeceras = [ | |
| 135 | 134 | { |
| 136 | 135 | label: 'Moneda:', |
| 137 | 136 | valor: notaPedido.cotizacion.moneda.DETALLE |
| ... | ... | @@ -161,18 +160,14 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 161 | 160 | notaPedido.vendedor.NUM, 3 |
| 162 | 161 | ) + ' - ' + notaPedido.vendedor.NOM |
| 163 | 162 | }, |
| 163 | + | |
| 164 | 164 | { |
| 165 | 165 | label: 'Proveedor:', |
| 166 | 166 | valor: $filter('rellenarDigitos') |
| 167 | 167 | (notaPedido.proveedor.COD, 5) + ' - ' + |
| 168 | 168 | notaPedido.proveedor.NOM |
| 169 | 169 | }, |
| 170 | - { | |
| 171 | - label: 'Precios y condiciones:', | |
| 172 | - valor: valorPrecioCondicion() + ' ' + | |
| 173 | - remitoBusinessService | |
| 174 | - .plazoToString(notaPedido.notaPedidoPlazo) | |
| 175 | - }, | |
| 170 | + | |
| 176 | 171 | { |
| 177 | 172 | label: 'Flete:', |
| 178 | 173 | valor: notaPedido.fob === 1 ? 'FOB' : ( |
| ... | ... | @@ -184,7 +179,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 184 | 179 | getCabeceraPuntoDescarga(puntosDescarga)) |
| 185 | 180 | } |
| 186 | 181 | ]; |
| 187 | - | |
| 182 | + valorPrecioCondicion(); | |
| 188 | 183 | // Seteo checked en cabeceras |
| 189 | 184 | $filter('filter')($scope.botonera, |
| 190 | 185 | { label: 'Cliente' })[0].checked = true; |
| ... | ... | @@ -205,10 +200,17 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 205 | 200 | } |
| 206 | 201 | |
| 207 | 202 | function valorPrecioCondicion() { |
| 208 | - if (notaPedido.idPrecioCondicion > 0) { | |
| 209 | - return notaPedido.precioCondicion.nombre; | |
| 210 | - } else { | |
| 211 | - return 'Ingreso Manual'; | |
| 203 | + if (parseInt(notaPedido.idListaPrecio) > 0) { | |
| 204 | + crearRemitoService.getListaPrecioById(parseInt(notaPedido.idListaPrecio)) | |
| 205 | + .then(function (res) { | |
| 206 | + $scope.cabeceras.push({ | |
| 207 | + label: 'Precios y Condiciones:', | |
| 208 | + valor: parseInt(res.data[0].ID) + ' - ' + res.data[0].DES + ' ' + | |
| 209 | + remitoBusinessService | |
| 210 | + .plazoToString(notaPedido.notaPedidoPlazo) | |
| 211 | + }); | |
| 212 | + addArrayCabecera($scope.cabeceras); | |
| 213 | + }); | |
| 212 | 214 | } |
| 213 | 215 | } |
| 214 | 216 | |
| ... | ... | @@ -222,9 +224,9 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 222 | 224 | label: 'Kilometros:', |
| 223 | 225 | valor: notaPedido.kilometros |
| 224 | 226 | }; |
| 225 | - cabeceras.push(cabeceraKilometros); | |
| 227 | + $scope.cabeceras.push(cabeceraKilometros); | |
| 226 | 228 | } |
| 227 | - cabeceras.push(cabeceraBomba); | |
| 229 | + $scope.cabeceras.push(cabeceraBomba); | |
| 228 | 230 | } |
| 229 | 231 | |
| 230 | 232 | $scope.remito = angular.copy(notaPedido); |
| ... | ... | @@ -248,7 +250,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 248 | 250 | } |
| 249 | 251 | |
| 250 | 252 | enableObservaciones(notaPedido.observaciones ? true : false); |
| 251 | - addArrayCabecera(cabeceras); | |
| 253 | + addArrayCabecera($scope.cabeceras); | |
| 252 | 254 | |
| 253 | 255 | }, function () { |
| 254 | 256 | // funcion ejecutada cuando se cancela el modal |
| ... | ... | @@ -425,7 +427,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 425 | 427 | if ($scope.notaPedido.id !== 0) { |
| 426 | 428 | $scope.idLista = parseInt($scope.notaPedido.idListaPrecio) |
| 427 | 429 | } |
| 428 | - if ($scope.idLista === undefined) { | |
| 430 | + if ($scope.remito.idListaPrecio === undefined) { | |
| 429 | 431 | focaModalService.alert( |
| 430 | 432 | 'Primero seleccione una lista de precio y condicion'); |
| 431 | 433 | return; |
| ... | ... | @@ -437,7 +439,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 437 | 439 | controller: 'modalBusquedaProductosCtrl', |
| 438 | 440 | resolve: { |
| 439 | 441 | parametroProducto: { |
| 440 | - idLista: $scope.idLista, | |
| 442 | + idLista: $scope.idLista || parseInt($scope.remito.idListaPrecio), | |
| 441 | 443 | cotizacion: $scope.remito.cotizacion.VENDEDOR, |
| 442 | 444 | simbolo: $scope.remito.cotizacion.moneda.SIMBOLO |
| 443 | 445 | } |
| ... | ... | @@ -718,6 +720,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 718 | 720 | } |
| 719 | 721 | |
| 720 | 722 | function abrirModal() { |
| 723 | + var parametros = { idCliente: $scope.remito.cliente.COD, idListaPrecio : $scope.remito.cliente.MOD}; | |
| 721 | 724 | var modalInstance = $uibModal.open( |
| 722 | 725 | { |
| 723 | 726 | ariaLabelledBy: 'Busqueda de Precio Condiciรณn', |
| ... | ... | @@ -725,8 +728,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 725 | 728 | controller: 'focaModalPrecioCondicionController', |
| 726 | 729 | size: 'lg', |
| 727 | 730 | resolve: { |
| 728 | - idListaPrecio: function () { return $scope.remito.cliente.MOD || null; }, | |
| 729 | - idCliente: function () { return $scope.remito.cliente.COD; } | |
| 731 | + parametros: function () { return parametros; } | |
| 730 | 732 | } |
| 731 | 733 | } |
| 732 | 734 | ); |
| ... | ... | @@ -739,6 +741,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 739 | 741 | $scope.remito.remitoPlazo = precioCondicion.plazoPago; |
| 740 | 742 | $scope.idLista = parseInt(precioCondicion.listaPrecio.ID) ? |
| 741 | 743 | parseInt(precioCondicion.listaPrecio.ID) : -1; |
| 744 | + $scope.remito.cliente.MOD = precioCondicion.listaPrecio.ID; | |
| 742 | 745 | for (var i = 0; i < precioCondicion.plazoPago.length; i++) { |
| 743 | 746 | plazosConcat += precioCondicion.plazoPago[i].dias + ', '; |
| 744 | 747 | } |
| ... | ... | @@ -753,17 +756,17 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 753 | 756 | for (var j = 0; j < precioCondicion.length; j++) { |
| 754 | 757 | plazosConcat += precioCondicion[j].dias + ' '; |
| 755 | 758 | } |
| 756 | - cabecera = 'Ingreso manual ' + plazosConcat.trim(); | |
| 759 | + cabecera = plazosConcat.trim(); | |
| 757 | 760 | } |
| 758 | 761 | $scope.remito.articulosRemito = []; |
| 759 | - $scope.$broadcast('addCabecera', { | |
| 760 | - label: 'Precios y condiciones:', | |
| 761 | - valor: cabecera | |
| 762 | - }); | |
| 762 | + $filter('filter')($scope.cabeceras, | |
| 763 | + { label: 'Precios y Condiciones' })[0].valor = cabecera; | |
| 764 | + | |
| 763 | 765 | $scope.remito.precioCondicion = precioCondicion; |
| 764 | 766 | |
| 765 | 767 | $filter('filter')($scope.botonera, |
| 766 | 768 | { label: 'Precios y Condiciones' })[0].checked = true; |
| 769 | + addArrayCabecera($scope.cabeceras); | |
| 767 | 770 | }, function () { |
| 768 | 771 | |
| 769 | 772 | } |
| ... | ... | @@ -1098,19 +1101,19 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 1098 | 1101 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
| 1099 | 1102 | $scope.$broadcast('removeCabecera', 'Vendedor:'); |
| 1100 | 1103 | |
| 1101 | - var cabeceras = []; | |
| 1104 | + $scope.cabeceras = []; | |
| 1102 | 1105 | |
| 1103 | 1106 | if (remito.cotizacion && remito.cotizacion.moneda.CODIGO_AFIP !== 'PES') { |
| 1104 | - cabeceras.push({ | |
| 1107 | + $scope.cabeceras.push({ | |
| 1105 | 1108 | label: 'Moneda:', |
| 1106 | 1109 | valor: remito.cotizacion.moneda.DETALLE |
| 1107 | 1110 | }); |
| 1108 | - cabeceras.push({ | |
| 1111 | + $scope.cabeceras.push({ | |
| 1109 | 1112 | label: 'Fecha cotizacion:', |
| 1110 | 1113 | valor: $filter('date')(remito.cotizacion.FECHA, |
| 1111 | 1114 | 'dd/MM/yyyy') |
| 1112 | 1115 | }); |
| 1113 | - cabeceras.push({ | |
| 1116 | + $scope.cabeceras.push({ | |
| 1114 | 1117 | label: 'Cotizacion:', |
| 1115 | 1118 | valor: $filter('number')(remito.cotizacion.VENDEDOR, |
| 1116 | 1119 | '2') |
| ... | ... | @@ -1122,12 +1125,12 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 1122 | 1125 | } |
| 1123 | 1126 | |
| 1124 | 1127 | if (remito.cliente && remito.cliente.COD) { |
| 1125 | - cabeceras.push({ | |
| 1128 | + $scope.cabeceras.push({ | |
| 1126 | 1129 | label: 'Cliente:', |
| 1127 | 1130 | valor: $filter('rellenarDigitos')(remito.cliente.COD, 3) + ' - ' + |
| 1128 | 1131 | remito.cliente.NOM |
| 1129 | 1132 | }); |
| 1130 | - cabeceras.push({ | |
| 1133 | + $scope.cabeceras.push({ | |
| 1131 | 1134 | label: 'Domicilio:', |
| 1132 | 1135 | valor: remito.domicilioStamp |
| 1133 | 1136 | }); |
| ... | ... | @@ -1135,14 +1138,14 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 1135 | 1138 | $filter('filter')($scope.botonera, { label: 'Cliente' })[0].checked = true; |
| 1136 | 1139 | } |
| 1137 | 1140 | if (remito.vendedor && remito.vendedor.NUM) { |
| 1138 | - cabeceras.push({ | |
| 1141 | + $scope.cabeceras.push({ | |
| 1139 | 1142 | label: 'Vendedor:', |
| 1140 | 1143 | valor: $filter('rellenarDigitos')(remito.vendedor.NUM, 3) + |
| 1141 | 1144 | ' - ' + remito.vendedor.NOM |
| 1142 | 1145 | }); |
| 1143 | 1146 | } |
| 1144 | 1147 | if (remito.proveedor && remito.proveedor.COD) { |
| 1145 | - cabeceras.push({ | |
| 1148 | + $scope.cabeceras.push({ | |
| 1146 | 1149 | label: 'Proveedor:', |
| 1147 | 1150 | valor: $filter('rellenarDigitos')(remito.proveedor.COD, 5) + |
| 1148 | 1151 | ' - ' + remito.proveedor.NOM |
| ... | ... | @@ -1151,29 +1154,36 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 1151 | 1154 | $filter('filter')($scope.botonera, { label: 'Proveedor' })[0].checked = true; |
| 1152 | 1155 | } |
| 1153 | 1156 | if (remito.flete !== undefined && remito.fob !== undefined) { |
| 1154 | - cabeceras.push({ | |
| 1157 | + $scope.cabeceras.push({ | |
| 1155 | 1158 | label: 'Flete:', |
| 1156 | 1159 | valor: remito.fob ? 'FOB' : ( |
| 1157 | 1160 | remito.flete ? 'Si' : 'No') |
| 1158 | 1161 | }); |
| 1159 | 1162 | } |
| 1160 | 1163 | if (remito.remitoPlazo) { |
| 1161 | - cabeceras.push({ | |
| 1162 | - label: 'Precio condicion:', | |
| 1163 | - valor: valorPrecioCondicion() + ' ' + | |
| 1164 | - remitoBusinessService.plazoToString(remito.remitoPlazo) | |
| 1165 | - }); | |
| 1166 | - | |
| 1164 | + valorPrecioCondicion(); | |
| 1167 | 1165 | $filter('filter')($scope.botonera, |
| 1168 | 1166 | { label: 'Precios y condiciones' })[0].checked = true; |
| 1169 | 1167 | } |
| 1168 | + | |
| 1170 | 1169 | function valorPrecioCondicion() { |
| 1171 | - if (remito.idPrecioCondicion > 0) { | |
| 1172 | - return remito.precioCondicion.nombre; | |
| 1173 | - } else { | |
| 1174 | - return 'Ingreso Manual'; | |
| 1170 | + if (parseInt(remito.idListaPrecio)) { | |
| 1171 | + crearRemitoService.getListaPrecioById(parseInt(remito.idListaPrecio)) | |
| 1172 | + .then(function (res) { | |
| 1173 | + $timeout(function () { | |
| 1174 | + $scope.cabeceras.push({ | |
| 1175 | + label: 'Precios y Condiciones:', | |
| 1176 | + valor: parseInt(res.data[0].ID) + ' - ' + res.data[0].DES + ' ' + | |
| 1177 | + remitoBusinessService | |
| 1178 | + .plazoToString(remito.remitoPlazo) | |
| 1179 | + }); | |
| 1180 | + addArrayCabecera($scope.cabeceras); | |
| 1181 | + },true); | |
| 1182 | + | |
| 1183 | + }); | |
| 1175 | 1184 | } |
| 1176 | 1185 | } |
| 1186 | + | |
| 1177 | 1187 | if (remito.flete === 1) { |
| 1178 | 1188 | var cabeceraBomba = { |
| 1179 | 1189 | label: 'Bomba', |
| ... | ... | @@ -1184,9 +1194,9 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 1184 | 1194 | label: 'Kilometros', |
| 1185 | 1195 | valor: remito.kilometros |
| 1186 | 1196 | }; |
| 1187 | - cabeceras.push(cabeceraKilometros); | |
| 1197 | + $scope.cabeceras.push(cabeceraKilometros); | |
| 1188 | 1198 | } |
| 1189 | - cabeceras.push(cabeceraBomba); | |
| 1199 | + $scope.cabeceras.push(cabeceraBomba); | |
| 1190 | 1200 | } |
| 1191 | 1201 | |
| 1192 | 1202 | if (remito.idPrecioCondicion > 0) { |
| ... | ... | @@ -1204,7 +1214,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 1204 | 1214 | puntoDescarga.push(remitoPuntoDescarga.puntoDescarga); |
| 1205 | 1215 | }); |
| 1206 | 1216 | |
| 1207 | - cabeceras.push({ | |
| 1217 | + $scope.cabeceras.push({ | |
| 1208 | 1218 | label: 'Puntos de descarga: ', |
| 1209 | 1219 | valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntoDescarga)) |
| 1210 | 1220 | }); |
| ... | ... | @@ -1212,7 +1222,7 @@ angular.module('focaCrearRemito').controller('remitoController', |
| 1212 | 1222 | $scope.remitoIsDirty = false; |
| 1213 | 1223 | |
| 1214 | 1224 | |
| 1215 | - addArrayCabecera(cabeceras); | |
| 1225 | + addArrayCabecera($scope.cabeceras); | |
| 1216 | 1226 | } |
| 1217 | 1227 | |
| 1218 | 1228 | function getLSRemito() { |
src/js/service.js
| ... | ... | @@ -48,6 +48,9 @@ angular.module('focaCrearRemito') |
| 48 | 48 | getPrecioCondicionById: function(id) { |
| 49 | 49 | return $http.get(route + '/precio-condicion/' + id); |
| 50 | 50 | }, |
| 51 | + getListaPrecioById: function (id) { | |
| 52 | + return $http.get(route + '/lista-precio/' + id); | |
| 53 | + }, | |
| 51 | 54 | getPlazoPagoByPrecioCondicion: function(id) { |
| 52 | 55 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); |
| 53 | 56 | }, |