use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class IncomingInvoiceBuilder method execute.
@Override
protected void execute(final ExecutionContext ec) {
checkParam("officeAdministrator", ec, Person.class);
checkParam("document", ec, Document.class);
checkParam("buyer", ec, Organisation.class);
checkParam("seller", ec, Organisation.class);
checkParam("sellerBankAccount", ec, BankAccount.class);
checkParam("property", ec, Property.class);
checkParam("dueDate", ec, LocalDate.class);
checkParam("invoiceDate", ec, LocalDate.class);
checkParam("dateReceived", ec, LocalDate.class);
checkParam("itemTax", ec, Tax.class);
checkParam("item1InvoiceType", ec, IncomingInvoiceType.class);
// checkParam("item1Project", ec, Project.class); // optional
checkParam("item1Charge", ec, Charge.class);
checkParam("item1Description", ec, String.class);
checkParam("item1NetAmount", ec, BigDecimal.class);
checkParam("item1VatAmount", ec, BigDecimal.class);
checkParam("item1GrossAmount", ec, BigDecimal.class);
checkParam("item1Period", ec, String.class);
if (getItem2InvoiceType() != null) {
checkParam("item2InvoiceType", ec, IncomingInvoiceType.class);
// checkParam("item2Project", ec, Project.class); // optional
checkParam("item2Charge", ec, Charge.class);
checkParam("item2Description", ec, String.class);
checkParam("item2NetAmount", ec, BigDecimal.class);
checkParam("item2VatAmount", ec, BigDecimal.class);
checkParam("item2GrossAmount", ec, BigDecimal.class);
checkParam("item2Period", ec, String.class);
}
// checkParam("orderDocument", ec, Document.class); // optional
if (order != null) {
checkParam("orderItemLinkAmount", ec, BigDecimal.class);
}
if (propertyManager != null) {
checkParam("propertyManager", ec, Person.class);
checkParam("assetManager", ec, Person.class);
checkParam("countryDirector", ec, Person.class);
checkParam("treasurer", ec, Person.class);
}
sudoService.sudo(officeAdministrator.getUsername(), (Runnable) () -> wrap(mixin(Document_categoriseAsPropertyInvoice.class, document)).act(property, ""));
final String documentName = document.getName();
IncomingInvoice invoice = incomingInvoiceRepository.findIncomingInvoiceByDocumentName(documentName).get(0);
invoice.setDateReceived(dateReceived);
invoice.setSeller(seller);
invoice.setBankAccount(sellerBankAccount);
invoice.setBuyer(buyer);
invoice.setType(invoiceType);
invoice.setDueDate(dueDate);
invoice.setInvoiceNumber(invoiceNumber);
invoice.setPaymentMethod(paymentMethod);
invoice.setInvoiceDate(invoiceDate);
invoice.setNetAmount(netAmount);
invoice.setGrossAmount(grossAmount);
invoice.addItem(item1InvoiceType, item1Charge, item1Description, item1NetAmount, item1VatAmount, item1GrossAmount, itemTax, dueDate, item1Period, property, item1Project, null);
if (order != null) {
IncomingInvoiceItem invoiceItemToLink = (IncomingInvoiceItem) invoice.getItems().first();
OrderItem orderItemToLink = order.getItems().first();
mixin(IncomingInvoiceItem_createOrderItemLink.class, invoiceItemToLink).act(orderItemToLink, orderItemLinkAmount);
}
if (item2InvoiceType != null) {
invoice.addItem(item2InvoiceType, item2Charge, item2Description, item2NetAmount, item2VatAmount, item2GrossAmount, itemTax, dueDate, item2Period, property, item2Project, null);
}
if (propertyManager != null) {
// complete and approve invoice and verify bankaccount
sudoService.sudo(propertyManager.getUsername(), (Runnable) () -> wrap(mixin(IncomingInvoice_complete.class, invoice)).act("PROPERTY_MANAGER", null, null));
sudoService.sudo(assetManager.getUsername(), (Runnable) () -> wrap(mixin(IncomingInvoice_approve.class, invoice)).act("ASSET_MANAGER", null, null, false));
sudoService.sudo(countryDirector.getUsername(), (Runnable) () -> wrap(mixin(IncomingInvoice_approveAsCountryDirector.class, invoice)).act(null, false));
sudoService.sudo(treasurer.getUsername(), (Runnable) () -> wrap(mixin(BankAccount_verify.class, sellerBankAccount)).act(null));
}
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class EstatioAppHomePage_verifyBankAccounts method act.
@Action(semantics = SemanticsOf.IDEMPOTENT, restrictTo = RestrictTo.PROTOTYPING)
@ActionLayout(position = ActionLayout.Position.PANEL)
public EstatioAppHomePage act(final List<IncomingInvoice> invoices, @Nullable final String comment) {
for (IncomingInvoice invoice : invoices) {
final BankAccount bankAccount = invoice.getBankAccount();
factoryService.mixin(BankAccount_verify.class, bankAccount).act(comment);
factoryService.mixin(IncomingInvoice_checkApprovalState.class, invoice).act();
}
return homePage;
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class IncomingInvoice_approve method act.
@Action(domainEvent = ActionDomainEvent.class, semantics = SemanticsOf.IDEMPOTENT)
@ActionLayout(cssClassFa = "fa-thumbs-o-up")
public Object act(final String role, @Nullable final Person personToAssignNextTo, @Nullable final String comment, final boolean goToNext) {
final IncomingInvoice next = nextAfterPendingIfRequested(goToNext);
trigger(personToAssignNextTo, comment, null);
return objectToReturn(next);
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class BankAccount_attachInvoiceAsIbanProof method choices0Act.
public List<Document> choices0Act() {
final List<Document> documents = Lists.newArrayList();
final List<IncomingInvoice> invoices = incomingInvoiceRepository.findByBankAccount(bankAccount);
for (IncomingInvoice invoice : invoices) {
final List<Document> attachedDocuments = lookupAttachedPdfService.lookupIncomingInvoicePdfsFrom(invoice);
documents.addAll(attachedDocuments);
}
final List<Document> documentsCurrentlyAttachedAsIbanProof = paperclipRepository.findByAttachedToAndRoleName(bankAccount, ROLE_NAME_FOR_IBAN_PROOF).stream().map(Paperclip::getDocument).filter(Document.class::isInstance).map(Document.class::cast).collect(Collectors.toList());
documents.removeAll(documentsCurrentlyAttachedAsIbanProof);
return documents;
}
use of org.estatio.module.capex.dom.invoice.IncomingInvoice in project estatio by estatio.
the class IncomingInvoiceMenu_Test method filterOrFindByGrossAmount_find_works.
@Test
public void filterOrFindByGrossAmount_find_works() {
IncomingInvoiceMenu.IncomingInvoiceFinder builder;
// given
builder = new IncomingInvoiceMenu.IncomingInvoiceFinder(mockInvoiceRepository, mockIncomingInvoiceRepository, mockPartyRepository);
IncomingInvoice invoice1 = new IncomingInvoice();
IncomingInvoice invoice2 = new IncomingInvoice();
IncomingInvoice invoice3 = new IncomingInvoice();
invoice1.setGrossAmount(new BigDecimal("9.50"));
invoice2.setGrossAmount(new BigDecimal("10.50"));
invoice3.setGrossAmount(new BigDecimal("10.51"));
final BigDecimal amountSearchedFor = new BigDecimal("10.00");
// expect
context.checking(new Expectations() {
{
oneOf(mockIncomingInvoiceRepository).listAll();
will(returnValue(Arrays.asList(invoice1, invoice2, invoice3)));
}
});
// when
builder.filterOrFindByGrossAmount(amountSearchedFor);
// then
Assertions.assertThat(builder.getResult().size()).isEqualTo(2);
Assertions.assertThat(builder.getResult()).contains(invoice1);
Assertions.assertThat(builder.getResult()).contains(invoice2);
}
Aggregations