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