mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-18 23:00:21 +00:00
trabajando en modificar para obtener los servicios
This commit is contained in:
@ -44,9 +44,6 @@ public class PresupuestoService {
|
||||
@Autowired
|
||||
protected MessageSource messageSource;
|
||||
|
||||
@Autowired
|
||||
protected skApiClient skApiClient;
|
||||
|
||||
@Autowired
|
||||
protected MaquetacionPreciosRepository maquetacionPreciosRepository;
|
||||
|
||||
@ -58,10 +55,12 @@ public class PresupuestoService {
|
||||
|
||||
private final PresupuestadorItems presupuestadorItems;
|
||||
private final PresupuestoFormatter presupuestoFormatter;
|
||||
private final skApiClient apiClient;
|
||||
|
||||
public PresupuestoService(PresupuestadorItems presupuestadorItems, PresupuestoFormatter presupuestoFormatter) {
|
||||
public PresupuestoService(PresupuestadorItems presupuestadorItems, PresupuestoFormatter presupuestoFormatter, skApiClient apiClient) {
|
||||
this.presupuestadorItems = presupuestadorItems;
|
||||
this.presupuestoFormatter = presupuestoFormatter;
|
||||
this.apiClient = apiClient;
|
||||
}
|
||||
|
||||
public boolean validateDatosGenerales(int[] tiradas) {
|
||||
@ -453,18 +452,18 @@ public class PresupuestoService {
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("tirada",
|
||||
presupuesto.getSelectedTirada() != null ? presupuesto.getSelectedTirada() : tirada_min);
|
||||
Double precio_retractilado = skApiClient.getRetractilado(requestBody);
|
||||
Double precio_retractilado = apiClient.getRetractilado(requestBody);
|
||||
return precio_retractilado != null
|
||||
? NumberFormat.getNumberInstance(locale)
|
||||
.format(Math.round(precio_retractilado * 100.0) / 100.0)
|
||||
: "0,00";
|
||||
}
|
||||
|
||||
public Map<String, Object> obtenerServiciosExtras(Presupuesto presupuesto, Locale locale, skApiClient apiClient) {
|
||||
public Map<String, Object> obtenerServiciosExtras(Presupuesto presupuesto, Locale locale) {
|
||||
|
||||
List<Object> opciones = new ArrayList<>();
|
||||
|
||||
Double price_prototipo = this.obtenerPrototipo(presupuesto, apiClient);
|
||||
Double price_prototipo = this.obtenerPrototipo(presupuesto);
|
||||
|
||||
opciones.add(new HashMap<String, String>() {
|
||||
{
|
||||
@ -561,7 +560,7 @@ public class PresupuestoService {
|
||||
return response;
|
||||
}
|
||||
|
||||
private Double obtenerPrototipo(Presupuesto presupuesto, skApiClient apiClient) {
|
||||
private Double obtenerPrototipo(Presupuesto presupuesto) {
|
||||
|
||||
// Obtenemos el precio de 1 unidad para el ejemplar de prueba
|
||||
HashMap<String, Object> price = new HashMap<>();
|
||||
@ -775,13 +774,30 @@ public class PresupuestoService {
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> getResumen(Presupuesto presupuesto, String[] servicios, Locale locale) {
|
||||
Map<String, Object> resumen = new HashMap<>();
|
||||
|
||||
|
||||
|
||||
resumen.put("titulo", presupuesto.getTitulo());
|
||||
resumen.put("texto", presupuestoFormatter.resumen(presupuesto, servicios, locale));
|
||||
|
||||
return resumen;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> calcularPresupuesto(Presupuesto presupuesto, Locale locale) {
|
||||
|
||||
HashMap<String, Object> price = new HashMap<>();
|
||||
String priceStr = apiClient.getPrice(this.toSkApiRequest(presupuesto));
|
||||
|
||||
try {
|
||||
price = new ObjectMapper().readValue(priceStr, new TypeReference<>() {
|
||||
});
|
||||
} catch (JsonProcessingException e) {
|
||||
price = new HashMap<>();
|
||||
price.put("error", messageSource.getMessage("presupuesto.error-obtener-precio", null, locale));
|
||||
}
|
||||
|
||||
return price;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user