package net.sourceforge.fenixedu.domain.serviceRequests.documentRequests; import net.sourceforge.fenixedu.dataTransferObject.serviceRequests.DocumentRequestCreateBean; import net.sourceforge.fenixedu.domain.accounting.EventType; import net.sourceforge.fenixedu.domain.exceptions.DomainException; import org.joda.time.YearMonthDay; import com.linkare.commons.metainfo.Linkare; public class IRSDeclarationRequest extends IRSDeclarationRequest_Base { static final private int FIRST_VALID_YEAR = 2006; protected IRSDeclarationRequest() { super(); } public IRSDeclarationRequest(final DocumentRequestCreateBean bean) { this(); super.init(bean); checkParameters(bean); super.setYear(bean.getYear()); } @Override protected void checkParameters(final DocumentRequestCreateBean bean) { if (bean.getYear() == null) { throw new DomainException( "error.serviceRequests.documentRequests.SchoolRegistrationDeclarationRequest.year.cannot.be.null"); } if (!bean.getRegistration().isActive()) { throw new DomainException("IRSDeclarationRequest.registration.is.not.active"); } if (new YearMonthDay(bean.getYear(), 1, 1).isBefore(new YearMonthDay(FIRST_VALID_YEAR, 1, 1))) { throw new DomainException("IRSDeclarationRequest.only.available.after.first.valid.year"); } } @Linkare(author = "Paulo Zenida", comments = "Changed the modifiers order according to the JLS suggestions") @Override public final DocumentRequestType getDocumentRequestType() { return DocumentRequestType.IRS_DECLARATION; } @Linkare(author = "Paulo Zenida", comments = "Changed the modifiers order according to the JLS suggestions") @Override public final String getDocumentTemplateKey() { return getClass().getName(); } @Linkare(author = "Paulo Zenida", comments = "Changed the modifiers order according to the JLS suggestions") @Override public final void setYear(Integer year) { throw new DomainException("error.serviceRequests.documentRequests.IRSDeclarationRequest.cannot.modify.year"); } @Linkare(author = "Paulo Zenida", comments = "Changed the modifiers order according to the JLS suggestions") @Override public final EventType getEventType() { return null; } @Override protected boolean hasFreeDeclarationRequests() { return false; } }