Search in sources :

Example 26 with LeaseItem

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

the class LeaseItemBuilder method execute.

@Override
protected void execute(final ExecutionContext ec) {
    checkParam("lease", ec, Lease.class);
    checkParam("charge", ec, Charge.class);
    checkParam("leaseItemType", ec, LeaseItemType.class);
    checkParam("invoicingFrequency", ec, InvoicingFrequency.class);
    defaultParam("sequence", ec, bi(1));
    defaultParam("invoicedBy", ec, LeaseAgreementRoleTypeEnum.LANDLORD);
    defaultParam("paymentMethod", ec, PaymentMethod.DIRECT_DEBIT);
    defaultParam("status", ec, LeaseItemStatus.ACTIVE);
    final ApplicationTenancy leaseApplicationTenancy = lease.getApplicationTenancy();
    final ApplicationTenancy countryApplicationTenancy = leaseApplicationTenancy.getParent();
    if (!ApplicationTenancyLevel.of(countryApplicationTenancy).isCountry()) {
        // not expected to happen...
        throw new IllegalStateException(String.format("Lease '%s' has an app tenancy '%s' whose parent is not at the country level", lease.getReference(), leaseApplicationTenancy.getName()));
    }
    LeaseItem leaseItem = lease.findItem(leaseItemType, lease.getStartDate(), invoicedBy);
    if (leaseItem == null) {
        leaseItem = lease.newItem(leaseItemType, invoicedBy, charge, invoicingFrequency, paymentMethod, lease.getStartDate());
        leaseItem.setType(leaseItemType);
        leaseItem.setStatus(status);
        leaseItem.setEndDate(lease.getEndDate());
        leaseItem.setSequence(sequence);
        ec.addResult(this, leaseItem);
    }
    object = leaseItem;
}
Also used : ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) LeaseItem(org.estatio.module.lease.dom.LeaseItem)

Example 27 with LeaseItem

use of org.estatio.module.lease.dom.LeaseItem 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 28 with LeaseItem

use of org.estatio.module.lease.dom.LeaseItem 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 29 with LeaseItem

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

the class LeaseItemForMarketingBuilder method execute.

@Override
protected void execute(final ExecutionContext ec) {
    defaultParam("charge", ec, Charge_enum.GbMarketing.findUsing(serviceRegistry));
    final ChargeGroup group = getCharge().getGroup();
    final ChargeGroup_enum expectedGroup = ChargeGroup_enum.Marketing;
    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 (LeaseTermForServiceChargeBuilder.TermSpec termSpec : termSpecs) {
        final LeaseTermForServiceCharge term = new LeaseTermForServiceChargeBuilder().setLeaseItem(leaseItem).setStartDate(termSpec.startDate).setEndDate(termSpec.endDate).setLeaseTermFrequency(termSpec.leaseTermFrequency).setBudgetedValue(termSpec.budgetedValue).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) LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge) LeaseItem(org.estatio.module.lease.dom.LeaseItem)

Example 30 with LeaseItem

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

the class LeaseItemForTaxBuilder method execute.

@Override
protected void execute(final ExecutionContext ec) {
    defaultParam("charge", ec, Charge_enum.ItTax.findUsing(serviceRegistry));
    final ChargeGroup group = getCharge().getGroup();
    final ChargeGroup_enum expectedGroup = ChargeGroup_enum.Tax;
    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 (LeaseTermForTaxBuilder.TermSpec termSpec : termSpecs) {
        final LeaseTermForTax term = new LeaseTermForTaxBuilder().setLeaseItem(leaseItem).setStartDate(termSpec.startDate).setEndDate(termSpec.endDate).setLeaseTermFrequency(termSpec.leaseTermFrequency).setTaxPercentage(termSpec.taxPercentage).setRecoverablePercentage(termSpec.recoverablePercentage).setTaxable(termSpec.taxable).build(this, ec).getObject();
        terms.add(term);
    }
    object = leaseItem;
}
Also used : LeaseTermForTax(org.estatio.module.lease.dom.LeaseTermForTax) ChargeGroup(org.estatio.module.charge.dom.ChargeGroup) ChargeGroup_enum(org.estatio.module.charge.fixtures.chargegroups.enums.ChargeGroup_enum) LeaseItem(org.estatio.module.lease.dom.LeaseItem)

Aggregations

LeaseItem (org.estatio.module.lease.dom.LeaseItem)35 ChargeGroup (org.estatio.module.charge.dom.ChargeGroup)10 ChargeGroup_enum (org.estatio.module.charge.fixtures.chargegroups.enums.ChargeGroup_enum)10 Lease (org.estatio.module.lease.dom.Lease)10 Programmatic (org.apache.isis.applib.annotation.Programmatic)7 Charge (org.estatio.module.charge.dom.Charge)6 LeaseTerm (org.estatio.module.lease.dom.LeaseTerm)6 LocalDate (org.joda.time.LocalDate)6 LeaseItemType (org.estatio.module.lease.dom.LeaseItemType)5 Test (org.junit.Test)5 LeaseTermForIndexable (org.estatio.module.lease.dom.LeaseTermForIndexable)4 LeaseTermForServiceCharge (org.estatio.module.lease.dom.LeaseTermForServiceCharge)4 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)4 BudgetCalculationResult (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult)3 LeaseItemStatus (org.estatio.module.lease.dom.LeaseItemStatus)3 LeaseTermForDeposit (org.estatio.module.lease.dom.LeaseTermForDeposit)3 LeaseTermForFixed (org.estatio.module.lease.dom.LeaseTermForFixed)3 LeaseTermForTurnoverRent (org.estatio.module.lease.dom.LeaseTermForTurnoverRent)2 LocalDateInterval (org.incode.module.base.dom.valuetypes.LocalDateInterval)2 Expectations (org.jmock.Expectations)2