@memberjunction/actions-bizapps-accounting
v2.124.0
Published
Accounting system integration actions for MemberJunction
Readme
@memberjunction/actions-bizapps-accounting
Accounting system integration actions for MemberJunction. This package provides a standardized way to interact with various accounting systems through MemberJunction's action framework.
Overview
This package implements actions for common accounting operations across multiple accounting systems:
- QuickBooks Online ✅
- Microsoft Dynamics 365 Business Central ✅
- NetSuite (coming soon)
- Sage Intacct (coming soon)
- Microsoft Dynamics GP (coming soon)
Architecture
Base Classes
BaseAccountingAction: Abstract base class providing common functionality for all accounting actions
- Company-based credential management via CompanyIntegration entity
- Common parameter definitions
- Validation helpers for accounting data
- Error handling patterns
Provider-Specific Base Classes (e.g., QuickBooksBaseAction):
- Handle provider-specific authentication
- API request/response handling
- Data mapping between provider formats and standard formats
Authentication
The package uses MemberJunction's CompanyIntegration entity to store credentials:
- Each Company can have multiple accounting system integrations
- OAuth tokens, API keys, and other credentials are stored securely
- Automatic token expiration checking
Setup
- Create Integration Records: First, create Integration entity records for your accounting systems:
QuickBooks Online:
INSERT INTO Integration (Name, Description, NavigationBaseURL, ClassName)
VALUES ('QuickBooks Online', 'QuickBooks Online Accounting Integration',
'https://quickbooks.api.intuit.com', 'QuickBooksIntegration');Business Central:
INSERT INTO Integration (Name, Description, NavigationBaseURL, ClassName)
VALUES ('Microsoft Dynamics 365 Business Central', 'Business Central Accounting Integration',
'', 'BusinessCentralIntegration');- Configure CompanyIntegration: For each company, create a CompanyIntegration record:
QuickBooks Online:
INSERT INTO CompanyIntegration (CompanyID, IntegrationID, ExternalSystemID,
CustomAttribute1, IsActive)
VALUES (@CompanyID, @QuickBooksIntegrationID, @RealmID, 'production', 1); -- or 'sandbox'Business Central:
INSERT INTO CompanyIntegration (CompanyID, IntegrationID, ExternalSystemID,
CustomAttribute1, IsActive)
VALUES (@CompanyID, @BCIntegrationID, @BCCompanyID, 'production', 1);
-- CustomAttribute1: environment name (production, sandbox, or custom)
-- ExternalSystemID: Business Central company ID (GUID)- Set Environment Variables: Configure credentials via environment variables:
QuickBooks Online:
# QuickBooks credentials for a specific company
BIZAPPS_QUICKBOOKS_ONLINE_[COMPANY_ID]_ACCESS_TOKEN=your_access_token
BIZAPPS_QUICKBOOKS_ONLINE_[COMPANY_ID]_REFRESH_TOKEN=your_refresh_token
BIZAPPS_QUICKBOOKS_ONLINE_[COMPANY_ID]_REALM_ID=your_realm_id # Optional if in DB
# Example for company ID "12345-67890"
BIZAPPS_QUICKBOOKS_ONLINE_12345-67890_ACCESS_TOKEN=eyJhbGc...
BIZAPPS_QUICKBOOKS_ONLINE_12345-67890_REFRESH_TOKEN=AB11590...Business Central:
# Business Central credentials for a specific company
BIZAPPS_BUSINESS_CENTRAL_[COMPANY_ID]_ACCESS_TOKEN=your_access_token
BIZAPPS_BUSINESS_CENTRAL_[COMPANY_ID]_REFRESH_TOKEN=your_refresh_token
BIZAPPS_BUSINESS_CENTRAL_[COMPANY_ID]_TENANT_ID=your_tenant_id
# Example for company ID "12345-67890"
BIZAPPS_BUSINESS_CENTRAL_12345-67890_ACCESS_TOKEN=eyJhbGc...
BIZAPPS_BUSINESS_CENTRAL_12345-67890_REFRESH_TOKEN=AB11590...
BIZAPPS_BUSINESS_CENTRAL_12345-67890_TENANT_ID=00000000-0000-0000-0000-000000000000Credential Priority
The system checks for credentials in this order:
- Environment Variables (recommended for security)
- Database (CompanyIntegration entity - for backwards compatibility)
This allows you to:
- Keep sensitive credentials out of the database
- Use the database for non-sensitive configuration (realm ID, environment, etc.)
- Gradually migrate existing implementations
Available Actions
QuickBooks Online
1. GetQuickBooksGLCodesAction
Retrieves the Chart of Accounts from QuickBooks Online.
Parameters:
CompanyID(required): MemberJunction Company IDIncludeInactive: Include inactive accountsAccountTypes: Filter by account types (comma-separated)ParentAccountID: Filter by parent account
2. GetQuickBooksTransactionsAction
Retrieves transactions with flexible filtering across multiple transaction types.
Parameters:
CompanyID(required): MemberJunction Company IDTransactionType: Specific type (Invoice, Bill, Payment, etc.) or leave empty for allStartDate/EndDate: Transaction date rangeEntityID: Filter by customer or vendorStatus: Transaction status filterMinAmount/MaxAmount: Amount rangeMaxResults: Limit results (default: 100, max: 1000)
3. GetQuickBooksAccountBalancesAction
Retrieves account balances (trial balance) for a specific date.
Parameters:
CompanyID(required): MemberJunction Company IDAsOfDate: Balance snapshot date (defaults to today)AccountTypes: Filter by account typesIncludeInactive: Include inactive accountsIncludeZeroBalances: Include zero balance accounts (default: true)SummarizeByType: Return summary by account type
4. GetQuickBooksInvoicesAction
Retrieves customer invoices with comprehensive filtering.
Parameters:
CompanyID(required): MemberJunction Company IDCustomerID: Filter by specific customerStatus: All, Open, Paid, OverdueStartDate/EndDate: Invoice date rangeDueStartDate/DueEndDate: Due date rangeMinAmount/MaxAmount: Amount rangeIncludeLines: Include line items (default: true)
5. GetQuickBooksBillsAction
Retrieves vendor bills with comprehensive filtering.
Parameters:
CompanyID(required): MemberJunction Company IDVendorID: Filter by specific vendorStatus: All, Open, Paid, OverdueStartDate/EndDate: Bill date rangeDueStartDate/DueEndDate: Due date rangeMinAmount/MaxAmount: Amount rangeIncludeLines: Include line items (default: true)
6. GetQuickBooksCustomersAction
Retrieves customers with search and filtering options.
Parameters:
CompanyID(required): MemberJunction Company IDSearchText: Search by name, email, or phoneIncludeInactive: Include inactive customersMinBalance/MaxBalance: Balance rangeSortBy: DisplayName, Balance, CreatedDateIncludeBalances: Include balance info (default: true)
7. GetQuickBooksVendorsAction
Retrieves vendors with search and filtering options.
Parameters:
CompanyID(required): MemberJunction Company IDSearchText: Search by name, email, or phoneIncludeInactive: Include inactive vendorsOnly1099Vendors: Only 1099-eligible vendorsMinBalance/MaxBalance: Balance rangeSortBy: DisplayName, Balance, CreatedDate
8. CreateQuickBooksJournalEntryAction
Creates a journal entry with automatic validation.
Parameters:
CompanyID(required): MemberJunction Company IDLines(required): Array of journal entry linesEntryDate: Date of entry (defaults to today)DocNumber: Journal entry number (auto-generated if not provided)PrivateNote: Internal memoAdjustmentEntry: Mark as adjustment
Line Format:
{
accountId: string;
debit?: number; // Either debit or credit
credit?: number; // Must balance to zero
description?: string;
entityType?: 'Customer' | 'Vendor' | 'Employee';
entityId?: string;
classId?: string;
departmentId?: string;
}Microsoft Dynamics 365 Business Central
1. GetBusinessCentralGLAccountsAction
Retrieves the Chart of Accounts from Business Central.
Parameters:
CompanyID(required): MemberJunction Company IDIncludeBlocked: Include blocked accountsAccountTypes: Filter by types (Posting, Heading, Total)Categories: Filter by categories (Assets, Liabilities, Equity, etc.)MinBalance/MaxBalance: Balance range filtersMaxResults: Limit results (default: 1000)
2. GetBusinessCentralGeneralLedgerEntriesAction
Retrieves general ledger entries (journal entries) from Business Central.
Parameters:
CompanyID(required): MemberJunction Company IDStartDate/EndDate: Posting date rangeAccountNumber: Filter by GL accountDocumentNumber: Filter by document numberDocumentType: Filter by type (Payment, Invoice, etc.)MinAmount/MaxAmount: Amount rangeIncludeDimensions: Include dimension detailsMaxResults: Limit results (default: 500)
3. GetBusinessCentralCustomersAction
Retrieves customers from Business Central.
Parameters:
CompanyID(required): MemberJunction Company IDSearchText: Search by name, number, or emailIncludeBlocked: Include blocked customersCustomerType: Filter by Company or PersonMinBalance/MaxBalance: Balance rangeOnlyOverdue: Only customers with overdue amountsSortBy: Sort field (displayName, number, balance, etc.)MaxResults: Limit results (default: 100)
4. GetBusinessCentralSalesInvoicesAction
Retrieves sales invoices from Business Central.
Parameters:
CompanyID(required): MemberJunction Company IDCustomerNumber: Filter by customerStatus: Filter by status (Draft, Open, Paid, etc.)StartDate/EndDate: Invoice date rangeDueStartDate/DueEndDate: Due date rangeMinAmount/MaxAmount: Amount rangeOnlyUnpaid: Only invoices with balanceIncludeLines: Include line itemsMaxResults: Limit results (default: 100)
Usage Example
import { GetQuickBooksGLCodesAction } from '@memberjunction/actions-bizapps-accounting';
// In your action execution context
const action = new GetQuickBooksGLCodesAction();
const result = await action.RunAction({
CompanyID: 'your-company-id',
IncludeInactive: false,
AccountTypes: 'Bank,Expense,Income'
}, contextUser);
if (result.Success) {
const glCodes = result.Results.GLCodes;
console.log(`Retrieved ${glCodes.length} GL codes`);
}Adding New Providers
To add support for a new accounting system:
- Create a provider folder:
src/providers/[provider-name]/ - Extend
BaseAccountingActionwith a provider-specific base class - Implement the required actions extending your provider base class
- Update exports in
src/index.ts
Development
# Build the package
npm run build
# Watch mode for development
npm run watchFuture Enhancements
- Automatic token refresh for OAuth providers
- Webhook support for real-time updates
- Bulk operations support
- Advanced filtering and pagination
- Write operations (create journal entries, etc.)
