Skip to content
Snippets Groups Projects
Commit 0b0e482e authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

TurnoverUtil.getForecastData fix

parent 44165770
No related branches found
No related tags found
No related merge requests found
......@@ -78,22 +78,33 @@ TurnoverUtil.getTurnoverData = function (pMaxYear, pYearCount, pSalesprojectId)
*/
TurnoverUtil.getForecastData = function (pMaxYear, pYearCount, pSalesprojectId)
{
var forecastCategory = translate.text('Forecast');
var forecastCategory = translate.text("Forecast");
var minYear = pMaxYear - pYearCount + 1;
var sqlMask = new SqlMaskingUtils();
// load data
var forecastSelect = newSelect("'" + forecastCategory + "', year(DATE_START) yearNum, month(DATE_START) monthNum, 0 discount, 0 vat, sum(VOLUME) price, 1 quantity, GROUPCODE prodGroup, (" + KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.productGroupcode(), "GROUPCODE") + ") prodGroupName")
.from("FORECAST")
.where("FORECAST.DATE_START", pMaxYear, "year(#) <= ?", SQLTYPES.INTEGER)
.and("FORECAST.DATE_START", minYear, "year(#) >= ?", SQLTYPES.INTEGER)
var forecastSelect = newSelect([
"'" + forecastCategory + "'",
sqlMask.yearFromDate("DATE_START") + " yearNum",
sqlMask.monthFromDate("DATE_START") + " monthNum",
"0 discount",
"0 vat",
"sum(VOLUME) price",
"1 quantity",
"GROUPCODE prodGroup",
"(" + KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.productGroupcode(), "GROUPCODE") + ") prodGroupName"
])
.from("FORECAST")
.where("FORECAST.DATE_START", pMaxYear, sqlMask.yearFromDate("#") + " <= ?", SQLTYPES.INTEGER)
.and("FORECAST.DATE_START", minYear, sqlMask.yearFromDate("#") + " >= ?", SQLTYPES.INTEGER);
if (pSalesprojectId)
{
forecastSelect.and("FORECAST.OBJECT_TYPE", 'Salesproject')
forecastSelect.and("FORECAST.OBJECT_TYPE", "Salesproject")
.and("FORECAST.OBJECT_ROWID", pSalesprojectId)
}
forecastSelect.groupBy("year(DATE_START), month(DATE_START), GROUPCODE")
forecastSelect.groupBy([sqlMask.yearFromDate("DATE_START"), sqlMask.monthFromDate("DATE_START"), "GROUPCODE"])
.orderBy("yearNum, monthNum");
return forecastSelect.table();
......
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