From 1e66900c30c90d303545b8088774bac6e40d0b19 Mon Sep 17 00:00:00 2001 From: soundsng Date: Sat, 27 Jun 2026 04:17:54 +0100 Subject: [PATCH 1/4] Fix payment enrollment validator query formatting --- .../payment-enrollment-validator.service.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/payments/services/payment-enrollment-validator.service.ts diff --git a/src/payments/services/payment-enrollment-validator.service.ts b/src/payments/services/payment-enrollment-validator.service.ts new file mode 100644 index 00000000..b804c1a7 --- /dev/null +++ b/src/payments/services/payment-enrollment-validator.service.ts @@ -0,0 +1,24 @@ +import { Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { Payment } from '../entities/payment.entity'; + +@Injectable() +export class PaymentEnrollmentValidatorService { + constructor( + @InjectRepository(Payment) + private readonly paymentRepo: Repository, + ) {} + + async validateEnrollmentExists(enrollmentId: string): Promise { + if (!enrollmentId) return true; + const result = await this.paymentRepo.query('SELECT id FROM enrollments WHERE id = $1', [enrollmentId]); + return result.length > 0; + } + + async findOrphanedPayments(): Promise { + return this.paymentRepo.query( + 'SELECT p.* FROM payments p LEFT JOIN enrollments e ON e.id = p."enrollmentId" WHERE p."enrollmentId" IS NOT NULL AND e.id IS NULL', + ); + } +} From bb1fcf6d867bd2814881e8afaa88314ee5d9619d Mon Sep 17 00:00:00 2001 From: soundsng Date: Sat, 27 Jun 2026 08:22:01 +0100 Subject: [PATCH 2/4] fix: prettier formatting - multiline query args --- .../services/payment-enrollment-validator.service.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/payments/services/payment-enrollment-validator.service.ts b/src/payments/services/payment-enrollment-validator.service.ts index b804c1a7..a5ddb5c3 100644 --- a/src/payments/services/payment-enrollment-validator.service.ts +++ b/src/payments/services/payment-enrollment-validator.service.ts @@ -12,7 +12,10 @@ export class PaymentEnrollmentValidatorService { async validateEnrollmentExists(enrollmentId: string): Promise { if (!enrollmentId) return true; - const result = await this.paymentRepo.query('SELECT id FROM enrollments WHERE id = $1', [enrollmentId]); + const result = await this.paymentRepo.query( + 'SELECT id FROM enrollments WHERE id = $1', + [enrollmentId], + ); return result.length > 0; } From 58d8861f4c0fb15badf15567ab90d6dd5a184893 Mon Sep 17 00:00:00 2001 From: soundsng Date: Sat, 27 Jun 2026 08:51:46 +0100 Subject: [PATCH 3/4] fix: single-line query --- .../services/payment-enrollment-validator.service.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/payments/services/payment-enrollment-validator.service.ts b/src/payments/services/payment-enrollment-validator.service.ts index a5ddb5c3..b804c1a7 100644 --- a/src/payments/services/payment-enrollment-validator.service.ts +++ b/src/payments/services/payment-enrollment-validator.service.ts @@ -12,10 +12,7 @@ export class PaymentEnrollmentValidatorService { async validateEnrollmentExists(enrollmentId: string): Promise { if (!enrollmentId) return true; - const result = await this.paymentRepo.query( - 'SELECT id FROM enrollments WHERE id = $1', - [enrollmentId], - ); + const result = await this.paymentRepo.query('SELECT id FROM enrollments WHERE id = $1', [enrollmentId]); return result.length > 0; } From 0fffd29dcf2cdb4288bea057b4c01fecd407f919 Mon Sep 17 00:00:00 2001 From: soundsng Date: Sat, 27 Jun 2026 08:54:55 +0100 Subject: [PATCH 4/4] fix: array on own line --- src/payments/services/payment-enrollment-validator.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/payments/services/payment-enrollment-validator.service.ts b/src/payments/services/payment-enrollment-validator.service.ts index b804c1a7..a3a48eb1 100644 --- a/src/payments/services/payment-enrollment-validator.service.ts +++ b/src/payments/services/payment-enrollment-validator.service.ts @@ -12,7 +12,9 @@ export class PaymentEnrollmentValidatorService { async validateEnrollmentExists(enrollmentId: string): Promise { if (!enrollmentId) return true; - const result = await this.paymentRepo.query('SELECT id FROM enrollments WHERE id = $1', [enrollmentId]); + const result = await this.paymentRepo.query('SELECT id FROM enrollments WHERE id = $1', [ + enrollmentId, + ]); return result.length > 0; }