Search in sources :

Example 11 with InvoiceForLease

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);
}
Also used : InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) Property_calculateInvoices(org.estatio.module.lease.contributions.Property_calculateInvoices) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) Test(org.junit.Test)

Example 12 with InvoiceForLease

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);
}
Also used : InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) Property_calculateInvoices(org.estatio.module.lease.contributions.Property_calculateInvoices) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) Test(org.junit.Test)

Example 13 with InvoiceForLease

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);
}
Also used : Party(org.estatio.module.party.dom.Party) Lease(org.estatio.module.lease.dom.Lease) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) LocalDate(org.joda.time.LocalDate)

Example 14 with InvoiceForLease

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"));
}
Also used : InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) LeaseTerm(org.estatio.module.lease.dom.LeaseTerm) Test(org.junit.Test)

Example 15 with InvoiceForLease

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);
}
Also used : InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) Before(org.junit.Before)

Aggregations

InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)22 InvoiceItemForLease (org.estatio.module.lease.dom.invoicing.InvoiceItemForLease)8 LocalDate (org.joda.time.LocalDate)8 Lease (org.estatio.module.lease.dom.Lease)7 Property (org.estatio.module.asset.dom.Property)6 Test (org.junit.Test)6 Property_calculateInvoices (org.estatio.module.lease.contributions.Property_calculateInvoices)4 Programmatic (org.apache.isis.applib.annotation.Programmatic)3 Unit (org.estatio.module.asset.dom.Unit)3 Invoice (org.estatio.module.invoice.dom.Invoice)3 Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)3 Brand (org.estatio.module.lease.dom.occupancy.tags.Brand)3 Before (org.junit.Before)3 Action (org.apache.isis.applib.annotation.Action)2 InvoiceDto (org.estatio.canonical.invoice.v1.InvoiceDto)2 FixedAsset (org.estatio.module.asset.dom.FixedAsset)2 Charge (org.estatio.module.charge.dom.Charge)2 ChargeGroup (org.estatio.module.charge.dom.ChargeGroup)2 LeaseTerm (org.estatio.module.lease.dom.LeaseTerm)2 Tax (org.estatio.module.tax.dom.Tax)2