use of org.estatio.module.lease.dom.Lease in project estatio by estatio.
the class OccupancyImport method fetchLease.
private Lease fetchLease(final String leaseReference) {
final Lease lease;
lease = leaseRepository.findLeaseByReference(leaseReference.trim().replaceAll("~", "+"));
if (lease == null) {
throw new ApplicationException(String.format("Lease with reference %s not found.", leaseReference));
}
return lease;
}
use of org.estatio.module.lease.dom.Lease in project estatio by estatio.
the class OccupancyImport method importData.
@Override
@Programmatic
public List<Object> importData(Object previousRow) {
final Lease lease = fetchLease(leaseReference);
final Unit unit = unitRepository.findUnitByReference(unitReference);
if (unitReference != null && unit == null) {
throw new ApplicationException(String.format("Unit with reference %s not found.", unitReference));
}
Occupancy occupancy = occupancyRepository.findByLeaseAndUnitAndStartDate(lease, unit, startDate);
if (occupancy == null) {
occupancy = occupancyRepository.newOccupancy(lease, unit, startDate);
}
occupancy.setEndDate(endDate);
occupancy.setUnitSizeName(size);
occupancy.setBrandName(brand != null ? brand.replaceAll("\\p{C}", "").trim() : null, null, null);
occupancy.setSectorName(sector);
occupancy.setActivityName(activity);
occupancy.setReportTurnover(reportTurnover != null ? Occupancy.OccupancyReportingType.valueOf(reportTurnover) : Occupancy.OccupancyReportingType.NO);
occupancy.setReportRent(reportRent != null ? Occupancy.OccupancyReportingType.valueOf(reportRent) : Occupancy.OccupancyReportingType.NO);
occupancy.setReportOCR(reportOCR != null ? Occupancy.OccupancyReportingType.valueOf(reportOCR) : Occupancy.OccupancyReportingType.NO);
return Lists.newArrayList(occupancy);
}
use of org.estatio.module.lease.dom.Lease 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.lease.dom.Lease in project estatio by estatio.
the class BankMandateImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
final Lease lease = fetchLease(leaseReference);
BankAccount bankAccount;
BankMandate bankMandate = null;
// find or create bank account
final Party owner = lease.getSecondaryParty();
bankAccount = (BankAccount) financialAccountRepository.findByOwnerAndReference(owner, bankAccountReference);
if (bankAccount == null) {
bankAccount = bankAccountRepository.newBankAccount(owner, bankAccountReference, null);
}
if (reference != null) {
bankMandate = bankMandateRepository.findByReference(reference);
}
if (bankMandate == null) {
lease.newMandate(bankAccount, reference, startDate, endDate, SequenceType.valueOf(sequenceType), Scheme.valueOf(scheme), signatureDate);
bankMandate = lease.getPaidBy();
}
bankMandate.setBankAccount(bankAccount);
bankMandate.setReference(reference);
bankMandate.setName(name);
bankMandate.setStartDate(startDate);
bankMandate.setEndDate(endDate);
bankMandate.setSepaMandateIdentifier(sepaMandateIdentifier);
bankMandate.setSequenceType(SequenceType.valueOf(sequenceType));
bankMandate.setScheme(Scheme.valueOf(scheme));
bankMandate.setSignatureDate(signatureDate);
lease.paidBy(bankMandate);
return Lists.newArrayList(bankMandate);
}
use of org.estatio.module.lease.dom.Lease in project estatio by estatio.
the class InvoiceForLease method getCurrentOccupancy.
@Programmatic
public Occupancy getCurrentOccupancy() {
final InvoiceForLease invoice = this;
final Lease leaseIfAny = invoice.getLease();
if (leaseIfAny == null) {
return null;
}
final SortedSet<Occupancy> occupancies = leaseIfAny.getOccupancies();
if (occupancies.isEmpty()) {
return null;
}
return occupancies.first();
}
Aggregations