mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-13 00:48:49 +00:00
corregidos varios fallos de presupuesto
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package com.imprimelibros.erp.externalApi;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
@ -20,6 +21,7 @@ import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.Locale;
|
||||
|
||||
@Service
|
||||
public class skApiClient {
|
||||
@ -30,11 +32,13 @@ public class skApiClient {
|
||||
private final AuthService authService;
|
||||
private final RestTemplate restTemplate;
|
||||
private final MargenPresupuestoDao margenPresupuestoDao;
|
||||
private final MessageSource messageSource;
|
||||
|
||||
public skApiClient(AuthService authService, MargenPresupuestoDao margenPresupuestoDao) {
|
||||
public skApiClient(AuthService authService, MargenPresupuestoDao margenPresupuestoDao, MessageSource messageSource) {
|
||||
this.authService = authService;
|
||||
this.restTemplate = new RestTemplate();
|
||||
this.margenPresupuestoDao = margenPresupuestoDao;
|
||||
this.messageSource = messageSource;
|
||||
}
|
||||
|
||||
public String getPrice(Map<String, Object> requestBody, TipoEncuadernacion tipoEncuadernacion,
|
||||
@ -113,7 +117,7 @@ public class skApiClient {
|
||||
});
|
||||
}
|
||||
|
||||
public Integer getMaxSolapas(Map<String, Object> requestBody) {
|
||||
public Integer getMaxSolapas(Map<String, Object> requestBody, Locale locale) {
|
||||
try {
|
||||
String jsonResponse = performWithRetry(() -> {
|
||||
String url = this.skApiUrl + "api/calcular-solapas";
|
||||
@ -150,7 +154,7 @@ public class skApiClient {
|
||||
JsonNode root = mapper.readTree(jsonResponse);
|
||||
|
||||
if (root.get("data") == null || !root.get("data").isInt()) {
|
||||
throw new RuntimeException("Respuesta inesperada de calcular-solapas: " + jsonResponse);
|
||||
throw new RuntimeException(messageSource.getMessage("presupuesto.errores.error-interior", new Object[]{1} , locale));
|
||||
}
|
||||
|
||||
return root.get("data").asInt();
|
||||
|
||||
Reference in New Issue
Block a user