Search in sources :

Example 21 with LeaseItem

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

the class BudgetAssignmentService_Test method findOrCreateLeaseItemForServiceChargeBudgeted_works_when_item_to_copy_from_found.

@Test
public void findOrCreateLeaseItemForServiceChargeBudgeted_works_when_item_to_copy_from_found() throws Exception {
    // given
    LeaseItem leaseItemToCopyFrom = new LeaseItem();
    leaseItemToCopyFrom.setInvoicingFrequency(InvoicingFrequency.QUARTERLY_IN_ADVANCE);
    leaseItemToCopyFrom.setPaymentMethod(PaymentMethod.CHEQUE);
    BudgetAssignmentService budgetAssignmentService = new BudgetAssignmentService() {

        @Override
        LeaseItem findItemToCopyFrom(final Lease lease) {
            return leaseItemToCopyFrom;
        }
    };
    Charge charge = new Charge();
    BudgetCalculationResult budgetCalculationResult = new BudgetCalculationResult();
    budgetCalculationResult.setInvoiceCharge(charge);
    LocalDate termStartDate = new LocalDate(2018, 1, 1);
    // expect
    context.checking(new Expectations() {

        {
            oneOf(mockLease).findFirstActiveItemOfTypeAndChargeOnDate(LeaseItemType.SERVICE_CHARGE, charge, termStartDate);
            will(returnValue(null));
            oneOf(mockLease).newItem(LeaseItemType.SERVICE_CHARGE, LeaseAgreementRoleTypeEnum.LANDLORD, budgetCalculationResult.getInvoiceCharge(), leaseItemToCopyFrom.getInvoicingFrequency(), leaseItemToCopyFrom.getPaymentMethod(), termStartDate);
        }
    });
    // when
    budgetAssignmentService.findOrCreateLeaseItemForServiceChargeBudgeted(mockLease, budgetCalculationResult, termStartDate);
}
Also used : Expectations(org.jmock.Expectations) Lease(org.estatio.module.lease.dom.Lease) Charge(org.estatio.module.charge.dom.Charge) LocalDate(org.joda.time.LocalDate) LeaseItem(org.estatio.module.lease.dom.LeaseItem) BudgetCalculationResult(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult) Test(org.junit.Test)

Example 22 with LeaseItem

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

the class BudgetAssignmentService method findOrCreateLeaseItemForServiceChargeBudgeted.

LeaseItem findOrCreateLeaseItemForServiceChargeBudgeted(final Lease lease, final BudgetCalculationResult calculationResult, final LocalDate startDate) {
    LeaseItem leaseItem = lease.findFirstActiveItemOfTypeAndChargeOnDate(LeaseItemType.SERVICE_CHARGE, calculationResult.getInvoiceCharge(), startDate);
    if (leaseItem == null) {
        // try to copy invoice frequency and payment method from another lease item
        LeaseItem itemToCopyFrom = findItemToCopyFrom(lease);
        leaseItem = lease.newItem(LeaseItemType.SERVICE_CHARGE, LeaseAgreementRoleTypeEnum.LANDLORD, calculationResult.getInvoiceCharge(), itemToCopyFrom != null ? itemToCopyFrom.getInvoicingFrequency() : InvoicingFrequency.QUARTERLY_IN_ADVANCE, itemToCopyFrom != null ? itemToCopyFrom.getPaymentMethod() : PaymentMethod.DIRECT_DEBIT, startDate);
    }
    return leaseItem;
}
Also used : LeaseItem(org.estatio.module.lease.dom.LeaseItem)

Example 23 with LeaseItem

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

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

the class LeaseStatusService_Test method tester.

void tester(LeaseStatus expectedStatus, LocalDate tenancyStartDate, LocalDate tenancyEndDate, LeaseItem... items) {
    lease.setTenancyStartDate(tenancyStartDate);
    lease.setTenancyEndDate(tenancyEndDate);
    int seq = 1;
    for (LeaseItem item : items) {
        item.setSequence(BigInteger.valueOf(seq));
        lease.getItems().add(item);
        seq++;
    }
    assertThat(lease.getItems()).hasSize(items.length);
    assertThat(service.statusOf(lease)).isEqualTo(expectedStatus);
}
Also used : LeaseItem(org.estatio.module.lease.dom.LeaseItem)

Example 25 with LeaseItem

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

the class LeaseMenu method verifyLeasesUntil.

@Action(semantics = SemanticsOf.IDEMPOTENT)
@MemberOrder(sequence = "4")
public String verifyLeasesUntil(final LeaseItemType leaseItemType, final LocalDate untilDate) {
    DateTime start = DateTime.now();
    List<Lease> leases = allLeases();
    for (Lease lease : leases) {
        for (LeaseItem leaseItem : lease.getItems()) {
            if (leaseItem.getType().equals(leaseItemType)) {
                leaseItem.verifyUntil(untilDate);
            }
        }
    }
    Period p = new Period(start, DateTime.now());
    return String.format("Verified %d leases in %s", leases.size(), JodaPeriodUtils.asString(p));
}
Also used : Lease(org.estatio.module.lease.dom.Lease) Period(org.joda.time.Period) DateTime(org.joda.time.DateTime) LeaseItem(org.estatio.module.lease.dom.LeaseItem) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder)

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