use of org.estatio.module.lease.dom.Lease in project estatio by estatio.
the class Occupancy_Test method validateNewOccupancy_Fails_Test.
@Test
public void validateNewOccupancy_Fails_Test() {
// given
Lease lease = new Lease();
LocalDate occStartDate = new LocalDate();
// when
Unit unit = new Unit() {
@Override
public boolean isActiveOn(final LocalDate date) {
return false;
}
};
// then
assertThat(lease.validateNewOccupancy(occStartDate, unit)).isEqualTo("At the start date of the occupancy this unit is not available.");
}
use of org.estatio.module.lease.dom.Lease in project estatio by estatio.
the class Occupancy_Test method validateNewOccupancy_Passes_Test.
@Test
public void validateNewOccupancy_Passes_Test() {
// given
Lease lease = new Lease();
LocalDate occStartDate = new LocalDate();
// when
Unit unit = new Unit() {
@Override
public boolean isActiveOn(final LocalDate date) {
return true;
}
};
// then
assertThat(lease.validateNewOccupancy(occStartDate, unit)).isNull();
}
use of org.estatio.module.lease.dom.Lease in project estatio by estatio.
the class LeaseStatusService_Test method setUp.
@Before
public void setUp() throws Exception {
lease = new Lease();
service = new LeaseStatusService();
service.clockService = new ClockService() {
@Override
public LocalDate now() {
// TODO Auto-generated method stub
return new LocalDate(2014, 4, 1);
}
};
}
use of org.estatio.module.lease.dom.Lease in project estatio by estatio.
the class InvoiceCalculationService method calculateAndInvoice.
@Programmatic
public String calculateAndInvoice(InvoiceCalculationParameters parameters) {
String lastInteractionId = null;
invoiceForLeaseRepository.removeRuns(parameters);
try {
startInteraction(parameters.toString());
final List<Lease> leases = parameters.leases();
for (Lease lease : leases.size() == 0 ? leaseRepository.findLeasesByProperty(parameters.property()) : leases) {
lease.verifyUntil(parameters.dueDateRange().endDateExcluding());
if (lease.getStatus() != LeaseStatus.SUSPENDED) {
SortedSet<LeaseItem> leaseItems = parameters.leaseItem() == null ? lease.getItems() : new TreeSet<>(Arrays.asList(parameters.leaseItem()));
for (LeaseItem leaseItem : leaseItems) {
if (!leaseItem.getStatus().equals(LeaseItemStatus.SUSPENDED) && leaseItem.getInvoicedBy().equals(LeaseAgreementRoleTypeEnum.LANDLORD)) {
// TODO: We only filter the Landlords
if (parameters.leaseItemTypes() == null || parameters.leaseItemTypes().contains(leaseItem.getType())) {
SortedSet<LeaseTerm> leaseTerms = parameters.leaseTerm() == null ? leaseItem.getTerms() : new TreeSet<>(Arrays.asList(parameters.leaseTerm()));
for (LeaseTerm leaseTerm : leaseTerms) {
final List<CalculationResult> results;
results = calculateDueDateRange(leaseTerm, parameters);
createInvoiceItems(leaseTerm, parameters, results);
}
}
}
}
}
}
} finally {
lastInteractionId = interactionId;
endInteraction();
}
return lastInteractionId;
}
use of org.estatio.module.lease.dom.Lease in project estatio by estatio.
the class InvoiceItemForLeaseRepository method newInvoiceItem.
@Programmatic
public InvoiceItemForLease newInvoiceItem(final LeaseTerm leaseTerm, final LocalDateInterval interval, final LocalDateInterval calculationInterval, final LocalDateInterval effectiveInterval, final LocalDate dueDate, final String interactionId) {
final Lease lease = leaseTerm.getLeaseItem().getLease();
final InvoiceForLease invoice = invoiceRepository.findOrCreateMatchingInvoice(leaseTerm.getApplicationTenancy(), leaseTerm.getLeaseItem().getPaymentMethod(), lease, InvoiceStatus.NEW, dueDate, interactionId);
final InvoiceItemForLease invoiceItem = newItem(invoice, dueDate);
invoiceItem.setLeaseTerm(leaseTerm);
invoiceItem.setStartDate(interval.startDate());
invoiceItem.setEndDate(interval.endDate());
invoiceItem.setEffectiveStartDate(effectiveInterval.startDate());
invoiceItem.setEffectiveEndDate(effectiveInterval.endDate());
invoiceItem.setCalculationStartDate(calculationInterval.startDate());
invoiceItem.setCalculationEndDate(calculationInterval.endDate());
// redundantly persist, these are immutable
// assumes only one occupancy per lease...
invoiceItem.setLease(lease);
final Optional<Occupancy> occupancyIfAny = lease.primaryOccupancy();
occupancyIfAny.ifPresent(occupancy -> {
Unit unit = occupancy.getUnit();
invoiceItem.setFixedAsset(unit);
});
persistIfNotAlready(invoiceItem);
return invoiceItem;
}
Aggregations