@@ -22,6 +22,7 @@ import { TransactionalConnection } from '../../connection/transactional-connecti
22
22
import { OrderLine } from '../../entity/order-line/order-line.entity' ;
23
23
import { StockLevel } from '../../entity/stock-level/stock-level.entity' ;
24
24
import { StockLocation } from '../../entity/stock-location/stock-location.entity' ;
25
+ import { EventBus , StockLocationEvent } from '../../event-bus/index' ;
25
26
import { CustomFieldRelationService } from '../helpers/custom-field-relation/custom-field-relation.service' ;
26
27
import { ListQueryBuilder } from '../helpers/list-query-builder/list-query-builder' ;
27
28
import { RequestContextService } from '../helpers/request-context/request-context.service' ;
@@ -41,6 +42,7 @@ export class StockLocationService {
41
42
private configService : ConfigService ,
42
43
private requestContextCache : RequestContextCacheService ,
43
44
private customFieldRelationService : CustomFieldRelationService ,
45
+ private eventBus : EventBus ,
44
46
) { }
45
47
46
48
async initStockLocations ( ) {
@@ -81,6 +83,7 @@ export class StockLocationService {
81
83
) ;
82
84
await this . channelService . assignToCurrentChannel ( stockLocation , ctx ) ;
83
85
await this . connection . getRepository ( ctx , StockLocation ) . save ( stockLocation ) ;
86
+ await this . eventBus . publish ( new StockLocationEvent ( ctx , stockLocation , 'created' , input ) ) ;
84
87
return stockLocation ;
85
88
}
86
89
@@ -94,6 +97,7 @@ export class StockLocationService {
94
97
input ,
95
98
updatedStockLocation ,
96
99
) ;
100
+ await this . eventBus . publish ( new StockLocationEvent ( ctx , updatedStockLocation , 'updated' , input ) ) ;
97
101
return assertFound ( this . findOne ( ctx , updatedStockLocation . id ) ) ;
98
102
}
99
103
@@ -147,7 +151,11 @@ export class StockLocationService {
147
151
}
148
152
}
149
153
try {
154
+ const deletedStockLocation = new StockLocation ( stockLocation ) ;
150
155
await this . connection . getRepository ( ctx , StockLocation ) . remove ( stockLocation ) ;
156
+ await this . eventBus . publish (
157
+ new StockLocationEvent ( ctx , deletedStockLocation , 'deleted' , input . id ) ,
158
+ ) ;
151
159
} catch ( e : any ) {
152
160
return {
153
161
result : DeletionResult . NOT_DELETED ,
0 commit comments