🚀 Elite Accountant Hub: Foundation & Trojan Horse deployment
This commit is contained in:
34
backend/src/modules/invoices/bulk-upload.processor.ts
Normal file
34
backend/src/modules/invoices/bulk-upload.processor.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Processor, Process } from '@nestjs/bull';
|
||||
import { Job } from 'bull';
|
||||
import { Logger } from '@nestjs/common';
|
||||
import { InjectRedis } from '@liaoliaots/nestjs-redis';
|
||||
import Redis from 'ioredis';
|
||||
import { InvoicesService } from './invoice.service';
|
||||
|
||||
@Processor('invoice-bulk-queue')
|
||||
export class BulkUploadProcessor {
|
||||
private readonly logger = new Logger(BulkUploadProcessor.name);
|
||||
|
||||
constructor(
|
||||
private readonly invoicesService: InvoicesService,
|
||||
@InjectRedis() private readonly redis: Redis,
|
||||
) {}
|
||||
|
||||
@Process('process-zip')
|
||||
async handleBulkZip(job: Job<{ filePath: string, companyId: string, tenantId: string }>) {
|
||||
const { filePath, companyId, tenantId } = job.data;
|
||||
this.logger.log(`Processing bulk ZIP: ${filePath} for Company: ${companyId}`);
|
||||
|
||||
// TODO: Implement ZIP extraction (adm-zip or unzipper)
|
||||
// TODO: For each file in ZIP:
|
||||
// 1. Calculate Hash (MD5/SHA256)
|
||||
// 2. Check Redis SMEMBERS to prevent duplicate processing
|
||||
// const hash = 'calculated_file_hash';
|
||||
// const exists = await this.redis.sismember(`company:${companyId}:invoice-hashes`, hash);
|
||||
// if (exists) return;
|
||||
|
||||
// 3. Save hash and trigger individual processing
|
||||
// await this.redis.sadd(`company:${companyId}:invoice-hashes`, hash);
|
||||
// await this.invoicesService.processSingleFile(fileInZip, tenantId, companyId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user