use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class OrderItem_Test method newIncomingInvoiceItem.
private IncomingInvoiceItem newIncomingInvoiceItem() {
final IncomingInvoiceItem incomingInvoiceItem = new IncomingInvoiceItem();
final IncomingInvoice incomingInvoice = new IncomingInvoice() {
@Override
protected EventBusService getEventBusService() {
return mockEventBusService;
}
};
context.ignoring(mockEventBusService);
incomingInvoiceItem.setInvoice(incomingInvoice);
return incomingInvoiceItem;
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class IncomingInvoiceDownloadManager method documentNumberFor.
String documentNumberFor(final IncomingInvoiceItem invoiceItem) {
final IncomingInvoice invoice = (IncomingInvoice) invoiceItem.getInvoice();
final Optional<Document> documentIfAny = lookupAttachedPdfService.lookupIncomingInvoicePdfFrom(invoice);
return documentIfAny.map(DocumentAbstract::getName).orElse(null);
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice 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.IncomingInvoice in project estatio by estatio.
the class PaymentBatchManager method autoCreateBatches.
@Action(semantics = SemanticsOf.IDEMPOTENT, publishing = Publishing.DISABLED)
public PaymentBatchManager autoCreateBatches(@Nullable final List<IncomingInvoice> payableInvoices) {
for (final IncomingInvoice payableInvoice : payableInvoices) {
final BankAccount uniqueBankAccountIfAny = debtorBankAccountService.uniqueDebtorAccountToPay(payableInvoice);
if (uniqueBankAccountIfAny != null && uniqueBankAccountIfAny.getBic() != null) {
// should be true, because those that don't pass this are filtered out in choicesXxx anyway.
PaymentBatch paymentBatch = paymentBatchRepository.findOrCreateNewByDebtorBankAccount(uniqueBankAccountIfAny);
paymentBatch.addLineIfRequired(payableInvoice);
}
}
final List<PaymentBatch> newBatches = getNewBatches();
for (final PaymentBatch paymentBatch : newBatches) {
removeNegativeTransfers(paymentBatch);
}
return new PaymentBatchManager(newBatches.isEmpty() ? null : 0);
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class UpcomingPaymentService method getUpcomingPayments.
@Programmatic
public List<UpcomingPaymentTotal> getUpcomingPayments() {
List<IncomingInvoice> invoiceSelectionForUpcomingPayments = new ArrayList<>();
invoiceSelectionForUpcomingPayments.addAll(incomingInvoiceRepository.findByApprovalStateAndPaymentMethod(IncomingInvoiceApprovalState.COMPLETED, PaymentMethod.BANK_TRANSFER));
invoiceSelectionForUpcomingPayments.addAll(incomingInvoiceRepository.findByApprovalStateAndPaymentMethod(IncomingInvoiceApprovalState.APPROVED, PaymentMethod.BANK_TRANSFER));
invoiceSelectionForUpcomingPayments.addAll(incomingInvoiceRepository.findByApprovalStateAndPaymentMethod(IncomingInvoiceApprovalState.PENDING_BANK_ACCOUNT_CHECK, PaymentMethod.BANK_TRANSFER));
List<UpcomingPaymentTotal> upcomingPayments = new ArrayList<>();
for (IncomingInvoice invoice : invoiceSelectionForUpcomingPayments) {
UpcomingPaymentTotal upcomingPaymentTotal;
if (paymentTotalForBankAccount(upcomingPayments, invoice).isEmpty()) {
upcomingPaymentTotal = new UpcomingPaymentTotal(debtorBankAccountService.uniqueDebtorAccountToPay(invoice));
upcomingPaymentTotal.addValue(invoice);
upcomingPayments.add(upcomingPaymentTotal);
} else {
upcomingPaymentTotal = paymentTotalForBankAccount(upcomingPayments, invoice).get(0);
upcomingPaymentTotal.addValue(invoice);
}
}
return upcomingPayments;
}
Aggregations