@cfxlabsinc/b2b-services
    Preparing search index...

    Variable victorAccountBankAccountViewConst

    victorAccountBankAccountView: PgViewWithSelection<
        "victor_account_bank_account_view",
        false,
        {
            accountNumber: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            bankId: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            bankName: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            createdAt: PgBuildColumn<
                "victor_account_bank_account_view",
                SetNotNull<PgTimestampBuilder>,
                {
                    data: Date;
                    dataType: "object date";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: true;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            credits: PgBuildColumn<
                "victor_account_bank_account_view",
                PgNumericBuilder,
                {
                    data: string;
                    dataType: "string numeric";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            creditsExInternal: PgBuildColumn<
                "victor_account_bank_account_view",
                PgNumericBuilder,
                {
                    data: string;
                    dataType: "string numeric";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            currency: PgBuildColumn<
                "victor_account_bank_account_view",
                SetNotNull<PgTextBuilder<[string, ...string[]]>>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: true;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            customerId: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            customerName: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            debits: PgBuildColumn<
                "victor_account_bank_account_view",
                PgNumericBuilder,
                {
                    data: string;
                    dataType: "string numeric";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            debitsExInternal: PgBuildColumn<
                "victor_account_bank_account_view",
                PgNumericBuilder,
                {
                    data: string;
                    dataType: "string numeric";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            deletedAt: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTimestampBuilder,
                {
                    data: Date;
                    dataType: "object date";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            entityId: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            entityName: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            entityType: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            firstPostedAt: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTimestampBuilder,
                {
                    data: Date;
                    dataType: "object date";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            id: PgBuildColumn<
                "victor_account_bank_account_view",
                SetNotNull<PgTextBuilder<[string, ...string[]]>>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: true;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            impliedBalance: PgBuildColumn<
                "victor_account_bank_account_view",
                PgNumericBuilder,
                {
                    data: string;
                    dataType: "string numeric";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            impliedBalanceExInternal: PgBuildColumn<
                "victor_account_bank_account_view",
                PgNumericBuilder,
                {
                    data: string;
                    dataType: "string numeric";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            key: PgBuildColumn<
                "victor_account_bank_account_view",
                SetNotNull<PgTextBuilder<[string, ...string[]]>>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: true;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            keyable: PgBuildColumn<
                "victor_account_bank_account_view",
                SetNotNull<PgBooleanBuilder>,
                {
                    data: boolean;
                    dataType: "boolean";
                    driverParam: boolean;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: true;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            lastPostedAt: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTimestampBuilder,
                {
                    data: Date;
                    dataType: "object date";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            ledgerAccountId: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            memo: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            name: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            parentKey: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            provider: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            providerAccountId: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            routingNumber: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            source: PgBuildColumn<
                "victor_account_bank_account_view",
                SetNotNull<PgTextBuilder<[string, ...string[]]>>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: true;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            sourceRecordId: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            status: PgBuildColumn<
                "victor_account_bank_account_view",
                SetNotNull<PgTextBuilder<[string, ...string[]]>>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: true;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            transactionCount: PgBuildColumn<
                "victor_account_bank_account_view",
                PgIntegerBuilder,
                {
                    data: number;
                    dataType: "number int32";
                    driverParam: string
                    | number;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            type: PgBuildColumn<
                "victor_account_bank_account_view",
                PgTextBuilder<[string, ...string[]]>,
                {
                    data: string;
                    dataType: "string";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: false;
                    tableName: "victor_account_bank_account_view";
                },
            >;
            updatedAt: PgBuildColumn<
                "victor_account_bank_account_view",
                SetNotNull<PgTimestampBuilder>,
                {
                    data: Date;
                    dataType: "object date";
                    driverParam: string;
                    enumValues: undefined;
                    generated: undefined;
                    hasDefault: false;
                    hasRuntimeDefault: false;
                    identity: undefined;
                    isAutoincrement: false;
                    isPrimaryKey: false;
                    name: string;
                    notNull: true;
                    tableName: "victor_account_bank_account_view";
                },
            >;
        },
    > = ...

    The VICTOR_ACCOUNT arm of bankAccountView — CFX's core accounts at Dart, with balances implied from the bank_transaction feed.

    The simplest of the five arms, and the one that establishes the shape the other four follow: a NOT MATERIALIZED CTE that resolves the source row and its owner, then one outer SELECT projecting bankAccountViewColumns() in declared order with the balance lateral joined on keyable.

    bank_id is the 'dart' literal rather than a column: victor_account has no bank FK because Victor is the Dart integration, and 'dart' is exactly what victorTransactionSyncActivities writes to bank_transaction.bank_id for these accounts. Every row here is keyable — both account columns are NOT NULL on the table.

    parent_key is deliberately NULL even for per-customer FBO rows. The table's own comment says a master pooled FBO carries a null customer_id, but whether per-customer FBOs are sub-ledgers of that pool or independent accounts at Dart is not something the schema states, and a wrong edge produces a confidently wrong rollup — see § 4.5 and open question 3.

    dbmate owns the DDL: the body below is mirrored by 20260814200000_bank_account_view.sql. securityInvoker is required, not decoration — every underlying table has RLS enabled, and without it the view would run with the owner's row visibility and silently bypass the querying role's policies.