cargando carrito desde backend

This commit is contained in:
2025-10-29 23:30:33 +01:00
parent ae2904aa71
commit feff9ee94a
23 changed files with 848 additions and 183 deletions

View File

@ -920,4 +920,28 @@ public class Presupuesto extends AbstractAuditedEntity implements Cloneable {
public void setId(Long id){
this.id = id;
}
public Double getPeso(){
// get peso from first element of pricingSnapshotJson (need to parse JSON)
// pricingSnapshotJson = {"xxx":{"peso":0.5,...}} is a String
if (this.pricingSnapshotJson != null && !this.pricingSnapshotJson.isEmpty()) {
try {
String json = this.pricingSnapshotJson.trim();
int pesoIndex = json.indexOf("\"peso\":");
if (pesoIndex != -1) {
int startIndex = pesoIndex + 7;
int endIndex = json.indexOf(",", startIndex);
if (endIndex == -1) {
endIndex = json.indexOf("}", startIndex);
}
String pesoStr = json.substring(startIndex, endIndex).trim();
return Double.parseDouble(pesoStr);
}
} catch (Exception e) {
// log error
e.printStackTrace();
}
}
return null;
}
}