use of org.apache.isis.applib.annotation.Action in project estatio by estatio.
the class IncomingInvoice_switchView method act.
@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(contributed = Contributed.AS_ACTION, // not sure why this isn't being picked up from isis-non-changing.properties
cssClassFa = "fa-exchange")
@MemberOrder(sequence = "1")
public IncomingDocAsInvoiceViewModel act() {
Optional<Document> documentIfAny = lookupAttachedPdfService.lookupIncomingInvoicePdfFrom(incomingInvoice);
// guaranteed to return, hidden if none
Document document = documentIfAny.get();
final IncomingDocAsInvoiceViewModel viewModel = new IncomingDocAsInvoiceViewModel(incomingInvoice, document);
serviceRegistry2.injectServicesInto(viewModel);
viewModel.init();
return viewModel;
}
use of org.apache.isis.applib.annotation.Action in project estatio by estatio.
the class IncomingInvoiceDownloadManager method report.
@Action(semantics = SemanticsOf.IDEMPOTENT_ARE_YOU_SURE)
public IncomingInvoiceDownloadManager report() {
LocalDate reportedDate = clockService.now();
final List<IncomingInvoiceItem> invoiceItems = getInvoiceItems();
for (IncomingInvoiceItem invoiceItem : invoiceItems) {
if (invoiceItem.getReportedDate() == null) {
invoiceItem.setReportedDate(reportedDate);
}
}
return new IncomingInvoiceDownloadManager(property, reportedDate, incomingInvoiceType);
}
use of org.apache.isis.applib.annotation.Action in project estatio by estatio.
the class IncomingDocAsOrderViewModel method save.
@Action(semantics = SemanticsOf.IDEMPOTENT)
@MemberOrder(sequence = "1")
public Order save() {
Order order = getDomainObject();
order.setOrderNumber(getOrderNumber());
order.setSellerOrderReference(getSellerOrderReference());
order.setEntryDate(clockService.now());
order.setOrderDate(getOrderDate());
order.setSeller(getSeller());
order.setBuyer(getBuyer());
Optional<OrderItem> firstItemIfAny = getFirstItemIfAny();
if (firstItemIfAny.isPresent()) {
OrderItem orderItem = firstItemIfAny.get();
orderItem.setCharge(getCharge());
orderItem.setDescription(getDescription());
orderItem.setNetAmount(getNetAmount());
orderItem.setVatAmount(getVatAmount());
orderItem.setGrossAmount(getGrossAmount());
orderItem.setTax(getTax());
orderItem.setStartDate(getStartDateFromPeriod());
orderItem.setEndDate(getEndDateFromPeriod());
orderItem.setProperty(getProperty());
orderItem.setProject(getProject());
orderItem.setBudgetItem(getBudgetItem());
} else {
order.addItem(getCharge(), getDescription(), getNetAmount(), getVatAmount(), getGrossAmount(), getTax(), getPeriod(), getProperty(), getProject(), getBudgetItem());
}
return order;
}
use of org.apache.isis.applib.annotation.Action in project estatio by estatio.
the class IncomingDocAsInvoiceViewModel method save.
@Action(semantics = SemanticsOf.IDEMPOTENT)
@MemberOrder(sequence = "1")
public IncomingInvoice save() {
IncomingInvoice incomingInvoice = getDomainObject();
IncomingInvoiceType previousType = incomingInvoice.getType();
incomingInvoice.setType(getIncomingInvoiceType());
incomingInvoice.setInvoiceNumber(getInvoiceNumber());
incomingInvoice.setBuyer(getBuyer());
incomingInvoice.setSeller(getSeller());
incomingInvoice.setInvoiceDate(getInvoiceDate());
incomingInvoice.setDueDate(getDueDate());
incomingInvoice.setPaymentMethod(getPaymentMethod());
incomingInvoice.setCurrency(getCurrency());
incomingInvoice.setDateReceived(getDateReceived());
incomingInvoice.setBankAccount(getBankAccount());
incomingInvoice.setNetAmount(getNetAmount());
incomingInvoice.setGrossAmount(getGrossAmount());
// if changed the type, then we need to re-evaluate the state machine
if (previousType != getIncomingInvoiceType()) {
stateTransitionService.trigger(incomingInvoice, IncomingInvoiceApprovalStateTransition.class, null, null, null);
}
// upsert invoice item
// this will also update the parent header's property with that from the first item
Optional<IncomingInvoiceItem> firstItemIfAny = getFirstItemIfAny();
IncomingInvoiceItem firstItem;
if (firstItemIfAny.isPresent()) {
IncomingInvoiceItem item = firstItemIfAny.get();
item.setIncomingInvoiceType(getIncomingInvoiceType());
item.setCharge(getCharge());
item.setDescription(getDescription());
item.setNetAmount(getNetAmount());
item.setVatAmount(getVatAmount());
item.setGrossAmount(getGrossAmount());
item.setTax(getTax());
item.setStartDate(getStartDateFromPeriod());
item.setEndDate(getEndDateFromPeriod());
item.setFixedAsset(getProperty());
item.setProject(getProject());
item.setBudgetItem(getBudgetItem());
firstItem = item;
} else {
firstItem = incomingInvoiceItemRepository.create(incomingInvoice.nextItemSequence(), incomingInvoice, incomingInvoiceType, getCharge(), getDescription(), getNetAmount(), getVatAmount(), getGrossAmount(), getTax(), getDueDate(), getStartDateFromPeriod(), getEndDateFromPeriod(), getProperty(), getProject(), getBudgetItem());
}
// 'switch view' will not be available subsequently because the Invoice/Item is "too complex")
if (getOrderItem() != null) {
Order order = getOrderItem().getOrdr();
Charge chargeFromWrapper = getOrderItem().getCharge();
OrderItem orderItemToLink = orderItemRepository.findByOrderAndCharge(order, chargeFromWrapper);
orderItemInvoiceItemLinkRepository.findOrCreateLink(orderItemToLink, firstItem, firstItem.getNetAmount());
} else {
// remove all (or the one and only) link.
final Optional<OrderItemInvoiceItemLink> links = orderItemInvoiceItemLinkRepository.findByInvoiceItem(firstItem);
links.ifPresent(link -> {
link.remove();
});
}
return incomingInvoice;
}
use of org.apache.isis.applib.annotation.Action in project estatio by estatio.
the class PaymentLineDownloadManager method downloadToExcel.
@Action(semantics = SemanticsOf.SAFE)
public Blob downloadToExcel(final String fileName) {
final List<PaymentLineExportV1> exportV1s = getPayments().stream().map(x -> new PaymentLineExportV1(x)).collect(Collectors.toList());
WorksheetSpec spec = new WorksheetSpec(exportClass, "invoiceExport");
WorksheetContent worksheetContent = new WorksheetContent(exportV1s, spec);
return excelService.toExcel(worksheetContent, fileName);
}
Aggregations