Files
zod-backend/src/common/modules/neoleap/__mocks__/create-application.mock.ts
2025-08-26 19:17:00 +03:00

199 lines
5.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { randomInt, randomUUID } from 'crypto';
/** Generate a string of `n` random digits (first digit never 0). */
function randomDigits(n: number): string {
if (n <= 0) return '0';
let s = String(randomInt(1, 10)); // first digit 19
for (let i = 1; i < n; i++) s += String(randomInt(0, 10));
return s;
}
/** Build a fresh mock object every time it's called */
export function buildCreateApplicationMock() {
const now = new Date().toISOString();
return {
ResponseHeader: {
Version: '1.0.0',
MsgUid: randomUUID(),
Source: 'ZOD',
ServiceId: 'CreateNewApplication',
ReqDateTime: now,
RspDateTime: now,
ResponseCode: '000',
ResponseType: 'Success',
ProcessingTime: 1665,
EncryptionKey: null,
ResponseDescription: 'Operation Successful',
LocalizedResponseDescription: null,
CustomerSpecificResponseDescriptionList: null,
HeaderUserDataList: null,
},
CreateNewApplicationResponseDetails: {
InstitutionCode: '1100',
ApplicationTypeDetails: {
TypeCode: '01',
Description: 'Normal Primary',
Additional: false,
Corporate: false,
UserData: null,
},
ApplicationDetails: {
cif: null,
ApplicationNumber: '3300000000073',
ExternalApplicationNumber: '3',
ApplicationStatus: '04',
Organization: 0,
Product: '1101',
ApplicatonDate: '2025-05-29',
ApplicationSource: 'O',
SalesSource: null,
DeliveryMethod: 'V',
ProgramCode: null,
Campaign: null,
Plastic: null,
Design: null,
ProcessStage: '99',
ProcessStageStatus: 'S',
Score: null,
ExternalScore: null,
RequestedLimit: 0,
SuggestedLimit: null,
AssignedLimit: 0,
AllowedLimitList: null,
EligibilityCheckResult: '00',
EligibilityCheckDescription: null,
Title: 'Mr.',
FirstName: 'Abdalhamid',
SecondName: null,
ThirdName: null,
LastName: ' Ahmad',
FullName: 'Abdalhamid Ahmad',
EmbossName: 'ABDALHAMID AHMAD',
PlaceOfBirth: null,
DateOfBirth: '1999-01-07',
LocalizedDateOfBirth: '1999-01-07',
Age: 26,
Gender: 'M',
Married: 'U',
Nationality: '682',
IdType: '01',
IdNumber: '1089055972',
IdExpiryDate: '2031-09-17',
EducationLevel: null,
ProfessionCode: 0,
NumberOfDependents: 0,
EmployerName: 'N/A',
EmploymentYears: 0,
EmploymentMonths: 0,
CIF: null,
BankAccountNumber: ' ',
Currency: { CurrCode: '682', AlphaCode: 'SAR' },
CreditAccountNumber: '6000000000000000',
AccountType: '30',
Income: 0,
AdditionalIncome: 0,
TotalIncome: 0,
CurrentBalance: 0,
AverageBalance: 0,
AssetsBalance: 0,
InsuranceBalance: 0,
DepositAmount: 0,
GuarenteeAccountNumber: null,
GuarenteeAmount: 0,
InstalmentAmount: 0,
AutoDebit: 'N',
PaymentMethod: '2',
BillingCycle: 'C1',
MaximumDelinquency: null,
CreditBureauDecision: null,
ECommerce: 'N',
NumberOfCards: 0,
SocialCode: '000',
JobGrade: 0,
Flags: Array.from({ length: 64 }, (_, i) => ({
Position: i + 1,
Value: '0',
})),
CheckFlags: Array.from({ length: 64 }, (_, i) => ({
Position: i + 1,
Value: '0',
})),
},
ApplicationStatusDetails: {
StatusCode: '04',
Description: 'Approved',
Canceled: false,
},
CustomerDetails: {
Id: 115158,
CustomerCode: '100000024619',
IdNumber: ' ',
TypeId: 0,
PreferredLanguage: 'EN',
ExternalCustomerCode: null,
Title: ' ',
FirstName: ' ',
LastName: ' ',
DateOfBirth: null,
UserData1: '2031-09-17',
UserData2: '01',
UserData3: null,
UserData4: '682',
CustomerSegment: null,
Gender: 'U',
Married: 'U',
},
AccountDetailsList: [
{
Id: randomDigits(5),
InstitutionCode: '1100',
AccountNumber: randomDigits(16),
Currency: { CurrCode: '682', AlphaCode: 'SAR' },
AccountTypeCode: '30',
ClassId: '2',
AccountStatus: '00',
VipFlag: '0',
BlockedAmount: 0,
AvailableBalance: 0,
UserData1: 'D36407C9AE4C28D2185',
UserData3: 'D36407C9AE4C28D2185',
UserData5: `SA${randomDigits(22)}`,
},
],
CardDetailsList: [
{
pvv: null,
ResponseCardIdentifier: {
Id: randomDigits(5),
Pan: 'DDDDDDDDDDDDDDDDDDD',
MaskedPan: '999999_9999',
VPan: randomDigits(16),
Seqno: 0,
},
ExpiryDate: '2031-09-30',
EffectiveDate: '2025-06-02',
CardStatus: '30',
EmbossingName: 'ABDALHAMID AHMAD',
Title: 'Mr.',
FirstName: 'Abdalhamid',
LastName: ' Ahmad',
BatchNumber: 8849,
ServiceCode: '226',
DateOfBirth: '1999-01-07',
LastStatusChangeDate: '2025-06-03',
PinStatus: '40',
OldPinStatus: '0',
CustomerIdNumber: '1089055972',
Language: 0,
},
],
},
};
}