use of org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink in project estatio by estatio.
the class OrderItem_Test method setupOrderItemInvoiceItemLinkRepository.
private OrderItemInvoiceItemLinkRepository setupOrderItemInvoiceItemLinkRepository(final IncomingInvoiceItem item1, final IncomingInvoiceItem item2) {
OrderItemInvoiceItemLink link1 = new OrderItemInvoiceItemLink();
OrderItemInvoiceItemLink link2 = new OrderItemInvoiceItemLink();
link1.setInvoiceItem(item1);
link1.setNetAmount(item1.getNetAmount());
link2.setInvoiceItem(item2);
link2.setNetAmount(item2.getNetAmount());
OrderItemInvoiceItemLinkRepository orderItemInvoiceItemLinkRepository = new OrderItemInvoiceItemLinkRepository() {
@Override
public List<OrderItemInvoiceItemLink> findByOrderItem(final OrderItem orderItem) {
return Arrays.asList(link1, link2);
}
};
return orderItemInvoiceItemLinkRepository;
}
use of org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink 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.orderinvoice.OrderItemInvoiceItemLink 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);
}
}
use of org.estatio.module.capex.dom.orderinvoice.OrderItemInvoiceItemLink in project estatio by estatio.
the class IncomingInvoice method copyWithLinks.
private IncomingInvoiceItem copyWithLinks(final IncomingInvoiceItem itemToReverse, final Sort sort) {
final IncomingInvoiceType type = itemToReverse.getIncomingInvoiceType();
final String description = itemToReverse.getDescription();
final Charge charge = itemToReverse.getCharge();
final BigDecimal netAmount = itemToReverse.getNetAmount();
final BigDecimal vatAmount = itemToReverse.getVatAmount();
final BigDecimal grossAmount = itemToReverse.getGrossAmount();
final Tax tax = itemToReverse.getTax();
final LocalDate dueDate = itemToReverse.getDueDate();
final String period = itemToReverse.getPeriod();
final FixedAsset fixedAsset = itemToReverse.getFixedAsset();
final Project project = itemToReverse.getProject();
final BudgetItem budgetItem = itemToReverse.getBudgetItem();
final IncomingInvoiceItem copyItem = addItemToThis(type, charge, sort.prefixTo(description), sort.adjust(netAmount), sort.adjust(vatAmount), sort.adjust(grossAmount), tax, dueDate, period, fixedAsset, project, budgetItem);
if (sort == Sort.REVERSAL) {
copyItem.setReversalOf(itemToReverse);
}
final Optional<OrderItemInvoiceItemLink> linkIfAny = orderItemInvoiceItemLinkRepository.findByInvoiceItem(itemToReverse);
linkIfAny.ifPresent(link -> {
orderItemInvoiceItemLinkRepository.createLink(link.getOrderItem(), copyItem, sort.adjust(link.getNetAmount()));
});
return copyItem;
}
Aggregations