const groupSum = (arr, idKey, ...sumKeys) =>
Object.values(arr.reduce((acc, n) => (
acc[n[idKey]] ??= sumKeys.reduce((group, k) => (group[k] = 0, group), {...n}),
sumKeys.forEach(k => acc[n[idKey]][k] += n[k]),
acc
), {}));
const result = groupSum(arr, 'product', 'price', 'selling_price', 'quantity');