I want to prepare an array for payment collection report I have a response array like:
orderDate:[{ 
    date: 21-01-20,
    sales: 20,
    method: Razorpay,
    sub: 1
},{ 
    date: 21-01-20,
    sales: 20,
    method: Simpl,
    sub: 1
},{ 
    date: 21-01-20,
    sales: 20,
    method: Razorpay,
    sub: 1
},{ 
    date: 21-01-20,
    sales: 20,
    method: Cash,
    sub: 1
},{ 
    date: 21-01-20,
    sales: 20,
    method: Credit,
    sub: 1
},{ 
    date: 22-01-20,
    sales: 10,
    method: Credit,
    sub: 1
},{ 
    date: 22-01-20,
    sales: 20,
    method: Razorpay,
    sub: 1
}];
And I have payment method array
paymentMethods:[Razorpay, Simpl, Paytm, Other];
I want to prepare a final array like:
final:[{
    date: 21-01-20,
    revenue:[40, 20, 0, 40] //method wise sum of sales for the respected date
},{
    date: 22-01-20,
    revenue:[20, 0, 0, 10] //method wise sum of sales for the respected date
}]
If no data found for a respected method then push 0 value at the index of that method
Thank you for the help
 
     
    