|
|
@ -214,19 +214,18 @@ export class ActivitiesService { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
if (updateAccountBalance === true) { |
|
|
if (updateAccountBalance === true) { |
|
|
let amount = new Big(data.unitPrice).mul(data.quantity).toNumber(); |
|
|
let amount = new Big(data.unitPrice).mul(data.quantity); |
|
|
|
|
|
|
|
|
if (['BUY', 'FEE'].includes(data.type)) { |
|
|
if (['BUY', 'FEE'].includes(data.type)) { |
|
|
amount = new Big(amount).mul(-1).toNumber(); |
|
|
amount = amount.mul(-1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Fees always reduce cash regardless of the activity direction
|
|
|
amount = amount.minus(data.fee); |
|
|
amount = new Big(amount).minus(data.fee).toNumber(); |
|
|
|
|
|
|
|
|
|
|
|
await this.accountService.updateAccountBalance({ |
|
|
await this.accountService.updateAccountBalance({ |
|
|
accountId, |
|
|
accountId, |
|
|
amount, |
|
|
|
|
|
userId, |
|
|
userId, |
|
|
|
|
|
amount: amount.toNumber(), |
|
|
currency: data.SymbolProfile.connectOrCreate.create.currency, |
|
|
currency: data.SymbolProfile.connectOrCreate.create.currency, |
|
|
date: data.date as Date |
|
|
date: data.date as Date |
|
|
}); |
|
|
}); |
|
|
|