/**
* Checks if a billing term scheme is used by a billing term.
*
* @param billingTermScheme - the billing term scheme to check
* @return true if a billing term scheme is used by a billing term, false if not
* @throws Exception
*/
public Boolean isUsedByBillingTerms(CRMDOBillingTermScheme billingTermScheme) throws Exception {
ArrayList<Object> parameters = new ArrayList<Object>();
String sql =
"\n SELECT 'x' FROM BILLINGTERMS " +
"\n WHERE BTDELETED = 0 " +
"\n AND " + DateUtil.getSelectSQLDate(getCRMSession().getDbtype(), "BTEFFECTIVEDATE") + "<=" + DateUtil.getCurrentSQLDate(getCRMSession().getDbtype(),getCRMSession().getTimezone()) +
"\n AND ((" + DateUtil.getSelectSQLDate(getCRMSession().getDbtype(), "BTEXPIRATIONDATE") + ">" + DateUtil.getCurrentSQLDate(getCRMSession().getDbtype(),getCRMSession().getTimezone()) +
"\n OR BTEXPIRATIONDATE IS NULL)) " +
"\n AND BTSCHEMECODE = ?";
parameters.add(billingTermScheme.getCode());
if (SQLUtil.queryReturnedRows(sql, getOrganisationID(), parameters, getCRMSession().getDbtype()))
{
return new Boolean(true);
}
else
{
return new Boolean(false);
}
} |