use of org.estatio.module.agreement.dom.AgreementRole in project estatio by estatio.
the class LeaseBuilder method createAddress.
private void createAddress(Lease lease, IAgreementRoleCommunicationChannelType addressType) {
final AgreementRoleType agreementRoleType = agreementRoleTypeRepository.find(LeaseAgreementRoleTypeEnum.TENANT);
final AgreementRole agreementRole = lease.findRoleWithType(agreementRoleType, ld(2010, 7, 15));
AgreementRoleCommunicationChannelType agreementRoleCommunicationChannelType = agreementRoleCommunicationChannelTypeRepository.find(addressType);
final SortedSet<CommunicationChannel> channels = communicationChannelRepository.findByOwnerAndType(lease.getSecondaryParty(), CommunicationChannelType.POSTAL_ADDRESS);
final CommunicationChannel postalAddress = channels.first();
agreementRole.addCommunicationChannel(agreementRoleCommunicationChannelType, postalAddress, null);
}
use of org.estatio.module.agreement.dom.AgreementRole in project estatio by estatio.
the class LeaseBuilder method addInvoiceAddressForTenant.
private void addInvoiceAddressForTenant(final Lease lease, final Party tenant, final CommunicationChannelType channelType) {
final AgreementRoleType inRoleOfTenant = agreementRoleTypeRepository.find(LeaseAgreementRoleTypeEnum.TENANT);
final AgreementRoleCommunicationChannelType inRoleOfInvoiceAddress = agreementRoleCommunicationChannelTypeRepository.find(AgreementRoleCommunicationChannelTypeEnum.INVOICE_ADDRESS);
final List<CommunicationChannelOwnerLink> addressLinks = communicationChannelOwnerLinkRepository.findByOwnerAndCommunicationChannelType(tenant, channelType);
final Optional<CommunicationChannel> communicationChannelIfAny = addressLinks.stream().map(CommunicationChannelOwnerLink::getCommunicationChannel).findFirst();
final SortedSet<AgreementRole> roles = lease.getRoles();
final Optional<AgreementRole> agreementRoleIfAny = Lists.newArrayList(roles).stream().filter(x -> x.getType() == inRoleOfTenant).findFirst();
if (agreementRoleIfAny.isPresent() && communicationChannelIfAny.isPresent()) {
final AgreementRole agreementRole = agreementRoleIfAny.get();
if (!Sets.filter(agreementRole.getCommunicationChannels(), inRoleOfInvoiceAddress.matchingCommunicationChannel()).isEmpty()) {
// already one set up
return;
}
final CommunicationChannel communicationChannel = communicationChannelIfAny.get();
agreementRole.addCommunicationChannel(inRoleOfInvoiceAddress, communicationChannel, null, null);
}
}
use of org.estatio.module.agreement.dom.AgreementRole 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;
}
use of org.estatio.module.agreement.dom.AgreementRole 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;
}
use of org.estatio.module.agreement.dom.AgreementRole 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;
}
}
Aggregations