Search in sources :

Example 1 with Brand

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;
}
Also used : Brand(org.estatio.module.lease.dom.occupancy.tags.Brand)

Example 2 with 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);
}
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 3 with Brand

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;
}
Also used : InvoiceItemDto(org.estatio.canonical.invoice.v1.InvoiceItemDto) Lease(org.estatio.module.lease.dom.Lease) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) Charge(org.estatio.module.charge.dom.Charge) InvoiceItemForLease(org.estatio.module.lease.dom.invoicing.InvoiceItemForLease) Tax(org.estatio.module.tax.dom.Tax) FixedAsset(org.estatio.module.asset.dom.FixedAsset) Brand(org.estatio.module.lease.dom.occupancy.tags.Brand) InvoiceForLease(org.estatio.module.lease.dom.invoicing.InvoiceForLease) ChargeGroup(org.estatio.module.charge.dom.ChargeGroup) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) TaxRate(org.estatio.module.tax.dom.TaxRate) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 4 with Brand

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;
    }
}
Also used : Brand(org.estatio.module.lease.dom.occupancy.tags.Brand) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 5 with Brand

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();
}
Also used : Brand(org.estatio.module.lease.dom.occupancy.tags.Brand) Occupancy(org.estatio.module.lease.dom.occupancy.Occupancy) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

Brand (org.estatio.module.lease.dom.occupancy.tags.Brand)6 Programmatic (org.apache.isis.applib.annotation.Programmatic)3 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)3 Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)3 Unit (org.estatio.module.asset.dom.Unit)2 Charge (org.estatio.module.charge.dom.Charge)2 ChargeGroup (org.estatio.module.charge.dom.ChargeGroup)2 Lease (org.estatio.module.lease.dom.Lease)2 InvoiceItemForLease (org.estatio.module.lease.dom.invoicing.InvoiceItemForLease)2 Tax (org.estatio.module.tax.dom.Tax)2 LocalDate (org.joda.time.LocalDate)2 Before (org.junit.Before)2 InvoiceItemDto (org.estatio.canonical.invoice.v1.InvoiceItemDto)1 FixedAsset (org.estatio.module.asset.dom.FixedAsset)1 Property (org.estatio.module.asset.dom.Property)1 FreemarkerModelOfPrelimLetterOrInvoiceDocForEmailCover (org.estatio.module.lease.spiimpl.document.binders.FreemarkerModelOfPrelimLetterOrInvoiceDocForEmailCover)1 Organisation (org.estatio.module.party.dom.Organisation)1 TaxRate (org.estatio.module.tax.dom.TaxRate)1 Expectations (org.jmock.Expectations)1