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 | // ================================================================ // PAYROLL RUN JOB PROCESSOR — Background Queue Worker // ================================================================ import { Processor, WorkerHost } from '@nestjs/bullmq'; import { Job } from 'bullmq'; import { Logger } from '@nestjs/common'; import { PayrollRunService } from '../services/payroll.service'; @Processor('payroll-run-processing') export class PayrollProcessor extends WorkerHost { private readonly logger = new Logger(PayrollProcessor.name); constructor(private readonly runService: PayrollRunService) { super(); } async process(job: Job<any, any, string>): Promise<any> { const { tenantId, runId, userId } = job.data; this.logger.log( `Starting background payroll run calculation for tenant ${tenantId}, run ${runId}`, ); if (job.name === 'payroll.run.calculate') { try { const result = await this.runService.calculate(tenantId, runId); this.logger.log( `Payroll run calculation completed: ${result.success} succeeded, ${result.failed} failed`, ); return result; } catch (err: unknown) { const msg = err instanceof Error ? err.message : String(err); this.logger.error(`Payroll run calculation failed: ${msg}`); throw err; } } return { status: 'ignored' }; } } |