Search in sources :

Example 6 with LeaseTermForServiceCharge

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

the class InvoiceCalculationService_normalRun_IntegTest method invoiceItemsForServiceChargeCreated.

@Test
public void invoiceItemsForServiceChargeCreated() throws Exception {
    leaseInvoicingSettingsService.updateEpochDate(VT.ld(1980, 1, 1));
    LeaseTermForServiceCharge leaseTopModelServiceChargeTerm0 = (LeaseTermForServiceCharge) leaseTopModelServiceChargeItem.getTerms().first();
    leaseTopModelServiceChargeTerm0.approve();
    // partial period
    calculateNormalRunAndAssert(leaseTopModelServiceChargeTerm0, VT.ld(2010, 7, 1), VT.ld(2010, 10, 1), VT.ldi("2010-07-01/2010-10-01"), 1271.74, false, null);
    // full period
    calculateNormalRunAndAssert(leaseTopModelServiceChargeTerm0, VT.ld(2010, 1, 10), VT.ld(2010, 10, 2), VT.ldi("2010-10-01/2011-01-01"), 1500.00, false, null);
    // restore epochdate for other integ tests
    leaseInvoicingSettingsService.updateEpochDate(VT.ld(2010, 1, 1));
}
Also used : LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge) Test(org.junit.Test)

Example 7 with LeaseTermForServiceCharge

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

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

the class LeaseTermForServiceChargeImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    // find or create leaseItem
    final Lease lease = fetchLease(leaseReference);
    final ApplicationTenancy leaseItemApplicationTenancy = ObjectUtils.firstNonNull(securityApplicationTenancyRepository.findByPath(leaseItemAtPath), lease.getApplicationTenancy());
    final Charge charge = fetchCharge(itemChargeReference);
    final LeaseItemType itemType = fetchLeaseItemType(itemTypeName);
    final LocalDate itemStartDateToUse = itemStartDate == null ? lease.getStartDate() : itemStartDate;
    final LeaseAgreementRoleTypeEnum invoicedByToUse = this.invoicedBy == null ? LeaseAgreementRoleTypeEnum.LANDLORD : LeaseAgreementRoleTypeEnum.valueOf(this.invoicedBy);
    final PaymentMethod paymentMethodToUse = itemPaymentMethod == null ? lease.defaultPaymentMethod() : PaymentMethod.valueOf(itemPaymentMethod);
    LeaseItem item = lease.findItem(itemType, charge, itemStartDateToUse, invoicedByToUse);
    if (item == null) {
        item = lease.newItem(itemType, invoicedByToUse, charge, InvoicingFrequency.valueOf(itemInvoicingFrequency), paymentMethodToUse, itemStartDateToUse);
        item.setSequence(itemSequence);
    }
    item.setEpochDate(itemEpochDate);
    item.setNextDueDate(itemNextDueDate);
    final LeaseItemStatus leaseItemStatus = LeaseItemStatus.valueOfElse(itemStatus, LeaseItemStatus.ACTIVE);
    item.setStatus(leaseItemStatus);
    // create term
    LeaseTermForServiceCharge term = (LeaseTermForServiceCharge) item.findTermWithSequence(sequence);
    if (term == null) {
        if (startDate == null) {
            throw new IllegalArgumentException("startDate cannot be empty");
        }
        if (sequence.equals(BigInteger.ONE)) {
            term = (LeaseTermForServiceCharge) item.newTerm(startDate, endDate);
        } else {
            final LeaseTerm previousTerm = item.findTermWithSequence(sequence.subtract(BigInteger.ONE));
            if (previousTerm == null) {
                throw new IllegalArgumentException(String.format("Previous term not found %s", lease.getReference()));
            }
            term = (LeaseTermForServiceCharge) previousTerm.createNext(startDate, endDate);
        }
        term.setSequence(sequence);
    }
    term.setStatus(LeaseTermStatus.valueOf(status));
    // set service charge term values
    term.setBudgetedValue(budgetedValue);
    term.setAuditedValue(auditedValue);
    return Lists.newArrayList(term);
}
Also used : LeaseAgreementRoleTypeEnum(org.estatio.module.lease.dom.LeaseAgreementRoleTypeEnum) Lease(org.estatio.module.lease.dom.Lease) LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge) Charge(org.estatio.module.charge.dom.Charge) PaymentMethod(org.estatio.module.invoice.dom.PaymentMethod) LeaseItemStatus(org.estatio.module.lease.dom.LeaseItemStatus) LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge) LeaseItemType(org.estatio.module.lease.dom.LeaseItemType) LocalDate(org.joda.time.LocalDate) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) LeaseItem(org.estatio.module.lease.dom.LeaseItem) LeaseTerm(org.estatio.module.lease.dom.LeaseTerm) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

LeaseTermForServiceCharge (org.estatio.module.lease.dom.LeaseTermForServiceCharge)8 LeaseItem (org.estatio.module.lease.dom.LeaseItem)4 Action (org.apache.isis.applib.annotation.Action)2 BudgetCalculationResult (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult)2 BudgetCalculationRun (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationRun)2 ChargeGroup (org.estatio.module.charge.dom.ChargeGroup)2 ChargeGroup_enum (org.estatio.module.charge.fixtures.chargegroups.enums.ChargeGroup_enum)2 Lease (org.estatio.module.lease.dom.Lease)2 LocalDate (org.joda.time.LocalDate)2 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 ActionLayout (org.apache.isis.applib.annotation.ActionLayout)1 Contributed (org.apache.isis.applib.annotation.Contributed)1 Mixin (org.apache.isis.applib.annotation.Mixin)1 ParameterLayout (org.apache.isis.applib.annotation.ParameterLayout)1 Programmatic (org.apache.isis.applib.annotation.Programmatic)1 SemanticsOf (org.apache.isis.applib.annotation.SemanticsOf)1 UserService (org.apache.isis.applib.services.user.UserService)1 EstatioRole (org.estatio.module.base.dom.EstatioRole)1 Budget (org.estatio.module.budget.dom.budget.Budget)1