use of org.estatio.module.capex.dom.order.OrderItem in project estatio by estatio.
the class IncomingDocAsInvoiceViewModel method init.
@Programmatic
public void init() {
IncomingInvoice incomingInvoice = getDomainObject();
setIncomingInvoiceType(incomingInvoice.getType());
setInvoiceNumber(incomingInvoice.getInvoiceNumber());
setBuyer(incomingInvoice.getBuyer());
setSeller(incomingInvoice.getSeller());
setInvoiceDate(incomingInvoice.getInvoiceDate());
setDueDate(incomingInvoice.getDueDate());
setPaymentMethod(incomingInvoice.getPaymentMethod());
setDateReceived(incomingInvoice.getDateReceived());
setBankAccount(incomingInvoice.getBankAccount());
setCurrency(incomingInvoice.getCurrency());
final Optional<IncomingInvoiceItem> firstItemIfAny = getFirstItemIfAny();
if (firstItemIfAny.isPresent()) {
IncomingInvoiceItem invoiceItem = firstItemIfAny.get();
setCharge(invoiceItem.getCharge());
setDescription(invoiceItem.getDescription());
setNetAmount(invoiceItem.getNetAmount());
setVatAmount(invoiceItem.getVatAmount());
setGrossAmount(invoiceItem.getGrossAmount());
setTax(invoiceItem.getTax());
setDueDate(invoiceItem.getDueDate());
setPeriod(periodFrom(invoiceItem.getStartDate(), invoiceItem.getEndDate()));
setProperty((org.estatio.module.asset.dom.Property) invoiceItem.getFixedAsset());
setProject(invoiceItem.getProject());
setBudgetItem(invoiceItem.getBudgetItem());
final Optional<OrderItemInvoiceItemLink> linkIfAny = orderItemInvoiceItemLinkRepository.findByInvoiceItem(invoiceItem);
linkIfAny.ifPresent(link -> {
final OrderItem linkOrderItem = link.getOrderItem();
IncomingDocAsInvoiceViewModel.this.setOrderItem(linkOrderItem);
});
} else {
// for the first time we edit there will be no first item,
// so we instead get the property from the header invoice
setProperty(incomingInvoice.getProperty());
}
}
use of org.estatio.module.capex.dom.order.OrderItem in project estatio by estatio.
the class IncomingDocAsInvoiceViewModel method autoFillIn.
private void autoFillIn() {
if (hasOrderItem()) {
Order order = orderRepository.findByOrderNumber(getOrderItem().getOrdr().getOrderNumber());
OrderItem orderItem = orderItemRepository.findByOrderAndCharge(order, getOrderItem().getCharge());
if (!(hasNetAmount() && hasGrossAmount() && hasVatAmount())) {
setNetAmount(orderItem.getNetAmount());
setVatAmount(orderItem.getVatAmount());
setGrossAmount(orderItem.getGrossAmount());
}
if (!hasTax()) {
setTax(orderItem.getTax());
}
if (!hasBuyer()) {
setBuyer(order.getBuyer());
}
if (!hasSeller()) {
setSeller(order.getSeller());
setBankAccount(bankAccountRepository.getFirstBankAccountOfPartyOrNull(order.getSeller()));
}
if (!hasDescription()) {
setDescription(orderItem.getDescription());
}
if (orderItem.getCharge() != null) {
setCharge(orderItem.getCharge());
}
if (orderItem.getProject() != null) {
setProject(orderItem.getProject());
}
if (orderItem.getProperty() != null) {
setProperty(orderItem.getProperty());
}
if (!hasBudgetItem()) {
setBudgetItem(orderItem.getBudgetItem());
}
if (!hasPeriod()) {
setPeriod(orderItem.getPeriod());
}
}
}
use of org.estatio.module.capex.dom.order.OrderItem in project estatio by estatio.
the class IncomingInvoice_outstandingOrderItemsForSeller method $$.
@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(contributed = Contributed.AS_ASSOCIATION)
public List<OrderItemPresentationViewmodel> $$() {
List<OrderItemPresentationViewmodel> result = new ArrayList<>();
if (invoice.getSeller() == null && invoice.getProperty() == null) {
return result;
}
List<OrderItem> itemsFound = orderItemRepository.findBySeller(invoice.getSeller()).stream().filter(linkedToInvoiceOrOutstanding).collect(Collectors.toList());
for (OrderItem item : itemsFound) {
result.add(new OrderItemPresentationViewmodel(item));
}
return result;
}
use of org.estatio.module.capex.dom.order.OrderItem in project estatio by estatio.
the class IncomingInvoiceItem_createOrderItemLink method choices0Act.
public List<OrderItem> choices0Act() {
// the disable guard ensures this is non-null
final Party seller = mixee.getInvoice().getSeller();
final Property property = (Property) mixee.getFixedAsset();
// candidates
final List<OrderItem> orderItems;
if (property == null) {
orderItems = orderItemRepository.findBySeller(seller);
} else {
orderItems = orderItemRepository.findBySellerAndProperty(seller, property);
}
return orderItems.stream().filter(x -> x.getOrdr().getApprovalState() == null || x.getOrdr().getApprovalState() != OrderApprovalState.DISCARDED).collect(Collectors.toList());
}
use of org.estatio.module.capex.dom.order.OrderItem in project estatio by estatio.
the class ProjectService method moveIncomingInvoiceItemToProject.
public void moveIncomingInvoiceItemToProject(final IncomingInvoiceItem incomingInvoiceItem, final Project project) {
Optional linkToOrderItemIfAny = orderItemInvoiceItemLinkRepository.findByInvoiceItem(incomingInvoiceItem);
if (linkToOrderItemIfAny.isPresent()) {
OrderItemInvoiceItemLink link = (OrderItemInvoiceItemLink) linkToOrderItemIfAny.get();
OrderItem linkedOrderItem = link.getOrderItem();
for (OrderItemInvoiceItemLink itemLinked : orderItemInvoiceItemLinkRepository.findByOrderItem(linkedOrderItem)) {
itemLinked.getInvoiceItem().setProjectByPassingInvalidateApproval(project);
}
linkedOrderItem.setProject(project);
} else {
incomingInvoiceItem.setProjectByPassingInvalidateApproval(project);
}
}
Aggregations