use of org.estatio.module.asset.dom.Property in project estatio by estatio.
the class PersonFixedAssetRolesBuilder method execute.
@Override
protected void execute(ExecutionContext executionContext) {
checkParam("person", executionContext, Person.class);
// party roles
PersonPartyRolesBuilder personPartyRolesBuilder = new PersonPartyRolesBuilder();
partyRoles = personPartyRolesBuilder.setPerson(person).addPartyRoleTypes(fixedAssetRoleSpecs.stream().map(x -> x.roleType).collect(Collectors.toList())).build(this, executionContext).getObject();
// fixed asset roles
for (FixedAssetRoleSpec spec : fixedAssetRoleSpecs) {
final Property property = spec.getProperty();
final FixedAssetRole fixedAssetRole = property.addRoleIfDoesNotExist(person, spec.roleType, null, null);
object.add(fixedAssetRole);
}
}
use of org.estatio.module.asset.dom.Property in project estatio by estatio.
the class IncomingInvoiceItem_createOrderItemLink method choices0Act.
public List<OrderItem> choices0Act() {
// the disable guard ensures this is non-null
final Party seller = mixee.getInvoice().getSeller();
final Property property = (Property) mixee.getFixedAsset();
// candidates
final List<OrderItem> orderItems;
if (property == null) {
orderItems = orderItemRepository.findBySeller(seller);
} else {
orderItems = orderItemRepository.findBySellerAndProperty(seller, property);
}
return orderItems.stream().filter(x -> x.getOrdr().getApprovalState() == null || x.getOrdr().getApprovalState() != OrderApprovalState.DISCARDED).collect(Collectors.toList());
}
use of org.estatio.module.asset.dom.Property in project estatio by estatio.
the class LeaseImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
final Party tenant = fetchParty(tenantReference);
final Party landlord = fetchParty(landlordReference);
Lease lease = leaseRepository.findLeaseByReferenceElseNull(reference);
final LeaseType leaseType = leaseTypeRepository.findByReference(type);
final Property property = fetchProperty(propertyReference, null, false);
if (lease == null) {
lease = leaseRepository.newLease(property.getApplicationTenancy(), reference, name, leaseType, startDate, endDate, tenancyStartDate, tenancyEndDate, landlord, tenant);
}
lease.setTenancyStartDate(tenancyStartDate);
lease.setTenancyEndDate(tenancyEndDate);
lease.setExternalReference(externalReference);
lease.setComments(getComments());
if (getProlongationPeriod() != null) {
prolongationOptionRepository.newProlongationOption(lease, getProlongationPeriod(), getNotificationPeriod(), null);
}
if (getPreviousLeaseReference() != null) {
Lease previous = leaseRepository.findLeaseByReference(getPreviousLeaseReference());
if (previous == null) {
// oops, not found?
System.out.println(String.format("On lease [%s] the previous lease [%s] was not found", getReference(), getPreviousLeaseReference()));
} else {
lease.setPrevious(previous);
// Huh? Two sided
previous.setNext(lease);
}
}
return Lists.newArrayList(lease);
}
use of org.estatio.module.asset.dom.Property in project estatio by estatio.
the class CreateRetroInvoices method createProperties.
@Programmatic
public ExecutionContext createProperties(final List<Property> properties, final LocalDate startDueDate, final LocalDate nextDueDate, final ExecutionContext executionContext) {
for (Property property : properties) {
executionContext.addResult(this, property.getReference(), property);
for (Lease lease : leaseRepository.findLeasesByProperty(property)) {
executionContext.addResult(this, lease.getReference(), lease);
createLease(lease, startDueDate, nextDueDate, executionContext);
}
}
return executionContext;
}
use of org.estatio.module.asset.dom.Property in project estatio by estatio.
the class Property_vacantUnits_Test method occupiedUnits.
@Test
public void occupiedUnits() throws Exception {
// given
Property property = new Property();
Unit unit1 = new Unit();
Unit unit2 = new Unit();
Property_vacantUnits mixin = new Property_vacantUnits(property);
mixin.occupancyRepository = mockOccupancyRepository;
mixin.clockService = mockClockService;
// when
Occupancy occupancy1 = new Occupancy();
occupancy1.setUnit(unit1);
Occupancy occupancy2 = new Occupancy();
occupancy1.setUnit(unit2);
// expect
context.checking(new Expectations() {
{
oneOf(mockOccupancyRepository).findByProperty(property);
will(returnValue(Arrays.asList(occupancy1, occupancy2)));
}
});
// then
Assertions.assertThat(mixin.occupiedUnits().size()).isEqualTo(2);
// and when
LocalDate now = new LocalDate(2017, 01, 01);
occupancy1.setEndDate(now);
occupancy2.setEndDate(now.plusDays(1));
// expect
context.checking(new Expectations() {
{
oneOf(mockOccupancyRepository).findByProperty(property);
will(returnValue(Arrays.asList(occupancy1, occupancy2)));
allowing(mockClockService).now();
will(returnValue(now));
}
});
// then
Assertions.assertThat(mixin.occupiedUnits().size()).isEqualTo(1);
}
Aggregations