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);
}
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;
}
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;
}
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;
}
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.");
}
Aggregations