use of org.estatio.module.lease.dom.invoicing.InvoiceForLease in project estatio by estatio.
the class InvoiceCalculationForDeposit_IntegTest method with_due_date_deposit_before_period_retro_run_yields_same_results.
@Test
public void with_due_date_deposit_before_period_retro_run_yields_same_results() {
// given
setUpTheGiven();
// EST-1750: to mimick behaviour through UI
sessionManagementService.nextSession();
// when
LocalDate invoiceDueDate = VT.ld(2012, 1, 1);
// NOT: NOW it does NOT matter that the due date of the deposit term is in the past
LocalDate startDueDate = VT.ld(2012, 1, 1);
LocalDate nextDueDate = VT.ld(2012, 1, 2);
Property oxford = Property_enum.OxfGb.findUsing(serviceRegistry);
final LocalDate dateOfInvoiceRun = VT.ld(2011, 12, 1);
setFixtureClockDate(dateOfInvoiceRun);
mixin(Property_calculateInvoices.class, oxford).exec(InvoiceRunType.RETRO_RUN, Arrays.asList(LeaseItemType.RENT, LeaseItemType.DEPOSIT), invoiceDueDate, startDueDate, nextDueDate);
// EST-1750: to mimick behaviour through UI
transactionService.nextTransaction();
// TODO: manage extra boilerplate because of new session -> to be handled in new programming model?
reloadObjectsForNewSession();
assertThat(rentItem010.getTerms().size()).isEqualTo(2);
assertThat(rentItem011.getTerms().size()).isEqualTo(2);
// then
InvoiceForLease invoiceFor010Advance = invoiceForLeaseRepository.findByLease(poisonLease010Advance).get(0);
assertThat(invoiceFor010Advance.getItems().size()).isEqualTo(6);
InvoiceItemForLease depositItem010Advance = (InvoiceItemForLease) invoiceFor010Advance.findFirstItemWithCharge(chargeForDeposit);
assertThat(depositItem010Advance.getNetAmount()).isEqualTo(depositValueAfterIndexation);
InvoiceForLease invoiceFor011Arrears = invoiceForLeaseRepository.findByLease(poisonLease011Arrears).get(0);
assertThat(invoiceFor011Arrears.getItems().size()).isEqualTo(6);
InvoiceItemForLease depositItem011Arrears = (InvoiceItemForLease) invoiceFor011Arrears.findFirstItemWithCharge(chargeForDeposit);
// The user expects that the indexation on 1-1-2012 - which is outside the quarter being invoiced in arrears - is NOT taken into account
assertThat(depositItem011Arrears.getNetAmount()).isEqualTo(depositValueBeforeIndexation);
}
use of org.estatio.module.lease.dom.invoicing.InvoiceForLease in project estatio by estatio.
the class InvoiceCalculationForDeposit_IntegTest method just_in_advance_in_one_normal_run_works.
@Test
public void just_in_advance_in_one_normal_run_works() {
// given
setUpTheGiven();
// EST-1750: to mimick behaviour through UI
sessionManagementService.nextSession();
// when
LocalDate invoiceDueDate = VT.ld(2012, 1, 1);
// NOTE: NOW it matters that the due date of the deposit term is in the past
LocalDate startDueDate = VT.ld(2012, 1, 1);
LocalDate nextDueDate = VT.ld(2012, 1, 2);
Property oxford = Property_enum.OxfGb.findUsing(serviceRegistry);
final LocalDate dateOfInvoiceRun = VT.ld(2011, 12, 1);
setFixtureClockDate(dateOfInvoiceRun);
mixin(Property_calculateInvoices.class, oxford).exec(InvoiceRunType.NORMAL_RUN, Arrays.asList(LeaseItemType.RENT, LeaseItemType.DEPOSIT), invoiceDueDate, startDueDate, nextDueDate);
// EST-1750: to mimick behaviour through UI
transactionService.nextTransaction();
// TODO: manage extra boilerplate because of new session -> to be handled in new programming model?
reloadObjectsForNewSession();
assertThat(rentItem010.getTerms().size()).isEqualTo(2);
assertThat(rentItem011.getTerms().size()).isEqualTo(2);
// then
InvoiceForLease invoiceFor010Advance = invoiceForLeaseRepository.findByLease(poisonLease010Advance).get(0);
assertThat(invoiceFor010Advance.getItems().size()).isEqualTo(2);
InvoiceItemForLease rentItem010 = (InvoiceItemForLease) invoiceFor010Advance.findFirstItemWithCharge(chargeForRent);
assertThat(rentItem010.getNetAmount()).isEqualTo(quarterlyRentAfterIndexation);
InvoiceItemForLease depositItem010Advance = (InvoiceItemForLease) invoiceFor010Advance.findFirstItemWithCharge(chargeForDeposit);
assertThat(depositItem010Advance.getNetAmount()).isEqualTo(depositValueAfterIndexation);
InvoiceForLease invoiceFor011Arrears = invoiceForLeaseRepository.findByLease(poisonLease011Arrears).get(0);
assertThat(invoiceFor011Arrears.getItems().size()).isEqualTo(1);
InvoiceItemForLease rentItem011 = (InvoiceItemForLease) invoiceFor011Arrears.findFirstItemWithCharge(chargeForRent);
assertThat(rentItem011.getNetAmount()).isEqualTo(quarterlyRentAfterIndexation);
}
use of org.estatio.module.lease.dom.invoicing.InvoiceForLease in project estatio by estatio.
the class Invoice_DocumentManagement_IntegTest method findInvoice.
Invoice findInvoice(final InvoiceStatus invoiceStatus) {
// clears out queryResultsCache
transactionService.nextTransaction();
final Party seller = InvoiceForLease_enum.OxfPoison003Gb.getSeller_d().findUsing(serviceRegistry);
final Party buyer = InvoiceForLease_enum.OxfPoison003Gb.getBuyer_d().findUsing(serviceRegistry);
final Lease lease = InvoiceForLease_enum.OxfPoison003Gb.getLease_d().findUsing(serviceRegistry);
final LocalDate invoiceStartDate = InvoiceForLease_enum.OxfPoison003Gb.getLease_d().getStartDate().plusYears(1);
List<InvoiceForLease> matchingInvoices = findMatchingInvoices(seller, buyer, lease, invoiceStartDate, invoiceStatus);
assertThat(matchingInvoices.size()).isLessThanOrEqualTo(1);
return matchingInvoices.isEmpty() ? null : matchingInvoices.get(0);
}
use of org.estatio.module.lease.dom.invoicing.InvoiceForLease in project estatio by estatio.
the class InvoiceCalculationService_normalRun_IntegTest method effective_interval_is_swapped.
@Test
public void effective_interval_is_swapped() throws Exception {
// given
lease.verifyUntil(VT.ld(2014, 1, 1));
LeaseTerm leaseTopModelRentTerm = leaseTopModelRentItem.findTerm(VT.ld(2010, 7, 15));
leaseTopModelRentTerm.approve();
assertThat(leaseTopModelRentTerm.getStatus()).isEqualTo(LeaseTermStatus.APPROVED);
assertThat(leaseTopModelRentTerm.getEffectiveValue()).isEqualTo(VT.bd2(20200));
final String runId = calculateNormalRunAndAssert(leaseTopModelRentTerm, VT.ld(2010, 7, 1), VT.ld(2010, 10, 01), VT.ldi("2010-07-01/2010-10-01"), 4239.13, false, VT.ldi("2010-07-15/2010-10-01"));
final InvoiceForLease invoiceForLease = invoiceForLeaseRepository.findInvoicesByRunId(runId).stream().findFirst().get();
wrap(mixin(InvoiceForLease._approve.class, invoiceForLease)).$$();
// when
lease.terminate(VT.ld(2010, 8, 31));
// then
final String runId2 = calculateNormalRunAndAssert(leaseTopModelRentTerm, VT.ld(2010, 7, 1), VT.ld(2010, 10, 01), VT.ldi("2010-07-01/2010-10-01"), -1630.43, false, VT.ldi("2010-09-01/2010-10-01"));
}
use of org.estatio.module.lease.dom.invoicing.InvoiceForLease in project estatio by estatio.
the class InvoiceAttributesVM_Test method setUp.
@Before
public void setUp() throws Exception {
invoiceForLease = new InvoiceForLease();
invoiceForLease.setItems(new TreeSet<>());
invoiceAttributesVM = new InvoiceAttributesVM(invoiceForLease);
}
Aggregations