Here is the Array that needs to be processed:
[
{
"batchno": "B-PI1-1",
"unitId": 341,
"productName": "Bar Soap",
"productProfileId": 3950,
"qty": 148,
"returnQty": "20",
"rate": 10,
"salesRate": 20,
"unitName": "PC",
"gross": 200,
"net": 200,
"remarks": "sxzxz"
},
{
"batchno": "B-PI4-1",
"unitId": 341,
"productName": "Biscuit",
"productProfileId": 3951,
"qty": 700,
"returnQty": "20",
"rate": 10,
"salesRate": 60,
"unitName": "PC",
"gross": 200,
"net": 200,
"remarks": "zxzxzx"
}
];
The task at hand is to create a new array, making sure not to duplicate entries:
if (this.primengTableHelper.initialRecords.length > 0) {
this.primengTableHelper.initialRecords.map((item: any) => {
console.log('item', item);
this.singleItem.batchNo = item.batchno;
this.singleItem.unitId = item.unitId;
this.singleItem.productName = item.productName;
this.singleItem.productProfileId = item.productProfileId;
this.singleItem.qty = item.qty;
this.singleItem.returnQty = item.returnQty
this.singleItem.rate = item.rate;
this.singleItem.salesRate = item.salesRate;
this.singleItem.unitName = item.unitName;
this.singleItem.gross = item.net;
this.singleItem.net = item.net;
this.singleItem.remarks = item.remarks;
this.createOrEditDamageStockDto.paymentNO = this.voucherNO;
this.createOrEditDamageStockDto.invoiceDate =
this.maxInvoiceDateFilter.toString();
this.createOrEditDamageStockDto.damageStockDetailsListDto
.push(this.singleItem);
});