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();
}
}
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;
}
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;
}
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;
}
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();
}
Aggregations