Search in sources :

Example 11 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class TaskRepository method findIncompleteForMeAndCreatedOnBefore.

/**
 * Incomplete, assigned explicitly to me, AND ALSO any tasks not assigned to anyone but for which
 * I have the (party) roles to perform them (so should be part of "my tasks") before {@param createdOn}
 * @param createdOn
 * @return
 */
@Programmatic
public List<Task> findIncompleteForMeAndCreatedOnBefore(final LocalDateTime createdOn) {
    final Person meAsPerson = meAsPerson();
    if (meAsPerson == null) {
        return Lists.newArrayList();
    }
    final List<Task> tasks = findIncompleteForAndCreatedOnBefore(meAsPerson, createdOn);
    final List<Task> myRolesTasksUnassigned = findIncompleteForMyRolesAndUnassignedAndCreatedOnBefore(createdOn);
    tasks.addAll(myRolesTasksUnassigned);
    tasks.sort(Ordering.natural().nullsLast().reverse().onResultOf(Task::getCreatedOn));
    return tasks;
}
Also used : Person(org.estatio.module.party.dom.Person) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 12 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class TaskRepository method previousTaskBefore.

@Programmatic
public Task previousTaskBefore(final Task previousTask) {
    final LocalDateTime previousCreatedOn = previousTask.getCreatedOn();
    final Optional<Task> firstTaskIfAny = findIncompleteForMeAndCreatedOnBefore(previousCreatedOn).stream().findFirst();
    return firstTaskIfAny.orElse(previousTask);
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 13 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic 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 14 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic 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 15 with Programmatic

use of org.apache.isis.applib.annotation.Programmatic in project estatio by estatio.

the class ChargeRepository method chargesForCountry.

@Programmatic
public List<Charge> chargesForCountry(final ApplicationTenancy countryOrLowerLevel) {
    final ApplicationTenancyLevel level = ApplicationTenancyLevel.of(countryOrLowerLevel);
    final String countryPath = level.getCountryPath();
    return chargesForCountry(countryPath);
}
Also used : ApplicationTenancyLevel(org.estatio.module.base.dom.apptenancy.ApplicationTenancyLevel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

Programmatic (org.apache.isis.applib.annotation.Programmatic)162 Party (org.estatio.module.party.dom.Party)21 Lease (org.estatio.module.lease.dom.Lease)16 DomainObject (org.apache.isis.applib.annotation.DomainObject)11 BankAccount (org.estatio.module.financial.dom.BankAccount)11 Charge (org.estatio.module.charge.dom.Charge)10 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)10 LocalDate (org.joda.time.LocalDate)10 BigDecimal (java.math.BigDecimal)9 Bookmark (org.apache.isis.applib.services.bookmark.Bookmark)9 ApplicationException (org.apache.isis.applib.ApplicationException)8 Property (org.estatio.module.asset.dom.Property)8 CommunicationChannel (org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)8 ArrayList (java.util.ArrayList)7 TranslatableString (org.apache.isis.applib.services.i18n.TranslatableString)7 InvoiceItem (org.estatio.module.invoice.dom.InvoiceItem)7 LeaseItem (org.estatio.module.lease.dom.LeaseItem)7 Inject (javax.inject.Inject)6 Unit (org.estatio.module.asset.dom.Unit)6 Document (org.incode.module.document.dom.impl.docs.Document)6