Remove Duplicates Sum ProductCount

PHOTO EMBED

Mon Oct 02 2023 05:12:35 GMT+0000 (Coordinated Universal Time)

Saved by @rtrmukesh

const reducedData = Object.values(stockEntryReportData.reduce((acc, obj) => {
  const key = obj.store_id + '-' + obj.date + '-' + obj.user_id;
  if (!acc[key]) {
    acc[key] = { ...obj };
  } else {
    acc[key].productCount += obj.productCount;
  }
  return acc;
}, {}));

console.log(reducedData);
content_copyCOPY

https://chat.openai.com/