Database

[{totalTaxInclusive:15,totalTaxExclusive:12.5,payments:[{method:"CB",amount:10},{method:"CASH",amount:5}],},{totalTaxInclusive:40,totalTaxExclusive:33.33,payments:[{method:"CB",amount:40}],},]

Query

db.collection.aggregate([{"$group":{"_id":null,"totalTaxInclusive":{"$addToSet":"$totalTaxInclusive"},"totalTaxExclusive":{"$addToSet":"$totalTaxExclusive"},"payments":{"$addToSet":"$payments"},"count":{"$sum":1}}},{"$set":{"totalTaxExclusive":{"$sum":"$totalTaxExclusive"},"totalTaxInclusive":{"$sum":"$totalTaxInclusive"}}},{"$unwind":"$payments"},{"$unwind":"$payments"},{"$group":{"_id":"$payments.method","amount":{"$sum":"$payments.amount"},"totalTaxInclusive":{"$first":"$totalTaxInclusive"},"totalTaxExclusive":{"$first":"$totalTaxExclusive"},"count":{"$first":"$count"}}},{"$group":{"_id":null,"payments":{"$addToSet":{"method":"$_id","amount":"$amount"}},"totalTaxInclusive":{"$first":"$totalTaxInclusive"},"totalTaxExclusive":{"$first":"$totalTaxExclusive"},"count":{"$first":"$count"}}}])

Result