Database

db={"funds":[{"_id":ObjectId("623dd490c00eec15c805920b"),balance:110}],"fundTransactions":[{"_id":ObjectId("623dd490c00eec15c805921a"),"fundID":ObjectId("623dd490c00eec15c805920b"),"transactionMethods":"Cash","transactionType":"Deposit","amount":100},{"_id":ObjectId("623dd490c00eec15c805931f"),"fundID":ObjectId("623dd490c00eec15c805920b"),"transactionMethods":"EBT","transactionType":"Deposit","amount":20},{"_id":ObjectId("623dd490c00eec15c805733d"),"fundID":ObjectId("623dd490c00eec15c805920b"),"transactionMethods":"Cash","transactionType":"Expense","amount":10},{"_id":ObjectId("623dd490c00eec15c805733c"),"fundID":ObjectId("623dd490c00eec15c805920b"),"transactionMethods":"Debit Card","transactionType":"Deposit","amount":50},]}

Query

db.funds.aggregate([{"$lookup":{"from":"fundTransactions","localField":"_id","foreignField":"fundID","as":"funds"}},{"$unwind":{"path":"$funds"}},{"$group":{"_id":{"funds":"$funds.transactionMethods"},"totalBalance":{"$sum":{"$cond":[{"$eq":["$funds.transactionType","Deposit"]},"$funds.amount",{"$multiply":["$funds.amount",-1.0]}]}},"Expense":{"$sum":{"$cond":[{"$eq":["$funds.transactionType","Expense"]},"$funds.amount",0.0]}}}},{"$addFields":{"EBT":{"$cond":[{"$eq":["$_id.funds","EBT"]},{"$round":["$totalBalance",0.0]},0.0]},"Cash":{"$cond":[{"$eq":["$_id.funds","Cash"]},{"$round":["$totalBalance",0.0]},0.0]},"Debit Card":{"$cond":[{"$eq":["$_id.funds","Debit Card"]},{"$round":["$totalBalance",0.0]},0.0]},"TotalExpense":{"$round":["$Expense",0.0]}}},{"$project":{"_id":0.0,"totalBalance":0.0}},{$group:{_id:"Total",Cash:{$sum:"$Cash"},"Debit Card":{$sum:"$Debit Card"},EBT:{$sum:"$EBT"},Expense:{$sum:"$Expense"},TotalExpense:{$sum:"$TotalExpense"}}}])

Result