Search in sources :

Example 36 with Property

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

the class InvoiceCalculationForDeposit_IntegTest method with_due_date_deposit_before_period_retro_run_yields_same_results.

@Test
public void with_due_date_deposit_before_period_retro_run_yields_same_results() {
    // given
    setUpTheGiven();
    // EST-1750: to mimick behaviour through UI
    sessionManagementService.nextSession();
    // when
    LocalDate invoiceDueDate = VT.ld(2012, 1, 1);
    // NOT: NOW it does NOT matter that the due date of the deposit term is in the past
    LocalDate startDueDate = VT.ld(2012, 1, 1);
    LocalDate nextDueDate = VT.ld(2012, 1, 2);
    Property oxford = Property_enum.OxfGb.findUsing(serviceRegistry);
    final LocalDate dateOfInvoiceRun = VT.ld(2011, 12, 1);
    setFixtureClockDate(dateOfInvoiceRun);
    mixin(Property_calculateInvoices.class, oxford).exec(InvoiceRunType.RETRO_RUN, Arrays.asList(LeaseItemType.RENT, LeaseItemType.DEPOSIT), invoiceDueDate, startDueDate, nextDueDate);
    // EST-1750: to mimick behaviour through UI
    transactionService.nextTransaction();
    // TODO: manage extra boilerplate because of new session -> to be handled in new programming model?
    reloadObjectsForNewSession();
    assertThat(rentItem010.getTerms().size()).isEqualTo(2);
    assertThat(rentItem011.getTerms().size()).isEqualTo(2);
    // then
    InvoiceForLease invoiceFor010Advance = invoiceForLeaseRepository.findByLease(poisonLease010Advance).get(0);
    assertThat(invoiceFor010Advance.getItems().size()).isEqualTo(6);
    InvoiceItemForLease depositItem010Advance = (InvoiceItemForLease) invoiceFor010Advance.findFirstItemWithCharge(chargeForDeposit);
    assertThat(depositItem010Advance.getNetAmount()).isEqualTo(depositValueAfterIndexation);
    InvoiceForLease invoiceFor011Arrears = invoiceForLeaseRepository.findByLease(poisonLease011Arrears).get(0);
    assertThat(invoiceFor011Arrears.getItems().size()).isEqualTo(6);
    InvoiceItemForLease depositItem011Arrears = (InvoiceItemForLease) invoiceFor011Arrears.findFirstItemWithCharge(chargeForDeposit);
    // The user expects that the indexation on 1-1-2012 - which is outside the quarter being invoiced in arrears - is NOT taken into account
    assertThat(depositItem011Arrears.getNetAmount()).isEqualTo(depositValueBeforeIndexation);
}
Also used : InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) Property_calculateInvoices(org.estatio.module.lease.contributions.Property_calculateInvoices) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) Test(org.junit.Test)

Example 37 with Property

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

the class InvoiceCalculationForDeposit_IntegTest method just_in_advance_in_one_normal_run_works.

@Test
public void just_in_advance_in_one_normal_run_works() {
    // given
    setUpTheGiven();
    // EST-1750: to mimick behaviour through UI
    sessionManagementService.nextSession();
    // when
    LocalDate invoiceDueDate = VT.ld(2012, 1, 1);
    // NOTE: NOW it matters that the due date of the deposit term is in the past
    LocalDate startDueDate = VT.ld(2012, 1, 1);
    LocalDate nextDueDate = VT.ld(2012, 1, 2);
    Property oxford = Property_enum.OxfGb.findUsing(serviceRegistry);
    final LocalDate dateOfInvoiceRun = VT.ld(2011, 12, 1);
    setFixtureClockDate(dateOfInvoiceRun);
    mixin(Property_calculateInvoices.class, oxford).exec(InvoiceRunType.NORMAL_RUN, Arrays.asList(LeaseItemType.RENT, LeaseItemType.DEPOSIT), invoiceDueDate, startDueDate, nextDueDate);
    // EST-1750: to mimick behaviour through UI
    transactionService.nextTransaction();
    // TODO: manage extra boilerplate because of new session -> to be handled in new programming model?
    reloadObjectsForNewSession();
    assertThat(rentItem010.getTerms().size()).isEqualTo(2);
    assertThat(rentItem011.getTerms().size()).isEqualTo(2);
    // then
    InvoiceForLease invoiceFor010Advance = invoiceForLeaseRepository.findByLease(poisonLease010Advance).get(0);
    assertThat(invoiceFor010Advance.getItems().size()).isEqualTo(2);
    InvoiceItemForLease rentItem010 = (InvoiceItemForLease) invoiceFor010Advance.findFirstItemWithCharge(chargeForRent);
    assertThat(rentItem010.getNetAmount()).isEqualTo(quarterlyRentAfterIndexation);
    InvoiceItemForLease depositItem010Advance = (InvoiceItemForLease) invoiceFor010Advance.findFirstItemWithCharge(chargeForDeposit);
    assertThat(depositItem010Advance.getNetAmount()).isEqualTo(depositValueAfterIndexation);
    InvoiceForLease invoiceFor011Arrears = invoiceForLeaseRepository.findByLease(poisonLease011Arrears).get(0);
    assertThat(invoiceFor011Arrears.getItems().size()).isEqualTo(1);
    InvoiceItemForLease rentItem011 = (InvoiceItemForLease) invoiceFor011Arrears.findFirstItemWithCharge(chargeForRent);
    assertThat(rentItem011.getNetAmount()).isEqualTo(quarterlyRentAfterIndexation);
}
Also used : InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) Property_calculateInvoices(org.estatio.module.lease.contributions.Property_calculateInvoices) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) Test(org.junit.Test)

Example 38 with Property

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

the class PropertyImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    final Party owner = partyRepository.findPartyByReference(ownerReference);
    final Country country = countryRepository.findCountry(countryCode);
    final ApplicationTenancy appTenancy = applicationTenancyRepository.findByPath(atPath);
    Property property = propertyRepository.findPropertyByReference(reference);
    if (property == null) {
        property = propertyRepository.newProperty(reference, name, PropertyType.valueOf(type), city, country, acquireDate);
    }
    property.setName(name);
    property.setFullName(fullName);
    property.setCountry(country);
    property.setCity(city);
    property.setType(PropertyType.valueOf(type));
    property.setAcquireDate(acquireDate);
    property.setDisposalDate(disposalDate);
    property.setOpeningDate(openingDate);
    property.setExternalReference(externalReference);
    property.addRoleIfDoesNotExist(owner, FixedAssetRoleTypeEnum.PROPERTY_OWNER, null, null);
    property.setParkingSpaces(parkingSpaces);
    property.setArea(grossLettableArea);
    property.setDisplayOrder(displayOrder);
    return Lists.newArrayList(property);
}
Also used : Party(org.estatio.module.party.dom.Party) Country(org.incode.module.country.dom.impl.Country) Property(org.estatio.module.asset.dom.Property) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 39 with Property

use of org.estatio.module.asset.dom.Property 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 40 with Property

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

the class PropertyOrderingViewModel method viewModelMemento.

@Override
public String viewModelMemento() {
    final Property property = getProperty();
    final Bookmark bookmark = bookmarkService.bookmarkFor(property);
    return bookmark.getIdentifier();
}
Also used : Bookmark(org.apache.isis.applib.services.bookmark.Bookmark) Property(org.estatio.module.asset.dom.Property)

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