Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | import { Processor, WorkerHost } from '@nestjs/bullmq'; import { Job } from 'bullmq'; import { Logger } from '@nestjs/common'; import { CarryForwardEngine } from '../carry-forward/carry-forward.engine'; import { CompOffService } from '../comp-off/comp-off.service'; @Processor('leave-carry-forward-processing') export class LeaveCarryForwardProcessor extends WorkerHost { private readonly logger = new Logger(LeaveCarryForwardProcessor.name); constructor( private cfEngine: CarryForwardEngine, private compOffService: CompOffService, ) { super(); } async process(job: Job<any, any, string>): Promise<any> { const { tenantId, fromPeriodId, toPeriodId, isDryRun, userId } = job.data; if (job.name === 'leave.carry-forward.process') { this.logger.log( `Starting leave carry forward processing for tenant ${tenantId}`, ); return this.cfEngine.executeCarryForward( tenantId, fromPeriodId, toPeriodId, isDryRun || false, userId || 'system', ); } if (job.name === 'leave.comp-off.expire') { this.logger.log(`Expiring comp-offs for tenant ${tenantId}`); return this.compOffService.expireEarnings(tenantId); } return { status: 'ignored' }; } } |