Search in sources :

Example 31 with Lease

use of org.estatio.module.lease.dom.Lease in project estatio by estatio.

the class BudgetOverride_IntegTest method findOrCreateValuesTest.

@Test
public void findOrCreateValuesTest() {
    // given
    Lease leaseTopModel = Lease_enum.OxfTopModel001Gb.findUsing(serviceRegistry);
    Charge invoiceCharge = Charge_enum.GbServiceCharge.findUsing(serviceRegistry);
    BigDecimal overrideValue = new BigDecimal("1234.56");
    String reason = "Some reason";
    budgetOverrideForFixed = wrap(budgetOverrideRepository).newBudgetOverrideForFixed(overrideValue, leaseTopModel, null, null, invoiceCharge, null, null, reason);
    assertThat(budgetOverrideValueRepository.allBudgetOverrideValues().size()).isEqualTo(0);
    // when
    budgetOverrideForFixed.findOrCreateValues(new LocalDate(2015, 01, 01));
    // then
    assertThat(budgetOverrideForFixed.getValues().size()).isEqualTo(2);
    assertThat(budgetOverrideForFixed.getValues().first().getType()).isEqualTo(BudgetCalculationType.BUDGETED);
    assertThat(budgetOverrideForFixed.getValues().last().getType()).isEqualTo(BudgetCalculationType.ACTUAL);
    // and when again
    budgetOverrideForFixed.findOrCreateValues(new LocalDate(2015, 01, 01));
    // then still
    assertThat(budgetOverrideForFixed.getValues().size()).isEqualTo(2);
}
Also used : Lease(org.estatio.module.lease.dom.Lease) Charge(org.estatio.module.charge.dom.Charge) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 32 with Lease

use of org.estatio.module.lease.dom.Lease 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 33 with Lease

use of org.estatio.module.lease.dom.Lease in project estatio by estatio.

the class BudgetAssignmentService_Test method findOrCreateLeaseItemForServiceChargeBudgeted_works_when_no_item_to_copy_from_found.

@Test
public void findOrCreateLeaseItemForServiceChargeBudgeted_works_when_no_item_to_copy_from_found() throws Exception {
    // given
    BudgetAssignmentService budgetAssignmentService = new BudgetAssignmentService() {

        @Override
        LeaseItem findItemToCopyFrom(final Lease lease) {
            return null;
        }
    };
    Charge charge = new Charge();
    BudgetCalculationResult budgetCalculationResult = new BudgetCalculationResult();
    budgetCalculationResult.setInvoiceCharge(charge);
    LocalDate termStartDate = new LocalDate(2018, 1, 1);
    InvoicingFrequency invoicingFrequencyGuess = InvoicingFrequency.QUARTERLY_IN_ADVANCE;
    PaymentMethod paymentMethodGuess = PaymentMethod.DIRECT_DEBIT;
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockLease).findFirstActiveItemOfTypeAndChargeOnDate(LeaseItemType.SERVICE_CHARGE, charge, termStartDate);
            will(returnValue(null));
            oneOf(mockLease).newItem(LeaseItemType.SERVICE_CHARGE, LeaseAgreementRoleTypeEnum.LANDLORD, budgetCalculationResult.getInvoiceCharge(), invoicingFrequencyGuess, paymentMethodGuess, termStartDate);
        }
    });
    // when
    budgetAssignmentService.findOrCreateLeaseItemForServiceChargeBudgeted(mockLease, budgetCalculationResult, termStartDate);
}
Also used : Expectations(org.jmock.Expectations) Lease(org.estatio.module.lease.dom.Lease) Charge(org.estatio.module.charge.dom.Charge) PaymentMethod(org.estatio.module.invoice.dom.PaymentMethod) LocalDate(org.joda.time.LocalDate) BudgetCalculationResult(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult) InvoicingFrequency(org.estatio.module.lease.dom.InvoicingFrequency) Test(org.junit.Test)

Example 34 with Lease

use of org.estatio.module.lease.dom.Lease in project estatio by estatio.

the class BudgetAssignmentService_Test method leasesWithActiveOccupanciesTest.

@Test
public void leasesWithActiveOccupanciesTest() {
    // given
    o1.setStartDate(new LocalDate(2015, 01, 01));
    o2.setStartDate(new LocalDate(2015, 01, 01));
    o3.setStartDate(new LocalDate(2015, 01, 01));
    o4.setEndDate(new LocalDate(2014, 12, 31));
    o5.setStartDate(new LocalDate(2015, 01, 01));
    leaseTerminated.setStatus(LeaseStatus.TERMINATED);
    // when
    List<Lease> leasesfound = budgetAssignmentService.leasesWithActiveOccupations(budget);
    // then
    assertThat(leasesfound.size()).isEqualTo(2);
    assertThat(leasesfound.get(0)).isEqualTo(leaseWith1ActiveOccupancy);
    assertThat(leasesfound.get(1)).isEqualTo(leaseWith2ActiveOccupancies);
}
Also used : Lease(org.estatio.module.lease.dom.Lease) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 35 with Lease

use of org.estatio.module.lease.dom.Lease in project estatio by estatio.

the class BudgetAssignmentService_Test method itemToCopyFrom_when_no_items_on_lease_returns_null.

@Test
public void itemToCopyFrom_when_no_items_on_lease_returns_null() throws Exception {
    // given
    Lease lease = new Lease();
    // when
    LeaseItem itemFound = budgetAssignmentService.findItemToCopyFrom(lease);
    // then
    assertThat(itemFound).isNull();
}
Also used : Lease(org.estatio.module.lease.dom.Lease) LeaseItem(org.estatio.module.lease.dom.LeaseItem) Test(org.junit.Test)

Aggregations

Lease (org.estatio.module.lease.dom.Lease)57 LocalDate (org.joda.time.LocalDate)17 Programmatic (org.apache.isis.applib.annotation.Programmatic)16 ApplicationException (org.apache.isis.applib.ApplicationException)11 Charge (org.estatio.module.charge.dom.Charge)11 Test (org.junit.Test)11 LeaseItem (org.estatio.module.lease.dom.LeaseItem)10 Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)10 Unit (org.estatio.module.asset.dom.Unit)9 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)9 Property (org.estatio.module.asset.dom.Property)7 Party (org.estatio.module.party.dom.Party)6 Action (org.apache.isis.applib.annotation.Action)5 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)5 Before (org.junit.Before)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 PaymentMethod (org.estatio.module.invoice.dom.PaymentMethod)4 InvoiceItemForLease (org.estatio.module.lease.dom.invoicing.InvoiceItemForLease)4 BigDecimal (java.math.BigDecimal)3