New PredefinedDateIntervals : this year and last year

Hi

CUBA proposes some useful predefined date intervals (e.g last month, this month) but not last year and this year, while the JPQL macro is already there.

It’s not difficult to create such bean (example below) and by extending PredefinedDateIntervalFactory but these intervals could be there in standard. In our case we have several years of data on line for statistics so for daily operations the filter “current year” is standard by default.

@Component("testcuba_LastYearPredefinedDateInterval")
@Order(60)
public class LastYearPredefinedDateInterval extends PredefinedDateInterval {

    public LastYearPredefinedDateInterval() {
        super("lastYear");
    }

    @Override
    public String getJPQL(String propertyName) {
        return String.format("@between({E}.%s, now-1, now, year)", propertyName);
    }
}

Regards,
Michael

Hi,
thanks for the idea. You’re right, it will be easy to add it. The issue: https://github.com/cuba-platform/cuba/issues/1047

You could as well add “this week”, “last week”. A bit less easy because it means @between macro needs to be modified to handle weeks. But very useful for sales & back-office people following activity.