use of org.estatio.module.lease.dom.LeaseItem in project estatio by estatio.
the class LeaseItemForTurnoverRentBuilder method execute.
@Override
protected void execute(final ExecutionContext ec) {
defaultParam("charge", ec, Charge_enum.ItTurnoverRent.findUsing(serviceRegistry));
final ChargeGroup group = getCharge().getGroup();
final ChargeGroup_enum expectedGroup = ChargeGroup_enum.TurnoverRent;
if (group != expectedGroup.findUsing(serviceRegistry)) {
throw new IllegalArgumentException("Charge's group must be " + expectedGroup.getRef());
}
LeaseItem leaseItem = new LeaseItemBuilder().setLease(lease).setCharge(charge).setLeaseItemType(LEASE_ITEM_TYPE).setInvoicingFrequency(INVOICING_FREQUENCY).setInvoicedBy(invoicedBy).setPaymentMethod(paymentMethod).setStatus(status).setSequence(sequence).build(this, ec).getObject();
if (sourceItem != null) {
if (leaseItem.getSourceItems().isEmpty()) {
leaseItem.newSourceItem(sourceItem);
}
}
for (LeaseTermForTurnoverRentBuilder.TermSpec termSpec : termSpecs) {
final LeaseTermForTurnoverRent term = new LeaseTermForTurnoverRentBuilder().setLeaseItem(leaseItem).setStartDate(termSpec.startDate).setEndDate(termSpec.endDate).setLeaseTermFrequency(termSpec.leaseTermFrequency).setTurnoverRentRule(termSpec.turnoverRentRule).build(this, ec).getObject();
terms.add(term);
}
object = leaseItem;
}
use of org.estatio.module.lease.dom.LeaseItem in project estatio by estatio.
the class LeaseTermForDepositImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
// Early validation
if (LeaseItemType.valueOf(itemTypeName) != LeaseItemType.DEPOSIT) {
throw new IllegalArgumentException("Not a deposit type");
}
// Find or create deposit item
final LeaseItemImport leaseItemImport = new LeaseItemImport(leaseReference, itemTypeName, itemSequence, itemStartDate, itemChargeReference, itemEpochDate, itemNextDueDate, itemInvoicingFrequency, itemPaymentMethod, itemStatus, itemAtPath);
domainObjectContainer.injectServicesInto(leaseItemImport);
LeaseItem depositItem = leaseItemImport.importItem(false);
// link to source item if sourceItemTypeName is given
if (sourceItemTypeName != null) {
// Find source item and find or create source link
final LeaseItemType sourceItemType = LeaseItemType.valueOf(sourceItemTypeName);
LeaseItem rentItem = depositItem.getLease().findItem(sourceItemType, sourceItemStartDate, sourceItemSequence);
depositItem.findOrCreateSourceItem(rentItem);
}
LeaseTermForDeposit term = (LeaseTermForDeposit) depositItem.findTermWithSequence(BigInteger.ONE);
if (term == null) {
// the start date of the term defaults to the start date of the item (which in turn defaults to the start date of the lease)
term = (LeaseTermForDeposit) depositItem.newTerm(ObjectUtils.firstNonNull(startDate, depositItem.getStartDate()), endDate);
}
// set deposit term values
term.setStatus(LeaseTermStatus.valueOf(status));
// fraction defaults to Manual
Fraction fractionOrDefault = fraction != null ? Fraction.valueOf(fraction) : Fraction.MANUAL;
term.setFraction(fractionOrDefault);
// when fraction is set to manual and fixed deposit calculation date is not given the startdate of the item is used
if (fraction.equals("MANUAL") && fixedDepositCalculationDate == null) {
term.setFixedDepositCalculationDate(term.getLeaseItem().getStartDate());
} else {
term.setFixedDepositCalculationDate(fixedDepositCalculationDate);
}
term.setIncludeVat(includeVat);
if (useManualDepositValue != null && useManualDepositValue) {
term.setManualDepositValue(manualDepositValue);
}
return Lists.newArrayList(term);
}
use of org.estatio.module.lease.dom.LeaseItem in project estatio by estatio.
the class LeaseTermForFixedImport method importData.
@Programmatic
@Override
public List<Object> importData(Object previousRow) {
LeaseItem item = initLeaseItem();
// create term
LeaseTermForFixed term = (LeaseTermForFixed) item.findTermWithSequence(getSequence());
if (term == null) {
if (getStartDate() == null) {
throw new IllegalArgumentException("startDate cannot be empty");
}
if (getSequence().equals(BigInteger.ONE)) {
term = (LeaseTermForFixed) item.newTerm(getStartDate(), getEndDate());
} else {
final LeaseTerm previousTerm = item.findTermWithSequence(getSequence().subtract(BigInteger.ONE));
if (previousTerm == null) {
throw new IllegalArgumentException("Previous term not found");
}
term = (LeaseTermForFixed) previousTerm.createNext(getStartDate(), getEndDate());
}
term.setSequence(getSequence());
}
term.setStatus(LeaseTermStatus.valueOf(getStatus()));
// set turnover rent term values
term.setValue(getValue());
return Lists.newArrayList(term);
}
use of org.estatio.module.lease.dom.LeaseItem in project estatio by estatio.
the class LeaseTermForIndexableRentImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
final LeaseItemImport leaseItemImport = new LeaseItemImport(leaseReference, itemTypeName, itemSequence, itemStartDate, itemChargeReference, itemEpochDate, itemNextDueDate, itemInvoicingFrequency, itemPaymentMethod, itemStatus, itemAtPath);
domainObjectContainer.injectServicesInto(leaseItemImport);
LeaseItem item = leaseItemImport.importItem(false);
// create term
LeaseTermForIndexable term = (LeaseTermForIndexable) item.findTermWithSequence(sequence);
if (term == null) {
if (startDate == null) {
throw new IllegalArgumentException("startDate cannot be empty");
}
if (sequence.equals(BigInteger.ONE) || !item.getType().autoCreateTerms()) {
// create a standalone term on the first or when autoCreateTerms is false
term = (LeaseTermForIndexable) item.newTerm(startDate, endDate);
} else {
// join the current with the previous
final LeaseTerm previousTerm = item.findTermWithSequence(sequence.subtract(BigInteger.ONE));
if (previousTerm == null) {
throw new IllegalArgumentException(String.format("Previous term not found: %s", this.toString()));
}
term = (LeaseTermForIndexable) previousTerm.createNext(startDate, endDate);
}
term.setSequence(sequence);
}
term.setStatus(LeaseTermStatus.valueOf(status));
final ApplicationTenancy applicationTenancy = term.getLeaseItem().getApplicationTenancy();
// set indexation term values
term.setIndexationMethod(indexationMethod == null ? null : IndexationMethod.valueOf(indexationMethod));
term.setIndex(indexReference == null ? null : indexRepository.findOrCreateIndex(applicationTenancy, indexReference, indexReference));
term.setFrequency(indexationFrequency == null ? null : LeaseTermFrequency.valueOf(indexationFrequency));
term.setEffectiveDate(effectiveDate);
term.setBaseValue(baseValue);
term.setIndexedValue(indexedValue);
term.setSettledValue(settledValue);
term.setBaseIndexStartDate(baseIndexStartDate);
term.setBaseIndexValue(baseIndexValue);
term.setNextIndexStartDate(nextIndexStartDate);
term.setNextIndexValue(nextIndexValue);
term.setIndexationPercentage(indexationPercentage);
term.setLevellingPercentage(levellingPercentage);
return Lists.newArrayList(term);
}
use of org.estatio.module.lease.dom.LeaseItem in project estatio by estatio.
the class LeaseTermForServiceChargeImport method importData.
@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
// find or create leaseItem
final Lease lease = fetchLease(leaseReference);
final ApplicationTenancy leaseItemApplicationTenancy = ObjectUtils.firstNonNull(securityApplicationTenancyRepository.findByPath(leaseItemAtPath), lease.getApplicationTenancy());
final Charge charge = fetchCharge(itemChargeReference);
final LeaseItemType itemType = fetchLeaseItemType(itemTypeName);
final LocalDate itemStartDateToUse = itemStartDate == null ? lease.getStartDate() : itemStartDate;
final LeaseAgreementRoleTypeEnum invoicedByToUse = this.invoicedBy == null ? LeaseAgreementRoleTypeEnum.LANDLORD : LeaseAgreementRoleTypeEnum.valueOf(this.invoicedBy);
final PaymentMethod paymentMethodToUse = itemPaymentMethod == null ? lease.defaultPaymentMethod() : PaymentMethod.valueOf(itemPaymentMethod);
LeaseItem item = lease.findItem(itemType, charge, itemStartDateToUse, invoicedByToUse);
if (item == null) {
item = lease.newItem(itemType, invoicedByToUse, charge, InvoicingFrequency.valueOf(itemInvoicingFrequency), paymentMethodToUse, itemStartDateToUse);
item.setSequence(itemSequence);
}
item.setEpochDate(itemEpochDate);
item.setNextDueDate(itemNextDueDate);
final LeaseItemStatus leaseItemStatus = LeaseItemStatus.valueOfElse(itemStatus, LeaseItemStatus.ACTIVE);
item.setStatus(leaseItemStatus);
// create term
LeaseTermForServiceCharge term = (LeaseTermForServiceCharge) item.findTermWithSequence(sequence);
if (term == null) {
if (startDate == null) {
throw new IllegalArgumentException("startDate cannot be empty");
}
if (sequence.equals(BigInteger.ONE)) {
term = (LeaseTermForServiceCharge) item.newTerm(startDate, endDate);
} else {
final LeaseTerm previousTerm = item.findTermWithSequence(sequence.subtract(BigInteger.ONE));
if (previousTerm == null) {
throw new IllegalArgumentException(String.format("Previous term not found %s", lease.getReference()));
}
term = (LeaseTermForServiceCharge) previousTerm.createNext(startDate, endDate);
}
term.setSequence(sequence);
}
term.setStatus(LeaseTermStatus.valueOf(status));
// set service charge term values
term.setBudgetedValue(budgetedValue);
term.setAuditedValue(auditedValue);
return Lists.newArrayList(term);
}
Aggregations