Search in sources :

Example 46 with Party

use of org.estatio.module.party.dom.Party in project estatio by estatio.

the class BankMandateImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    final Lease lease = fetchLease(leaseReference);
    BankAccount bankAccount;
    BankMandate bankMandate = null;
    // find or create bank account
    final Party owner = lease.getSecondaryParty();
    bankAccount = (BankAccount) financialAccountRepository.findByOwnerAndReference(owner, bankAccountReference);
    if (bankAccount == null) {
        bankAccount = bankAccountRepository.newBankAccount(owner, bankAccountReference, null);
    }
    if (reference != null) {
        bankMandate = bankMandateRepository.findByReference(reference);
    }
    if (bankMandate == null) {
        lease.newMandate(bankAccount, reference, startDate, endDate, SequenceType.valueOf(sequenceType), Scheme.valueOf(scheme), signatureDate);
        bankMandate = lease.getPaidBy();
    }
    bankMandate.setBankAccount(bankAccount);
    bankMandate.setReference(reference);
    bankMandate.setName(name);
    bankMandate.setStartDate(startDate);
    bankMandate.setEndDate(endDate);
    bankMandate.setSepaMandateIdentifier(sepaMandateIdentifier);
    bankMandate.setSequenceType(SequenceType.valueOf(sequenceType));
    bankMandate.setScheme(Scheme.valueOf(scheme));
    bankMandate.setSignatureDate(signatureDate);
    lease.paidBy(bankMandate);
    return Lists.newArrayList(bankMandate);
}
Also used : Party(org.estatio.module.party.dom.Party) Lease(org.estatio.module.lease.dom.Lease) BankAccount(org.estatio.module.financial.dom.BankAccount) BankMandate(org.estatio.module.bankmandate.dom.BankMandate) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 47 with Party

use of org.estatio.module.party.dom.Party in project estatio by estatio.

the class PartyRelationshipRepository method on.

// //////////////////////////////////////
/**
 * Although this is an intra-module interaction, we use the subscriber because many of the other modules need to subscribe to this event also.
 */
@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final Party.DeleteEvent ev) {
    Party sourceParty = ev.getSource();
    Party replacementParty = ev.getReplacement();
    switch(ev.getEventPhase()) {
        case VALIDATE:
            break;
        case EXECUTING:
            for (PartyRelationship partyRelationship : findByParty(sourceParty)) {
                if (replacementParty == null) {
                    // Remove relationships when no replacement is provided
                    partyRelationship.doRemove();
                } else {
                    if (partyRelationship.getFrom().equals(sourceParty)) {
                        partyRelationship.setFrom(replacementParty);
                    }
                    if (partyRelationship.getTo().equals(sourceParty)) {
                        partyRelationship.setTo(replacementParty);
                    }
                }
            }
            break;
        default:
            break;
    }
}
Also used : Party(org.estatio.module.party.dom.Party) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 48 with Party

use of org.estatio.module.party.dom.Party in project estatio by estatio.

the class AgreementCommunicationChannelLocator method onFile.

@Programmatic
public List<CommunicationChannel> onFile(final Agreement agreement, final String art, final List<CommunicationChannelType> communicationChannelTypes) {
    final List<CommunicationChannel> communicationChannels = Lists.newArrayList();
    final AgreementRoleType partyInRoleOf = agreementRoleTypeRepository.findByTitle(art);
    final SortedSet<AgreementRole> agreementRoles = agreement.getRoles();
    for (final AgreementRole role : agreementRoles) {
        if (role.getType() == partyInRoleOf) {
            final Party party = role.getParty();
            final SortedSet<CommunicationChannel> channels = communicationChannelRepository.findByOwner(party);
            for (CommunicationChannel channel : channels) {
                if (communicationChannelTypes.contains(channel.getType())) {
                    communicationChannels.add(channel);
                }
            }
            break;
        }
    }
    return communicationChannels;
}
Also used : AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Party(org.estatio.module.party.dom.Party) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) AgreementRoleCommunicationChannel(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 49 with Party

use of org.estatio.module.party.dom.Party in project estatio by estatio.

the class InvoiceAttributesVM method getSellerBankAccountBankName.

@Programmatic
public String getSellerBankAccountBankName() {
    FinancialAccount financialAccount = invoice.getSellerBankAccount();
    if (!(financialAccount instanceof BankAccount)) {
        return null;
    }
    final BankAccount bankAccount = (BankAccount) financialAccount;
    Party bank = bankAccount.getBank();
    if (bank == null) {
        return null;
    }
    return bank.getName();
}
Also used : Party(org.estatio.module.party.dom.Party) FinancialAccount(org.estatio.module.financial.dom.FinancialAccount) BankAccount(org.estatio.module.financial.dom.BankAccount) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 50 with Party

use of org.estatio.module.party.dom.Party in project estatio by estatio.

the class OrderItem_createInvoiceItemLink method choices0Act.

public List<IncomingInvoiceItem> choices0Act() {
    // the disable guard ensures this is non-null
    final Party seller = mixee.getOrdr().getSeller();
    // candidates
    final List<IncomingInvoiceItem> invoiceItems = invoiceItemRepository.findBySeller(seller);
    // exclude any invoice items already linked to this order
    invoiceItems.removeAll(orderItemInvoiceItemLinkRepository.findLinkedInvoiceItemsByOrderItem(mixee));
    // exclude those where the net amount for the invoice item has already been linked to other order items
    for (Iterator<IncomingInvoiceItem> iterator = invoiceItems.iterator(); iterator.hasNext(); ) {
        final IncomingInvoiceItem invoiceItem = iterator.next();
        final BigDecimal netAmountNotLinked = orderItemInvoiceItemLinkRepository.calculateNetAmountNotLinkedFromInvoiceItem(invoiceItem);
        if (netAmountNotLinked.compareTo(BigDecimal.ZERO) <= 0) {
            iterator.remove();
        }
    }
    return invoiceItems;
}
Also used : Party(org.estatio.module.party.dom.Party) IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) BigDecimal(java.math.BigDecimal)

Aggregations

Party (org.estatio.module.party.dom.Party)51 Programmatic (org.apache.isis.applib.annotation.Programmatic)22 Test (org.junit.Test)15 Property (org.estatio.module.asset.dom.Property)13 BankAccount (org.estatio.module.financial.dom.BankAccount)13 Organisation (org.estatio.module.party.dom.Organisation)13 IncomingInvoice (org.estatio.module.capex.dom.invoice.IncomingInvoice)10 Expectations (org.jmock.Expectations)10 AgreementRole (org.estatio.module.agreement.dom.AgreementRole)8 ArrayList (java.util.ArrayList)7 AgreementRoleType (org.estatio.module.agreement.dom.role.AgreementRoleType)7 Lease (org.estatio.module.lease.dom.Lease)6 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)6 List (java.util.List)5 Inject (javax.inject.Inject)4 Action (org.apache.isis.applib.annotation.Action)4 Country (org.incode.module.country.dom.impl.Country)4 LocalDate (org.joda.time.LocalDate)4 Optional (java.util.Optional)3 SortedSet (java.util.SortedSet)3