Search in sources :

Example 1 with LeaseTermForFixed

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;
}
Also used : ChargeGroup(org.estatio.module.charge.dom.ChargeGroup) ChargeGroup_enum(org.estatio.module.charge.fixtures.chargegroups.enums.ChargeGroup_enum) LeaseTermForFixed(org.estatio.module.lease.dom.LeaseTermForFixed) LeaseItem(org.estatio.module.lease.dom.LeaseItem)

Example 2 with LeaseTermForFixed

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;
}
Also used : ChargeGroup(org.estatio.module.charge.dom.ChargeGroup) ChargeGroup_enum(org.estatio.module.charge.fixtures.chargegroups.enums.ChargeGroup_enum) LeaseTermForFixed(org.estatio.module.lease.dom.LeaseTermForFixed) LeaseItem(org.estatio.module.lease.dom.LeaseItem)

Example 3 with LeaseTermForFixed

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;
}
Also used : LeaseTermForFixed(org.estatio.module.lease.dom.LeaseTermForFixed)

Example 4 with LeaseTermForFixed

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);
}
Also used : LeaseTermForFixed(org.estatio.module.lease.dom.LeaseTermForFixed) LeaseItem(org.estatio.module.lease.dom.LeaseItem) LeaseTerm(org.estatio.module.lease.dom.LeaseTerm) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

LeaseTermForFixed (org.estatio.module.lease.dom.LeaseTermForFixed)4 LeaseItem (org.estatio.module.lease.dom.LeaseItem)3 ChargeGroup (org.estatio.module.charge.dom.ChargeGroup)2 ChargeGroup_enum (org.estatio.module.charge.fixtures.chargegroups.enums.ChargeGroup_enum)2 Programmatic (org.apache.isis.applib.annotation.Programmatic)1 LeaseTerm (org.estatio.module.lease.dom.LeaseTerm)1