Search in sources :

Example 41 with Property

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);
    }
}
Also used : PersonPartyRolesBuilder(org.estatio.module.party.fixtures.person.builders.PersonPartyRolesBuilder) Person(org.estatio.module.party.dom.Person) Setter(lombok.Setter) Accessors(lombok.experimental.Accessors) Getter(lombok.Getter) PersonPartyRolesBuilder(org.estatio.module.party.fixtures.person.builders.PersonPartyRolesBuilder) Property(org.estatio.module.asset.dom.Property) EqualsAndHashCode(lombok.EqualsAndHashCode) Collectors(java.util.stream.Collectors) BuilderScriptAbstract(org.apache.isis.applib.fixturescripts.BuilderScriptAbstract) List(java.util.List) Lists(com.google.common.collect.Lists) FixedAssetRole(org.estatio.module.asset.dom.role.FixedAssetRole) FixedAssetRoleTypeEnum(org.estatio.module.asset.dom.role.FixedAssetRoleTypeEnum) Data(lombok.Data) ToString(lombok.ToString) PartyRole(org.estatio.module.party.dom.role.PartyRole) FixedAssetRole(org.estatio.module.asset.dom.role.FixedAssetRole) Property(org.estatio.module.asset.dom.Property)

Example 42 with Property

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());
}
Also used : Action(org.apache.isis.applib.annotation.Action) OrderApprovalState(org.estatio.module.capex.dom.order.approval.OrderApprovalState) Party(org.estatio.module.party.dom.Party) Property(org.estatio.module.asset.dom.Property) OrderItem(org.estatio.module.capex.dom.order.OrderItem) Collectors(java.util.stream.Collectors) MemberOrder(org.apache.isis.applib.annotation.MemberOrder) BigDecimal(java.math.BigDecimal) Mixin(org.apache.isis.applib.annotation.Mixin) SemanticsOf(org.apache.isis.applib.annotation.SemanticsOf) List(java.util.List) ReasonBuffer2(org.estatio.module.base.platform.applib.ReasonBuffer2) Digits(javax.validation.constraints.Digits) IncomingInvoiceItem(org.estatio.module.capex.dom.invoice.IncomingInvoiceItem) Party(org.estatio.module.party.dom.Party) OrderItem(org.estatio.module.capex.dom.order.OrderItem) Property(org.estatio.module.asset.dom.Property)

Example 43 with Property

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);
}
Also used : Party(org.estatio.module.party.dom.Party) Lease(org.estatio.module.lease.dom.Lease) LeaseType(org.estatio.module.lease.dom.LeaseType) Property(org.estatio.module.asset.dom.Property) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 44 with Property

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;
}
Also used : Lease(org.estatio.module.lease.dom.Lease) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) Property(org.estatio.module.asset.dom.Property) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 45 with Property

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);
}
Also used : Expectations(org.jmock.Expectations) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) Unit(org.estatio.module.asset.dom.Unit) Property(org.estatio.module.asset.dom.Property) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Aggregations

Property (org.estatio.module.asset.dom.Property)47 LocalDate (org.joda.time.LocalDate)19 Test (org.junit.Test)19 Party (org.estatio.module.party.dom.Party)12 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)11 Programmatic (org.apache.isis.applib.annotation.Programmatic)10 Budget (org.estatio.module.budget.dom.budget.Budget)8 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)8 BigDecimal (java.math.BigDecimal)7 List (java.util.List)6 Charge (org.estatio.module.charge.dom.Charge)6 Lease (org.estatio.module.lease.dom.Lease)6 InvoiceItemForLease (org.estatio.module.lease.dom.invoicing.InvoiceItemForLease)6 Expectations (org.jmock.Expectations)6 Before (org.junit.Before)6 Unit (org.estatio.module.asset.dom.Unit)5 Project (org.estatio.module.capex.dom.project.Project)5 Organisation (org.estatio.module.party.dom.Organisation)5 BudgetItemValue (org.estatio.module.budget.dom.budgetitem.BudgetItemValue)4 BankAccount (org.estatio.module.financial.dom.BankAccount)4