Skip to content

Commit

Permalink
fix(core): Correctly update StockLocation custom fields
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Jul 13, 2023
1 parent d36ac84 commit 1cb676a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions packages/core/src/service/services/stock-location.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { OrderLine, StockLevel } from '../../entity/index';
import { StockLocation } from '../../entity/stock-location/stock-location.entity';
import { ListQueryBuilder } from '../helpers/list-query-builder/list-query-builder';
import { RequestContextService } from '../helpers/request-context/request-context.service';
import { patchEntity } from '../helpers/utils/patch-entity';

import { ChannelService } from './channel.service';
import { RoleService } from './role.service';
Expand Down Expand Up @@ -75,6 +76,7 @@ export class StockLocationService {
new StockLocation({
name: input.name,
description: input.description ?? '',
customFields: input.customFields ?? {},
}),
);
await this.channelService.assignToCurrentChannel(stockLocation, ctx);
Expand All @@ -84,13 +86,8 @@ export class StockLocationService {

async update(ctx: RequestContext, input: UpdateStockLocationInput): Promise<StockLocation> {
const stockLocation = await this.connection.getEntityOrThrow(ctx, StockLocation, input.id);
if (input.name) {
stockLocation.name = input.name;
}
if (input.description) {
stockLocation.description = input.description;
}
return this.connection.getRepository(ctx, StockLocation).save(stockLocation);
const updatedStockLocation = patchEntity(stockLocation, input);
return this.connection.getRepository(ctx, StockLocation).save(updatedStockLocation);
}

async delete(ctx: RequestContext, input: DeleteStockLocationInput): Promise<DeletionResponse> {
Expand Down

0 comments on commit 1cb676a

Please sign in to comment.