use of org.estatio.module.lease.dom.invoicing.InvoiceCalculationParameters 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.invoicing.InvoiceCalculationParameters in project estatio by estatio.
the class InvoiceCalculationService_normalRun_IntegTest method calculateNormalRunAndAssert.
private String calculateNormalRunAndAssert(final LeaseTerm leaseTerm, final LocalDate startDueDate, final LocalDate nextDueDate, final LocalDateInterval interval, final Double expected, final boolean expectedAdjustment, final LocalDateInterval expectedEffectiveInterval) {
transactionService.nextTransaction();
isisJdoSupport.refresh(leaseTerm);
InvoiceCalculationParameters parameters = InvoiceCalculationParameters.builder().leaseTerm(leaseTerm).invoiceRunType(InvoiceRunType.NORMAL_RUN).invoiceDueDate(startDueDate).startDueDate(startDueDate).nextDueDate(nextDueDate).build();
final String runId = invoiceCalculationService.calculateAndInvoice(parameters);
InvoiceItemForLease invoiceItem = invoiceItemForLeaseRepository.findUnapprovedInvoiceItem(leaseTerm, interval);
isisJdoSupport.refresh(leaseTerm);
BigDecimal netAmount = invoiceItem == null ? VT.bd2(0) : invoiceItem.getNetAmount();
final String reason = "size " + invoiceItemForLeaseRepository.findByLeaseTermAndInvoiceStatus(leaseTerm, InvoiceStatus.NEW).size();
assertThat(netAmount).isEqualTo(VT.bd2hup(expected)).as(reason);
Boolean adjustment = invoiceItem == null ? false : invoiceItem.getAdjustment();
assertThat(adjustment).isEqualTo(expectedAdjustment);
if (expectedEffectiveInterval != null) {
assertThat(invoiceItem.getEffectiveInterval()).isEqualTo(expectedEffectiveInterval);
}
return runId;
}
use of org.estatio.module.lease.dom.invoicing.InvoiceCalculationParameters in project estatio by estatio.
the class CreateRetroInvoices method createLease.
@Programmatic
public ExecutionContext createLease(final Lease lease, final LocalDate startDueDate, final LocalDate nextDueDate, final ExecutionContext fixtureResults) {
final SortedSet<LocalDate> dueDates = lease.dueDatesInRange(startDueDate, nextDueDate);
for (LocalDate dueDate : dueDates) {
InvoiceCalculationParameters parameters = InvoiceCalculationParameters.builder().lease(lease).leaseItemTypes(InvoiceCalculationSelection.ALL_ITEMS.selectedTypes()).invoiceRunType(InvoiceRunType.NORMAL_RUN).invoiceDueDate(dueDate).startDueDate(startDueDate).nextDueDate(dueDate.plusDays(1)).build();
createAndApprove(parameters, fixtureResults);
}
return fixtureResults;
}
Aggregations