this.coreManager = coreManager;
}
@Get("json")
public SgwtRestResponseBase getRepresent(){
SgwtRestFetchResponseBase resp = null;
Integer retId = RequestUtil.getInteger(getQuery().getValues("retId"));
List<ReturnToSupplierDetail> details = coreManager.getReturnToSupplierDetails(retId);
List<DisplayReturnToSupplierDetail> resultList = new ArrayList<DisplayReturnToSupplierDetail>();
for (ReturnToSupplierDetail retDetail : details) {
ProductMeasurement productMeasurement = null;
if(retDetail.getProduct().getProductMeasurement() != null && !retDetail.getProduct().getProductMeasurement().isEmpty()){
productMeasurement = retDetail.getProduct().getProductMeasurement().iterator().next();
}
DisplayReturnToSupplierDetail det = mapper.map(retDetail, DisplayReturnToSupplierDetail.class);
if(retDetail.getReturnToSupplier().getStatus().equals(Status.COMPLETED)){
det.setCostPrice(retDetail.getCostPriceOnCompleted());
}else{
det.setCostPrice(retDetail.getProduct().getBuying().getCostPrice());
}
if(productMeasurement != null){
det.getProduct().setProductMeasurement(mapper.map(productMeasurement, DisplayProductMeasurement.class));
}
resultList.add(det);
}
resp = new SgwtRestFetchResponseBase(resultList);
return resp;
}