Search in sources :

Example 6 with InvoiceForLease

use of org.estatio.module.lease.dom.invoicing.InvoiceForLease in project estatio by estatio.

the class InvoiceCalculationForDeposit_IntegTest method in_arrears_and_in_advance_in_one_retro_run_works.

@Test
public void in_arrears_and_in_advance_in_one_retro_run_works() {
    // given
    setUpTheGiven();
    // EST-1750: to mimick behaviour through UI
    sessionManagementService.nextSession();
    // when
    LocalDate invoiceDueDate = VT.ld(2012, 1, 1);
    // NOTE: the user has to realize that the due date for invoices in arrears is the last date of the period
    LocalDate startDueDate = VT.ld(2011, 12, 31);
    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 7 with InvoiceForLease

use of org.estatio.module.lease.dom.invoicing.InvoiceForLease in project estatio by estatio.

the class DocumentTypeAndTemplatesFSForInvoicesUsingSsrs_Test method setUp.

@Before
public void setUp() throws Exception {
    stubDocumentType = DocumentTypeData.PRELIM_LETTER.create();
    stubInvoice = new InvoiceForLease();
    stubInvoice.setDueDate(new LocalDate(2016, 11, 1));
    stubBuyer = new Organisation();
    stubBuyer.setName("Buyer-1");
    stubInvoice.setBuyer(stubBuyer);
    stubInvoice.setLease(mockLease);
    stubProperty = new Property();
    stubProperty.setReference("XXX");
    stubUnit = new Unit();
    stubUnit.setName("XXX-123");
    stubBrand = new Brand();
    stubBrand.setName("Brandino");
    // expect
    context.checking(new Expectations() {

        {
            allowing(mockPaperclipRepository).paperclipAttaches(mockDocument, InvoiceForLease.class);
            will(returnValue(stubInvoice));
            allowing(mockLease).getProperty();
            will(returnValue(stubProperty));
            allowing(mockLease).getReference();
            will(returnValue("XXX-ABC-789"));
            allowing(mockDocument).getType();
            will(returnValue(stubDocumentType));
        }
    });
    // expecting
    context.checking(new Expectations() {

        {
            allowing(mockConfigurationService).getProperty("isis.deploymentType");
            will(returnValue("prototyping"));
        }
    });
    rendererModelFactory = new FreemarkerModelOfPrelimLetterOrInvoiceDocForEmailCover();
    inject(rendererModelFactory, "paperclipRepository", mockPaperclipRepository);
}
Also used : Brand(org.estatio.module.lease.dom.occupancy.tags.Brand) Expectations(org.jmock.Expectations) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) Organisation(org.estatio.module.party.dom.Organisation) Unit(org.estatio.module.asset.dom.Unit) LocalDate(org.joda.time.LocalDate) Property(org.estatio.module.asset.dom.Property) FreemarkerModelOfPrelimLetterOrInvoiceDocForEmailCover(org.estatio.module.lease.spiimpl.document.binders.FreemarkerModelOfPrelimLetterOrInvoiceDocForEmailCover) Before(org.junit.Before)

Example 8 with InvoiceForLease

use of org.estatio.module.lease.dom.invoicing.InvoiceForLease in project estatio by estatio.

the class FreemarkerModelOfPrelimLetterOrInvoiceDocForEmailCover method doNewRendererModel.

@Override
protected Object doNewRendererModel(final DocumentTemplate documentTemplate, final Document prelimLetterOrInvoiceNoteDoc) {
    boolean isPrimaryType = DocumentTypeData.isPrimaryType(prelimLetterOrInvoiceNoteDoc);
    if (!isPrimaryType) {
        final String docTypeRef2 = prelimLetterOrInvoiceNoteDoc.getType().getReference();
        throw new IllegalArgumentException(String.format("Document must be a prelim letter or invoice (provided document's type is '%s')", docTypeRef2));
    }
    final InvoiceForLease invoice = paperclipRepository.paperclipAttaches(prelimLetterOrInvoiceNoteDoc, InvoiceForLease.class);
    final DataModel dataModel = new DataModel();
    dataModel.setInvoice(invoice);
    dataModel.setTenant(invoice.getBuyer());
    dataModel.setProperty(invoice.getLease().getProperty());
    final Optional<Occupancy> occupancyIfAny = invoice.getLease().primaryOccupancy();
    if (occupancyIfAny.isPresent()) {
        final Occupancy occupancy = occupancyIfAny.get();
        final Unit unit = occupancy.getUnit();
        dataModel.setUnit(unit);
        dataModel.setBrand(occupancy.getBrand());
    }
    dataModel.setDocument(prelimLetterOrInvoiceNoteDoc);
    return dataModel;
}
Also used : InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) Unit(org.estatio.module.asset.dom.Unit)

Example 9 with InvoiceForLease

use of org.estatio.module.lease.dom.invoicing.InvoiceForLease 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);
}
Also used : Lease(org.estatio.module.lease.dom.Lease) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) List(java.util.List) CommunicationChannel(org.incode.module.communications.dom.impl.commchannel.CommunicationChannel)

Example 10 with InvoiceForLease

use of org.estatio.module.lease.dom.invoicing.InvoiceForLease in project estatio by estatio.

the class InvoiceCalculationForDeposit_IntegTest method in_arrears_and_in_advance_in_one_normal_run_works.

@Test
public void in_arrears_and_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: the user has to realize that the due date for invoices in arrears is the last date of the period
    LocalDate startDueDate = VT.ld(2011, 12, 31);
    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(2);
    InvoiceItemForLease rentItem011 = (InvoiceItemForLease) invoiceFor011Arrears.findFirstItemWithCharge(chargeForRent);
    assertThat(rentItem011.getNetAmount()).isEqualTo(quarterlyRentAfterIndexation);
    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)

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