@Override public DGuiValidation validateForm() { String message = ""; DDbDpsSeriesNumber dpsSeriesNumber = DTrnUtils.getDpsSeriesNumber( miClient.getSession(), moRegistry.getDpsTypeKey(), moTextSeries.getValue(), moIntNumber.getValue()); DGuiValidation validation = moFields.validateFields(); if (validation.isValid()) { if (DLibTimeUtils.digestYear(moDateDate.getValue())[0] != mnOriginalYear) { validation.setMessage( DGuiConsts.ERR_MSG_FIELD_DATE_ + "'" + DGuiUtils.getLabelName(jlDateDate.getText()) + "'" + DGuiConsts.ERR_MSG_FIELD_DATE_YEAR + DLibUtils.DecimalFormatCalendarYear.format(mnOriginalYear) + "."); validation.setComponent(moDateDate); } else if (dpsSeriesNumber != null && dpsSeriesNumber.getApprobationDate_n() != null && dpsSeriesNumber.getApprobationDate_n().after(moDateDate.getValue())) { validation.setMessage( DGuiConsts.ERR_MSG_FIELD_DATE_ + "'" + DGuiUtils.getLabelName(jlDateDate.getText()) + "'" + DGuiConsts.ERR_MSG_FIELD_DATE_GREAT_EQUAL + DLibUtils.DateFormatDate.format(dpsSeriesNumber.getApprobationDate_n()) + ", fecha de aprobación de los folios del documento."); validation.setComponent(moDateDate); } else { // Validate document number: if (validation.isValid()) { moRegistry.setSeries(moTextSeries.getValue()); moRegistry.setNumber(moIntNumber.getValue()); message = DTrnUtils.validateNumberForDps(miClient.getSession(), moRegistry); if (!message.isEmpty()) { validation.setMessage(message); validation.setComponent(moIntNumber); } else if (moRegistry.isRegistryNew() && DTrnUtils.isDpsNumberAutomatic(moRegistry.getDpsClassKey())) { moIntNumber.setValue(moRegistry.getNumber()); // new document number could be updated } } } } return validation; }