@Transactional public long createPreApprovedVoucherFromBill(final int billId,final String voucherNumber,final Date voucherDate) throws ApplicationRuntimeException, ValidationException {
  String voucherStatus=null;
  long vh=-1;
  try {
    final List vStatusList=appConfigValuesService.getConfigValuesByModuleAndKey("EGF","PREAPPROVEDVOUCHERSTATUS");
    if (!vStatusList.isEmpty() && vStatusList.size() == 1) {
      final AppConfigValues appVal=(AppConfigValues)vStatusList.get(0);
      voucherStatus=appVal.getValue();
    }
 else     throw new ApplicationRuntimeException("PREAPPROVEDVOUCHERSTATUS" + MISSINGMSG);
    vh=createVoucher.createVoucherFromBill(billId,voucherStatus,voucherNumber,voucherDate);
  }
 catch (  final ValidationException e) {
    LOGGER.error(e.getErrors());
    throw new ValidationException(e.getErrors());
  }
catch (  final Exception e) {
    LOGGER.error(e.getMessage());
    throw new ApplicationRuntimeException(e.getMessage());
  }
  return vh;
}

@ Transactional public long createPreApprovedVoucherFromBill ( final int billId , final String voucherNumber , final Date voucherDate ) throws ApplicationRuntimeException , ValidationException { String voucherStatus = null ; long vh = - 1 ; try { final List vStatusList = appConfigValuesService . getConfigValuesByModuleAndKey ( "EGF" , "PREAPPROVEDVOUCHERSTATUS" ) ; if ( ! vStatusList . isEmpty ( ) && vStatusList . size ( ) == 1 ) { final AppConfigValues appVal = ( AppConfigValues ) vStatusList . get ( 0 ) ; voucherStatus = appVal . getValue ( ) ; } else throw new ApplicationRuntimeException ( "PREAPPROVEDVOUCHERSTATUS" + MISSINGMSG ) ; vh = createVoucher . createVoucherFromBill ( billId , voucherStatus , voucherNumber , voucherDate ) ; } catch ( final ValidationException e ) { LOGGER . error ( e . getErrors ( ) ) ; throw new ValidationException ( e . getErrors ( ) ) ; } catch ( final Exception e ) { LOGGER . error ( e . getMessage ( ) ) ; throw new ApplicationRuntimeException ( e . getMessage ( ) ) ; } return vh ; }
api to create voucher in pre approved status
