Search in sources :

Example 1 with LeaseTermForTurnoverRent

use of org.estatio.module.lease.dom.LeaseTermForTurnoverRent in project estatio by estatio.

the class LeaseTermForTurnoverRentImport method importData.

@Programmatic
@Override
public List<Object> importData(Object previousRow) {
    LeaseItem item = initLeaseItem();
    // create term
    LeaseTermForTurnoverRent term = (LeaseTermForTurnoverRent) item.findTermWithSequence(getSequence());
    if (term == null) {
        if (getStartDate() == null) {
            throw new IllegalArgumentException("startDate cannot be empty");
        }
        if (getSequence().equals(BigInteger.ONE)) {
            term = (LeaseTermForTurnoverRent) 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 = (LeaseTermForTurnoverRent) previousTerm.createNext(getStartDate(), getEndDate());
        }
        term.setSequence(getSequence());
    }
    term.setStatus(LeaseTermStatus.valueOf(getStatus()));
    // set turnover rent term values
    term.setTurnoverRentRule(turnoverRentRule);
    term.setAuditedTurnover(auditedTurnover);
    term.setAuditedTurnoverRent(auditedTurnoverRent);
    return Lists.newArrayList(term);
}
Also used : LeaseTermForTurnoverRent(org.estatio.module.lease.dom.LeaseTermForTurnoverRent) LeaseItem(org.estatio.module.lease.dom.LeaseItem) LeaseTerm(org.estatio.module.lease.dom.LeaseTerm) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 2 with LeaseTermForTurnoverRent

use of org.estatio.module.lease.dom.LeaseTermForTurnoverRent in project estatio by estatio.

the class LeaseTermForTurnoverRentManager method upload.

// endregion
// region > upload (action)
@Action(publishing = Publishing.DISABLED, semantics = SemanticsOf.IDEMPOTENT)
public LeaseTermForTurnoverRentManager upload(@Parameter(fileAccept = ".xlsx") @ParameterLayout(named = "Excel spreadsheet") final Blob spreadsheet) {
    List<LeaseTermForTurnoverRentLineItem> lineItems = excelService.fromExcel(spreadsheet, LeaseTermForTurnoverRentLineItem.class, LEASE_TERM_FOR_TURNOVER_RENT_SHEET_NAME);
    for (LeaseTermForTurnoverRentLineItem lineItem : lineItems) {
        final LeaseTermForTurnoverRent leaseTerm = lineItem.getLeaseTerm();
        leaseTerm.setAuditedTurnover(lineItem.getAuditedTurnover());
        leaseTerm.verify();
    }
    return this;
}
Also used : LeaseTermForTurnoverRent(org.estatio.module.lease.dom.LeaseTermForTurnoverRent) Action(org.apache.isis.applib.annotation.Action)

Example 3 with LeaseTermForTurnoverRent

use of org.estatio.module.lease.dom.LeaseTermForTurnoverRent in project estatio by estatio.

the class LeaseTermForTurnoverRentBuilder method execute.

@Override
protected void execute(final ExecutionContext ec) {
    checkParam("leaseItem", ec, LeaseItem.class);
    defaultParam("startDate", ec, leaseItem.getStartDate());
    defaultParam("leaseTermFrequency", ec, LeaseTermFrequency.YEARLY);
    final Class<?> expectedClass = LeaseTermForTurnoverRent.class;
    if (!leaseItem.getType().isCreate(expectedClass)) {
        throw new IllegalArgumentException(String.format("LeaseItem type must instantiate %s (is %s)", expectedClass, leaseItem.getType()));
    }
    final LeaseTermForTurnoverRent leaseTerm = (LeaseTermForTurnoverRent) leaseItem.newTerm(startDate, endDate);
    leaseTerm.setFrequency(LeaseTermFrequency.YEARLY);
    leaseTerm.setTurnoverRentRule(turnoverRentRule);
    ec.addResult(this, leaseTerm);
    object = leaseTerm;
}
Also used : LeaseTermForTurnoverRent(org.estatio.module.lease.dom.LeaseTermForTurnoverRent)

Example 4 with LeaseTermForTurnoverRent

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

Aggregations

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