use of org.estatio.module.invoice.dom.Invoice 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.invoice.dom.Invoice in project estatio by estatio.
the class InvoiceSummaryForPropertyDueDateStatus_sendByPostAbstract method $$.
@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public Blob $$(final String fileName) throws IOException {
final List<byte[]> pdfBytes = Lists.newArrayList();
for (final InvoiceAndDocument invoiceAndDocument : invoiceAndDocumentsToSend()) {
final Invoice invoice = invoiceAndDocument.getInvoice();
final Document prelimLetterOrInvoiceNote = invoiceAndDocument.getDocument();
final InvoiceForLease_sendByPost invoice_sendByPost = invoice_sendByPost(invoice);
final PostalAddress postalAddress = invoice_sendByPost.default1$$(prelimLetterOrInvoiceNote);
invoice_sendByPost.createPostalCommunicationAsSent(prelimLetterOrInvoiceNote, postalAddress);
invoice_sendByPost.appendPdfBytes(prelimLetterOrInvoiceNote, pdfBytes);
}
final byte[] mergedBytes = pdfBoxService.merge(pdfBytes.toArray(new byte[][] {}));
return new Blob(fileName, DocumentConstants.MIME_TYPE_APPLICATION_PDF, mergedBytes);
}
use of org.estatio.module.invoice.dom.Invoice in project estatio by estatio.
the class InvoiceSummaryAbstract method validate0InvoiceAll.
public String validate0InvoiceAll(final LocalDate invoiceDate) {
for (Invoice invoice : getInvoices()) {
try {
final InvoiceForLease._invoice mixin = mixin(InvoiceForLease._invoice.class, invoice);
wrapperFactory.wrapNoExecute(mixin).$$(invoiceDate);
} catch (InvalidException ex) {
final String reasonMessage = ex.getInteractionEvent() != null ? ex.getInteractionEvent().getReason() : null;
return titleService.titleOf(invoice) + ": " + (reasonMessage != null ? reasonMessage : ex.getMessage());
} catch (HiddenException | DisabledException ex) {
// ignore
}
}
return null;
}
use of org.estatio.module.invoice.dom.Invoice in project estatio by estatio.
the class InvoiceSummaryForPropertyDueDateStatus_backgroundPrepareAbstract method $$.
@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public InvoiceSummaryForPropertyDueDateStatus $$() throws IOException {
final List<InvoiceForLease> invoices = invoicesToPrepare();
for (Invoice invoice : invoices) {
final DocumentTemplate documentTemplate = documentTemplateFor(invoice);
factoryService.mixin(InvoiceForLease_backgroundPrepare.class, invoice).$$(documentTemplate);
}
return this.invoiceSummary;
}
use of org.estatio.module.invoice.dom.Invoice in project estatio by estatio.
the class Invoice_DocumentManagement_IntegTest method sendToFor.
<T extends CommunicationChannel> T sendToFor(final Invoice invoice, final Class<T> communicationChannelClass) {
final CommunicationChannel sendTo = invoice.getSendTo();
if (communicationChannelClass.isAssignableFrom(sendTo.getClass())) {
return communicationChannelClass.cast(sendTo);
}
final List<CommunicationChannel> communicationChannels = mixin(InvoiceForLease_overrideSendTo.class, invoice).choices0$$();
final Optional<CommunicationChannel> commChannelIfAny = communicationChannels.stream().filter(x -> communicationChannelClass.isAssignableFrom(x.getClass())).findFirst();
if (!commChannelIfAny.isPresent()) {
throw new IllegalStateException("could not locate communication channel of type " + communicationChannelClass.getSimpleName());
}
final CommunicationChannel communicationChannel = commChannelIfAny.get();
wrap(mixin(InvoiceForLease_overrideSendTo.class, invoice)).$$(communicationChannel);
return communicationChannelClass.cast(communicationChannel);
}
Aggregations