|
@@ -3,6 +3,7 @@ import {
|
|
|
CreateTaxRateInput,
|
|
CreateTaxRateInput,
|
|
|
DeletionResponse,
|
|
DeletionResponse,
|
|
|
DeletionResult,
|
|
DeletionResult,
|
|
|
|
|
+ TaxRateFilterParameter,
|
|
|
UpdateTaxRateInput,
|
|
UpdateTaxRateInput,
|
|
|
} from '@vendure/common/lib/generated-types';
|
|
} from '@vendure/common/lib/generated-types';
|
|
|
import { ID, PaginatedList } from '@vendure/common/lib/shared-types';
|
|
import { ID, PaginatedList } from '@vendure/common/lib/shared-types';
|
|
@@ -65,8 +66,30 @@ export class TaxRateService {
|
|
|
options?: ListQueryOptions<TaxRate>,
|
|
options?: ListQueryOptions<TaxRate>,
|
|
|
relations?: RelationPaths<TaxRate>,
|
|
relations?: RelationPaths<TaxRate>,
|
|
|
): Promise<PaginatedList<TaxRate>> {
|
|
): Promise<PaginatedList<TaxRate>> {
|
|
|
|
|
+ const effectiveRelations = relations || ['customerGroup'];
|
|
|
|
|
+ const customPropertyMap: { [name: string]: string } = {};
|
|
|
|
|
+ const hasZoneIdFilter = this.listQueryBuilder.filterObjectHasProperty<TaxRateFilterParameter>(
|
|
|
|
|
+ options?.filter,
|
|
|
|
|
+ 'zoneId',
|
|
|
|
|
+ );
|
|
|
|
|
+ const hasCategoryIdFilter = this.listQueryBuilder.filterObjectHasProperty<TaxRateFilterParameter>(
|
|
|
|
|
+ options?.filter,
|
|
|
|
|
+ 'categoryId',
|
|
|
|
|
+ );
|
|
|
|
|
+ if (hasZoneIdFilter) {
|
|
|
|
|
+ effectiveRelations.push('zone');
|
|
|
|
|
+ customPropertyMap.zoneId = 'zone.id';
|
|
|
|
|
+ }
|
|
|
|
|
+ if (hasCategoryIdFilter) {
|
|
|
|
|
+ effectiveRelations.push('category');
|
|
|
|
|
+ customPropertyMap.zoneId = 'category.id';
|
|
|
|
|
+ }
|
|
|
return this.listQueryBuilder
|
|
return this.listQueryBuilder
|
|
|
- .build(TaxRate, options, { relations: relations ?? ['category', 'zone', 'customerGroup'], ctx })
|
|
|
|
|
|
|
+ .build(TaxRate, options, {
|
|
|
|
|
+ relations: effectiveRelations,
|
|
|
|
|
+ ctx,
|
|
|
|
|
+ customPropertyMap,
|
|
|
|
|
+ })
|
|
|
.getManyAndCount()
|
|
.getManyAndCount()
|
|
|
.then(([items, totalItems]) => ({
|
|
.then(([items, totalItems]) => ({
|
|
|
items,
|
|
items,
|