Search in sources :

Example 1 with FixedAssetRole

use of org.estatio.module.asset.dom.role.FixedAssetRole in project estatio by estatio.

the class PartyRoleMemberInferenceServiceForFixedAssetRoleAndIncomingInvoice method doInferMembersOf.

@Override
protected List<Person> doInferMembersOf(final FixedAssetRoleTypeEnum partyRoleType, final IncomingInvoice incomingInvoice) {
    final FixedAsset fixedAsset = incomingInvoice.getProperty();
    if (fixedAsset == null) {
        // can't go any further
        return null;
    }
    final List<FixedAssetRole> fixedAssetRoles = fixedAssetRoleRepository.findByAssetAndType(fixedAsset, partyRoleType);
    return currentPersonsFrom(fixedAssetRoles);
}
Also used : FixedAssetRole(org.estatio.module.asset.dom.role.FixedAssetRole) FixedAsset(org.estatio.module.asset.dom.FixedAsset)

Example 2 with FixedAssetRole

use of org.estatio.module.asset.dom.role.FixedAssetRole in project estatio by estatio.

the class CreateInvoiceNumerators method execute.

@Override
protected void execute(ExecutionContext ec) {
    final List<FixedAssetRoleTypeEnum> roleTypes = Arrays.asList(FixedAssetRoleTypeEnum.PROPERTY_OWNER, FixedAssetRoleTypeEnum.TENANTS_ASSOCIATION);
    for (final Property property : propertyRepository.allProperties()) {
        for (final FixedAssetRole fixedAssetRole : fixedAssetRoleRepository.findAllForProperty(property)) {
            if (roleTypes.contains(fixedAssetRole.getType())) {
                ApplicationTenancy applicationTenancy = estatioApplicationTenancyRepository.findOrCreateTenancyFor(property, fixedAssetRole.getParty());
                final Numerator numerator = estatioNumeratorRepository.createInvoiceNumberNumerator(property, PropertyOwnerBuilder.numeratorReferenceFor(property), bi(0), applicationTenancy);
                ec.addResult(this, property.getReference(), numerator);
            }
        }
    }
}
Also used : Numerator(org.estatio.module.numerator.dom.Numerator) FixedAssetRole(org.estatio.module.asset.dom.role.FixedAssetRole) FixedAssetRoleTypeEnum(org.estatio.module.asset.dom.role.FixedAssetRoleTypeEnum) Property(org.estatio.module.asset.dom.Property) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)

Example 3 with FixedAssetRole

use of org.estatio.module.asset.dom.role.FixedAssetRole in project estatio by estatio.

the class PropertyOwnerBuilder method execute.

@Override
protected void execute(final ExecutionContext ec) {
    checkParam("property", ec, Property.class);
    checkParam("owner", ec, Party.class);
    final FixedAssetRole fixedAssetRole = property.addRoleIfDoesNotExist(owner, FixedAssetRoleTypeEnum.PROPERTY_OWNER, startDate, endDate);
    ec.addResult(this, fixedAssetRole);
    this.object = fixedAssetRole;
}
Also used : FixedAssetRole(org.estatio.module.asset.dom.role.FixedAssetRole)

Example 4 with FixedAssetRole

use of org.estatio.module.asset.dom.role.FixedAssetRole in project estatio by estatio.

the class FixedAsset method validateNewRole.

public String validateNewRole(final FixedAssetRoleTypeEnum type, final Party party, final LocalDate startDate, final LocalDate endDate) {
    List<FixedAssetRole> currentRoles = fixedAssetRoleRepository.findAllForPropertyAndPartyAndType(this, party, type);
    for (FixedAssetRole fixedAssetRole : currentRoles) {
        LocalDateInterval existingInterval = new LocalDateInterval(fixedAssetRole.getStartDate(), fixedAssetRole.getEndDate());
        LocalDateInterval newInterval = new LocalDateInterval(startDate, endDate);
        if (existingInterval.overlaps(newInterval)) {
            return "The provided dates overlap with a current role of this type and party";
        }
    }
    if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
        return "End date cannot be earlier than start date";
    }
    if (!Sets.filter(getRoles(), type.matchingRole()).isEmpty()) {
        return "Add a successor/predecessor from existing role";
    }
    return null;
}
Also used : FixedAssetRole(org.estatio.module.asset.dom.role.FixedAssetRole) LocalDateInterval(org.incode.module.base.dom.valuetypes.LocalDateInterval)

Example 5 with FixedAssetRole

use of org.estatio.module.asset.dom.role.FixedAssetRole 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)

Aggregations

FixedAssetRole (org.estatio.module.asset.dom.role.FixedAssetRole)8 Property (org.estatio.module.asset.dom.Property)3 Programmatic (org.apache.isis.applib.annotation.Programmatic)2 FixedAsset (org.estatio.module.asset.dom.FixedAsset)2 FixedAssetRoleTypeEnum (org.estatio.module.asset.dom.role.FixedAssetRoleTypeEnum)2 Lists (com.google.common.collect.Lists)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Data (lombok.Data)1 EqualsAndHashCode (lombok.EqualsAndHashCode)1 Getter (lombok.Getter)1 Setter (lombok.Setter)1 ToString (lombok.ToString)1 Accessors (lombok.experimental.Accessors)1 BuilderScriptAbstract (org.apache.isis.applib.fixturescripts.BuilderScriptAbstract)1 Unit (org.estatio.module.asset.dom.Unit)1 Numerator (org.estatio.module.numerator.dom.Numerator)1 Party (org.estatio.module.party.dom.Party)1 Person (org.estatio.module.party.dom.Person)1 PartyRole (org.estatio.module.party.dom.role.PartyRole)1