mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-24 09:40:21 +00:00
cargando carrito desde backend
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user