Search in sources :

Example 16 with Property

use of org.estatio.module.asset.dom.Property in project estatio by estatio.

the class NumeratorCollectionRepository_Test method setup.

@Before
public void setup() {
    seller = new PartyForTesting();
    buyer = new PartyForTesting();
    paymentMethod = PaymentMethod.BANK_TRANSFER;
    lease = new Lease() {

        @Override
        public Property getProperty() {
            return null;
        }
    };
    invoiceStatus = InvoiceStatus.APPROVED;
    dueDate = new LocalDate(2013, 4, 1);
    invoiceRepository = new InvoiceRepository() {

        @Override
        protected <T> T firstMatch(Query<T> query) {
            finderInteraction = new FinderInteraction(query, FinderInteraction.FinderMethod.FIRST_MATCH);
            return null;
        }

        @Override
        protected List<Invoice> allInstances() {
            finderInteraction = new FinderInteraction(null, FinderInteraction.FinderMethod.ALL_INSTANCES);
            return null;
        }

        @Override
        protected <T> List<T> allMatches(Query<T> query) {
            finderInteraction = new FinderInteraction(query, FinderInteraction.FinderMethod.ALL_MATCHES);
            return null;
        }
    };
    invoiceForLeaseRepository = new InvoiceForLeaseRepository() {
    };
    estatioNumeratorRepository = new NumeratorForCollectionRepository();
}
Also used : Lease(org.estatio.module.lease.dom.Lease) InvoiceRepository(org.estatio.module.invoice.dom.InvoiceRepository) List(java.util.List) PartyForTesting(org.estatio.module.party.dom.PartyForTesting) Property(org.estatio.module.asset.dom.Property) LocalDate(org.joda.time.LocalDate) FinderInteraction(org.incode.module.unittestsupport.dom.repo.FinderInteraction) Before(org.junit.Before)

Example 17 with Property

use of org.estatio.module.asset.dom.Property in project estatio by estatio.

the class LeaseRepository_Test method setup.

@Before
public void setup() {
    asset = new FixedAssetForTesting();
    property = new Property();
    leaseRepository = new LeaseRepository() {

        @Override
        protected <T> T uniqueMatch(Query<T> query) {
            finderInteraction = new FinderInteraction(query, FinderMethod.UNIQUE_MATCH);
            return (T) new Lease();
        }

        @Override
        protected List<Lease> allInstances() {
            finderInteraction = new FinderInteraction(null, FinderMethod.ALL_INSTANCES);
            return null;
        }

        @Override
        protected <T> List<T> allMatches(Query<T> query) {
            finderInteraction = new FinderInteraction(query, FinderMethod.ALL_MATCHES);
            return null;
        }
    };
    leaseRepository.clockService = new ClockService();
}
Also used : ClockService(org.apache.isis.applib.services.clock.ClockService) FixedAssetForTesting(org.estatio.module.asset.dom.FixedAssetForTesting) List(java.util.List) Property(org.estatio.module.asset.dom.Property) FinderInteraction(org.incode.module.unittestsupport.dom.repo.FinderInteraction) Before(org.junit.Before)

Example 18 with Property

use of org.estatio.module.asset.dom.Property in project estatio by estatio.

the class InvoiceMenu method newInvoiceForLease.

@ActionLayout(contributed = Contributed.AS_NEITHER)
@Action(semantics = SemanticsOf.NON_IDEMPOTENT)
@MemberOrder(sequence = "1")
public Invoice newInvoiceForLease(final Lease lease, final LocalDate dueDate, @Parameter(optionality = Optionality.OPTIONAL) final PaymentMethod paymentMethod, final Currency currency) {
    final Property propertyIfAny = lease.getProperty();
    final Party seller = lease.getPrimaryParty();
    final Party buyer = lease.getSecondaryParty();
    final ApplicationTenancy propertySellerTenancy = estatioApplicationTenancyRepositoryForLease.findOrCreateTenancyFor(propertyIfAny, seller);
    return invoiceForLeaseRepository.newInvoice(propertySellerTenancy, seller, buyer, paymentMethod == null ? lease.defaultPaymentMethod() : paymentMethod, currency, dueDate, lease, null);
}
Also used : Party(org.estatio.module.party.dom.Party) Property(org.estatio.module.asset.dom.Property) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Example 19 with Property

use of org.estatio.module.asset.dom.Property in project estatio by estatio.

the class IncomingInvoiceItemRepository_Test method upsert_works.

@Test
public void upsert_works() throws Exception {
    // given
    IncomingInvoiceItemRepository incomingInvoiceItemRepository = new IncomingInvoiceItemRepository() {

        @Override
        public IncomingInvoiceItem findByInvoiceAndChargeAndSequence(final IncomingInvoice invoice, final Charge charge, final BigInteger sequence) {
            return invoiceItem;
        }
    };
    BigInteger sequence = new BigInteger("1");
    String description = "";
    Tax tax = new Tax();
    LocalDate dueDate = new LocalDate(2017, 1, 1);
    LocalDate startDate = new LocalDate(2017, 1, 2);
    LocalDate endDate = new LocalDate(2017, 1, 3);
    Property property = new Property();
    Project project = new Project();
    BudgetItem budgetItem = new BudgetItem();
    IncomingInvoiceType type = IncomingInvoiceType.CORPORATE_EXPENSES;
    invoiceItem.setInvoice(mockInvoice);
    assertThat(invoiceItem.getInvoice()).isEqualTo(mockInvoice);
    assertThat(invoiceItem.getIncomingInvoiceType()).isNull();
    assertThat(invoiceItem.getCharge()).isNull();
    assertThat(invoiceItem.getSequence()).isNull();
    assertThat(invoiceItem.getDescription()).isNull();
    assertThat(invoiceItem.getNetAmount()).isNull();
    assertThat(invoiceItem.getVatAmount()).isNull();
    assertThat(invoiceItem.getGrossAmount()).isNull();
    assertThat(invoiceItem.getTax()).isNull();
    assertThat(invoiceItem.getDueDate()).isNull();
    assertThat(invoiceItem.getStartDate()).isNull();
    assertThat(invoiceItem.getEndDate()).isNull();
    assertThat(invoiceItem.getFixedAsset()).isNull();
    assertThat(invoiceItem.getProject()).isNull();
    // when
    incomingInvoiceItemRepository.upsert(sequence, mockInvoice, type, mockCharge, description, BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN, tax, dueDate, startDate, endDate, property, project, budgetItem);
    // then
    // should not updated
    assertThat(invoiceItem.getInvoice()).isEqualTo(mockInvoice);
    // should not updated
    assertThat(invoiceItem.getCharge()).isNull();
    // should not be updated
    assertThat(invoiceItem.getIncomingInvoiceType()).isNull();
    assertThat(invoiceItem.getSequence()).isEqualTo(sequence);
    assertThat(invoiceItem.getDescription()).isEqualTo(description);
    assertThat(invoiceItem.getNetAmount()).isEqualTo(BigDecimal.ZERO);
    assertThat(invoiceItem.getVatAmount()).isEqualTo(BigDecimal.ONE);
    assertThat(invoiceItem.getGrossAmount()).isEqualTo(BigDecimal.TEN);
    assertThat(invoiceItem.getTax()).isEqualTo(tax);
    assertThat(invoiceItem.getDueDate()).isEqualTo(dueDate);
    assertThat(invoiceItem.getStartDate()).isEqualTo(startDate);
    assertThat(invoiceItem.getEndDate()).isEqualTo(endDate);
    assertThat(invoiceItem.getFixedAsset()).isEqualTo(property);
    assertThat(invoiceItem.getProject()).isEqualTo(project);
}
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) BigInteger(java.math.BigInteger) Tax(org.estatio.module.tax.dom.Tax) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) Test(org.junit.Test)

Example 20 with Property

use of org.estatio.module.asset.dom.Property in project estatio by estatio.

the class DebtorBankAccountService_Test method unique_Debtor_Account_To_Pay_works_when_bankaccounts_and_one_for_property.

@Test
public void unique_Debtor_Account_To_Pay_works_when_bankaccounts_and_one_for_property() throws Exception {
    // given
    DebtorBankAccountService service = new DebtorBankAccountService();
    service.bankAccountRepository = mockBankAccountRepository;
    service.fixedAssetFinancialAccountRepository = mockFixedAssetFinancialAccountRepository;
    BankAccount bankAccount = new BankAccount();
    BankAccount bankAccountForProperty = new BankAccount();
    FixedAssetFinancialAccount fixedAssetFinancialAccount = new FixedAssetFinancialAccount();
    fixedAssetFinancialAccount.setFinancialAccount(bankAccountForProperty);
    List<BankAccount> bankAccounts = new ArrayList<>();
    bankAccounts.add(bankAccount);
    bankAccounts.add(bankAccountForProperty);
    IncomingInvoice invoice = new IncomingInvoice();
    Party debtor = new Organisation();
    invoice.setBuyer(debtor);
    Property property = new Property();
    invoice.setProperty(property);
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockBankAccountRepository).findBankAccountsByOwner(debtor);
            will(returnValue(bankAccounts));
            oneOf(mockFixedAssetFinancialAccountRepository).findByFixedAsset(property);
            will(returnValue(Arrays.asList(fixedAssetFinancialAccount)));
        }
    });
    // when, then
    assertThat(service.uniqueDebtorAccountToPay(invoice)).isEqualTo(bankAccountForProperty);
}
Also used : Expectations(org.jmock.Expectations) FixedAssetFinancialAccount(org.estatio.module.assetfinancial.dom.FixedAssetFinancialAccount) Party(org.estatio.module.party.dom.Party) Organisation(org.estatio.module.party.dom.Organisation) ArrayList(java.util.ArrayList) IncomingInvoice(org.estatio.module.capex.dom.invoice.IncomingInvoice) BankAccount(org.estatio.module.financial.dom.BankAccount) Property(org.estatio.module.asset.dom.Property) Test(org.junit.Test)

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