|
@@ -4,7 +4,6 @@ import { Column, Entity, ManyToOne } from 'typeorm';
|
|
|
|
|
|
|
|
import { AdjustmentSource } from '../../common/types/adjustment-source';
|
|
import { AdjustmentSource } from '../../common/types/adjustment-source';
|
|
|
import { idsAreEqual } from '../../common/utils';
|
|
import { idsAreEqual } from '../../common/utils';
|
|
|
-import { getConfig } from '../../config/vendure-config';
|
|
|
|
|
import { CustomerGroup } from '../customer-group/customer-group.entity';
|
|
import { CustomerGroup } from '../customer-group/customer-group.entity';
|
|
|
import { TaxCategory } from '../tax-category/tax-category.entity';
|
|
import { TaxCategory } from '../tax-category/tax-category.entity';
|
|
|
import { Zone } from '../zone/zone.entity';
|
|
import { Zone } from '../zone/zone.entity';
|
|
@@ -12,11 +11,9 @@ import { Zone } from '../zone/zone.entity';
|
|
|
@Entity()
|
|
@Entity()
|
|
|
export class TaxRate extends AdjustmentSource {
|
|
export class TaxRate extends AdjustmentSource {
|
|
|
readonly type = AdjustmentType.TAX;
|
|
readonly type = AdjustmentType.TAX;
|
|
|
- private readonly round: (input: number) => number;
|
|
|
|
|
|
|
|
|
|
constructor(input?: DeepPartial<TaxRate>) {
|
|
constructor(input?: DeepPartial<TaxRate>) {
|
|
|
super(input);
|
|
super(input);
|
|
|
- this.round = getConfig().roundingStrategy.round;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Column() name: string;
|
|
@Column() name: string;
|
|
@@ -38,7 +35,7 @@ export class TaxRate extends AdjustmentSource {
|
|
|
* Returns the tax component of a given gross price.
|
|
* Returns the tax component of a given gross price.
|
|
|
*/
|
|
*/
|
|
|
taxComponentOf(grossPrice: number): number {
|
|
taxComponentOf(grossPrice: number): number {
|
|
|
- return this.round(grossPrice - grossPrice / ((100 + this.value) / 100));
|
|
|
|
|
|
|
+ return Math.round(grossPrice - grossPrice / ((100 + this.value) / 100));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -52,7 +49,7 @@ export class TaxRate extends AdjustmentSource {
|
|
|
* Returns the tax applicable to the given net price.
|
|
* Returns the tax applicable to the given net price.
|
|
|
*/
|
|
*/
|
|
|
taxPayableOn(netPrice: number): number {
|
|
taxPayableOn(netPrice: number): number {
|
|
|
- return this.round(netPrice * (this.value / 100));
|
|
|
|
|
|
|
+ return Math.round(netPrice * (this.value / 100));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|