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;
}
}
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);
}
}
}
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();
}
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();
}
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;
}
Aggregations