Search in sources :

Example 21 with Property

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);
}
Also used : Project(org.estatio.module.capex.dom.project.Project) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Charge(org.estatio.module.charge.dom.Charge) Tax(org.estatio.module.tax.dom.Tax) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 22 with Property

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();
}
Also used : Party(org.estatio.module.party.dom.Party) Organisation(org.estatio.module.party.dom.Organisation) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) OrderApprovalState(org.estatio.module.capex.dom.order.approval.OrderApprovalState) Test(org.junit.Test)

Example 23 with Property

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);
}
Also used : Party(org.estatio.module.party.dom.Party) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) PaymentMethod(org.estatio.module.invoice.dom.PaymentMethod) BankAccount(org.estatio.module.financial.dom.BankAccount) LocalDate(org.joda.time.LocalDate) InvoiceStatus(org.estatio.module.invoice.dom.InvoiceStatus) Property(org.estatio.module.asset.dom.Property) Test(org.junit.Test)

Example 24 with Property

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();
}
Also used : ApplicationException(org.apache.isis.applib.ApplicationException) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Partitioning(org.estatio.module.budget.dom.partioning.Partitioning) Charge(org.estatio.module.charge.dom.Charge) Budget(org.estatio.module.budget.dom.budget.Budget) KeyTable(org.estatio.module.budget.dom.keytable.KeyTable) Property(org.estatio.module.asset.dom.Property) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 25 with Property

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();
}
Also used : Party(org.estatio.module.party.dom.Party) BankAccount(org.estatio.module.financial.dom.BankAccount) Property(org.estatio.module.asset.dom.Property) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

Property (org.estatio.module.asset.dom.Property)47 LocalDate (org.joda.time.LocalDate)19 Test (org.junit.Test)19 Party (org.estatio.module.party.dom.Party)12 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)11 Programmatic (org.apache.isis.applib.annotation.Programmatic)10 Budget (org.estatio.module.budget.dom.budget.Budget)8 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)8 BigDecimal (java.math.BigDecimal)7 List (java.util.List)6 Charge (org.estatio.module.charge.dom.Charge)6 Lease (org.estatio.module.lease.dom.Lease)6 InvoiceItemForLease (org.estatio.module.lease.dom.invoicing.InvoiceItemForLease)6 Expectations (org.jmock.Expectations)6 Before (org.junit.Before)6 Unit (org.estatio.module.asset.dom.Unit)5 Project (org.estatio.module.capex.dom.project.Project)5 Organisation (org.estatio.module.party.dom.Organisation)5 BudgetItemValue (org.estatio.module.budget.dom.budgetitem.BudgetItemValue)4 BankAccount (org.estatio.module.financial.dom.BankAccount)4