use of org.estatio.module.capex.dom.order.Order 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.Order in project estatio by estatio.
the class Document_categoriseAsOrder method act.
@Action(domainEvent = ActionDomainEvent.class, semantics = SemanticsOf.IDEMPOTENT)
@ActionLayout(cssClassFa = "folder-open-o")
public Object act(@Nullable final Property property, @Nullable final String comment) {
final Document document = getDomainObject();
document.setType(DocumentTypeData.INCOMING_ORDER.findUsing(documentTypeRepository));
// create order
final Order order = orderRepository.create(property, // order number
null, // sellerOrderReference
null, // entryDate
clockService.now(), // orderDate
null, // seller
null, // buyer
buyerFinder.buyerDerivedFromDocumentName(document), document.getAtPath(), // approval state... will cause state transition to be created automatically by subscriber
null);
paperclipRepository.attach(document, null, order);
trigger(comment, null);
return order;
}
use of org.estatio.module.capex.dom.order.Order in project estatio by estatio.
the class OrderInvoiceImportHandlerTest method determine_ordernumber_works.
@Test
public void determine_ordernumber_works() throws Exception {
// given
OrderInvoiceImportHandler handler = new OrderInvoiceImportHandler();
handler.setOrderDate(new LocalDate(2017, 01, 31));
handler.orderRepository = orderRepository;
// expect
context.checking(new Expectations() {
{
oneOf(orderRepository).findByOrderNumber(with("20170131-001"));
will(returnValue(new Order()));
oneOf(orderRepository).findByOrderNumber(with("20170131-002"));
will(returnValue(null));
}
});
// when
String orderNumber = handler.determineOrderNumber();
// then
assertThat(orderNumber).isEqualTo("20170131-002");
}
Aggregations