Search in sources :

Example 31 with Property

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

the class BudgetAssignmentService_Test method before.

@Before
public void before() throws Exception {
    budgetAssignmentService = new BudgetAssignmentService();
    o1 = new Occupancy();
    leaseWith1ActiveOccupancy = new Lease() {

        @Override
        public SortedSet<Occupancy> getOccupancies() {
            return new TreeSet<>(Arrays.asList(o1));
        }
    };
    o2 = new Occupancy();
    o3 = new Occupancy();
    leaseWith2ActiveOccupancies = new Lease() {

        @Override
        public SortedSet<Occupancy> getOccupancies() {
            return new TreeSet<>(Arrays.asList(o2, o3));
        }
    };
    o4 = new Occupancy();
    leaseWithNoActiveOccupancies = new Lease() {

        @Override
        public SortedSet<Occupancy> getOccupancies() {
            return new TreeSet<>(Arrays.asList(o4));
        }
    };
    o5 = new Occupancy();
    leaseTerminated = new Lease() {

        @Override
        public SortedSet<Occupancy> getOccupancies() {
            return new TreeSet<>(Arrays.asList(o5));
        }
    };
    budget = new Budget();
    LocalDate startDate = new LocalDate(2015, 01, 01);
    LocalDate endDate = new LocalDate(2015, 12, 31);
    budget.setStartDate(startDate);
    budget.setEndDate(endDate);
    LeaseRepository leaseRepository = new LeaseRepository() {

        @Override
        public List<Lease> findLeasesByProperty(final Property property) {
            return Arrays.asList(leaseWith1ActiveOccupancy, leaseWith2ActiveOccupancies, leaseWithNoActiveOccupancies, leaseTerminated);
        }
    };
    budgetAssignmentService.leaseRepository = leaseRepository;
}
Also used : Lease(org.estatio.module.lease.dom.Lease) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) Budget(org.estatio.module.budget.dom.budget.Budget) SortedSet(java.util.SortedSet) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) LeaseRepository(org.estatio.module.lease.dom.LeaseRepository) Before(org.junit.Before)

Example 32 with Property

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

the class BudgetItemValueRepository_IntegTest method updateOrCreateTest_Create.

@Test
public void updateOrCreateTest_Create() {
    // given
    LocalDate budgetStart = new LocalDate(2015, 1, 1);
    Property property = Property_enum.OxfGb.findUsing(serviceRegistry);
    Budget budget = budgetRepository.findByPropertyAndStartDate(property, budgetStart);
    BudgetItem budgetItem = budget.getItems().first();
    assertThat(budgetItem.getValues().size()).isEqualTo(1);
    assertThat(budgetItem.getValues().first().getType()).isEqualTo(BudgetCalculationType.BUDGETED);
    assertThat(budgetItem.getValues().first().getValue()).isEqualTo(new BigDecimal("30000.55"));
    // when
    BudgetItemValue result = wrap(budgetItemValueRepository).updateOrCreateBudgetItemValue(new BigDecimal("33333.00"), budgetItem, budgetStart, BudgetCalculationType.ACTUAL);
    transactionService.flushTransaction();
    // then
    assertThat(budgetItem.getValues().size()).isEqualTo(2);
    assertThat(result.getValue()).isEqualTo(new BigDecimal("33333.00"));
    assertThat(result.getType()).isEqualTo(BudgetCalculationType.ACTUAL);
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Budget(org.estatio.module.budget.dom.budget.Budget) BudgetItemValue(org.estatio.module.budget.dom.budgetitem.BudgetItemValue) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 33 with Property

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

the class BudgetItemValueRepository_IntegTest method findByBudgetItemAndType.

@Test
public void findByBudgetItemAndType() {
    // given
    Property property = Property_enum.OxfGb.findUsing(serviceRegistry);
    Budget budget = budgetRepository.findByPropertyAndStartDate(property, new LocalDate(2015, 01, 01));
    BudgetItem budgetItem = budget.getItems().first();
    assertThat(budgetItem.getValues().size()).isEqualTo(1);
    assertThat(budgetItem.getValues().first().getType()).isEqualTo(BudgetCalculationType.BUDGETED);
    // when
    List<BudgetItemValue> results = budgetItemValueRepository.findByBudgetItemAndType(budgetItem, BudgetCalculationType.BUDGETED);
    // then
    assertThat(results.size()).isEqualTo(1);
}
Also used : BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) Budget(org.estatio.module.budget.dom.budget.Budget) BudgetItemValue(org.estatio.module.budget.dom.budgetitem.BudgetItemValue) Property(org.estatio.module.asset.dom.Property) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 34 with Property

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

the class DebtorBankAccountService method uniqueDebtorAccountToPay.

@Programmatic
public BankAccount uniqueDebtorAccountToPay(final IncomingInvoice invoice) {
    final Party buyer = invoice.getBuyer();
    List<BankAccount> bankAccountsForBuyer = bankAccountRepository.findBankAccountsByOwner(buyer);
    final Property propertyIfAny = invoice.getProperty();
    if (propertyIfAny != null) {
        List<FixedAssetFinancialAccount> fafrList = fixedAssetFinancialAccountRepository.findByFixedAsset(propertyIfAny);
        List<FinancialAccount> bankAccountsForProperty = fafrList.stream().map(FixedAssetFinancialAccount::getFinancialAccount).filter(BankAccount.class::isInstance).map(BankAccount.class::cast).collect(Collectors.toList());
        bankAccountsForBuyer.retainAll(bankAccountsForProperty);
    }
    // original implementation ... see if we already have a unique bank account
    int numBankAccounts = bankAccountsForBuyer.size();
    switch(numBankAccounts) {
        case 0:
            return null;
        case 1:
            return bankAccountsForBuyer.get(0);
        default:
    }
    // see if removing non-preferred helps
    bankAccountsForBuyer.removeIf(x -> (x.getPreferred() == null || !x.getPreferred()));
    numBankAccounts = bankAccountsForBuyer.size();
    switch(numBankAccounts) {
        case 0:
            return null;
        case 1:
            return bankAccountsForBuyer.get(0);
        default:
            // give up, still non-duplicate
            return null;
    }
}
Also used : FixedAssetFinancialAccount(org.estatio.module.assetfinancial.dom.FixedAssetFinancialAccount) Party(org.estatio.module.party.dom.Party) FinancialAccount(org.estatio.module.financial.dom.FinancialAccount) FixedAssetFinancialAccount(org.estatio.module.assetfinancial.dom.FixedAssetFinancialAccount) BankAccount(org.estatio.module.financial.dom.BankAccount) Property(org.estatio.module.asset.dom.Property) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 35 with Property

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

the class InvoiceCalculationForDeposit_IntegTest method in_arrears_and_in_advance_in_one_normal_run_works.

@Test
public void in_arrears_and_in_advance_in_one_normal_run_works() {
    // given
    setUpTheGiven();
    // EST-1750: to mimick behaviour through UI
    sessionManagementService.nextSession();
    // when
    LocalDate invoiceDueDate = VT.ld(2012, 1, 1);
    // NOTE: the user has to realize that the due date for invoices in arrears is the last date of the period
    LocalDate startDueDate = VT.ld(2011, 12, 31);
    LocalDate nextDueDate = VT.ld(2012, 1, 2);
    Property oxford = Property_enum.OxfGb.findUsing(serviceRegistry);
    final LocalDate dateOfInvoiceRun = VT.ld(2011, 12, 1);
    setFixtureClockDate(dateOfInvoiceRun);
    mixin(Property_calculateInvoices.class, oxford).exec(InvoiceRunType.NORMAL_RUN, Arrays.asList(LeaseItemType.RENT, LeaseItemType.DEPOSIT), invoiceDueDate, startDueDate, nextDueDate);
    // EST-1750: to mimick behaviour through UI
    transactionService.nextTransaction();
    // TODO: manage extra boilerplate because of new session -> to be handled in new programming model?
    reloadObjectsForNewSession();
    assertThat(rentItem010.getTerms().size()).isEqualTo(2);
    assertThat(rentItem011.getTerms().size()).isEqualTo(2);
    // then
    InvoiceForLease invoiceFor010Advance = invoiceForLeaseRepository.findByLease(poisonLease010Advance).get(0);
    assertThat(invoiceFor010Advance.getItems().size()).isEqualTo(2);
    InvoiceItemForLease rentItem010 = (InvoiceItemForLease) invoiceFor010Advance.findFirstItemWithCharge(chargeForRent);
    assertThat(rentItem010.getNetAmount()).isEqualTo(quarterlyRentAfterIndexation);
    InvoiceItemForLease depositItem010Advance = (InvoiceItemForLease) invoiceFor010Advance.findFirstItemWithCharge(chargeForDeposit);
    assertThat(depositItem010Advance.getNetAmount()).isEqualTo(depositValueAfterIndexation);
    InvoiceForLease invoiceFor011Arrears = invoiceForLeaseRepository.findByLease(poisonLease011Arrears).get(0);
    assertThat(invoiceFor011Arrears.getItems().size()).isEqualTo(2);
    InvoiceItemForLease rentItem011 = (InvoiceItemForLease) invoiceFor011Arrears.findFirstItemWithCharge(chargeForRent);
    assertThat(rentItem011.getNetAmount()).isEqualTo(quarterlyRentAfterIndexation);
    InvoiceItemForLease depositItem011Arrears = (InvoiceItemForLease) invoiceFor011Arrears.findFirstItemWithCharge(chargeForDeposit);
    // The user expects that the indexation on 1-1-2012 - which is outside the quarter being invoiced in arrears - is NOT taken into account
    assertThat(depositItem011Arrears.getNetAmount()).isEqualTo(depositValueBeforeIndexation);
}
Also used : InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) Property_calculateInvoices(org.estatio.module.lease.contributions.Property_calculateInvoices) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) LocalDate(org.joda.time.LocalDate) 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