feat: send the adress data to noleap

This commit is contained in:
Abdalhamid Alhamad
2025-12-16 14:51:21 +03:00
parent 3200f60821
commit fe11f35b32
2 changed files with 39 additions and 11 deletions

View File

@ -93,25 +93,27 @@ export class NeoLeapService {
incomeSource: dto.incomeSource,
jobCategory: dto.jobCategory,
incomeRange: dto.incomeRange,
// Send empty address strings (Neoleap doesn't validate content)
// Map collected address fields to Neoleap's format
address: {
national: {
buildingNumber: '',
buildingNumber: dto.building || '',
additionalNumber: '',
street: '',
streetEn: '',
city: '',
cityEn: '',
street: dto.street || '',
streetEn: dto.street || '',
city: dto.city || '',
cityEn: dto.city || '',
zipcode: '',
unitNumber: '',
district: '',
districtEn: '',
district: dto.neighborhood || '',
districtEn: dto.neighborhood || '',
},
general: {
address: '',
address: [dto.building, dto.street, dto.neighborhood, dto.city, dto.region]
.filter(Boolean)
.join(', '),
website: '',
email: '',
telephone1: '',
email: dto.email || '',
telephone1: dto.mobileNumber || '',
telephone2: '',
fax1: '',
fax2: '',

View File

@ -0,0 +1,26 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddNationalIdToKycTransactions1765877128065 implements MigrationInterface {
name = 'AddNationalIdToKycTransactions1765877128065'
public async up(queryRunner: QueryRunner): Promise<void> {
// Add column as nullable first (to handle existing records)
await queryRunner.query(`ALTER TABLE "kyc_transactions" ADD "national_id" character varying(50)`);
// Backfill existing records from form_data->poiNumber
await queryRunner.query(`
UPDATE "kyc_transactions"
SET "national_id" = form_data->>'poiNumber'
WHERE "national_id" IS NULL AND form_data->>'poiNumber' IS NOT NULL
`);
// Now make it NOT NULL with a default empty string for safety
await queryRunner.query(`ALTER TABLE "kyc_transactions" ALTER COLUMN "national_id" SET DEFAULT ''`);
await queryRunner.query(`ALTER TABLE "kyc_transactions" ALTER COLUMN "national_id" SET NOT NULL`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "kyc_transactions" DROP COLUMN "national_id"`);
}
}