Search in sources :

Example 1 with Charge

use of org.estatio.module.charge.dom.Charge in project estatio by estatio.

the class CodaMappingImport method handleRow.

@Override
public void handleRow(final CodaMappingImport previousRow) {
    atPath = atPath == null && previousRow != null ? previousRow.atPath : atPath;
    if (codaElementName == null) {
        String.format("");
    }
    if ((documentType != null || incomingInvoiceType != null) && chargeName != null) {
        IncomingInvoiceType incomingInvoiceTypeEnum = IncomingInvoiceType.valueOf(incomingInvoiceType);
        DocumentType documentTypeEnum = incomingInvoiceTypeEnum == null ? DocumentType.valueOf(documentType) : DocumentType.INVOICE_IN;
        CodaElementLevel codaElementLevelEnum = CodaElementLevel.valueOf(codaElementLevel);
        CodaElement codaElement = codaElementRepository.findOrCreate(codaElementLevelEnum, codaElementCode, codaElementName);
        Charge charge = chargeRepository.findOrCreate(atPath, chargeReference != null ? chargeReference : chargeNameToReference(chargeName), chargeName, "", Applicability.INCOMING);
        final LocalDateInterval interval = period == null ? new LocalDateInterval() : PeriodUtil.yearFromPeriod(period);
        final CodaTransactionType codaTransactionType = valueOfElseDefault(transactionType, CodaTransactionType.STAT);
        codaMappingRepository.findOrCreate(atPath, documentTypeEnum, incomingInvoiceTypeEnum, codaTransactionType, charge, propertyFullyOwned(propertyOwnershipType), interval.startDate(), interval.endDate(), startDate, endDate, codaElement);
    }
}
Also used : IncomingInvoiceType(org.estatio.module.capex.dom.invoice.IncomingInvoiceType) CodaElementLevel(org.estatio.module.capex.dom.coda.CodaElementLevel) CodaElement(org.estatio.module.capex.dom.coda.CodaElement) Charge(org.estatio.module.charge.dom.Charge) DocumentType(org.estatio.module.capex.dom.coda.DocumentType) CodaTransactionType(org.estatio.module.capex.dom.coda.CodaTransactionType) LocalDateInterval(org.incode.module.base.dom.valuetypes.LocalDateInterval)

Example 2 with Charge

use of org.estatio.module.charge.dom.Charge in project estatio by estatio.

the class CapexChargeHierarchyXlsxFixture method execute.

@Override
protected void execute(final ExecutionContext executionContext) {
    Charge before = chargeRepository.findByReference("WORKS");
    List<Charge> beforeAll = chargeRepository.listAll();
    setExcelResource(Resources.getResource(getClass(), "CapexChargeHierarchy.xlsx"));
    setMatcher(sheetName -> {
        if (sheetName.startsWith("ChargeHierarchy")) {
            return new WorksheetSpec(rowFactoryFor(IncomingChargeHandler.class, executionContext), sheetName, Mode.STRICT);
        } else {
            return null;
        }
    });
    super.execute(executionContext);
    Charge after = chargeRepository.findByReference("WORKS");
    List<Charge> afterAll = chargeRepository.listAll();
}
Also used : WorksheetSpec(org.isisaddons.module.excel.dom.WorksheetSpec) Charge(org.estatio.module.charge.dom.Charge)

Example 3 with Charge

use of org.estatio.module.charge.dom.Charge in project estatio by estatio.

the class InvoiceAttributesVM method getChargeDescriptions.

@Programmatic
public String getChargeDescriptions() {
    final StringBuilder buf = new StringBuilder();
    SortedSet<InvoiceItem> invoiceItems = invoice.getItems();
    Set<String> descriptions = FluentIterable.from(invoiceItems).transform(x -> {
        Charge charge = x.getCharge();
        return charge != null ? charge.getDescription() : null;
    }).filter(Objects::nonNull).toSortedSet(Ordering.natural());
    final List<String> items = Lists.newArrayList(descriptions);
    final int numItems = items.size();
    for (int i = 0; i < numItems; i++) {
        buf.append(items.get(i));
        if (i == numItems - 2) {
            buf.append(" e ");
        } else if (i != numItems - 1) {
            buf.append(", ");
        }
    }
    return buf.toString();
}
Also used : InvoiceItem(org.estatio.module.invoice.dom.InvoiceItem) Charge(org.estatio.module.charge.dom.Charge) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 4 with Charge

use of org.estatio.module.charge.dom.Charge in project estatio by estatio.

the class LeaseTermImportAbstract method initLeaseItem.

protected LeaseItem initLeaseItem() {
    // find or create leaseItem
    final Lease lease = fetchLease(getLeaseReference());
    final ApplicationTenancy leaseItemApplicationTenancy = ObjectUtils.firstNonNull(securityApplicationTenancyRepository.findByPath(getLeaseItemAtPath()), lease.getApplicationTenancy());
    final Charge charge = fetchCharge(getItemChargeReference());
    final LeaseItemType itemType = fetchLeaseItemType(getItemTypeName());
    LeaseItem item = lease.findItem(itemType, getItemStartDate(), getItemSequence());
    if (item == null) {
        item = lease.newItem(itemType, LeaseAgreementRoleTypeEnum.LANDLORD, charge, InvoicingFrequency.valueOf(getItemInvoicingFrequency()), PaymentMethod.valueOf(getItemPaymentMethod()), getItemStartDate());
        item.setSequence(getItemSequence());
    }
    item.setEpochDate(getItemEpochDate());
    item.setNextDueDate(getItemNextDueDate());
    final LeaseItemStatus leaseItemStatus = LeaseItemStatus.valueOfElse(getItemStatus(), LeaseItemStatus.ACTIVE);
    item.setStatus(leaseItemStatus);
    // Find source item and create source link
    if (getSourceItemTypeName() != null) {
        final LeaseItemType sourceItemType = LeaseItemType.valueOf(sourceItemTypeName);
        LeaseItem sourceItem = item.getLease().findItem(sourceItemType, sourceItemStartDate, sourceItemSequence);
        if (sourceItem != null) {
            item.findOrCreateSourceItem(sourceItem);
        }
    }
    return item;
}
Also used : Lease(org.estatio.module.lease.dom.Lease) Charge(org.estatio.module.charge.dom.Charge) LeaseItemStatus(org.estatio.module.lease.dom.LeaseItemStatus) LeaseItemType(org.estatio.module.lease.dom.LeaseItemType) ApplicationTenancy(org.isisaddons.module.security.dom.tenancy.ApplicationTenancy) LeaseItem(org.estatio.module.lease.dom.LeaseItem)

Example 5 with Charge

use of org.estatio.module.charge.dom.Charge in project estatio by estatio.

the class LeaseItemImport method importItem.

@Programmatic
public LeaseItem importItem(boolean updateExisting) {
    final Lease lease = fetchLease(leaseReference);
    final Charge charge = fetchCharge(chargeReference);
    final LeaseItemType itemType = fetchLeaseItemType(itemTypeName);
    // for deposit items the start date defaults to the start date of the lease
    LocalDate startDateOrDefault;
    if (itemType == LeaseItemType.DEPOSIT) {
        startDateOrDefault = ObjectUtils.firstNonNull(startDate, lease.getStartDate());
    } else {
        startDateOrDefault = startDate;
    }
    LeaseItem item = lease.findItem(itemType, startDateOrDefault, sequence);
    if (item == null) {
        item = lease.newItem(itemType, LeaseAgreementRoleTypeEnum.LANDLORD, charge, InvoicingFrequency.valueOf(invoicingFrequency), PaymentMethod.valueOf(paymentMethod), startDateOrDefault);
        item.setSequence(sequence);
    }
    if (updateExisting) {
        item.setApplicationTenancyPath(atPath);
        item.setEpochDate(epochDate);
        item.setNextDueDate(nextDueDate);
        item.setStatus(LeaseItemStatus.valueOfElse(status, LeaseItemStatus.ACTIVE));
    }
    return item;
}
Also used : Lease(org.estatio.module.lease.dom.Lease) Charge(org.estatio.module.charge.dom.Charge) LeaseItemType(org.estatio.module.lease.dom.LeaseItemType) LocalDate(org.joda.time.LocalDate) LeaseItem(org.estatio.module.lease.dom.LeaseItem) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Aggregations

Charge (org.estatio.module.charge.dom.Charge)41 Test (org.junit.Test)18 BigDecimal (java.math.BigDecimal)14 LocalDate (org.joda.time.LocalDate)14 Lease (org.estatio.module.lease.dom.Lease)11 Programmatic (org.apache.isis.applib.annotation.Programmatic)10 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)9 Project (org.estatio.module.capex.dom.project.Project)9 Tax (org.estatio.module.tax.dom.Tax)9 Property (org.estatio.module.asset.dom.Property)7 LeaseItem (org.estatio.module.lease.dom.LeaseItem)6 ApplicationException (org.apache.isis.applib.ApplicationException)4 BudgetCalculationResult (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult)4 ChargeGroup (org.estatio.module.charge.dom.ChargeGroup)4 Action (org.apache.isis.applib.annotation.Action)3 LeaseItemType (org.estatio.module.lease.dom.LeaseItemType)3 Organisation (org.estatio.module.party.dom.Organisation)3 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)3 Expectations (org.jmock.Expectations)3 ArrayList (java.util.ArrayList)2