use of org.estatio.module.capex.dom.invoice.IncomingInvoiceItem 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.invoice.IncomingInvoiceItem in project estatio by estatio.
the class OrderItem_createInvoiceItemLink method choices0Act.
public List<IncomingInvoiceItem> choices0Act() {
// the disable guard ensures this is non-null
final Party seller = mixee.getOrdr().getSeller();
// candidates
final List<IncomingInvoiceItem> invoiceItems = invoiceItemRepository.findBySeller(seller);
// exclude any invoice items already linked to this order
invoiceItems.removeAll(orderItemInvoiceItemLinkRepository.findLinkedInvoiceItemsByOrderItem(mixee));
// exclude those where the net amount for the invoice item has already been linked to other order items
for (Iterator<IncomingInvoiceItem> iterator = invoiceItems.iterator(); iterator.hasNext(); ) {
final IncomingInvoiceItem invoiceItem = iterator.next();
final BigDecimal netAmountNotLinked = orderItemInvoiceItemLinkRepository.calculateNetAmountNotLinkedFromInvoiceItem(invoiceItem);
if (netAmountNotLinked.compareTo(BigDecimal.ZERO) <= 0) {
iterator.remove();
}
}
return invoiceItems;
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoiceItem in project estatio by estatio.
the class IncomingInvoiceItemRepository_IntegTest method findByInvoiceAndChargeAndSequence_works.
@Test
public void findByInvoiceAndChargeAndSequence_works() throws Exception {
// given
IncomingInvoice invoice = createIncomingInvoiceAndTwoItemsWithSameCharge();
// when
Charge chargeToFindOnItem = charge;
IncomingInvoiceItem item1 = incomingInvoiceItemRepository.findByInvoiceAndChargeAndSequence(invoice, chargeToFindOnItem, BigInteger.valueOf(1L));
IncomingInvoiceItem item2 = incomingInvoiceItemRepository.findByInvoiceAndChargeAndSequence(invoice, chargeToFindOnItem, BigInteger.valueOf(2L));
// then
assertThat(item1.getInvoice()).isEqualTo(invoice);
assertThat(item1.getCharge()).isEqualTo(charge);
assertThat(item1.getSequence()).isEqualTo(BigInteger.valueOf(1L));
assertThat(item2.getInvoice()).isEqualTo(invoice);
assertThat(item2.getCharge()).isEqualTo(charge);
assertThat(item2.getSequence()).isEqualTo(BigInteger.valueOf(2L));
// and when
Charge chargeNotToBeFoundOnItem = chargeRepository.findByReference("OTHER");
IncomingInvoiceItem itemNotToBeFound = incomingInvoiceItemRepository.findByInvoiceAndChargeAndSequence(invoice, chargeNotToBeFoundOnItem, BigInteger.valueOf(1L));
// then
assertThat(itemNotToBeFound).isNull();
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoiceItem in project estatio by estatio.
the class IncomingInvoice_IntegTest method firstItemIsReported.
private IncomingInvoiceItem firstItemIsReported() {
IncomingInvoiceItem reportedItem = (IncomingInvoiceItem) incomingInvoice.getItems().first();
reportedItem.setReportedDate(LocalDate.now());
return reportedItem;
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoiceItem in project estatio by estatio.
the class IncomingInvoice_IntegTest method when_incoming_invoice_type_is_changed_reported_items_are_reversed.
@Test
public void when_incoming_invoice_type_is_changed_reported_items_are_reversed() {
// given
incomingInvoiceSetup();
incomingInvoiceIsCompleted();
IncomingInvoiceItem reportedItem = firstItemIsReported();
assertThat(reportedItem.getCharge()).isEqualTo(charge_for_marketing);
IncomingInvoiceItem unreportedItem = (IncomingInvoiceItem) incomingInvoice.getItems().last();
assertThat(unreportedItem.getCharge()).isEqualTo(charge_for_other);
assertThat(incomingInvoice.getType()).isEqualTo(IncomingInvoiceType.CAPEX);
assertThat(reportedItem.getIncomingInvoiceType()).isEqualTo(IncomingInvoiceType.CAPEX);
assertThat(unreportedItem.getIncomingInvoiceType()).isEqualTo(IncomingInvoiceType.PROPERTY_EXPENSES);
// when
incomingInvoice.editType(IncomingInvoiceType.SERVICE_CHARGES, true);
// then
assertThat(incomingInvoice.getType()).isEqualTo(IncomingInvoiceType.SERVICE_CHARGES);
assertThat(incomingInvoice.getItems().size()).isEqualTo(4);
assertThat(unreportedItem.getIncomingInvoiceType()).isEqualTo(IncomingInvoiceType.SERVICE_CHARGES);
assertThat(reportedItem.getIncomingInvoiceType()).isEqualTo(IncomingInvoiceType.CAPEX);
IncomingInvoiceItem reversalOfReportedItem = incomingInvoiceItemRepository.findByInvoiceAndChargeAndSequence(incomingInvoice, charge_for_marketing, BigInteger.valueOf(3));
assertThat(reversalOfReportedItem.getCharge()).isEqualTo(charge_for_marketing);
assertThat(reversalOfReportedItem.getIncomingInvoiceType()).isEqualTo(IncomingInvoiceType.CAPEX);
IncomingInvoiceItem correctionOfReportedItem = incomingInvoiceItemRepository.findByInvoiceAndChargeAndSequence(incomingInvoice, charge_for_marketing, BigInteger.valueOf(4));
assertThat(reversalOfReportedItem.getCharge()).isEqualTo(charge_for_marketing);
assertThat(correctionOfReportedItem.getIncomingInvoiceType()).isEqualTo(IncomingInvoiceType.SERVICE_CHARGES);
// and when changing type again
incomingInvoice.editType(IncomingInvoiceType.PROPERTY_EXPENSES, true);
// then still
assertThat(incomingInvoice.getItems().size()).isEqualTo(4);
assertThat(incomingInvoice.getType()).isEqualTo(IncomingInvoiceType.PROPERTY_EXPENSES);
}
Aggregations