Search in sources :

Example 6 with Party

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

the class LeaseBuilderLEGACY method createLease.

protected Lease createLease(String reference, String name, String unitReference, String brand, BrandCoverage brandCoverage, String countryOfOriginRef, String sector, String activity, String landlordReference, String tenantReference, LocalDate startDate, LocalDate endDate, boolean createManagerRole, boolean createLeaseUnitAndTags, Party manager, ExecutionContext fixtureResults) {
    Unit unit = unitRepository.findUnitByReference(unitReference);
    Party landlord = findPartyByReferenceOrNameElseNull(landlordReference);
    Party tenant = findPartyByReferenceOrNameElseNull(tenantReference);
    Lease lease = leaseRepository.newLease(unit.getApplicationTenancy(), reference, name, null, startDate, null, endDate, landlord, tenant);
    fixtureResults.addResult(this, lease.getReference(), lease);
    if (createManagerRole) {
        final AgreementRole role = lease.createRole(agreementRoleTypeRepository.findByTitle(LeaseAgreementRoleTypeEnum.MANAGER.getTitle()), manager, null, null);
        fixtureResults.addResult(this, role);
    }
    if (createLeaseUnitAndTags) {
        Country countryOfOrigin = countryRepository.findCountry(countryOfOriginRef);
        Occupancy occupancy = occupancyRepository.newOccupancy(lease, unit, startDate);
        occupancy.setBrandName(brand, brandCoverage, countryOfOrigin);
        occupancy.setSectorName(sector);
        occupancy.setActivityName(activity);
        fixtureResults.addResult(this, occupancy);
    }
    if (leaseRepository.findLeaseByReference(reference) == null) {
        throw new RuntimeException("could not find lease reference='" + reference + "'");
    }
    return lease;
}
Also used : Party(org.estatio.module.party.dom.Party) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Lease(org.estatio.module.lease.dom.Lease) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) Country(org.incode.module.country.dom.impl.Country) Unit(org.estatio.module.asset.dom.Unit)

Example 7 with Party

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

the class BankMandateBuilder method execute.

@Override
protected void execute(final ExecutionContext ec) {
    checkParam("agreement", ec, Agreement.class);
    checkParam("bankAccount", ec, BankAccount.class);
    checkParam("sequence", ec, Integer.class);
    // these are optional in the domain, so perhaps don't need to be mandatory
    checkParam("sequenceType", ec, Integer.class);
    checkParam("scheme", ec, Scheme.class);
    checkParam("leaseDate", ec, LocalDate.class);
    final AgreementRoleType agreementRoleType = agreementRoleTypeRepository.findByTitle(LeaseAgreementRoleTypeEnum.TENANT.getTitle());
    final AgreementRole role = agreementRoleRepository.findByAgreementAndTypeAndContainsDate(agreement, agreementRoleType, leaseDate);
    final Party owner = role.getParty();
    final BankMandate bankMandate = bankMandateRepository.newBankMandate(referenceFrom(owner, sequence), owner.getReference(), agreement.getStartDate(), agreement.getEndDate(), agreement.getSecondaryParty(), agreement.getPrimaryParty(), bankAccount, sequenceType, scheme, agreement.getStartDate());
    ec.addResult(this, bankMandate.getReference(), bankMandate);
    object = bankMandate;
}
Also used : AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Party(org.estatio.module.party.dom.Party) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) BankMandate(org.estatio.module.bankmandate.dom.BankMandate)

Example 8 with Party

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

the class PartySubscriptions method on.

@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final Party.FixEvent ev) {
    switch(ev.getEventPhase()) {
        case EXECUTING:
            Party sourceParty = (Party) ev.getSource();
            final List<AgreementRole> roles = agreementRoleRepository.findByParty(sourceParty);
            for (AgreementRole role : roles) {
                sourceParty.addRole(role.getType());
            }
            break;
        default:
            break;
    }
}
Also used : Party(org.estatio.module.party.dom.Party) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 9 with Party

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

the class PartySubscriptions method on.

@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final Party.DeleteEvent ev) {
    Party sourceParty = (Party) ev.getSource();
    Party replacementParty = ev.getReplacement();
    List<AgreementRole> agreementRoles;
    switch(ev.getEventPhase()) {
        case VALIDATE:
            agreementRoles = agreementRoleRepository.findByParty(sourceParty);
            if (replacementParty == null && agreementRoles.size() > 0) {
                ev.invalidate("Party is being used in an agreement role: remove roles or provide a replacement");
            } else {
                scratchpad.put(onPartyRemoveScratchpadKey = UUID.randomUUID(), agreementRoles);
            }
            break;
        case EXECUTING:
            agreementRoles = (List<AgreementRole>) scratchpad.get(onPartyRemoveScratchpadKey);
            for (AgreementRole agreementRole : agreementRoles) {
                agreementRole.setParty(replacementParty);
            }
            break;
        default:
            break;
    }
}
Also used : Party(org.estatio.module.party.dom.Party) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 10 with Party

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

the class Order method title.

public String title() {
    final TitleBuffer buf = new TitleBuffer();
    final Optional<Document> document = lookupAttachedPdfService.lookupOrderPdfFrom(this);
    document.ifPresent(d -> buf.append(d.getName()));
    final Party seller = getSeller();
    if (seller != null) {
        buf.append(": ", seller);
    }
    final String orderNumber = getOrderNumber();
    if (orderNumber != null) {
        buf.append(", ", orderNumber);
    }
    return buf.toString();
}
Also used : Party(org.estatio.module.party.dom.Party) TitleBuffer(org.apache.isis.applib.util.TitleBuffer) Document(org.incode.module.document.dom.impl.docs.Document)

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