diff --git a/api/models/Transaction.js b/api/models/Transaction.js index e5092efe1f..635db45b63 100644 --- a/api/models/Transaction.js +++ b/api/models/Transaction.js @@ -3,6 +3,7 @@ const { isEnabled } = require('../server/utils/handleText'); const transactionSchema = require('./schema/transaction'); const { getMultiplier } = require('./tx'); const Balance = require('./Balance'); +const cancelRate = 1.15; // Method to calculate and set the tokenValue for a transaction transactionSchema.methods.calculateTokenValue = function () { @@ -11,9 +12,11 @@ transactionSchema.methods.calculateTokenValue = function () { } const { valueKey, tokenType, model } = this; const multiplier = getMultiplier({ valueKey, tokenType, model }); + this.rate = multiplier; this.tokenValue = this.rawAmount * multiplier; if (this.context && this.tokenType === 'completion' && this.context === 'incomplete') { - this.tokenValue = Math.floor(this.tokenValue * 1.15); + this.tokenValue = Math.ceil(this.tokenValue * cancelRate); + this.rate *= cancelRate; } }; diff --git a/api/models/schema/transaction.js b/api/models/schema/transaction.js index 71ddb6a0b4..95fd9fc86a 100644 --- a/api/models/schema/transaction.js +++ b/api/models/schema/transaction.js @@ -26,6 +26,7 @@ const transactionSchema = mongoose.Schema({ valueKey: { type: String, }, + rate: Number, rawAmount: Number, tokenValue: Number, });