|
@@ -151,9 +151,18 @@ export class CintasImportProcessor {
|
|
|
// Run the stored procedure to calculate summary
|
|
// Run the stored procedure to calculate summary
|
|
|
console.log(`[${new Date().toISOString()}] [CintasImport] Running summary calculation procedure...`);
|
|
console.log(`[${new Date().toISOString()}] [CintasImport] Running summary calculation procedure...`);
|
|
|
try {
|
|
try {
|
|
|
- await this.prisma.$executeRawUnsafe(
|
|
|
|
|
- `CALL cintas_calculate_summary(${importId})`
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ await this.prisma.cintasInstallCalendar.deleteMany({
|
|
|
|
|
+ where: {
|
|
|
|
|
+ importId,
|
|
|
|
|
+ OR: [
|
|
|
|
|
+ { installDate: { equals: 'Date of Install', mode: 'insensitive' } },
|
|
|
|
|
+ { opportunityStatus: { equals: 'Opportunity Status', mode: 'insensitive' } },
|
|
|
|
|
+ { trr: { equals: 'TRR', mode: 'insensitive' } },
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ await this.prisma.$executeRaw`CALL cintas_calculate_summary(${importId})`;
|
|
|
console.log(`[${new Date().toISOString()}] [CintasImport] Summary calculation completed successfully`);
|
|
console.log(`[${new Date().toISOString()}] [CintasImport] Summary calculation completed successfully`);
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error(`[${new Date().toISOString()}] [CintasImport] ERROR: Summary calculation failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
console.error(`[${new Date().toISOString()}] [CintasImport] ERROR: Summary calculation failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
|