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