Search in sources :

Example 1 with LeaseItemType

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

the class BudgetAssignmentService_Test method findOrCreateLeaseItemForServiceChargeBudgeted_returns_active_item_when_found.

@Test
public void findOrCreateLeaseItemForServiceChargeBudgeted_returns_active_item_when_found() throws Exception {
    // given
    LeaseItem itemToBeFound = new LeaseItem();
    Lease lease = new Lease() {

        @Override
        public LeaseItem findFirstActiveItemOfTypeAndChargeOnDate(final LeaseItemType leaseItemType, final Charge charge, final LocalDate date) {
            return itemToBeFound;
        }
    };
    BudgetCalculationResult budgetCalculationResult = new BudgetCalculationResult();
    LocalDate termStartDate = new LocalDate(2018, 1, 1);
    // when
    LeaseItem itemFound = budgetAssignmentService.findOrCreateLeaseItemForServiceChargeBudgeted(lease, budgetCalculationResult, termStartDate);
    // then
    assertThat(itemFound).isEqualTo(itemToBeFound);
}
Also used : Lease(org.estatio.module.lease.dom.Lease) Charge(org.estatio.module.charge.dom.Charge) LeaseItemType(org.estatio.module.lease.dom.LeaseItemType) 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 2 with LeaseItemType

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

the class LeaseTermImportAbstract method initLeaseItem.

protected LeaseItem initLeaseItem() {
    // find or create leaseItem
    final Lease lease = fetchLease(getLeaseReference());
    final ApplicationTenancy leaseItemApplicationTenancy = ObjectUtils.firstNonNull(securityApplicationTenancyRepository.findByPath(getLeaseItemAtPath()), lease.getApplicationTenancy());
    final Charge charge = fetchCharge(getItemChargeReference());
    final LeaseItemType itemType = fetchLeaseItemType(getItemTypeName());
    LeaseItem item = lease.findItem(itemType, getItemStartDate(), getItemSequence());
    if (item == null) {
        item = lease.newItem(itemType, LeaseAgreementRoleTypeEnum.LANDLORD, charge, InvoicingFrequency.valueOf(getItemInvoicingFrequency()), PaymentMethod.valueOf(getItemPaymentMethod()), getItemStartDate());
        item.setSequence(getItemSequence());
    }
    item.setEpochDate(getItemEpochDate());
    item.setNextDueDate(getItemNextDueDate());
    final LeaseItemStatus leaseItemStatus = LeaseItemStatus.valueOfElse(getItemStatus(), LeaseItemStatus.ACTIVE);
    item.setStatus(leaseItemStatus);
    // Find source item and create source link
    if (getSourceItemTypeName() != null) {
        final LeaseItemType sourceItemType = LeaseItemType.valueOf(sourceItemTypeName);
        LeaseItem sourceItem = item.getLease().findItem(sourceItemType, sourceItemStartDate, sourceItemSequence);
        if (sourceItem != null) {
            item.findOrCreateSourceItem(sourceItem);
        }
    }
    return item;
}
Also used : Lease(org.estatio.module.lease.dom.Lease) Charge(org.estatio.module.charge.dom.Charge) LeaseItemStatus(org.estatio.module.lease.dom.LeaseItemStatus) LeaseItemType(org.estatio.module.lease.dom.LeaseItemType) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) LeaseItem(org.estatio.module.lease.dom.LeaseItem)

Example 3 with LeaseItemType

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

the class LeaseItemImport method importItem.

@Programmatic
public LeaseItem importItem(boolean updateExisting) {
    final Lease lease = fetchLease(leaseReference);
    final Charge charge = fetchCharge(chargeReference);
    final LeaseItemType itemType = fetchLeaseItemType(itemTypeName);
    // for deposit items the start date defaults to the start date of the lease
    LocalDate startDateOrDefault;
    if (itemType == LeaseItemType.DEPOSIT) {
        startDateOrDefault = ObjectUtils.firstNonNull(startDate, lease.getStartDate());
    } else {
        startDateOrDefault = startDate;
    }
    LeaseItem item = lease.findItem(itemType, startDateOrDefault, sequence);
    if (item == null) {
        item = lease.newItem(itemType, LeaseAgreementRoleTypeEnum.LANDLORD, charge, InvoicingFrequency.valueOf(invoicingFrequency), PaymentMethod.valueOf(paymentMethod), startDateOrDefault);
        item.setSequence(sequence);
    }
    if (updateExisting) {
        item.setApplicationTenancyPath(atPath);
        item.setEpochDate(epochDate);
        item.setNextDueDate(nextDueDate);
        item.setStatus(LeaseItemStatus.valueOfElse(status, LeaseItemStatus.ACTIVE));
    }
    return item;
}
Also used : Lease(org.estatio.module.lease.dom.Lease) Charge(org.estatio.module.charge.dom.Charge) LeaseItemType(org.estatio.module.lease.dom.LeaseItemType) LocalDate(org.joda.time.LocalDate) LeaseItem(org.estatio.module.lease.dom.LeaseItem) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 4 with LeaseItemType

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

the class LeaseTermForServiceChargeBudgetAuditManager_Test method TypesToStringTest.

@Test
public void TypesToStringTest() {
    // given
    LeaseTermForServiceChargeBudgetAuditManager manager = new LeaseTermForServiceChargeBudgetAuditManager();
    // when
    List<LeaseItemType> listToConvert = Arrays.asList(LeaseItemType.SERVICE_CHARGE, LeaseItemType.MARKETING, LeaseItemType.PROPERTY_TAX);
    String result = manager.typesToString(listToConvert);
    // then
    assertThat(result).isEqualTo("SERVICE_CHARGE, MARKETING, PROPERTY_TAX");
    // and when
    listToConvert = Arrays.asList(LeaseItemType.SERVICE_CHARGE);
    result = manager.typesToString(listToConvert);
    // then
    assertThat(result).isEqualTo("SERVICE_CHARGE");
}
Also used : LeaseItemType(org.estatio.module.lease.dom.LeaseItemType) LeaseTermForServiceChargeBudgetAuditManager(org.estatio.module.budgetassignment.imports.LeaseTermForServiceChargeBudgetAuditManager) Test(org.junit.Test)

Example 5 with LeaseItemType

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

the class LeaseTermForServiceChargeBudgetAuditManager_Test method TypesFromStringTest.

@Test
public void TypesFromStringTest() {
    // given
    LeaseTermForServiceChargeBudgetAuditManager manager = new LeaseTermForServiceChargeBudgetAuditManager();
    // when
    String stringToConvert = "SERVICE_CHARGE, MARKETING, PROPERTY_TAX";
    List<LeaseItemType> result = manager.typesFromString(stringToConvert);
    // then
    assertThat(result.size()).isEqualTo(3);
    assertThat(result.get(0)).isEqualTo(LeaseItemType.SERVICE_CHARGE);
    // and when
    stringToConvert = "MARKETING";
    result = manager.typesFromString(stringToConvert);
    // then
    assertThat(result.size()).isEqualTo(1);
    assertThat(result.get(0)).isEqualTo(LeaseItemType.MARKETING);
}
Also used : LeaseItemType(org.estatio.module.lease.dom.LeaseItemType) LeaseTermForServiceChargeBudgetAuditManager(org.estatio.module.budgetassignment.imports.LeaseTermForServiceChargeBudgetAuditManager) Test(org.junit.Test)

Aggregations

LeaseItemType (org.estatio.module.lease.dom.LeaseItemType)7 LeaseItem (org.estatio.module.lease.dom.LeaseItem)5 Charge (org.estatio.module.charge.dom.Charge)4 Lease (org.estatio.module.lease.dom.Lease)4 Programmatic (org.apache.isis.applib.annotation.Programmatic)3 LocalDate (org.joda.time.LocalDate)3 Test (org.junit.Test)3 LeaseTermForServiceChargeBudgetAuditManager (org.estatio.module.budgetassignment.imports.LeaseTermForServiceChargeBudgetAuditManager)2 LeaseItemStatus (org.estatio.module.lease.dom.LeaseItemStatus)2 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)2 BudgetCalculationResult (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult)1 PaymentMethod (org.estatio.module.invoice.dom.PaymentMethod)1 Fraction (org.estatio.module.lease.dom.Fraction)1 LeaseAgreementRoleTypeEnum (org.estatio.module.lease.dom.LeaseAgreementRoleTypeEnum)1 LeaseTerm (org.estatio.module.lease.dom.LeaseTerm)1 LeaseTermForDeposit (org.estatio.module.lease.dom.LeaseTermForDeposit)1 LeaseTermForServiceCharge (org.estatio.module.lease.dom.LeaseTermForServiceCharge)1