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