Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/subdomains/generic/kyc/services/kyc-file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ export class KycFileService {

entity.uid = Util.createUid(Config.prefixes.kycFileUidPrefix);

return this.kycFileRepository.save(entity);
const saved = await this.kycFileRepository.save(entity);

// Invalidate cache so new files are visible immediately
this.kycFileRepository.invalidateCache();

return saved;
}

async getKycFile(uid: string, relations?: FindOptionsRelations<KycFile>): Promise<KycFile> {
Expand Down
55 changes: 54 additions & 1 deletion src/subdomains/generic/kyc/services/kyc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Util } from 'src/shared/utils/util';
import { CheckStatus } from 'src/subdomains/core/aml/enums/check-status.enum';
import { PaymentLinkRecipientDto } from 'src/subdomains/core/payment-link/dto/payment-link-recipient.dto';
import { MailFactory, MailTranslationKey } from 'src/subdomains/supporting/notification/factories/mail.factory';
import { FindOptionsWhere, IsNull, LessThan, MoreThan, Not } from 'typeorm';
import { FindOptionsWhere, In, IsNull, LessThan, MoreThan, Not } from 'typeorm';
import { MergeReason } from '../../user/models/account-merge/account-merge.entity';
import { AccountMergeService } from '../../user/models/account-merge/account-merge.service';
import { BankDataType } from '../../user/models/bank-data/bank-data.entity';
Expand Down Expand Up @@ -1805,4 +1805,57 @@ export class KycService {
);
}
}

// --- Company Onboarding Queries ---

async getPendingCompanyOnboardings(): Promise<{ userDataId: number; date: Date }[]> {
const companyStepNames = [
KycStepName.LEGAL_ENTITY,
KycStepName.AUTHORITY,
KycStepName.OWNER_DIRECTORY,
KycStepName.SIGNATORY_POWER,
KycStepName.BENEFICIAL_OWNER,
KycStepName.OPERATIONAL_ACTIVITY,
KycStepName.DFX_APPROVAL,
];

const results = await this.kycStepRepo
.createQueryBuilder('step')
.select('step.userDataId', 'userDataId')
.addSelect('MIN(step.updated)', 'date')
.innerJoin('step.userData', 'userData')
.where('step.name IN (:...names)', { names: companyStepNames })
.andWhere('step.status = :status', { status: ReviewStatus.MANUAL_REVIEW })
.andWhere('userData.accountType IN (:...accountTypes)', {
accountTypes: [AccountType.ORGANIZATION, AccountType.SOLE_PROPRIETORSHIP],
})
.andWhere(
`step.userDataId NOT IN (
SELECT s2.userDataId FROM kyc_step s2
WHERE s2.name = :approvalName AND s2.status IN (:...doneStatuses)
)`,
{
approvalName: KycStepName.DFX_APPROVAL,
doneStatuses: [ReviewStatus.COMPLETED, ReviewStatus.FAILED],
},
)
.groupBy('step.userDataId')
.orderBy('date', 'ASC')
.getRawMany<{ userDataId: number; date: Date }>();

return results;
}

async getDfxApprovalSteps(userDataIds: number[]): Promise<KycStep[]> {
if (userDataIds.length === 0) return [];

return this.kycStepRepo.find({
where: {
userData: { id: In(userDataIds) },
name: KycStepName.DFX_APPROVAL,
status: In([ReviewStatus.COMPLETED, ReviewStatus.FAILED]),
},
relations: ['userData'],
});
}
}
37 changes: 37 additions & 0 deletions src/subdomains/generic/support/dto/onboarding-pdf.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { IsString, IsOptional } from 'class-validator';

export class GenerateOnboardingPdfDto {
@IsString()
finalDecision: string;

@IsString()
processedBy: string;

@IsOptional()
@IsString()
complexOrgStructure?: string;

@IsOptional()
@IsString()
highRisk?: string;

@IsOptional()
@IsString()
depositLimit?: string;

@IsOptional()
@IsString()
amlAccountType?: string;

@IsOptional()
@IsString()
commentGmeR?: string;

@IsOptional()
@IsString()
reasonSeatingCompany?: string;

@IsOptional()
@IsString()
businessActivities?: string;
}
14 changes: 14 additions & 0 deletions src/subdomains/generic/support/dto/user-data-support.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,25 @@ export class UserDataSupportInfoResult {
bankTx: BankTxSupportInfo[];
}

export enum OnboardingStatus {
OPEN = 'Open',
COMPLETED = 'Completed',
REJECTED = 'Rejected',
}

export class UserDataSupportInfo {
id: number;
kycStatus: KycStatus;
accountType?: AccountType;
mail?: string;
name?: string;
onboardingStatus?: OnboardingStatus;
}

export class PendingOnboardingInfo {
id: number;
name?: string;
date: Date;
}

export class BankTxSupportInfo {
Expand Down Expand Up @@ -86,6 +99,7 @@ export class KycStepSupportInfo {
export class KycLogSupportInfo {
id: number;
type: string;
result?: string;
comment?: string;
created: Date;
}
Expand Down
Loading
Loading