import { Injectable } from '@nestjs/common';
import { CostRecalculationWorker } from '../workers/cost-recalculation.worker';
@Injectable()
export class CostingEventHandlerService {
constructor(private readonly jobs: CostRecalculationWorker) {}
supplierPriceChanged(input: {
organizationId: string;
locationId: string;
stockItemId: string;
}) {
return this.jobs.enqueue({
organizationId: input.organizationId,
locationId: input.locationId,
scopeType: 'stock_item',
scopeId: input.stockItemId,
reason: 'SupplierPriceChanged',
});
}
goodsReceived(input: {
organizationId: string;
locationId: string;
stockItemId: string;
}) {
return this.jobs.enqueue({
organizationId: input.organizationId,
locationId: input.locationId,
scopeType: 'stock_item',
scopeId: input.stockItemId,
reason: 'GoodsReceived',
});
}
recipePublished(input: {
organizationId: string;
locationId: string;
recipeId: string;
}) {
return this.jobs.enqueue({
organizationId: input.organizationId,
locationId: input.locationId,
scopeType: 'recipe',
scopeId: input.recipeId,
reason: 'RecipePublished',
});
}
productPriceChanged(input: {
organizationId: string;
locationId: string;
productId: string;
}) {
return this.jobs.enqueue({
organizationId: input.organizationId,
locationId: input.locationId,
scopeType: 'product',
scopeId: input.productId,
reason: 'ProductPriceChanged',
});
}
}
