Member Junction
    Preparing search index...

    Base class for all accounting-related actions. Provides common functionality and patterns for interacting with accounting systems.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    accountingProvider: string

    The accounting provider this action is designed for (e.g., 'QuickBooks', 'NetSuite', etc.) Can be 'Generic' for provider-agnostic actions

    integrationName: string

    The integration name to look up in the Integration entity

    requestProvider: IMetadataProvider

    The request's metadata provider (RunActionParams.Provider), captured in Run so the connection and Credential lookups bind to it even in helpers that only receive the param array. undefined when the caller supplied none, and the lookups fall back to the global provider.

    AuthorizesCaller: boolean

    True when the action authorizes its caller itself, so a public entry point such as the RunAction mutation may run it for an authenticated user without an MJ: Action Authorizations link. Set it only on an action that either checks an authorization the caller must hold, or reads and writes only with the caller's own permissions. Leave it false for an action that acts with more authority than its caller, or that reaches data or sends messages the caller chooses but could not otherwise reach.

    The engine reads the marker only from the class that runs, never from its parent classes. A subclass that overrides a marked action must declare the marker again.

    Accessors

    • get SupportsAudience(): boolean

      Whether this action can bound what it returns to an audience (RunActionParams.Audience): everyone besides the caller who will see its output, such as the other participants of a shared conversation.

      false by default, and the engine enforces it: when a run's audience adds a reader beyond the caller, ActionEngineServer.RunAction refuses the action with result code AUDIENCE_UNSUPPORTED, without running it. Override to return true only when the action honours the audience in full — every record, snippet and count it returns is something every reader may see (pass the audience to the search engine, check each reader's entitlement to anything it scopes by, and leave out aggregates computed before that filtering).

      Returns boolean

    Methods

    • Helper to build consistent error messages for accounting operations

      Parameters

      • operation: string
      • details: string
      • OptionalsystemError: any

      Returns string

    • Resolve the company's ERP connection and invoke the plugin registered as ${verb}:${canonical provider name}.

      The connection is the one named by the CompanyIntegrationID param when given, otherwise the company's single active accounting connection. Its ID is then written into the params (added when absent) so the plugin runs against that same connection instead of looking one up again. Plugin.Run → InternalRunAction with the caller's params.

      Parameters

      Returns Promise<ActionResultSimple>

    • Common accounting parameters that many actions will need.

      CompanyIntegrationID names the exact MJ: Company Integrations row to run against. It is optional: without it the company's single active connection for the provider is used, and a company with more than one is refused rather than guessed at.

      Returns ActionParam[]

    • Gets the company's connection for this action's accounting provider.

      With companyIntegrationId, exactly that row is loaded; it must belong to companyId, be active, and be one of this provider's Integrations. Without it, the company's active connections for the provider (under any of its Integration names) are searched, and more than one match is an error that names them — the first match is never taken.

      Parameters

      • companyId: string

        The MJ Company the action runs for.

      • contextUser: UserInfo

        The user the lookup runs as.

      • OptionalcompanyIntegrationId: string

        Optional ID of the exact connection to use.

      Returns Promise<MJCompanyIntegrationEntity>

      The connection.

      Error when no connection, more than one connection, or an unusable connection is found.

    • Gets credentials from environment variables Format: BIZAPPS_{PROVIDER}{COMPANY_ID}{CREDENTIAL_TYPE} Example: BIZAPPS_QUICKBOOKS_12345_ACCESS_TOKEN

      Parameters

      • companyId: string
      • credentialType: string

      Returns string

    • Loads one connection by ID and checks that it can be used for companyId: it must exist, belong to that company, be active, and be one of allowedIntegrationNames.

      Parameters

      • companyIntegrationId: string
      • companyId: string
      • allowedIntegrationNames: readonly string[]
      • contextUser: UserInfo

      Returns Promise<MJCompanyIntegrationEntity>

      AccountingIntegrationError with a result code naming what is wrong.

    • Load the company's accounting CompanyIntegration: its single active connection whose Integration is any known ERP name or alias (or, with integrationName, any name of that provider). Does not hard-filter to a single vendor.

      More than one match is refused (AMBIGUOUS_ACCOUNTING_INTEGRATION), even when integrationName narrows the search: a company with a production and a sandbox connection to the same ERP must say which one with CompanyIntegrationID.

      Parameters

      • companyId: string
      • contextUser: UserInfo
      • OptionalintegrationName: string

      Returns Promise<ResolvedAccountingIntegration>

    • Validates journal entry balance (debits must equal credits)

      Parameters

      • lines: { credit?: number; debit?: number }[]

      Returns boolean