public ActionForward generateNewIRSDeclaration(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
HttpServletResponse response) {
final Person person = getPerson(request);
final IRSDeclarationDTO declarationDTO = getRenderedObject("declarationDTO");
try {
if (declarationDTO.getCivilYear().intValue() >= new LocalDate().getYear()) {
addActionMessage("error", request, "error.annual.irs.declaration.year.must.be.previous.to.current");
} else {
byte[] declaration = buildIRSCustomDeclaration(declarationDTO, person);
AnnualIRSDeclarationDocument.create(person, getLoggedPerson(request), declaration, declarationDTO.getCivilYear());
addActionMessage("success", request, "message.new.irs.annual.document.generated.with.success");
}
} catch (final DomainException e) {
addActionMessage("error", request, e.getMessage(), e.getArgs());