I have GenericValue called value that I use to put transaction details before proceeding to the delegator.create(makevalue) inside try-catch block
I want to check the amount inside the delegator before that try-catch block if it's really a BigDecimal or a String was put inside and return the error to the client before I get that database error.
How can I get that amount field inside that makevalue GenericValue?
public static Map<String, Object> createTransaction(Delegator delegator, String caseIds, BigDecimal amountToPay,String createdBy) {
String caseId = caseIds.replaceAll(",", "");
GenericValue caseELI = getEntityValue(delegator,"Cases", "caseId", caseId);
GenericValue makeValue = delegator.makeValue("AccountTransaction");
Long accountTransactionId = delegator.getNextSeqIdLong("AccountTransaction");
makeValue.put("accountTransactionId", accountTransactionId);
makeValue.put("caseId",caseId);
makeValue.put("clientId", caseELI.getString("clientId"));
makeValue.put("amount",amountToPay);
makeValue.put("isCash","Y");
makeValue.put("isPosted","Y");
makeValue.put("createdBy",createdBy);
try {
delegator.create(makeValue);
} catch(GenericEntityException e){
e.printStackTrace();
}
Map<String, Object> result = ServiceUtil.returnSuccess("Transaction processed successfully");
return result;
}