Fixed amount calculations

This commit is contained in:
2020-12-04 22:07:30 +01:00
parent b480912bd8
commit afef95e14e
4 changed files with 15 additions and 9 deletions

View File

@@ -29,10 +29,17 @@ export class DistanceDonation extends Donation {
* The exact implementation may differ for each type of donation.
*/
@IsInt()
public get amount(): number {
public get amount() {
return this.getAmount();
}
/**
* The function that calculates the amount based on the runner object's distance.
*/
public async getAmount(): Promise<number> {
let calculatedAmount = -1;
try {
calculatedAmount = this.amountPerDistance * this.runner.distance;
calculatedAmount = this.amountPerDistance * await this.runner.distance();
} catch (error) {
throw error;
}