Adjust totalDeposits on charity donation

This commit is contained in:
Austin Chen 2022-04-30 08:52:24 -04:00
parent 5c03f1581a
commit cc300c84e1

View File

@ -51,7 +51,10 @@ export const transact = functions
return { status: 'error', message: 'User not found' }
}
const toUser = toSnap.data() as User
transaction.update(toDoc, { balance: toUser.balance + amount })
transaction.update(toDoc, {
balance: toUser.balance + amount,
totalDeposits: toUser.totalDeposits + amount,
})
}
const newTxnDoc = firestore.collection(`txns/`).doc()
@ -73,7 +76,10 @@ export const transact = functions
})
transaction.create(newTxnDoc, txn)
transaction.update(fromDoc, { balance: fromUser.balance - amount })
transaction.update(fromDoc, {
balance: fromUser.balance - amount,
totalDeposits: fromUser.totalDeposits - amount,
})
return { status: 'success', txn }
})