@RequestMapping(value="/fe/taxreceipts/process/donate") public ResponseEntity<String> processDonate(@RequestParam(value="cnpj") String cnpj,@RequestParam(value="date") Date date,@RequestParam(value="coo") String coo,@RequestParam(value="total") double total,@RequestParam(value="transactionId") String transactionId){
  HttpHeaders responseHeaders=super.createBasicHttpHeaderResponse(APPLICATION_JSON);
  Gson gson=new Gson();
  ResultResponse resultResponse;
  try {
    Assert.isTrue(StringUtils.validateCNPJ(cnpj));
    Assert.notNull(coo);
    Assert.isTrue(StringUtils.isNumeric(coo));
    Assert.isTrue(total != 0);
    Assert.notNull(transactionId);
    Assert.isTrue(!transactionId.equals(""));
    OCRTransaction ocrTransaction=ocrTransactionDAO.findById(new OCRTransaction(transactionId));
    Assert.notNull(ocrTransaction);
    TaxReceipt taxReceipt=new TaxReceipt();
    taxReceipt.setCnpj(cnpj.replaceAll("[^\\d]",""));
    taxReceipt.setDate(date);
    taxReceipt.setCoo(coo);
    taxReceipt.setTotal(total);
    taxReceipt.setS3Object(ocrTransaction.getS3Object());
    taxReceipt.setDateInsertion(new Date());
    taxReceiptDAO.save(taxReceipt);
    ocrTransactionDAO.remove(ocrTransaction);
    resultResponse=new ResultResponse(true);
  }
 catch (  Exception ex) {
    ex.printStackTrace();
    resultResponse=new ResultResponse(false);
  }
  return new ResponseEntity<>(gson.toJson(resultResponse),responseHeaders,HttpStatus.OK);
}

@ RequestMapping ( value = "/fe/taxreceipts/process/donate" ) public ResponseEntity < String > processDonate ( @ RequestParam ( value = "cnpj" ) String cnpj , @ RequestParam ( value = "date" ) Date date , @ RequestParam ( value = "coo" ) String coo , @ RequestParam ( value = "total" ) double total , @ RequestParam ( value = "transactionId" ) String transactionId ) { HttpHeaders responseHeaders = super . createBasicHttpHeaderResponse ( APPLICATION_JSON ) ; Gson gson = new Gson ( ) ; ResultResponse resultResponse ; try { Assert . isTrue ( StringUtils . validateCNPJ ( cnpj ) ) ; Assert . notNull ( coo ) ; Assert . isTrue ( StringUtils . isNumeric ( coo ) ) ; Assert . isTrue ( total != 0 ) ; Assert . notNull ( transactionId ) ; Assert . isTrue ( ! transactionId . equals ( "" ) ) ; OCRTransaction ocrTransaction = ocrTransactionDAO . findById ( new OCRTransaction ( transactionId ) ) ; Assert . notNull ( ocrTransaction ) ; TaxReceipt taxReceipt = new TaxReceipt ( ) ; taxReceipt . setCnpj ( cnpj . replaceAll ( "[^\\d]" , "" ) ) ; taxReceipt . setDate ( date ) ; taxReceipt . setCoo ( coo ) ; taxReceipt . setTotal ( total ) ; taxReceipt . setS3Object ( ocrTransaction . getS3Object ( ) ) ; taxReceipt . setDateInsertion ( new Date ( ) ) ; taxReceiptDAO . save ( taxReceipt ) ; ocrTransactionDAO . remove ( ocrTransaction ) ; resultResponse = new ResultResponse ( true ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; resultResponse = new ResultResponse ( false ) ; } return new ResponseEntity < > ( gson . toJson ( resultResponse ) , responseHeaders , HttpStatus . OK ) ; }
donates the tax receipt after the user has verified all meaningful values and fixed if needed
