@memberjunction/actions-bizapps-accounting
Version:
Accounting system integration actions for MemberJunction
80 lines • 3.18 kB
TypeScript
import { BaseAction } from '@memberjunction/actions';
import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
import { UserInfo } from '@memberjunction/core';
import { CompanyIntegrationEntity } from '@memberjunction/core-entities';
/**
* Base class for all accounting-related actions.
* Provides common functionality and patterns for interacting with accounting systems.
*/
export declare abstract class BaseAccountingAction extends BaseAction {
/**
* The accounting provider this action is designed for (e.g., 'QuickBooks', 'NetSuite', etc.)
* Can be 'Generic' for provider-agnostic actions
*/
protected abstract accountingProvider: string;
/**
* The integration name to look up in the Integration entity
*/
protected abstract integrationName: string;
/**
* Cached company integration for the current execution
*/
private _companyIntegration;
/**
* Override of the required abstract method from BaseAction
*/
protected abstract InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
/**
* Helper to get a parameter value from the params array
*/
protected getParamValue(params: ActionParam[], name: string): any;
/**
* Common accounting parameters that many actions will need
*/
protected getCommonAccountingParams(): ActionParam[];
/**
* Gets the company integration record for the specified company and accounting system
*/
protected getCompanyIntegration(companyId: string, contextUser: UserInfo): Promise<CompanyIntegrationEntity>;
/**
* Gets credentials from environment variables
* Format: BIZAPPS_{PROVIDER}_{COMPANY_ID}_{CREDENTIAL_TYPE}
* Example: BIZAPPS_QUICKBOOKS_12345_ACCESS_TOKEN
*/
protected getCredentialFromEnv(companyId: string, credentialType: string): string | undefined;
/**
* Gets OAuth tokens - first tries environment variables, then falls back to database
*/
protected getOAuthTokens(integration: CompanyIntegrationEntity): Promise<{
accessToken: string;
refreshToken?: string;
}>;
/**
* Gets the base URL for API calls from the integration
*/
protected getAPIBaseURL(contextUser: UserInfo): Promise<string>;
/**
* Validates common accounting data formats
*/
protected validateAccountNumber(accountNumber: string): boolean;
/**
* Validates journal entry balance (debits must equal credits)
*/
protected validateJournalEntryBalance(lines: Array<{
debit?: number;
credit?: number;
}>): boolean;
/**
* Formats currency values consistently
*/
protected formatCurrency(amount: number, currencyCode?: string): string;
/**
* Standard date format for accounting systems (ISO 8601)
*/
protected formatAccountingDate(date: Date): string;
/**
* Helper to build consistent error messages for accounting operations
*/
protected buildAccountingErrorMessage(operation: string, details: string, systemError?: any): string;
}
//# sourceMappingURL=base-accounting-action.d.ts.map