Skip to content
Snippets Groups Projects
Commit 58dc831c authored by Sebastian Pongratz's avatar Sebastian Pongratz :ping_pong:
Browse files

Merge branch 'sales_1080138_FixVolumeAggregationFilterExtention' into '2021.1'

[Projekt: xRM-Sales][TicketNr.: 1080138][Salesproject_entity:...

See merge request xrm/basic!1079
parents 3f83f6eb 161855af
No related branches found
No related tags found
No related merge requests found
import("Salesproject_lib");
import("system.result");
import("Sql_lib");
import("system.vars");
result.string(newWhereIfSet( "SALESPROJECT.PHASE", vars.get("$local.rawvalue")));
\ No newline at end of file
result.string(SalesprojectPhaseFilterUtils.makeFilterCondition());
\ No newline at end of file
import("system.logging");
import("Sql_lib");
import("Salesproject_lib");
import("system.result");
import("system.vars");
import("KeywordRegistry_basic");
import("Keyword_lib");
var order = vars.get("$local.order");
var sqlHelper = new SqlMaskingUtils();
var groupedList = "SALESPROJECT.PHASE"
var condition = vars.get("$local.condition");
var stmt = new SqlBuilder().from("SALESPROJECT").join("AB_KEYWORD_ENTRY", newWhere("AB_KEYWORD_ENTRY.KEYID = SALESPROJECT.PHASE").and("AB_KEYWORD_ENTRY.AB_KEYWORD_CATEGORY_ID", KeywordUtils.getCategoryIdByName($KeywordRegistry.salesprojectPhase()))).groupBy(groupedList + ", AB_KEYWORD_ENTRY.SORTING, AB_KEYWORD_ENTRY.KEYID");
if (condition != " ")
stmt.where(condition);
if (vars.get("$local.count")) // TRUE if the count of the records is needed
{
stmt.select(["1 COUNT", groupedList]) //from ACTIVITY where " + condition + " group by "+groupedList+") X";
stmt = newSelect("STMT.COUNT")
.from(stmt, "STMT")
}
else
{
stmt.select([groupedList , KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.salesprojectPhase(),"AB_KEYWORD_ENTRY.KEYID"), "count(*)", "count(*)"])
if (order != null)
stmt.orderBy("AB_KEYWORD_ENTRY.SORTING, " + order);
}
result.string(stmt.toString());
\ No newline at end of file
result.string(SalesprojectPhaseFilterUtils.makeGroupQueryProcess());
\ No newline at end of file
......@@ -410,3 +410,58 @@ SalesprojectConversionRate.prototype._getTitleOfKey = function (pKey, pIsGroupin
return pKey;
}
/**
* Methods used by the Salesproject.
* Do not create an instance of this!
*
* @class
*/
function SalesprojectPhaseFilterUtils() {}
/**
* Builds a Sql-condition for a salesproject filter extension. This allows to filter via the salesproject phase whilst havin them in the correct Order
*
* @return {String} condition
*/
SalesprojectPhaseFilterUtils.makeFilterCondition = function()
{
return newWhereIfSet( "SALESPROJECT.PHASE", vars.get("$local.rawvalue"));
}
/**
* Builds a Sql-condition for a salesproject filter extension. This allows to filter via the salesproject phase whilst havin them in the correct Order
*
* @return {String} condition
*/
SalesprojectPhaseFilterUtils.makeGroupQueryProcess = function()
{
var order = vars.get("$local.order");
var sqlHelper = new SqlMaskingUtils();
var groupedList = "SALESPROJECT.PHASE"
var condition = vars.get("$local.condition");
var stmt = new SqlBuilder().from("SALESPROJECT").join("AB_KEYWORD_ENTRY", newWhere("AB_KEYWORD_ENTRY.KEYID = SALESPROJECT.PHASE").and("AB_KEYWORD_ENTRY.AB_KEYWORD_CATEGORY_ID", KeywordUtils.getCategoryIdByName($KeywordRegistry.salesprojectPhase()))).groupBy(groupedList + ", AB_KEYWORD_ENTRY.SORTING, AB_KEYWORD_ENTRY.KEYID");
if (!Utils.isNullOrEmptyString(condition.trim()))
{
stmt.where(condition);
}
if (vars.get("$local.count")) // TRUE if the count of the records is needed
{
stmt.select(["1 COUNT", groupedList]) //from ACTIVITY where " + condition + " group by "+groupedList+") X";
stmt = newSelect("STMT.COUNT")
.from(stmt, "STMT")
}
else
{
stmt.select([groupedList , KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.salesprojectPhase(),"AB_KEYWORD_ENTRY.KEYID"), "count(*)", "count(*)"])
if (order != null)
{
stmt.orderBy("AB_KEYWORD_ENTRY.SORTING, " + order);
}
}
return stmt.toString();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment