use of org.estatio.module.invoice.dom.Invoice 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.estatio.module.invoice.dom.Invoice in project estatio by estatio.
the class InvoiceSummaryForPropertyDueDateStatus_sendByEmailAbstract method $$.
@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public InvoiceSummaryForPropertyDueDateStatus $$() throws IOException {
final List<InvoiceAndDocument> invoiceAndDocuments = invoiceAndDocumentsToSend();
for (InvoiceAndDocument invoiceAndDocument : invoiceAndDocuments) {
final Invoice invoice = invoiceAndDocument.getInvoice();
final Document document = invoiceAndDocument.getDocument();
final InvoiceForLease_sendByEmail invoice_sendByEmail = invoice_email(invoice);
final EmailAddress emailAddress = invoice_sendByEmail.default1$$(document);
final String cc = invoice_sendByEmail.default2$$(document);
final String bcc = invoice_sendByEmail.default5$$(document);
invoice_sendByEmail.$$(document, emailAddress, cc, null, null, bcc, null);
}
return this.invoiceSummary;
}
use of org.estatio.module.invoice.dom.Invoice in project estatio by estatio.
the class InvoiceImportLine method importData.
@Override
@Programmatic
public List<Object> importData(final Object previousRow) {
List<Object> result = new ArrayList<>();
Lease lease = fetchLease(getLeaseReference());
PaymentMethod paymentMethod = fetchPaymentMethod(getPaymentMethod());
String atPath = lease.getApplicationTenancyPath().concat("/").concat(lease.getPrimaryParty().getReference());
ApplicationTenancy applicationTenancy = applicationTenancyRepository.findByPath(atPath);
Invoice invoice = invoiceForLeaseRepository.newInvoice(applicationTenancy, lease.getPrimaryParty(), lease.getSecondaryParty(), paymentMethod, currencyRepository.findCurrency("EUR"), getDueDate(), lease, null);
InvoiceItem invoiceItem = factoryService.mixin(InvoiceForLease._newItem.class, invoice).$$(fetchCharge(getItemChargeReference()), BigDecimal.ONE, getItemNetAmount(), getItemStartDate(), getItemEndDate());
if (getItemDescription() != null) {
invoiceItem.setDescription(getItemDescription());
}
result.add(invoice);
return result;
}
use of org.estatio.module.invoice.dom.Invoice in project estatio by estatio.
the class CreateRetroInvoices method createAndApprove.
// //////////////////////////////////////
private ExecutionContext createAndApprove(final InvoiceCalculationParameters parameters, final ExecutionContext executionContext) {
invoiceCalculationService.calculateAndInvoice(parameters);
for (Invoice invoice : invoiceRepository.findByStatus(InvoiceStatus.NEW)) {
factoryService.mixin(InvoiceForLease._saveAsHistoric.class, invoice).$$();
executionContext.addResult(this, invoice.getInvoiceNumber(), invoice);
}
return executionContext;
}
Aggregations