Search in sources :

Example 81 with Programmatic

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

the class CommunicationChannelSubscriptions method on.

@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final CommunicationChannel.RemoveEvent ev) {
    CommunicationChannel sourceCommunicationChannel = ev.getSource();
    CommunicationChannel replacementCommunicationChannel = ev.getReplacement();
    List<Invoice> notYetInvoiced;
    List<Invoice> alreadyInvoiced;
    switch(ev.getEventPhase()) {
        case VALIDATE:
            List<Invoice> invoices = invoiceRepository.findBySendTo(sourceCommunicationChannel);
            notYetInvoiced = invoices.stream().filter(invoice -> invoice.getInvoiceNumber() == null).collect(Collectors.toList());
            alreadyInvoiced = invoices.stream().filter(invoice -> invoice.getInvoiceNumber() != null).collect(Collectors.toList());
            scratchpad.put("notYetInvoiced", notYetInvoiced);
            scratchpad.put("alreadyInvoiced", alreadyInvoiced);
            // (it doesn't matter if no replacement was provided only for already-invoiced invoices)
            if (replacementCommunicationChannel == null && !notYetInvoiced.isEmpty()) {
                ev.invalidate(TranslatableString.tr("Communication channel is being used (as the 'sendTo' channel for {num} invoice(s); " + "provide a replacement", "num", notYetInvoiced.size()));
            }
            break;
        case EXECUTING:
            notYetInvoiced = (List<Invoice>) scratchpad.get("notYetInvoiced");
            alreadyInvoiced = (List<Invoice>) scratchpad.get("alreadyInvoiced");
            for (Invoice invoice : notYetInvoiced) {
                invoice.setSendTo(replacementCommunicationChannel);
            }
            for (Invoice invoice : alreadyInvoiced) {
                if (invoice.getInvoiceNumber() != null) {
                    // just blank out
                    invoice.setSendTo(null);
                }
            }
            break;
        default:
            break;
    }
}
Also used : Invoice(org.estatio.module.invoice.dom.Invoice) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 82 with Programmatic

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

the class InvoiceForLease_sendAbstract method appendPdfBytes.

@Programmatic
public void appendPdfBytes(final Document prelimLetterOrInvoiceDoc, final List<byte[]> pdfBytes) {
    // this one should be a PDF
    appendBytesIfPdf(prelimLetterOrInvoiceDoc, pdfBytes);
    // and any attachments that are PDFs are also merged in
    final List<Paperclip> paperclips = paperclipRepository.findByDocument(prelimLetterOrInvoiceDoc);
    for (Paperclip paperclip : paperclips) {
        final Object objAttachedToDocument = paperclip.getAttachedTo();
        if (objAttachedToDocument instanceof Document) {
            final Document docAttachedToDocument = (Document) objAttachedToDocument;
            appendBytesIfPdf(docAttachedToDocument, pdfBytes);
        }
    }
}
Also used : Paperclip(org.incode.module.document.dom.impl.paperclips.Paperclip) Document(org.incode.module.document.dom.impl.docs.Document) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 83 with Programmatic

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

the class LeaseTerm method initialize.

// //////////////////////////////////////
@Programmatic
protected final void initialize() {
    setStatus(LeaseTermStatus.NEW);
    LeaseTerm previousTerm = getPrevious();
    BigInteger sequence = BigInteger.ONE;
    if (previousTerm != null) {
        sequence = previousTerm.getSequence().add(BigInteger.ONE);
        setFrequency(previousTerm.getFrequency());
    }
    setSequence(sequence);
    doInitialize();
}
Also used : BigInteger(java.math.BigInteger) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 84 with Programmatic

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

the class PartitionItemImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    Property property = propertyRepository.findPropertyByReference(propertyReference);
    if (property == null)
        throw new ApplicationException(String.format("Property with reference [%s] not found.", propertyReference));
    final Budget budget = budgetRepository.findOrCreateBudget(property, startDate, endDate);
    final KeyTable keyTable = keyTableRepository.findOrCreateBudgetKeyTable(budget, keyTableName, FoundationValueType.MANUAL, KeyValueMethod.PERCENT, 6);
    findOrCreateBudgetKeyItem(keyTable, unitRepository.findUnitByReference(unitReference), keyValue, sourceValue);
    final Charge charge = fetchCharge(budgetChargeReference);
    final BudgetItem butgetItem = findOrCreateBudgetItem(budget, charge, budgetValue);
    final Charge scheduleCharge = fetchCharge(invoiceChargeReference);
    final Partitioning partitioning = findOrCreatePartitioning(budget);
    findOrCreatePartitionItem(partitioning, scheduleCharge, butgetItem, keyTable, percentage);
    return Lists.newArrayList();
}
Also used : ApplicationException(org.apache.isis.applib.ApplicationException) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Partitioning(org.estatio.module.budget.dom.partioning.Partitioning) Charge(org.estatio.module.charge.dom.Charge) Budget(org.estatio.module.budget.dom.budget.Budget) KeyTable(org.estatio.module.budget.dom.keytable.KeyTable) Property(org.estatio.module.asset.dom.Property) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 85 with Programmatic

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

the class PartyBankAccountsAndMandatesDtoFactory method newDto.

@Programmatic
public BankAccountsAndMandatesDto newDto(final Party party) {
    final BankAccountsAndMandatesDto dto = new BankAccountsAndMandatesDto();
    final List<FinancialAccount> financialAccountList = financialAccountRepository.findAccountsByTypeOwner(FinancialAccountType.BANK_ACCOUNT, party);
    final List<BankAccountDto> bankAccountDtos = financialAccountList.stream().map(x -> bankAccountDtoFactory.newDto((BankAccount) x)).collect(Collectors.toList());
    dto.setBankAccounts(bankAccountDtos);
    final AgreementType bankMandateAt = agreementTypeRepository.find(BankMandateAgreementTypeEnum.MANDATE);
    final AgreementRoleType debtorOfMandate = agreementRoleTypeRepository.findByAgreementTypeAndTitle(bankMandateAt, BankMandateAgreementRoleTypeEnum.DEBTOR.getTitle());
    final List<AgreementRole> agreementRoles = agreementRoleRepository.findByPartyAndType(party, debtorOfMandate);
    final List<BankMandateDto> mandateDtos = agreementRoles.stream().map(x -> x.getAgreement()).map(x -> bankMandateDtoFactory.newDto((BankMandate) x)).collect(Collectors.toList());
    dto.setBankMandates(mandateDtos);
    return dto;
}
Also used : BankAccountsAndMandatesDto(org.estatio.canonical.bankmandate.v1.BankAccountsAndMandatesDto) BankAccountDto(org.estatio.canonical.financial.v1.BankAccountDto) DtoFactoryAbstract(org.estatio.module.base.platform.applib.DtoFactoryAbstract) FinancialAccount(org.estatio.module.financial.dom.FinancialAccount) BankMandateDto(org.estatio.canonical.bankmandate.v1.BankMandateDto) AgreementType(org.estatio.module.agreement.dom.type.AgreementType) AgreementTypeRepository(org.estatio.module.agreement.dom.type.AgreementTypeRepository) DomainService(org.apache.isis.applib.annotation.DomainService) BankAccountDto(org.estatio.canonical.financial.v1.BankAccountDto) FinancialAccountRepository(org.estatio.module.financial.dom.FinancialAccountRepository) Programmatic(org.apache.isis.applib.annotation.Programmatic) Inject(javax.inject.Inject) BankMandateAgreementRoleTypeEnum(org.estatio.module.bankmandate.dom.BankMandateAgreementRoleTypeEnum) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) BankAccountsAndMandatesDto(org.estatio.canonical.bankmandate.v1.BankAccountsAndMandatesDto) BankAccount(org.estatio.module.financial.dom.BankAccount) NatureOfService(org.apache.isis.applib.annotation.NatureOfService) BankMandateAgreementTypeEnum(org.estatio.module.bankmandate.dom.BankMandateAgreementTypeEnum) Party(org.estatio.module.party.dom.Party) AgreementRoleTypeRepository(org.estatio.module.agreement.dom.role.AgreementRoleTypeRepository) Collectors(java.util.stream.Collectors) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) List(java.util.List) BankAccountDtoFactory(org.estatio.module.financial.canonical.v1.BankAccountDtoFactory) AgreementRoleRepository(org.estatio.module.agreement.dom.AgreementRoleRepository) BankMandate(org.estatio.module.bankmandate.dom.BankMandate) FinancialAccountType(org.estatio.module.financial.dom.FinancialAccountType) AgreementType(org.estatio.module.agreement.dom.type.AgreementType) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) AgreementRoleType(org.estatio.module.agreement.dom.role.AgreementRoleType) FinancialAccount(org.estatio.module.financial.dom.FinancialAccount) BankMandateDto(org.estatio.canonical.bankmandate.v1.BankMandateDto) 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