Skip to content

Commit

Permalink
fix(core): Use MoneyStrategy in Surcharges (#2294)
Browse files Browse the repository at this point in the history
  • Loading branch information
skid authored Jul 18, 2023
1 parent 83ecec9 commit efee8ec
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/core/src/entity/surcharge/surcharge.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { summate } from '@vendure/common/lib/shared-utils';
import { Column, Entity, Index, ManyToOne } from 'typeorm';

import { Calculated } from '../../common/calculated-decorator';
import { roundMoney } from '../../common/round-money';
import { grossPriceOf, netPriceOf } from '../../common/tax-utils';
import { VendureEntity } from '../base/base.entity';
import { Money } from '../money.decorator';
Expand Down Expand Up @@ -48,12 +49,16 @@ export class Surcharge extends VendureEntity {

@Calculated()
get price(): number {
return this.listPriceIncludesTax ? netPriceOf(this.listPrice, this.taxRate) : this.listPrice;
return roundMoney(
this.listPriceIncludesTax ? netPriceOf(this.listPrice, this.taxRate) : this.listPrice,
);
}

@Calculated()
get priceWithTax(): number {
return this.listPriceIncludesTax ? this.listPrice : grossPriceOf(this.listPrice, this.taxRate);
return roundMoney(
this.listPriceIncludesTax ? this.listPrice : grossPriceOf(this.listPrice, this.taxRate),
);
}

@Calculated()
Expand Down

0 comments on commit efee8ec

Please sign in to comment.