Search in sources :

Example 1 with LeaseTermForDeposit

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

the class InvoiceCalculationForDeposit_IntegTest method setUpDepositItem.

private LeaseItem setUpDepositItem(final Lease lease, final LeaseItem source, final InvoicingFrequency invoicingFrequency) {
    LeaseItem depositItem = wrap(lease).newItem(LeaseItemType.DEPOSIT, LeaseAgreementRoleTypeEnum.LANDLORD, chargeForDeposit, invoicingFrequency, PaymentMethod.DIRECT_DEBIT, startDateForItems);
    wrap(depositItem).newSourceItem(source);
    LeaseTermForDeposit term = (LeaseTermForDeposit) wrap(depositItem).newTerm(startDateForItems, null);
    wrap(term).changeParameters(Fraction.M6, null, false);
    return depositItem;
}
Also used : LeaseTermForDeposit(org.estatio.module.lease.dom.LeaseTermForDeposit) LeaseItem(org.estatio.module.lease.dom.LeaseItem)

Example 2 with LeaseTermForDeposit

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

the class LeaseItemForDepositBuilder method execute.

@Override
protected void execute(final ExecutionContext ec) {
    defaultParam("charge", ec, Charge_enum.ItDeposit.findUsing(serviceRegistry));
    final ChargeGroup group = getCharge().getGroup();
    final ChargeGroup_enum expectedGroup = ChargeGroup_enum.Deposit;
    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).setSequence(sequence).setInvoicedBy(invoicedBy).setPaymentMethod(paymentMethod).setStatus(status).build(this, ec).getObject();
    if (sourceItem != null) {
        if (leaseItem.getSourceItems().isEmpty()) {
            leaseItem.newSourceItem(sourceItem);
        }
    }
    for (LeaseTermForDepositBuilder.TermSpec termSpec : termSpecs) {
        final LeaseTermForDeposit term = new LeaseTermForDepositBuilder().setLeaseItem(leaseItem).setStartDate(termSpec.startDate).setEndDate(termSpec.endDate).setFraction(termSpec.fraction).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) LeaseTermForDeposit(org.estatio.module.lease.dom.LeaseTermForDeposit) LeaseItem(org.estatio.module.lease.dom.LeaseItem)

Example 3 with LeaseTermForDeposit

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

the class LeaseTermForDepositBuilder method execute.

@Override
protected void execute(final ExecutionContext ec) {
    checkParam("leaseItem", ec, LeaseItem.class);
    defaultParam("startDate", ec, leaseItem.getStartDate());
    checkParam("fraction", ec, Fraction.class);
    defaultParam("leaseTermFrequency", ec, LeaseTermFrequency.YEARLY);
    final Class<?> expectedClass = LeaseTermForDeposit.class;
    if (!leaseItem.getType().isCreate(expectedClass)) {
        throw new IllegalArgumentException(String.format("LeaseItem type must instantiate %s (is %s)", expectedClass, leaseItem.getType()));
    }
    final LeaseTermForDeposit leaseTerm = (LeaseTermForDeposit) leaseItem.newTerm(startDate, endDate);
    leaseTerm.setFraction(fraction);
    // unlike other terms, didn't see this being set...
    // leaseTerm.setFrequency(leaseTermFrequency);
    ec.addResult(this, leaseTerm);
    object = leaseTerm;
}
Also used : LeaseTermForDeposit(org.estatio.module.lease.dom.LeaseTermForDeposit)

Example 4 with LeaseTermForDeposit

use of org.estatio.module.lease.dom.LeaseTermForDeposit 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);
}
Also used : LeaseTermForDeposit(org.estatio.module.lease.dom.LeaseTermForDeposit) Fraction(org.estatio.module.lease.dom.Fraction) LeaseItemType(org.estatio.module.lease.dom.LeaseItemType) LeaseItem(org.estatio.module.lease.dom.LeaseItem) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

LeaseTermForDeposit (org.estatio.module.lease.dom.LeaseTermForDeposit)4 LeaseItem (org.estatio.module.lease.dom.LeaseItem)3 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 Fraction (org.estatio.module.lease.dom.Fraction)1 LeaseItemType (org.estatio.module.lease.dom.LeaseItemType)1