package net.sourceforge.fenixedu.dataTransferObject.accounting; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import net.sourceforge.fenixedu.domain.DomainReference; import net.sourceforge.fenixedu.domain.accounting.Entry; import net.sourceforge.fenixedu.domain.accounting.Receipt; public class CreateCreditNoteBean implements Serializable { private List creditNoteEntryDTOs; private DomainReference receipt; public CreateCreditNoteBean(final Receipt receipt) { setReceipt(receipt); setCreditNoteEntryDTOs(buildCreditNoteEntryDTOs(receipt)); } public Receipt getReceipt() { return (this.receipt != null) ? this.receipt.getObject() : null; } public void setReceipt(Receipt receipt) { this.receipt = (receipt != null) ? new DomainReference(receipt) : null; } public List getCreditNoteEntryDTOs() { return creditNoteEntryDTOs; } public void setCreditNoteEntryDTOs(List creditNoteEntryDTOs) { this.creditNoteEntryDTOs = creditNoteEntryDTOs; } private List buildCreditNoteEntryDTOs(final Receipt receipt) { final List result = new ArrayList(); for (final Entry entry : receipt.getReimbursableEntries()) { result.add(new CreditNoteEntryDTO(entry)); } return result; } public List getSelectedEntries() { final List result = new ArrayList(); for (final CreditNoteEntryDTO creditNoteEntryDTO : getCreditNoteEntryDTOs()) { if (creditNoteEntryDTO.isSelected()) { result.add(creditNoteEntryDTO); } } return result; } }