Skip to content

Commit 71d9c85

Browse files
authored
Merge pull request #1084 from rit-construct-makerspace/main
Accidentally forgot the sign on a value
2 parents b0f1f41 + 1d03ae3 commit 71d9c85

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

server/src/integrations/currency/transactions.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@ export async function UpdateTransaction(transactionID: number, deltaCents: numbe
8080
const lastCharges = await TransactionRepo.getLastChargesForTransactionById(transactionID);
8181
if (lastCharges != undefined) {
8282
console.log("Have history", lastCharges);
83-
const amountAlreadyCharged = (lastCharges.atrium?.amount ?? 0) + (lastCharges.credit?.amount ?? 0)
84-
if (centsToCharge + -amountAlreadyCharged > 0){
83+
// If we have charged the user money last time, this will be negative
84+
// If it is positive, we have somehow paid them
85+
const deltaForThisTransaction = (lastCharges.atrium?.amount ?? 0) + (lastCharges.credit?.amount ?? 0)
86+
if (centsToCharge + deltaForThisTransaction > 0){
8587
// recharge would give the user money (something fishy)
86-
console.error(`Currency: Caught fraudulent refund before refund. Not gonna refund it. Probably needs manual rectification. tid: ${transactionID} asking for ${centsToCharge}, only ever spent ${-amountAlreadyCharged}`)
88+
console.error(`Currency: Caught fraudulent refund before refund. Not gonna refund it. Probably needs manual rectification. tid: ${transactionID} asking for ${centsToCharge}, only ever spent ${-deltaForThisTransaction}`)
8789
return false;
8890
}
8991
const res = await Currency.refundChargeGroup(lastCharges, parent, entryId);
@@ -92,7 +94,7 @@ export async function UpdateTransaction(transactionID: number, deltaCents: numbe
9294
return res
9395
}
9496
// update amount to charge based on how much was already refunded/spent
95-
centsToCharge = amountAlreadyCharged + centsToCharge;
97+
centsToCharge = deltaForThisTransaction + centsToCharge;
9698
}
9799
if (centsToCharge > 0){
98100
console.error(`Currency: Illegal attempt to refund more than spent: tid:${transactionID}, tried to adjust ${centsToCharge} with reason ${reason}`)

0 commit comments

Comments
 (0)