Search in sources :

Example 1 with LeaseTermForServiceCharge

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

the class BudgetAssignmentService method assign.

public void assign(final Budget budget) {
    for (BudgetCalculationRun run : budgetCalculationRunRepository.findByBudgetAndTypeAndStatus(budget, BudgetCalculationType.BUDGETED, Status.NEW)) {
        for (BudgetCalculationResult resultForLease : run.getBudgetCalculationResults()) {
            LocalDate termStartDate = run.getLease().getStartDate().isAfter(budget.getStartDate()) ? run.getLease().getStartDate() : budget.getStartDate();
            LeaseItem leaseItem = findOrCreateLeaseItemForServiceChargeBudgeted(run.getLease(), resultForLease, termStartDate);
            LeaseTermForServiceCharge leaseTerm = (LeaseTermForServiceCharge) leaseTermRepository.findOrCreateWithStartDate(leaseItem, new LocalDateInterval(termStartDate, budget.getEndDate()));
            budgetCalculationResultLinkRepository.findOrCreateLink(resultForLease, leaseTerm);
            leaseTerm.setBudgetedValue(resultForLease.getValue());
        }
        run.finalizeRun();
    }
}
Also used : LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge) BudgetCalculationRun(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationRun) LocalDate(org.joda.time.LocalDate) LeaseItem(org.estatio.module.lease.dom.LeaseItem) LocalDateInterval(org.incode.module.base.dom.valuetypes.LocalDateInterval) BudgetCalculationResult(org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult)

Example 2 with LeaseTermForServiceCharge

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

the class LeaseTermForServiceChargeBudgetAuditManager method upload.

// endregion
// region > upload (action)
@Action(publishing = Publishing.DISABLED, semantics = SemanticsOf.IDEMPOTENT)
public LeaseTermForServiceChargeBudgetAuditManager upload(@Parameter(fileAccept = ".xlsx") @ParameterLayout(named = "Excel spreadsheet") final Blob spreadsheet) {
    List<LeaseTermForServiceChargeBudgetAuditLineItem> lineItems = excelService.fromExcel(spreadsheet, LeaseTermForServiceChargeBudgetAuditLineItem.class, "lease terms");
    for (LeaseTermForServiceChargeBudgetAuditLineItem lineItem : lineItems) {
        final LeaseTermForServiceCharge leaseTerm = lineItem.getLeaseTerm();
        leaseTerm.setAuditedValue(lineItem.getAuditedValue());
        leaseTerm.setBudgetedValue(lineItem.getBudgetedValue());
        final LeaseTermForServiceCharge nextLeaseTerm = (LeaseTermForServiceCharge) leaseTerm.getNext();
        final LeaseTermForServiceCharge nextLeaseTermUploaded = lineItem.getNextLeaseTerm();
        if (nextLeaseTerm != null && nextLeaseTerm == nextLeaseTermUploaded) {
            nextLeaseTerm.setBudgetedValue(lineItem.getNextBudgetedValue());
        }
    }
    return this;
}
Also used : LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge) Action(org.apache.isis.applib.annotation.Action)

Example 3 with LeaseTermForServiceCharge

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

the class LeaseItemForServiceChargeBuilder method execute.

@Override
protected void execute(final ExecutionContext ec) {
    defaultParam("charge", ec, Charge_enum.GbServiceCharge.findUsing(serviceRegistry));
    final ChargeGroup group = getCharge().getGroup();
    final ChargeGroup_enum expectedGroup = ChargeGroup_enum.ServiceCharge;
    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 4 with LeaseTermForServiceCharge

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

the class LeaseTermForServiceChargeBuilder method execute.

@Override
protected void execute(final ExecutionContext ec) {
    checkParam("leaseItem", ec, LeaseItem.class);
    defaultParam("startDate", ec, leaseItem.getStartDate());
    defaultParam("leaseTermFrequency", ec, LeaseTermFrequency.YEARLY);
    final Class<?> expectedClass = LeaseTermForServiceCharge.class;
    if (!leaseItem.getType().isCreate(expectedClass)) {
        throw new IllegalArgumentException(String.format("LeaseItem type must instantiate %s (is %s)", expectedClass, leaseItem.getType()));
    }
    final LeaseTermForServiceCharge leaseTerm = (LeaseTermForServiceCharge) leaseItem.newTerm(startDate, endDate);
    leaseTerm.setFrequency(leaseTermFrequency);
    leaseTerm.setBudgetedValue(budgetedValue);
    ec.addResult(this, leaseTerm);
    object = leaseTerm;
}
Also used : LeaseTermForServiceCharge(org.estatio.module.lease.dom.LeaseTermForServiceCharge)

Example 5 with LeaseTermForServiceCharge

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

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