@@ -0,0 +1,1307 @@
+package org.openlmis.report.builder.helpers;%0A%0Aimport org.apache.commons.lang.StringUtils;%0A%0Aimport static org.apache.ibatis.jdbc.SqlBuilder.WHERE;%0A%0Apublic class RequisitionPredicateHelper %7B%0A%0A  public static void whereMultiProductFilter(String products)%7B%0A    if(products.equals(%22-1%22))%7B%0A      WHERE(%22p.tracer = true%22);%0A    %7D else if(!products.equals(%220%22) && !products.isEmpty())%7B%0A      WHERE(%22 p.id = ANY(array%5B%22 + products + %22 %5D::INT%5B%5D)%22);%0A    %7D%0A  %7D%0A%0A  public static void whereProductCategory(Long productCategory)%7B%0A    if(productCategory %3E 0)%7B%0A      WHERE( %22ppc.productCategoryId = #%7BfilterCriteria.productCategory%7D%22);%0A    %7D%0A  %7D%0A%0A  public static void whereFacilityPermission()%7B%0A    WHERE(%22f.id in (select facility_id from vw_user_facilities where user_id = #%7BuserId%7D and program_id = #%7BfilterCriteria.program%7D) %22 );%0A  %7D%0A%0A  public static void whereGeographicZoneFilter(Long geographicZone)%7B%0A    if(geographicZone != 0)%7B%0A      WHERE( %22(d.zone_id = #%7BfilterCriteria.zone%7D or d.parent = #%7BfilterCriteria.zone%7D or d.region_id = #%7BfilterCriteria.zone%7D or d.district_id = #%7BfilterCriteria.zone%7D) %22) ;%0A    %7D%0A  %7D%0A%0A  public static void whereProgramFilter()%7B%0A    WHERE(%22r.programId = #%7BfilterCriteria.program%7D%22);%0A  %7D%0A%0A  public static void wherePeriodFilter()%7B%0A    WHERE(%22r.periodId = #%7BfilterCriteria.period%7D%22);%0A  %7D%0A%0A%7D%0A

Introduce Requisition Predicate Helper - Helper applies most common requisition related where conditions. Note: this is only usable based on predefined alias for r for requisitions, p for programs, pr for products tables. A later version should remove the aliases for less confusion.