use of org.estatio.module.lease.dom.LeaseTermForFixed in project estatio by estatio.
the class LeaseItemForEntryFeeBuilder method execute.
@Override
protected void execute(final ExecutionContext ec) {
defaultParam("charge", ec, Charge_enum.ItEntryFee.findUsing(serviceRegistry));
final ChargeGroup group = getCharge().getGroup();
final ChargeGroup_enum expectedGroup = ChargeGroup_enum.EntryFee;
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();
for (final LeaseTermForFixedBuilder.TermSpec termSpec : termSpecs) {
final LeaseTermForFixed term = new LeaseTermForFixedBuilder().setLeaseItem(leaseItem).setStartDate(termSpec.startDate).setEndDate(termSpec.endDate).setLeaseTermFrequency(termSpec.leaseTermFrequency).setValue(termSpec.value).build(this, ec).getObject();
terms.add(term);
}
object = leaseItem;
}
use of org.estatio.module.lease.dom.LeaseTermForFixed in project estatio by estatio.
the class LeaseItemForDiscountBuilder method execute.
@Override
protected void execute(final ExecutionContext ec) {
defaultParam("charge", ec, Charge_enum.ItDiscount.findUsing(serviceRegistry));
final ChargeGroup group = getCharge().getGroup();
final ChargeGroup_enum expectedGroup = ChargeGroup_enum.Discount;
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).setSequence(sequence).setStatus(status).build(this, ec).getObject();
for (LeaseTermForFixedBuilder.TermSpec termSpec : termSpecs) {
final LeaseTermForFixed term = new LeaseTermForFixedBuilder().setLeaseItem(leaseItem).setStartDate(termSpec.startDate).setEndDate(termSpec.endDate).setLeaseTermFrequency(termSpec.leaseTermFrequency).setValue(termSpec.value).build(this, ec).getObject();
terms.add(term);
}
object = leaseItem;
}
use of org.estatio.module.lease.dom.LeaseTermForFixed in project estatio by estatio.
the class LeaseTermForFixedBuilder method execute.
@Override
protected void execute(final ExecutionContext ec) {
checkParam("leaseItem", ec, LeaseItem.class);
defaultParam("startDate", ec, leaseItem.getStartDate());
checkParam("value", ec, BigDecimal.class);
defaultParam("leaseTermFrequency", ec, LeaseTermFrequency.YEARLY);
final Class<?> expectedClass = LeaseTermForFixed.class;
if (!leaseItem.getType().isCreate(expectedClass)) {
throw new IllegalArgumentException(String.format("LeaseItem type must instantiate %s (is %s)", expectedClass, leaseItem.getType()));
}
final LeaseTermForFixed leaseTerm = (LeaseTermForFixed) leaseItem.newTerm(startDate, endDate);
leaseTerm.setValue(value);
leaseTerm.setFrequency(leaseTermFrequency);
ec.addResult(this, leaseTerm);
object = leaseTerm;
}
use of org.estatio.module.lease.dom.LeaseTermForFixed 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);
}
Aggregations