use of org.estatio.module.asset.dom.Property in project estatio by estatio.
the class OrderItemRepository_Test method upsert_works.
@Test
public void upsert_works() throws Exception {
// given
OrderItemRepository orderItemRepository = new OrderItemRepository() {
@Override
public OrderItem findByOrderAndCharge(final Order order, final Charge charge) {
return orderItem;
}
};
String description = new String("some description");
BigDecimal netAmount = BigDecimal.ZERO;
BigDecimal vatAmount = BigDecimal.ONE;
BigDecimal grossAmount = BigDecimal.TEN;
Tax tax = new Tax();
LocalDate startDate = new LocalDate(2017, 1, 1);
LocalDate endDate = new LocalDate(2017, 1, 2);
Property property = new Property();
Project project = new Project();
BudgetItem budgetItem = new BudgetItem();
assertThat(orderItem.getOrdr()).isNull();
assertThat(orderItem.getCharge()).isNull();
// when
orderItemRepository.upsert(mockOrder, mockCharge, description, netAmount, vatAmount, grossAmount, tax, startDate, endDate, property, project, budgetItem);
// then
assertThat(orderItem.getOrdr()).isNull();
assertThat(orderItem.getCharge()).isNull();
assertThat(orderItem.getDescription()).isEqualTo(description);
assertThat(orderItem.getNetAmount()).isEqualTo(netAmount);
assertThat(orderItem.getVatAmount()).isEqualTo(vatAmount);
assertThat(orderItem.getGrossAmount()).isEqualTo(grossAmount);
assertThat(orderItem.getTax()).isEqualTo(tax);
assertThat(orderItem.getStartDate()).isEqualTo(startDate);
assertThat(orderItem.getEndDate()).isEqualTo(endDate);
assertThat(orderItem.getProperty()).isEqualTo(property);
assertThat(orderItem.getProject()).isEqualTo(project);
assertThat(orderItem.getBudgetItem()).isEqualTo(budgetItem);
}
use of org.estatio.module.asset.dom.Property in project estatio by estatio.
the class OrderRepository_Test method upsert_when_already_exists.
@Test
public void upsert_when_already_exists() throws Exception {
// given
OrderRepository orderRepository = new OrderRepository() {
@Override
public Order findByOrderNumber(final String orderNumber) {
return order;
}
};
String number = "some number";
String sellerOrderReference = "ref";
LocalDate entryDate = new LocalDate(2017, 1, 1);
LocalDate orderDate = new LocalDate(2017, 1, 2);
Party seller = new Organisation();
Party buyer = new Organisation();
Property property = new Property();
String atPath = "atPath";
OrderApprovalState approvalState = OrderApprovalState.APPROVED;
assertThat(order.getOrderNumber()).isNull();
// when
orderRepository.upsert(property, number, sellerOrderReference, entryDate, orderDate, seller, buyer, atPath, approvalState);
// then
assertThat(order.getOrderNumber()).isNull();
assertThat(order.getSellerOrderReference()).isEqualTo(sellerOrderReference);
assertThat(order.getEntryDate()).isEqualTo(entryDate);
assertThat(order.getOrderDate()).isEqualTo(orderDate);
assertThat(order.getSeller()).isEqualTo(seller);
assertThat(order.getBuyer()).isEqualTo(buyer);
assertThat(order.getProperty()).isEqualTo(property);
assertThat(order.getAtPath()).isEqualTo(atPath);
// is ignored.
assertThat(order.getApprovalState()).isNull();
}
use of org.estatio.module.asset.dom.Property in project estatio by estatio.
the class IncomingInvoiceRepository_IntegTest method upsert_works.
@Test
public void upsert_works() throws Exception {
// given
IncomingInvoice existingInvoice = createIncomingInvoice();
IncomingInvoice invoice = incomingInvoiceRepository.findByInvoiceNumberAndSellerAndInvoiceDate(invoiceNumber, seller, invoiceDate);
assertThat(invoice.getInvoiceNumber()).isEqualTo(invoiceNumber);
assertThat(invoice.getAtPath()).isEqualTo(atPath);
assertThat(invoice.getBuyer()).isEqualTo(buyer);
assertThat(invoice.getDueDate()).isEqualTo(dueDate);
assertThat(invoice.getPaymentMethod()).isEqualTo(paymentMethod);
assertThat(invoice.getStatus()).isEqualTo(invoiceStatus);
assertThat(invoice.getDateReceived()).isNull();
assertThat(invoice.getBankAccount()).isNull();
// when
String updatedAtPath = "/NLD";
Party updatedBuyer = Organisation_enum.HelloWorldNl.findUsing(serviceRegistry);
LocalDate updatedDueDate = dueDate.minusWeeks(1);
PaymentMethod updatedPaymentMethod = PaymentMethod.DIRECT_DEBIT;
InvoiceStatus updatedStatus = InvoiceStatus.INVOICED;
LocalDate updatedDateReceived = new LocalDate(2017, 1, 2);
BankAccount updatedBankAccount = bankAccountRepository.allBankAccounts().get(0);
Property property = existingInvoice.getProperty();
IncomingInvoice updatedInvoice = incomingInvoiceRepository.upsert(IncomingInvoiceType.CAPEX, invoiceNumber, property, updatedAtPath, updatedBuyer, seller, invoiceDate, updatedDueDate, updatedPaymentMethod, updatedStatus, updatedDateReceived, updatedBankAccount, null);
// then
assertThat(updatedInvoice.getInvoiceNumber()).isEqualTo(invoiceNumber);
assertThat(updatedInvoice.getSeller()).isEqualTo(seller);
assertThat(updatedInvoice.getInvoiceDate()).isEqualTo(invoiceDate);
assertThat(updatedInvoice.getAtPath()).isEqualTo(updatedAtPath);
assertThat(updatedInvoice.getBuyer()).isEqualTo(updatedBuyer);
assertThat(updatedInvoice.getDueDate()).isEqualTo(updatedDueDate);
assertThat(updatedInvoice.getPaymentMethod()).isEqualTo(updatedPaymentMethod);
assertThat(updatedInvoice.getStatus()).isEqualTo(updatedStatus);
assertThat(updatedInvoice.getDateReceived()).isEqualTo(updatedDateReceived);
assertThat(updatedInvoice.getBankAccount()).isEqualTo(updatedBankAccount);
}
use of org.estatio.module.asset.dom.Property in project estatio by estatio.
the class PartitionItemImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
Property property = propertyRepository.findPropertyByReference(propertyReference);
if (property == null)
throw new ApplicationException(String.format("Property with reference [%s] not found.", propertyReference));
final Budget budget = budgetRepository.findOrCreateBudget(property, startDate, endDate);
final KeyTable keyTable = keyTableRepository.findOrCreateBudgetKeyTable(budget, keyTableName, FoundationValueType.MANUAL, KeyValueMethod.PERCENT, 6);
findOrCreateBudgetKeyItem(keyTable, unitRepository.findUnitByReference(unitReference), keyValue, sourceValue);
final Charge charge = fetchCharge(budgetChargeReference);
final BudgetItem butgetItem = findOrCreateBudgetItem(budget, charge, budgetValue);
final Charge scheduleCharge = fetchCharge(invoiceChargeReference);
final Partitioning partitioning = findOrCreatePartitioning(budget);
findOrCreatePartitionItem(partitioning, scheduleCharge, butgetItem, keyTable, percentage);
return Lists.newArrayList();
}
use of org.estatio.module.asset.dom.Property in project estatio by estatio.
the class BankAccountImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
if (IBANValidator.valid(iban)) {
final Party owner = partyRepository.findPartyByReference(ownerReference);
BankAccount bankAccount = (BankAccount) financialAccountRepository.findByOwnerAndReference(owner, iban);
if (owner == null)
return Lists.newArrayList();
if (bankAccount == null) {
bankAccount = bankAccountRepository.newBankAccount(owner, iban, bic);
} else {
bankAccount.setIban(iban);
bankAccount.verifyIban();
bankAccount.setBic(BankAccount.trimBic(bic));
}
if (propertyReference != null) {
final Property property = propertyRepository.findPropertyByReference(propertyReference);
if (property == null) {
throw new IllegalArgumentException(String.format("Property with reference [%s] not found", propertyReference));
}
fixedAssetFinancialAccountRepository.findOrCreate(property, bankAccount);
}
}
return Lists.newArrayList();
}
Aggregations