use of org.estatio.module.party.dom.Party in project estatio by estatio.
the class IncomingDocAsInvoiceViewModel method choicesOrderItem.
public List<OrderItem> choicesOrderItem() {
final Party seller = getSeller();
final org.estatio.module.asset.dom.Property property = getProperty();
final List<OrderItem> orderItems;
if (property == null) {
orderItems = orderItemRepository.findBySeller(seller);
} else {
orderItems = orderItemRepository.findBySellerAndProperty(seller, property);
}
if (getOrderItem() != null && !orderItems.contains(getOrderItem())) {
orderItems.add(getOrderItem());
}
return orderItems.stream().filter(x -> x.getOrdr().getApprovalState() == null || x.getOrdr().getApprovalState() != OrderApprovalState.DISCARDED).collect(Collectors.toList());
}
use of org.estatio.module.party.dom.Party in project estatio by estatio.
the class IncomingDocViewModel method deriveBuyer.
private void deriveBuyer() {
Party ownerCandidate = null;
if (hasProperty()) {
for (FixedAssetOwnership fos : getProperty().getOwners()) {
if (fos.getOwnershipType() == OwnershipType.FULL) {
ownerCandidate = fos.getOwner();
continue;
}
}
// temporary extra search until fixed asset ownership is fully in use
if (ownerCandidate == null && getProperty().ownerCandidates().size() > 0) {
ownerCandidate = getProperty().ownerCandidates().get(0).getParty();
}
}
setBuyer(ownerCandidate);
}
use of org.estatio.module.party.dom.Party in project estatio by estatio.
the class PartySubscriptionsForIncomingInvoices 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 = ev.getSource();
if (incomingInvoiceRepository.findByBuyer(sourceParty).size() > 0) {
sourceParty.addRole(Constants.InvoiceRoleTypeEnum.BUYER);
sourceParty.addRole(IncomingInvoiceRoleTypeEnum.ECP);
}
if (incomingInvoiceRepository.findBySeller(sourceParty).size() > 0) {
sourceParty.addRole(Constants.InvoiceRoleTypeEnum.SELLER);
sourceParty.addRole(IncomingInvoiceRoleTypeEnum.SUPPLIER);
}
break;
default:
break;
}
}
use of org.estatio.module.party.dom.Party in project estatio by estatio.
the class PartySubscriptionsForIncomingInvoices 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();
switch(ev.getEventPhase()) {
case VALIDATE:
if (replacementParty == null && incomingInvoiceRepository.findBySeller(sourceParty).size() > 0) {
ev.invalidate("Party is in use as seller in an invoice. Provide replacement");
}
if (replacementParty == null && incomingInvoiceRepository.findByBuyer(sourceParty).size() > 0) {
ev.invalidate("Party is in use as buyer in an invoice. Provide replacement");
}
break;
case EXECUTING:
if (replacementParty != null) {
for (Invoice invoice : incomingInvoiceRepository.findByBuyer(sourceParty)) {
invoice.setBuyer(replacementParty);
}
for (Invoice invoice : incomingInvoiceRepository.findBySeller(sourceParty)) {
invoice.setSeller(replacementParty);
}
}
break;
default:
break;
}
}
use of org.estatio.module.party.dom.Party 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);
}
}
Aggregations