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