Skip to content

Commit

Permalink
fix(core): Persist custom field relations on TaxRate
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Apr 3, 2024
1 parent f9e3d21 commit 7eaa641
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/core/src/service/services/tax-rate.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { Zone } from '../../entity/zone/zone.entity';
import { EventBus } from '../../event-bus/event-bus';
import { TaxRateEvent } from '../../event-bus/events/tax-rate-event';
import { TaxRateModificationEvent } from '../../event-bus/events/tax-rate-modification-event';
import { CustomFieldRelationService } from '../helpers/custom-field-relation/custom-field-relation.service';
import { ListQueryBuilder } from '../helpers/list-query-builder/list-query-builder';
import { patchEntity } from '../helpers/utils/patch-entity';

Expand All @@ -46,6 +47,7 @@ export class TaxRateService {
private eventBus: EventBus,
private listQueryBuilder: ListQueryBuilder,
private configService: ConfigService,
private customFieldRelationService: CustomFieldRelationService,
) {}

/**
Expand Down Expand Up @@ -96,6 +98,7 @@ export class TaxRateService {
);
}
const newTaxRate = await this.connection.getRepository(ctx, TaxRate).save(taxRate);
await this.customFieldRelationService.updateRelations(ctx, TaxRate, input, newTaxRate);
await this.updateActiveTaxRates(ctx);
await this.eventBus.publish(new TaxRateModificationEvent(ctx, newTaxRate));
await this.eventBus.publish(new TaxRateEvent(ctx, newTaxRate, 'created', input));
Expand Down Expand Up @@ -126,6 +129,7 @@ export class TaxRateService {
);
}
await this.connection.getRepository(ctx, TaxRate).save(updatedTaxRate, { reload: false });
await this.customFieldRelationService.updateRelations(ctx, TaxRate, input, updatedTaxRate);
await this.updateActiveTaxRates(ctx);

// Commit the transaction so that the worker process can access the updated
Expand Down

0 comments on commit 7eaa641

Please sign in to comment.