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);
}
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);
}
}
}
}
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;
}
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;
}
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);
}
Aggregations