Search in sources :

Example 1 with Unit

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

the class BudgetOverride method getCalculatedValueByBudget.

@Programmatic
BigDecimal getCalculatedValueByBudget(final LocalDate budgetStartDate, final BudgetCalculationType type) {
    BigDecimal value = BigDecimal.ZERO;
    List<Unit> unitsForLease = new ArrayList<>();
    List<BudgetCalculation> calculationsForLeaseAndCharges = new ArrayList<>();
    for (Occupancy occupancy : getLease().getOccupancies()) {
        unitsForLease.add(occupancy.getUnit());
    }
    Budget budget = budgetRepository.findByPropertyAndDate(getLease().getProperty(), budgetStartDate);
    if (getIncomingCharge() == null) {
        for (Unit unit : unitsForLease) {
            calculationsForLeaseAndCharges.addAll(budgetCalculationRepository.findByBudgetAndUnitAndInvoiceChargeAndType(budget, unit, getInvoiceCharge(), type));
        }
    } else {
        for (Unit unit : unitsForLease) {
            calculationsForLeaseAndCharges.addAll(budgetCalculationRepository.findByBudgetAndUnitAndInvoiceChargeAndIncomingChargeAndType(budget, unit, getInvoiceCharge(), getIncomingCharge(), type));
        }
    }
    for (BudgetCalculation calculation : calculationsForLeaseAndCharges) {
        value = value.add(calculation.getEffectiveValue());
    }
    return value;
}
Also used : Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) ArrayList(java.util.ArrayList) Budget(org.estatio.module.budget.dom.budget.Budget) Unit(org.estatio.module.asset.dom.Unit) BigDecimal(java.math.BigDecimal) BudgetCalculation(org.estatio.module.budget.dom.budgetcalculation.BudgetCalculation) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 2 with Unit

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

the class KeyItemRepository_Test method zeroSourceValue.

@Test
public void zeroSourceValue() {
    // given
    KeyTable keyTable = new KeyTable();
    Unit unit = new Unit();
    BigDecimal sourcevalue = BigDecimal.ZERO;
    BigDecimal keyValue = new BigDecimal(10);
    // when
    String validateNewBudgetKeyItem = keyItemRepository.validateNewItem(keyTable, unit, sourcevalue, keyValue);
    // then
    assertThat(validateNewBudgetKeyItem).isEqualTo("sourceValue cannot be zero or less than zero");
}
Also used : KeyTable(org.estatio.module.budget.dom.keytable.KeyTable) Unit(org.estatio.module.asset.dom.Unit) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 3 with Unit

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

the class FoundationValueType_Test method testEquals.

@Test
public void testEquals() {
    // when
    FoundationValueType foundationValueType = FoundationValueType.AREA;
    FoundationValueType foundationValueType2 = FoundationValueType.COUNT;
    FoundationValueType foundationValueType3 = FoundationValueType.MANUAL;
    Unit unit = new Unit();
    unit.setArea(bigDecimal);
    // then
    assertEquals(foundationValueType.valueOf(unit), bigDecimal);
    assertEquals(foundationValueType2.valueOf(unit), BigDecimal.ONE);
    assertEquals(foundationValueType3.valueOf(unit), null);
}
Also used : Unit(org.estatio.module.asset.dom.Unit) Test(org.junit.Test)

Example 4 with Unit

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

the class UnitMenu_Test method changeUnit.

@Test
public void changeUnit() {
    final Unit changeUnit = new Unit();
    changeUnit.setReference("REF-1");
    changeUnit.setName("Name-1");
    changeUnit.setType(UnitType.EXTERNAL);
    changeUnit.changeAsset("Name-2", UnitType.BOUTIQUE);
    assertThat(changeUnit.getName()).isEqualTo("Name-2");
    assertThat(changeUnit.getType()).isEqualTo(UnitType.BOUTIQUE);
}
Also used : Unit(org.estatio.module.asset.dom.Unit) Test(org.junit.Test)

Example 5 with Unit

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

the class LeaseBuilderLEGACY method createLease.

protected Lease createLease(String reference, String name, String unitReference, String brand, BrandCoverage brandCoverage, String countryOfOriginRef, String sector, String activity, String landlordReference, String tenantReference, LocalDate startDate, LocalDate endDate, boolean createManagerRole, boolean createLeaseUnitAndTags, Party manager, ExecutionContext fixtureResults) {
    Unit unit = unitRepository.findUnitByReference(unitReference);
    Party landlord = findPartyByReferenceOrNameElseNull(landlordReference);
    Party tenant = findPartyByReferenceOrNameElseNull(tenantReference);
    Lease lease = leaseRepository.newLease(unit.getApplicationTenancy(), reference, name, null, startDate, null, endDate, landlord, tenant);
    fixtureResults.addResult(this, lease.getReference(), lease);
    if (createManagerRole) {
        final AgreementRole role = lease.createRole(agreementRoleTypeRepository.findByTitle(LeaseAgreementRoleTypeEnum.MANAGER.getTitle()), manager, null, null);
        fixtureResults.addResult(this, role);
    }
    if (createLeaseUnitAndTags) {
        Country countryOfOrigin = countryRepository.findCountry(countryOfOriginRef);
        Occupancy occupancy = occupancyRepository.newOccupancy(lease, unit, startDate);
        occupancy.setBrandName(brand, brandCoverage, countryOfOrigin);
        occupancy.setSectorName(sector);
        occupancy.setActivityName(activity);
        fixtureResults.addResult(this, occupancy);
    }
    if (leaseRepository.findLeaseByReference(reference) == null) {
        throw new RuntimeException("could not find lease reference='" + reference + "'");
    }
    return lease;
}
Also used : Party(org.estatio.module.party.dom.Party) AgreementRole(org.estatio.module.agreement.dom.AgreementRole) Lease(org.estatio.module.lease.dom.Lease) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) Country(org.incode.module.country.dom.impl.Country) Unit(org.estatio.module.asset.dom.Unit)

Aggregations

Unit (org.estatio.module.asset.dom.Unit)27 Test (org.junit.Test)10 BigDecimal (java.math.BigDecimal)8 Lease (org.estatio.module.lease.dom.Lease)8 Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)8 LocalDate (org.joda.time.LocalDate)8 Programmatic (org.apache.isis.applib.annotation.Programmatic)6 Property (org.estatio.module.asset.dom.Property)5 ArrayList (java.util.ArrayList)3 KeyTable (org.estatio.module.budget.dom.keytable.KeyTable)3 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)3 Expectations (org.jmock.Expectations)3 Before (org.junit.Before)3 Action (org.apache.isis.applib.annotation.Action)2 InvoiceItemForLease (org.estatio.module.lease.dom.invoicing.InvoiceItemForLease)2 Brand (org.estatio.module.lease.dom.occupancy.tags.Brand)2 Party (org.estatio.module.party.dom.Party)2 LandRegister (org.estatio.module.registration.dom.LandRegister)2 AbstractBeanPropertiesTest (org.incode.module.unittestsupport.dom.bean.AbstractBeanPropertiesTest)2 List (java.util.List)1