Search in sources :

Example 1 with Party

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());
}
Also used : OrderApprovalState(org.estatio.module.capex.dom.order.approval.OrderApprovalState) Order(org.estatio.module.capex.dom.order.Order) SortedSet(java.util.SortedSet) Currency(org.estatio.module.currency.dom.Currency) InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) IncomingInvoiceType(org.estatio.module.capex.dom.invoice.IncomingInvoiceType) PaymentMethod(org.estatio.module.invoice.dom.PaymentMethod) PropertyLayout(org.apache.isis.applib.annotation.PropertyLayout) MinLength(org.apache.isis.applib.annotation.MinLength) XmlJavaTypeAdapter(javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter) BankAccount(org.estatio.module.financial.dom.BankAccount) FactoryService(org.apache.isis.applib.services.factory.FactoryService) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) XmlAccessorType(javax.xml.bind.annotation.XmlAccessorType) IncomingInvoiceRepository(org.estatio.module.capex.dom.invoice.IncomingInvoiceRepository) Party(org.estatio.module.party.dom.Party) Charge(org.estatio.module.charge.dom.Charge) OrderItemRepository(org.estatio.module.capex.dom.order.OrderItemRepository) IncomingInvoiceApprovalState(org.estatio.module.capex.dom.invoice.approval.IncomingInvoiceApprovalState) XmlTransient(javax.xml.bind.annotation.XmlTransient) JodaLocalDateStringAdapter(org.apache.isis.schema.utils.jaxbadapters.JodaLocalDateStringAdapter) OrderItem(org.estatio.module.capex.dom.order.OrderItem) Collectors(java.util.stream.Collectors) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) SellerBankAccountCreator(org.estatio.module.capex.dom.invoice.SellerBankAccountCreator) XmlAccessType(javax.xml.bind.annotation.XmlAccessType) List(java.util.List) DomainObject(org.apache.isis.applib.annotation.DomainObject) Optional(java.util.Optional) StateTransitionService(org.estatio.module.capex.dom.state.StateTransitionService) OrderItemInvoiceItemLink(org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink) OrderRepository(org.estatio.module.capex.dom.order.OrderRepository) Project(org.estatio.module.capex.dom.project.Project) Optionality(org.apache.isis.applib.annotation.Optionality) Setter(lombok.Setter) IncomingInvoiceItemRepository(org.estatio.module.capex.dom.invoice.IncomingInvoiceItemRepository) Getter(lombok.Getter) Document(org.incode.module.document.dom.impl.docs.Document) Programmatic(org.apache.isis.applib.annotation.Programmatic) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) XmlType(javax.xml.bind.annotation.XmlType) Lists(com.google.common.collect.Lists) AccessLevel(lombok.AccessLevel) Parameter(org.apache.isis.applib.annotation.Parameter) IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) Nullable(javax.annotation.Nullable) Action(org.apache.isis.applib.annotation.Action) BuyerFinder(org.estatio.module.capex.dom.documents.BuyerFinder) Property(org.apache.isis.applib.annotation.Property) ClockService(org.apache.isis.applib.services.clock.ClockService) OrderItemInvoiceItemLinkRepository(org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLinkRepository) XmlRootElement(javax.xml.bind.annotation.XmlRootElement) LocalDate(org.joda.time.LocalDate) Mixin(org.apache.isis.applib.annotation.Mixin) SemanticsOf(org.apache.isis.applib.annotation.SemanticsOf) Editing(org.apache.isis.applib.annotation.Editing) IncomingDocViewModel(org.estatio.module.capex.app.document.IncomingDocViewModel) ReasonBuffer2(org.estatio.module.base.platform.applib.ReasonBuffer2) IncomingInvoiceApprovalStateTransition(org.estatio.module.capex.dom.invoice.approval.IncomingInvoiceApprovalStateTransition) XmlElement(javax.xml.bind.annotation.XmlElement) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Party(org.estatio.module.party.dom.Party) OrderItem(org.estatio.module.capex.dom.order.OrderItem)

Example 2 with Party

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);
}
Also used : Party(org.estatio.module.party.dom.Party) FixedAssetOwnership(org.estatio.module.asset.dom.ownership.FixedAssetOwnership)

Example 3 with Party

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;
    }
}
Also used : Party(org.estatio.module.party.dom.Party) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 4 with Party

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;
    }
}
Also used : Party(org.estatio.module.party.dom.Party) Invoice(org.estatio.module.invoice.dom.Invoice) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 5 with Party

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);
    }
}
Also used : Setter(lombok.Setter) Accessors(lombok.experimental.Accessors) SortedSet(java.util.SortedSet) AgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType) Getter(lombok.Getter) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Lease(org.estatio.module.lease.dom.Lease) BuilderScriptAbstract(org.apache.isis.applib.fixturescripts.BuilderScriptAbstract) VT.ld(org.incode.module.base.integtests.VT.ld) Inject(javax.inject.Inject) AgreementRoleCommunicationChannelTypeEnum(org.estatio.module.lease.dom.AgreementRoleCommunicationChannelTypeEnum) Lists(com.google.common.collect.Lists) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) ToString(lombok.ToString) CommunicationChannelOwnerLink(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelOwnerLink) LeaseAgreementRoleTypeEnum(org.estatio.module.lease.dom.LeaseAgreementRoleTypeEnum) Unit(org.estatio.module.asset.dom.Unit) OccupancyRepository(org.estatio.module.lease.dom.occupancy.OccupancyRepository) CommunicationChannelOwnerLinkRepository(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelOwnerLinkRepository) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) AgreementRoleCommunicationChannelTypeRepository(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelTypeRepository) Party(org.estatio.module.party.dom.Party) CommunicationChannelType(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelType) ApplicationTenancy_enum(org.incode.module.apptenancy.fixtures.enums.ApplicationTenancy_enum) LeaseType(org.estatio.module.lease.dom.LeaseType) AgreementRoleTypeRepository(org.estatio.module.agreement.dom.role.AgreementRoleTypeRepository) Property(org.estatio.module.asset.dom.Property) EqualsAndHashCode(lombok.EqualsAndHashCode) CommunicationChannelRepository(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelRepository) Sets(com.google.common.collect.Sets) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) LeaseRepository(org.estatio.module.lease.dom.LeaseRepository) LocalDate(org.joda.time.LocalDate) List(java.util.List) LeaseRoleTypeEnum(org.estatio.module.lease.dom.LeaseRoleTypeEnum) BrandCoverage(org.estatio.module.lease.dom.occupancy.tags.BrandCoverage) Data(lombok.Data) Optional(java.util.Optional) IAgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.commchantype.IAgreementRoleCommunicationChannelType) Country(org.incode.module.country.dom.impl.Country) AllArgsConstructor(lombok.AllArgsConstructor) LeaseTypeRepository(org.estatio.module.lease.dom.LeaseTypeRepository) AgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.AgreementRoleCommunicationChannelType) IAgreementRoleCommunicationChannelType(org.estatio.module.agreement.dom.commchantype.IAgreementRoleCommunicationChannelType) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) CommunicationChannelOwnerLink(org.incode.module.communications.dom.impl.commchannel.CommunicationChannelOwnerLink) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)

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