Search in sources :

Example 6 with Unit

use of org.estatio.module.asset.dom.Unit 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 7 with Unit

use of org.estatio.module.asset.dom.Unit 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 8 with Unit

use of org.estatio.module.asset.dom.Unit in project estatio by estatio.

the class LandRegisterImport method importData.

@Programmatic
@Override
public List<Object> importData(final Object previousRow) {
    counter++;
    if (counter == 1) {
        System.out.println();
        LOG.info("importing");
    }
    Unit unit = unitRepository.findUnitByReference(unitReference);
    if (unit == null) {
        unit = unitRepository.findUnitByReference(unitReference.replace(" ", "+"));
    }
    if (unit == null) {
        throw new IllegalArgumentException("Unknown unit: ".concat(unitReference));
    }
    LandRegister landRegister = null;
    List<FixedAssetRegistration> farts = fixedAssetRegistrationRepository.findBySubject(unit);
    if (!farts.isEmpty()) {
        landRegister = (LandRegister) farts.get(0);
    }
    if (landRegister == null) {
        landRegister = (LandRegister) fixedAssetRegistrationTypeRepository.findByTitle("LandRegister").create(factoryService);
        container.persistIfNotAlready(landRegister);
    }
    landRegister.setSubject(unit);
    landRegister.setComuneAmministrativo(comuneAmministrativo);
    landRegister.setComuneCatastale(comuneCatastale);
    landRegister.setCodiceComuneCatastale(codiceComuneCatastale);
    landRegister.setRendita(rendita == null ? null : rendita.setScale(2, RoundingMode.HALF_EVEN));
    landRegister.setFoglio(foglio);
    landRegister.setParticella(particella);
    landRegister.setSubalterno(subalterno);
    landRegister.setCategoria(categoria);
    landRegister.setClasse(classe);
    landRegister.setConsistenza(consistenza);
    System.out.print(".");
    return null;
}
Also used : FixedAssetRegistration(org.estatio.module.asset.dom.registration.FixedAssetRegistration) LandRegister(org.estatio.module.registration.dom.LandRegister) Unit(org.estatio.module.asset.dom.Unit) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 9 with Unit

use of org.estatio.module.asset.dom.Unit in project estatio by estatio.

the class PropertyAndUnitsAndOwnerAndManagerBuilder method execute.

@Override
protected void execute(final ExecutionContext executionContext) {
    defaultParam("numberOfUnits", executionContext, fakeDataService.ints().between(10, 20));
    final Property property = new PropertyBuilder().setReference(reference).setName(name).setCity(city).setCountry(country).setPropertyType(propertyType).setAcquireDate(acquireDate).setOpeningDate(openingDate).setLocationStr(locationStr).build(this, executionContext).getObject();
    if (owner != null) {
        ownerRole = new PropertyOwnerBuilder().setProperty(property).setOwner(owner).setStartDate(ownerStartDate).setEndDate(ownerEndDate).build(this, executionContext).getObject();
    }
    if (manager != null) {
        managerrole = new PropertyManagerBuilder().setProperty(property).setManager(manager).setStartDate(managerStartDate).setEndDate(managerEndDate).build(this, executionContext).getObject();
    }
    for (int i = 0; i < getNumberOfUnits(); i++) {
        int unitNumber = i + 1;
        final Unit unit = wrap(property).newUnit(String.format("%s-%03d", property.getReference(), unitNumber), "Unit " + unitNumber, unitType(i));
        unit.setArea(new BigDecimal((i + 1) * 100));
        units.add(unit);
    }
    object = property;
}
Also used : Unit(org.estatio.module.asset.dom.Unit) Property(org.estatio.module.asset.dom.Property) BigDecimal(java.math.BigDecimal)

Example 10 with Unit

use of org.estatio.module.asset.dom.Unit in project estatio by estatio.

the class Occupancy_Test method validateNewOccupancy_Fails_Test.

@Test
public void validateNewOccupancy_Fails_Test() {
    // given
    Lease lease = new Lease();
    LocalDate occStartDate = new LocalDate();
    // when
    Unit unit = new Unit() {

        @Override
        public boolean isActiveOn(final LocalDate date) {
            return false;
        }
    };
    // then
    assertThat(lease.validateNewOccupancy(occStartDate, unit)).isEqualTo("At the start date of the occupancy this unit is not available.");
}
Also used : Lease(org.estatio.module.lease.dom.Lease) Unit(org.estatio.module.asset.dom.Unit) LocalDate(org.joda.time.LocalDate) AbstractBeanPropertiesTest(org.incode.module.unittestsupport.dom.bean.AbstractBeanPropertiesTest) Test(org.junit.Test)

Aggregations

Unit (org.estatio.module.asset.dom.Unit)27 Test (org.junit.Test)10 BigDecimal (java.math.BigDecimal)8 Lease (org.estatio.module.lease.dom.Lease)8 Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)8 LocalDate (org.joda.time.LocalDate)8 Programmatic (org.apache.isis.applib.annotation.Programmatic)6 Property (org.estatio.module.asset.dom.Property)5 ArrayList (java.util.ArrayList)3 KeyTable (org.estatio.module.budget.dom.keytable.KeyTable)3 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)3 Expectations (org.jmock.Expectations)3 Before (org.junit.Before)3 Action (org.apache.isis.applib.annotation.Action)2 InvoiceItemForLease (org.estatio.module.lease.dom.invoicing.InvoiceItemForLease)2 Brand (org.estatio.module.lease.dom.occupancy.tags.Brand)2 Party (org.estatio.module.party.dom.Party)2 LandRegister (org.estatio.module.registration.dom.LandRegister)2 AbstractBeanPropertiesTest (org.incode.module.unittestsupport.dom.bean.AbstractBeanPropertiesTest)2 List (java.util.List)1