Search in sources :

Example 1 with LocalDateInterval

use of org.incode.module.base.dom.valuetypes.LocalDateInterval in project estatio by estatio.

the class PeriodUtil method yearFromPeriod.

@Nullable
public static LocalDateInterval yearFromPeriod(final String period) {
    if (period == null) {
        // Interval with open start and end date
        return new LocalDateInterval();
    }
    LocalDate startDate = null;
    LocalDate endDate = null;
    if (financialYearPattern.matcher(period).matches()) {
        Integer year = Integer.valueOf(period.substring(1, 5));
        startDate = new LocalDate(year - 1, 07, 01);
        endDate = new LocalDate(year, 06, 30);
    }
    if (yearPattern.matcher(period).matches()) {
        Integer year = Integer.valueOf(period.substring(0, 4));
        startDate = new LocalDate(year, 01, 01);
        endDate = new LocalDate(year, 12, 31);
    }
    return new LocalDateInterval(startDate, endDate);
}
Also used : LocalDate(org.joda.time.LocalDate) LocalDateInterval(org.incode.module.base.dom.valuetypes.LocalDateInterval) Nullable(javax.annotation.Nullable)

Example 2 with LocalDateInterval

use of org.incode.module.base.dom.valuetypes.LocalDateInterval 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 3 with LocalDateInterval

use of org.incode.module.base.dom.valuetypes.LocalDateInterval in project estatio by estatio.

the class FixedAsset method validateNewRole.

public String validateNewRole(final FixedAssetRoleTypeEnum type, final Party party, final LocalDate startDate, final LocalDate endDate) {
    List<FixedAssetRole> currentRoles = fixedAssetRoleRepository.findAllForPropertyAndPartyAndType(this, party, type);
    for (FixedAssetRole fixedAssetRole : currentRoles) {
        LocalDateInterval existingInterval = new LocalDateInterval(fixedAssetRole.getStartDate(), fixedAssetRole.getEndDate());
        LocalDateInterval newInterval = new LocalDateInterval(startDate, endDate);
        if (existingInterval.overlaps(newInterval)) {
            return "The provided dates overlap with a current role of this type and party";
        }
    }
    if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
        return "End date cannot be earlier than start date";
    }
    if (!Sets.filter(getRoles(), type.matchingRole()).isEmpty()) {
        return "Add a successor/predecessor from existing role";
    }
    return null;
}
Also used : FixedAssetRole(org.estatio.module.asset.dom.role.FixedAssetRole) LocalDateInterval(org.incode.module.base.dom.valuetypes.LocalDateInterval)

Example 4 with LocalDateInterval

use of org.incode.module.base.dom.valuetypes.LocalDateInterval in project estatio by estatio.

the class Partitioning method getFractionOfYear.

@Programmatic
public BigDecimal getFractionOfYear() {
    BigDecimal numberOfDaysInInterval = BigDecimal.valueOf(getInterval().days());
    BigDecimal numberOfDaysInYear = BigDecimal.valueOf(new LocalDateInterval(new LocalDate(getStartDate().getYear(), 01, 01), new LocalDate(getStartDate().getYear() + 1, 01, 01), AbstractInterval.IntervalEnding.EXCLUDING_END_DATE).days());
    return numberOfDaysInInterval.divide(numberOfDaysInYear, MathContext.DECIMAL64);
}
Also used : LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) LocalDateInterval(org.incode.module.base.dom.valuetypes.LocalDateInterval) Programmatic(org.apache.isis.applib.annotation.Programmatic)

Example 5 with LocalDateInterval

use of org.incode.module.base.dom.valuetypes.LocalDateInterval in project estatio by estatio.

the class InvoiceCalculationParameters method toString.

public String toString() {
    TitleBuffer tb = new TitleBuffer();
    tb.append(" -", property().getReference()).append(" -", leasesToReferences()).append(" -", leaseItemTypes()).append(" -", invoiceDueDate()).append(" -", new LocalDateInterval(startDueDate, nextDueDate, IntervalEnding.EXCLUDING_END_DATE)).toString();
    return tb.toString();
}
Also used : TitleBuffer(org.apache.isis.applib.util.TitleBuffer) LocalDateInterval(org.incode.module.base.dom.valuetypes.LocalDateInterval)

Aggregations

LocalDateInterval (org.incode.module.base.dom.valuetypes.LocalDateInterval)17 LocalDate (org.joda.time.LocalDate)8 BigDecimal (java.math.BigDecimal)4 Action (org.apache.isis.applib.annotation.Action)4 Programmatic (org.apache.isis.applib.annotation.Programmatic)3 ArrayList (java.util.ArrayList)2 MemberOrder (org.apache.isis.applib.annotation.MemberOrder)2 Charge (org.estatio.module.charge.dom.Charge)2 InvoicingInterval (org.estatio.module.invoice.dom.InvoicingInterval)2 LeaseItem (org.estatio.module.lease.dom.LeaseItem)2 Test (org.junit.Test)2 Nullable (javax.annotation.Nullable)1 TitleBuffer (org.apache.isis.applib.util.TitleBuffer)1 FixedAssetRole (org.estatio.module.asset.dom.role.FixedAssetRole)1 BudgetCalculationResult (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationResult)1 BudgetCalculationRun (org.estatio.module.budgetassignment.dom.calculationresult.BudgetCalculationRun)1 CodaElement (org.estatio.module.capex.dom.coda.CodaElement)1 CodaElementLevel (org.estatio.module.capex.dom.coda.CodaElementLevel)1 CodaTransactionType (org.estatio.module.capex.dom.coda.CodaTransactionType)1 DocumentType (org.estatio.module.capex.dom.coda.DocumentType)1