package net.sourceforge.fenixedu.domain.candidacy.accounting; import java.util.ArrayList; import java.util.Collection; import java.util.List; import net.sourceforge.fenixedu.domain.RootDomainObject; import net.sourceforge.fenixedu.domain.candidacy.SecondCycleCandidacy; import net.sourceforge.fenixedu.domain.candidacy.SubmittedDataCandidacySituation; import net.sourceforge.fenixedu.domain.candidacy.accounting.paymentCodes.SecondCycleCandidacyPaymentCode; import net.sourceforge.fenixedu.domain.transactions.PaymentType; import net.sourceforge.fenixedu.util.Money; import org.joda.time.DateTime; public class ATMCandidacyPaymentDetails extends ATMCandidacyPaymentDetails_Base { public ATMCandidacyPaymentDetails(SecondCycleCandidacyPaymentCode paymentCode, SecondCycleCandidacy candidacy) { super(); setPaymentCode(paymentCode); setSecondCycleCandidacy(candidacy); } @Override public boolean isCandidacyPayed() { return getPaymentCode().isProcessed(); } @Override public Money getAmount() { return getPaymentCode().getMinAmount(); } @Override public String getDescription() { return super.getDescription() + " (" + getPaymentCode().getFormattedCode() + ")"; } @Override public DateTime getWhenRegistered() { return getPaymentCode().getWhenRegistered(); } @Override public boolean isATM() { return true; } @Override public void flagAsPayed() { new SubmittedDataCandidacySituation(getSecondCycleCandidacy()); notifyCandidateOfPayment(); } public static Collection getPayedAfter(DateTime minimunDate) { List result = new ArrayList(); for (CandidacyPaymentDetails candidacyPaymentDetails : RootDomainObject.getInstance().getCandidacyPaymentDetails()) { if (candidacyPaymentDetails.isATM() && candidacyPaymentDetails.isCandidacyPayed()) { if (minimunDate == null || candidacyPaymentDetails.getWhenRegistered().isAfter(minimunDate)) { result.add((ATMCandidacyPaymentDetails) candidacyPaymentDetails); } } } return result; } @Override public PaymentType getPaymentType() { return PaymentType.ATM; } }