The netsuite query module is broken. Run the following query in your account code and you'll get listed values instead of grouped ones. In the occurances variable you'll see how many there are for each entity. There should never be more than 1
let myQuery = query.create({
type: 'transaction'
});
let transactionlinesJoin = myQuery.autoJoin({ fieldId:'transactionlines'});
let accountingimpactJoin = transactionlinesJoin.autoJoin({ fieldId:'accountingimpact'});
myQuery.columns = [
accountingimpactJoin.createColumn({fieldId: "amount", alias: "amount", aggregate:query.Aggregate.SUM, context: query.FieldContext.CURRENCY_CONSOLIDATED}),
myQuery.createColumn({fieldId: "entity", alias: "entity", groupBy:true, context: query.FieldContext.DISPLAY})];
let resultSet = myQuery.runPaged({pageSize:1000});
let occurrances = {};
for (let i = 0; i < resultSet.pageRanges.length; i++) {
let thisPage = resultSet.fetch({ index: i });
let pagedResults = thisPage.data.asMappedResults();
pagedResults.forEach( (mappedResult) => {
let {amount, entity} = mappedResult;
if (occurrances[entity] === undefined) occurrances[entity] = 0;
occurrances[entity]++
//console.log(entity, amount);
});
}