use of org.estatio.module.lease.dom.occupancy.tags.Brand in project estatio by estatio.
the class BrandBuilder method execute.
@Override
protected void execute(final ExecutionContext executionContext) {
checkParam("name", executionContext, String.class);
defaultParam("brandCoverage", executionContext, BrandCoverage.INTERNATIONAL);
defaultParam("atPath", executionContext, "/");
final Brand brand = brandRepository.newBrand(name, brandCoverage, countryOfOrigin, group, applicationTenancy);
executionContext.addResult(this, brand);
object = brand;
}
use of org.estatio.module.lease.dom.occupancy.tags.Brand 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.lease.dom.occupancy.tags.Brand in project estatio by estatio.
the class InvoiceItemForLeaseDtoFactory method newDto.
@Programmatic
public InvoiceItemDto newDto(final InvoiceItem item) {
InvoiceItemDto dto = new InvoiceItemDto();
if (item instanceof InvoiceItemForLease) {
InvoiceItemForLease invoiceItemForLease = (InvoiceItemForLease) item;
final Lease lease = invoiceItemForLease.getLease();
if (lease != null) {
dto.setAgreementReference(lease.getReference());
}
final FixedAsset fixedAsset = invoiceItemForLease.getFixedAsset();
if (fixedAsset != null) {
dto.setFixedAssetReference(fixedAsset.getReference());
dto.setFixedAssetExternalReference(fixedAsset.getExternalReference());
}
}
final Charge charge = item.getCharge();
dto.setChargeReference(charge.getReference());
dto.setChargeDescription(charge.getDescription());
dto.setChargeExternalReference(charge.getExternalReference());
dto.setChargeName(charge.getName());
final ChargeGroup group = charge.getGroup();
dto.setChargeGroupReference(group.getReference());
dto.setChargeGroupName(group.getName());
final Tax tax = item.getTax();
final TaxRate rate = item.getTaxRate();
dto.setTaxReference(tax.getReference());
dto.setTaxName(tax.getName());
dto.setTaxDescription(tax.getDescription());
dto.setTaxExternalReference(rate == null || rate.getExternalReference() == null ? tax.getExternalReference() : rate.getExternalReference());
dto.setNetAmount(item.getNetAmount());
dto.setGrossAmount(item.getGrossAmount());
dto.setVatAmount(item.getVatAmount());
dto.setDescription(item.getDescription());
dto.setStartDate(asXMLGregorianCalendar(item.getStartDate()));
dto.setEndDate(asXMLGregorianCalendar(item.getEndDate()));
dto.setEffectiveStartDate(asXMLGregorianCalendar(firstNonNull(item.getEffectiveStartDate(), item.getStartDate())));
dto.setEffectiveEndDate(asXMLGregorianCalendar(firstNonNull(item.getEffectiveEndDate(), item.getEndDate())));
if (item instanceof InvoiceItemForLease) {
final InvoiceItemForLease invoiceItemForLease = (InvoiceItemForLease) item;
final InvoiceForLease invoice = (InvoiceForLease) invoiceItemForLease.getInvoice();
final Lease leaseIfAny = invoice.getLease();
if (leaseIfAny != null) {
final SortedSet<Occupancy> occupancies = leaseIfAny.getOccupancies();
if (!occupancies.isEmpty()) {
// final Optional<Occupancy> occupancyIfAny =
// occupancies.stream().filter(x -> x.getInterval().overlaps(item.getEffectiveInterval())).findFirst();
final Optional<Occupancy> occupancyIfAny = Optional.ofNullable(occupancies.first());
if (occupancyIfAny.isPresent()) {
final Occupancy occupancy = occupancyIfAny.orElse(occupancies.last());
final Brand brand = occupancy.getBrand();
dto.setOccupancyBrand(brand == null ? null : brand.getName());
if (dto.getFixedAssetReference() == null) {
// the unit was not retrieved through the invoice item, so get it from the occupancy then.
dto.setFixedAssetReference(occupancy.getUnit().getReference());
dto.setFixedAssetExternalReference(occupancy.getUnit().getExternalReference());
}
} else {
// throw new IllegalArgumentException("Invoice has an effective date range outside the scope of the occupanies");
throw new IllegalArgumentException("No Occupancy Found");
}
}
}
}
return dto;
}
use of org.estatio.module.lease.dom.occupancy.tags.Brand in project estatio by estatio.
the class OccupancyRepository method on.
// //////////////////////////////////////
// TODO: REVIEW, should this be removed since it is intra-module? However, we might split occupancy away from lease, in which case this will be needed after all.
@Programmatic
@com.google.common.eventbus.Subscribe
@org.axonframework.eventhandling.annotation.EventHandler
public void on(final Brand.RemoveEvent ev) {
Brand sourceBrand = (Brand) ev.getSource();
Brand replacementBrand = ev.getReplacement();
List<Occupancy> occupancies;
switch(ev.getEventPhase()) {
case VALIDATE:
occupancies = findByBrand(sourceBrand, true);
if (replacementBrand == null && occupancies.size() > 0) {
ev.invalidate("Brand is being used in an occupancy. Remove occupancy or provide a replacement");
} else {
scratchpad.put(onBrandRemoveScratchpadKey = UUID.randomUUID(), occupancies);
}
break;
case EXECUTING:
occupancies = (List<Occupancy>) scratchpad.get(onBrandRemoveScratchpadKey);
for (Occupancy occupancy : occupancies) {
occupancy.setBrand(replacementBrand);
}
break;
default:
break;
}
}
use of org.estatio.module.lease.dom.occupancy.tags.Brand in project estatio by estatio.
the class InvoiceAttributesVM method getCurrentOccupancyBrandName.
@Programmatic
public String getCurrentOccupancyBrandName() {
final Occupancy currentOccupancy = invoice.getCurrentOccupancy();
if (currentOccupancy == null) {
return null;
}
final Brand brand = currentOccupancy.getBrand();
if (brand == null) {
return null;
}
return brand.getName();
}
Aggregations