Search in sources :

Example 16 with Unit

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

the class KeyItemRepository_Test method negativeKeyValue.

@Test
public void negativeKeyValue() {
    // given
    KeyTable keyTable = new KeyTable();
    Unit unit = new Unit();
    BigDecimal sourcevalue = new BigDecimal(1);
    BigDecimal keyValue = BigDecimal.valueOf(-0.001);
    // when
    String validateNewBudgetKeyItem = keyItemRepository.validateNewItem(keyTable, unit, sourcevalue, keyValue);
    // then
    assertThat(validateNewBudgetKeyItem).isEqualTo("keyValue cannot be 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 17 with Unit

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

the class LandRegisterForOxfordUnit001 method execute.

@Override
protected void execute(ExecutionContext executionContext) {
    // prereqs
    executionContext.executeChild(this, PropertyAndUnitsAndOwnerAndManager_enum.OxfGb.builder());
    Unit unit = Property_enum.OxfGb.findUsing(serviceRegistry).getUnits().first();
    LandRegister landRegister = landRegisters.newRegistration(unit, null, "comuneAmministrativo", "comuneCatastale", "codiceComuneCatastale", new BigDecimal("123.45"), "foglio", "particella", "subalterno", "categoria", "classe", "consistenza", null, "description");
    executionContext.addResult(this, landRegister.title(), landRegister);
}
Also used : LandRegister(org.estatio.module.registration.dom.LandRegister) Unit(org.estatio.module.asset.dom.Unit) BigDecimal(java.math.BigDecimal)

Example 18 with Unit

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

the class PropertyUnitsBuilder method execute.

@Override
protected void execute(final ExecutionContext executionContext) {
    checkParam("property", executionContext, Property.class);
    defaultParam("numberOfUnits", executionContext, fakeDataService.ints().between(10, 20));
    for (int i = 0; i < getNumberOfUnits(); i++) {
        final int unitNum = i + 1;
        final String unitRef = buildUnitReference(property.getReference(), unitNum);
        final UnitType unitType = fakeDataService.enums().anyOf(UnitType.class);
        final String unitName = fakeDataService.name().firstName();
        final Unit unit = wrap(property).newUnit(unitRef, unitName, unitType);
        unit.setArea(new BigDecimal(unitNum * 100));
        object.add(unit);
        executionContext.addResult(this, unitRef, unit);
    }
}
Also used : UnitType(org.estatio.module.asset.dom.UnitType) ToString(lombok.ToString) Unit(org.estatio.module.asset.dom.Unit) BigDecimal(java.math.BigDecimal)

Example 19 with Unit

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

the class UnitImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    final Property property = propertyRepository.findPropertyByReference(propertyReference);
    Unit unit = unitRepository.findUnitByReference(reference);
    if (unit == null) {
        unit = property.newUnit(reference, name, UnitType.BOUTIQUE);
    }
    // set attributes
    unit.setName(name);
    unit.setType(UnitType.valueOf(type));
    unit.changeDates(startDate, endDate);
    unit.setArea(area);
    unit.setSalesArea(salesArea);
    unit.setStorageArea(storageArea);
    unit.setMezzanineArea(mezzanineArea);
    unit.setDehorsArea(dehorsArea);
    unit.setExternalReference(externalReference);
    if (communicationChannelRepository.findByOwnerAndType(unit, CommunicationChannelType.POSTAL_ADDRESS).size() == 0) {
        communicationChannelRepository.newPostal(unit, CommunicationChannelType.POSTAL_ADDRESS, address1, address2, address3, postalCode, city, stateRepository.findState(stateCode), countryRepository.findCountry(countryCode));
    }
    if (ownerReference != null) {
        Party party = partyRepository.findPartyByReference(ownerReference);
        if (party == null) {
            throw new IllegalArgumentException(String.format("Party with ownerReference %s not found", getOwnerReference()));
        }
        // create property owner of not found one already
        FixedAssetRole propertyOwnerRole = fixedAssetRoleRepository.findRole(unitRepository.findUnitByReference(reference), FixedAssetRoleTypeEnum.PROPERTY_OWNER);
        if (propertyOwnerRole == null) {
            unit.createRole(FixedAssetRoleTypeEnum.PROPERTY_OWNER, party, null, null);
        }
    }
    return Lists.newArrayList(unit);
}
Also used : Party(org.estatio.module.party.dom.Party) FixedAssetRole(org.estatio.module.asset.dom.role.FixedAssetRole) Unit(org.estatio.module.asset.dom.Unit) Property(org.estatio.module.asset.dom.Property) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 20 with Unit

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

the class ClassificationForOccImport method importData.

@Override
public List<Object> importData(final Object previousRow) {
    final Lease lease = leaseRepository.findLeaseByReference(getLeaseReference());
    if (lease == null) {
        throw new IllegalArgumentException(String.format("No lease found for '%s'", getLeaseReference()));
    }
    final Unit unit = unitRepository.findUnitByReference(getUnitReference());
    if (unit == null) {
        throw new IllegalArgumentException(String.format("No unit found for '%s'", getUnitReference()));
    }
    final Occupancy occupancy = occupancyRepository.findByLease(lease).stream().filter(x -> x.getUnit().equals(unit)).findFirst().get();
    if (occupancy == null) {
        throw new IllegalArgumentException(String.format("No occupancy found for lease '%s' and unit '%s'", getLeaseReference(), getUnitReference()));
    }
    final Taxonomy taxonomy = (Taxonomy) categoryRepository.findByReference(getTaxonomyReference());
    if (taxonomy == null) {
        throw new IllegalArgumentException(String.format("No taxonomy found for '%s'", getTaxonomyReference()));
    }
    final Category category = categoryRepository.findByTaxonomyAndReference(taxonomy, getCategoryReference());
    if (category == null) {
        throw new IllegalArgumentException(String.format("No category found for '%s'", getCategoryReference()));
    }
    final Classification classification = classificationRepository.create(category, occupancy);
    return Lists.newArrayList(classification);
}
Also used : Category(org.incode.module.classification.dom.impl.category.Category) Lease(org.estatio.module.lease.dom.Lease) Taxonomy(org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) Classification(org.incode.module.classification.dom.impl.classification.Classification) 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