Search in sources :

Example 26 with Lease

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

the class DocumentCommunicationSupportForDocumentsAttachedToInvoiceForLease method addTo.

private <T extends CommunicationChannel> void addTo(final InvoiceForLease invoice, final CommHeaderAbstract<T> header, final CommunicationChannelType channelType) {
    final Lease lease = invoice.getLease();
    // current choice(s) and default
    final List current = locator.current(lease, LeaseAgreementRoleTypeEnum.TENANT.getTitle(), AgreementRoleCommunicationChannelTypeEnum.INVOICE_ADDRESS.getTitle(), channelType);
    header.getToChoices().addAll(current);
    final CommunicationChannel sendTo = invoice.getSendTo();
    if (sendTo != null && sendTo.getType() == channelType) {
        header.setToDefault((T) sendTo);
    } else {
        header.setToDefault((T) firstIfAny(current));
    }
    // additional choices (those on file)
    final List onFile = locator.onFile(lease, LeaseAgreementRoleTypeEnum.TENANT.getTitle(), channelType);
    header.getToChoices().addAll(onFile);
}
Also used : Lease(org.estatio.module.lease.dom.Lease) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) List(java.util.List) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)

Example 27 with Lease

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

the class InvoiceServiceMenu method doCalculateRetroInvoices.

// //////////////////
private Object doCalculateRetroInvoices(final ApplicationTenancy applicationTenancy, final List<LeaseItemType> leaseItemTypes, final LocalDate startDueDate, final LocalDate nextDueDate) {
    for (Lease lease : leaseRepository.allLeases()) {
        if (lease.getApplicationTenancy().getPath().matches(applicationTenancy.getPath() + ".*")) {
            for (LocalDate dueDate : lease.dueDatesInRange(startDueDate, nextDueDate)) {
                InvoiceCalculationParameters parameters = InvoiceCalculationParameters.builder().lease(lease).leaseItemTypes(leaseItemTypes).invoiceRunType(InvoiceRunType.NORMAL_RUN).invoiceDueDate(dueDate).startDueDate(startDueDate).nextDueDate(dueDate.plusDays(1)).build();
                String runId = invoiceCalculationService.calculateAndInvoice(parameters);
                if (runId != null) {
                    final InvoiceSummaryForInvoiceRun summaryForInvoiceRun = invoiceSummaries.findByRunId(runId);
                    if (summaryForInvoiceRun != null) {
                        summaryForInvoiceRun.saveAllAsHistoric();
                    } else {
                        getContainer().warnUser(String.format("Run Id [%s] not found", runId));
                    }
                }
            }
        }
    }
    return "Done";
}
Also used : Lease(org.estatio.module.lease.dom.Lease) InvoiceSummaryForInvoiceRun(org.estatio.module.lease.dom.invoicing.summary.InvoiceSummaryForInvoiceRun) InvoiceCalculationParameters(org.estatio.module.lease.dom.invoicing.InvoiceCalculationParameters) LocalDate(org.joda.time.LocalDate)

Example 28 with Lease

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

the class LeaseMenu method verifyAllLeases.

@Action(semantics = SemanticsOf.IDEMPOTENT, restrictTo = RestrictTo.PROTOTYPING)
@MemberOrder(sequence = "98")
public String verifyAllLeases() {
    DateTime dt = DateTime.now();
    List<Lease> leases = allLeases();
    for (Lease lease : leases) {
        lease.verifyUntil(clockService.now());
    }
    Period p = new Period(dt, 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) Action(org.apache.isis.applib.annotation.Action) MemberOrder(org.apache.isis.applib.annotation.MemberOrder)

Example 29 with Lease

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

the class BudgetOverrideValueRepository_IntegTest method findOrCreateBudgetOverrideValueWorks.

@Test
public void findOrCreateBudgetOverrideValueWorks() {
    BudgetOverrideForFixed budgetOverrideForFixed;
    BudgetOverrideValue budgetOverrideValue;
    BigDecimal calculatedValue = new BigDecimal("1234.56");
    // given
    Lease leaseTopModel = Lease_enum.OxfTopModel001Gb.findUsing(serviceRegistry);
    Charge invoiceCharge = Charge_enum.GbServiceCharge.findUsing(serviceRegistry);
    BigDecimal overrideValue = new BigDecimal("1234.56");
    String reason = "Some reason";
    budgetOverrideForFixed = wrap(budgetOverrideRepository).newBudgetOverrideForFixed(overrideValue, leaseTopModel, null, null, invoiceCharge, null, null, reason);
    assertThat(budgetOverrideValueRepository.allBudgetOverrideValues().size()).isEqualTo(0);
    // when
    budgetOverrideValue = wrap(budgetOverrideValueRepository).findOrCreateOverrideValue(calculatedValue, budgetOverrideForFixed, BudgetCalculationType.BUDGETED);
    // then
    assertThat(budgetOverrideValueRepository.allBudgetOverrideValues().size()).isEqualTo(1);
    assertThat(budgetOverrideValue.getValue()).isEqualTo(calculatedValue);
    assertThat(budgetOverrideValue.getBudgetOverride()).isEqualTo(budgetOverrideForFixed);
    assertThat(budgetOverrideValue.getType()).isEqualTo(BudgetCalculationType.BUDGETED);
    assertThat(budgetOverrideValue.getStatus()).isEqualTo(Status.NEW);
    assertThat(budgetOverrideValue.getApplicationTenancy()).isEqualTo(budgetOverrideForFixed.getApplicationTenancy());
    // and when again
    budgetOverrideValue = wrap(budgetOverrideValueRepository).findOrCreateOverrideValue(calculatedValue, budgetOverrideForFixed, BudgetCalculationType.BUDGETED);
    // then still
    assertThat(budgetOverrideValueRepository.allBudgetOverrideValues().size()).isEqualTo(1);
}
Also used : Lease(org.estatio.module.lease.dom.Lease) Charge(org.estatio.module.charge.dom.Charge) BudgetOverrideValue(org.estatio.module.budgetassignment.dom.override.BudgetOverrideValue) BudgetOverrideForFixed(org.estatio.module.budgetassignment.dom.override.BudgetOverrideForFixed) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 30 with Lease

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

the class Budget_Remove method removeBudget.

@Action(semantics = SemanticsOf.NON_IDEMPOTENT_ARE_YOU_SURE)
@ActionLayout(contributed = Contributed.AS_ACTION)
public void removeBudget(@ParameterLayout(named = "This will delete the budget and all associated data including keytables, calculations, runs, results and lease terms. (You may consider downloading the budget and the keytables beforehand.) Are you sure?") final boolean areYouSure) {
    // delete results and runs
    for (BudgetCalculationRun run : budgetCalculationRunRepository.allBudgetCalculationRuns().stream().filter(x -> x.getBudget().equals(budget)).collect(Collectors.toList())) {
        for (BudgetCalculationResult result : run.getBudgetCalculationResults()) {
            // delete links and lease terms
            for (BudgetCalculationResultLink link : budgetCalculationResultLinkRepository.findByCalculationResult(result)) {
                LeaseTermForServiceCharge leaseTermToRemove = null;
                if (link.getLeaseTermForServiceCharge() != null) {
                    leaseTermToRemove = link.getLeaseTermForServiceCharge();
                }
                link.remove();
                if (leaseTermToRemove != null) {
                    leaseTermToRemove.remove();
                }
            }
        }
        run.remove();
    }
    // delete overrides and values
    for (Lease lease : leaseRepository.findByAssetAndActiveOnDate(budget.getProperty(), budget.getStartDate())) {
        for (BudgetOverride override : budgetOverrideRepository.findByLease(lease)) {
            override.remove();
        }
    }
    // delete partition items
    for (BudgetItem budgetItem : budget.getItems()) {
        for (PartitionItem item : partitionItemRepository.findByBudgetItem(budgetItem)) {
            item.remove();
        }
    }
    budget.remove();
}
Also used : BudgetOverrideRepository(org.estatio.module.budgetassignment.dom.override.BudgetOverrideRepository) BudgetCalculationRepository(org.estatio.module.budget.dom.budgetcalculation.BudgetCalculationRepository) EstatioRole(org.estatio.module.base.dom.EstatioRole) Lease(org.estatio.module.lease.dom.Lease) Inject(javax.inject.Inject) ActionLayout(org.apache.isis.applib.annotation.ActionLayout) BudgetCalculationRun(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationRun) Budget(org.estatio.module.budget.dom.budget.Budget) UserService(org.apache.isis.applib.services.user.UserService) Action(org.apache.isis.applib.annotation.Action) LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge) BudgetOverride(org.estatio.module.budgetassignment.dom.override.BudgetOverride) PartitionItem(org.estatio.module.budget.dom.partioning.PartitionItem) BudgetCalculationType(org.estatio.module.budget.dom.budgetcalculation.BudgetCalculationType) BudgetCalculationResultLinkRepository(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResultLinkRepository) BudgetCalculationResult(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult) BudgetCalculationResultLink(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResultLink) Collectors(java.util.stream.Collectors) PartitionItemRepository(org.estatio.module.budget.dom.partioning.PartitionItemRepository) LeaseRepository(org.estatio.module.lease.dom.LeaseRepository) Mixin(org.apache.isis.applib.annotation.Mixin) SemanticsOf(org.apache.isis.applib.annotation.SemanticsOf) ParameterLayout(org.apache.isis.applib.annotation.ParameterLayout) Contributed(org.apache.isis.applib.annotation.Contributed) BudgetCalculationRunRepository(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationRunRepository) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) BudgetCalculationResultLink(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResultLink) Lease(org.estatio.module.lease.dom.Lease) BudgetOverride(org.estatio.module.budgetassignment.dom.override.BudgetOverride) BudgetItem(org.estatio.module.budget.dom.budgetitem.BudgetItem) LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge) BudgetCalculationRun(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationRun) PartitionItem(org.estatio.module.budget.dom.partioning.PartitionItem) BudgetCalculationResult(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult) Action(org.apache.isis.applib.annotation.Action) ActionLayout(org.apache.isis.applib.annotation.ActionLayout)

Aggregations

Lease (org.estatio.module.lease.dom.Lease)57 LocalDate (org.joda.time.LocalDate)17 Programmatic (org.apache.isis.applib.annotation.Programmatic)16 ApplicationException (org.apache.isis.applib.ApplicationException)11 Charge (org.estatio.module.charge.dom.Charge)11 Test (org.junit.Test)11 LeaseItem (org.estatio.module.lease.dom.LeaseItem)10 Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)10 Unit (org.estatio.module.asset.dom.Unit)9 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)9 Property (org.estatio.module.asset.dom.Property)7 Party (org.estatio.module.party.dom.Party)6 Action (org.apache.isis.applib.annotation.Action)5 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)5 Before (org.junit.Before)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 PaymentMethod (org.estatio.module.invoice.dom.PaymentMethod)4 InvoiceItemForLease (org.estatio.module.lease.dom.invoicing.InvoiceItemForLease)4 BigDecimal (java.math.BigDecimal)3