Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
3.0 kB
1
Indexable
Never
import { DateTime } from "luxon";
import { FaFirm } from '@lambdas/shared/models/FaFirm';
import { generateCsvReport } from "./generate-monthly-firm-crm-report/generateCsvReport";
import { SerializeFirmData } from "./generate-monthly-firm-crm-report/serializeFirmData";
import {
  AccountHolderType,
  Relationship,
  ReportData,
} from "./generate-monthly-firm-crm-report/types";
import * as fs from "fs";
import * as Money from "@lambdas/shared/money";
import type { GenerateFirmCrmReportParserPayload } from "./generate-monthly-firm-crm-report/parser";
import { AiStatus, CRSStatus, CkaStatus, VerificationSource } from "./shared/types";
import { User } from "./shared/models";
const serializeFirmData: SerializeFirmData = {
  name: "Hello",
  reportDate: DateTime.now().toFormat("dd MMMM yyyy"),
  data: [
    {
      adviserName: "Test 2 , Andrew",
      rnfCode: "MAS123",
      adviserEmail: "wmsupport@iress.com.sg;",
      accountOpeningDate: "24 May 2019",
      accountHolderType: AccountHolderType.client,
      rsp: "No",
      paymentMethod: "Cash",
      aum: "27,035.14",
      idNumber: "1234567",
      clientName: "1, Client Test",
      clientNationality: "Singaporean",
      clientDob: "1 May 2000",
      clientGender: "Male",
      country: "500 58692999 859",
      postalCode: "100000",
      addressStressName: "Monaco",
      addressUnit: "Monaco",
      addressState: "Monaco",
      clientMobile: "(+65)86945356",
      clientEmail: "sheehwa.ho@gmail.com",
      relationShip: "Inbound lead (via Invite)",
    },
  ],
};

const payload: GenerateFirmCrmReportParserPayload = {
  id: 1,
  reportDate: DateTime.now(),
  currency: "SGD",
};

const mockUser = new User({
    id: "uuid",
    full_name: "Full Name",
    mobile_country_code: "84",
    mobile: "123123123",
    phone_number_verified: true,
    created_at: "2022-02-22 02:00:00.000000",
    updated_at: "2022-02-22 02:00:00.000000",
    sex: "MALE",
    id_number: "111222333",
    date_of_birth: "2002-02-02",
    nationality: "SG",
    email: "test@chocfin.com",
    addr_line_1: "address line 1",
    addr_line_2: "address line 2",
    addr_line_3: "address line 3",
    addr_country: "SG",
    addr_postal: "123456",
    cka_status: CkaStatus.Passed,
    ai_status: AiStatus.Ai,
    crs_status: CRSStatus.declared,
    verification_source: VerificationSource.Singpass,
    preferred_name: "Preferred Name",
    is_step_up_pin_set: true,
    isAdminUserSession: false,
  });

const reportData: ReportData[] = [
    {
        userInfo: mockUser,
        userAum: Money.SGD.amount(8),
        accountHolderType: AccountHolderType.client,
        type: Relationship.firstLevelInvite,
    }
];

const mockFaFirm: FaFirm = {
    id: 1,
    name: "mock-name",
    createdDate: DateTime.now(),
    allowInboundLeads: false,
    assignmentRatio: 0
};

const a = generateCsvReport(payload, mockFaFirm, reportData);
console.log(a);

fs.writeFileSync("./output.csv", a);