### Bkper-js Usage Example Source: https://github.com/bkper/bkper-js/blob/main/README.md Demonstrates how to set global configuration, create a Bkper instance, and perform basic operations like getting a book, listing books, and retrieving user information. ```typescript import { Bkper } from 'bkper-js'; // Set global configuration Bkper.setConfig({ apiKeyProvider: () => process.env.BKPER_API_KEY, oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN }); // Create Bkper instance (uses global config) const bkper = new Bkper(); // Get a book and work with it const book = await bkper.getBook('your-book-id'); console.log(`Book: ${book.getName()}`); // List all books const books = await bkper.getBooks(); console.log(`You have ${books.length} books`); // Get current user const user = await bkper.getUser(); console.log(`Logged in as: ${user.getName()}`); ``` -------------------------------- ### Install bkper-js Source: https://github.com/bkper/bkper-js/blob/main/README.md Instructions for installing the bkper-js library using different package managers. ```bash npm i -S bkper-js ``` ```bash yarn add bkper-js ``` ```bash bun add bkper-js ``` -------------------------------- ### Account Management Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Provides methods for managing Bkper accounts, including adding/removing groups, creating, deleting, updating, and retrieving account details. It also allows setting and getting account properties and types. ```APIDOC Account: __init__(book: Book, payload?: bkper.Account) Initializes an Account object. Parameters: book: The Book object associated with the account. payload: Optional payload for account data. addGroup(group: Group | bkper.Group): Account Adds a group to the account. Parameters: group: The Group object or its payload to add. Returns: The updated Account object. create(): Promise Creates the account in Bkper. Returns: A Promise that resolves with the created Account object. deleteProperty(key: string): Account Deletes a property from the account. Parameters: key: The key of the property to delete. Returns: The updated Account object. getGroups(): Promise Retrieves all groups associated with the account. Returns: A Promise that resolves with an array of Group objects. getId(): string | undefined Gets the unique identifier of the account. Returns: The account ID or undefined if not set. getName(): string | undefined Gets the name of the account. Returns: The account name or undefined if not set. getNormalizedName(): string Gets the normalized name of the account. Returns: The normalized account name. getProperties(): { [key: string]: string } Gets all properties of the account. Returns: An object containing account properties. getProperty(...keys: string[]): string | undefined Gets the value of one or more account properties. Parameters: keys: One or more property keys. Returns: The property value or undefined if not found. getType(): AccountType Gets the type of the account. Returns: The AccountType enum value. hasTransactionPosted(): boolean | undefined Checks if the account has any transactions posted. Returns: True if transactions are posted, false otherwise, or undefined. isArchived(): boolean | undefined Checks if the account is archived. Returns: True if archived, false otherwise, or undefined. isCredit(): boolean | undefined Checks if the account is a credit account. Returns: True if credit, false otherwise, or undefined. isInGroup(group: string | Group): Promise Checks if the account belongs to a specific group. Parameters: group: The Group object or its ID. Returns: A Promise that resolves with a boolean indicating group membership. isPermanent(): boolean | undefined Checks if the account is a permanent account. Returns: True if permanent, false otherwise, or undefined. json(): bkper.Account Returns the raw payload of the account. Returns: The bkper.Account payload object. remove(): Promise Deletes the account from Bkper. Returns: A Promise that resolves with the deleted Account object. removeGroup(group: string | Group): Promise Removes a group from the account. Parameters: group: The Group object or its ID to remove. Returns: A Promise that resolves with the updated Account object. setArchived(archived: boolean): Account Sets the archived status of the account. Parameters: archived: Boolean indicating the archived status. Returns: The updated Account object. setGroups(groups: Group[] | bkper.Group[]): Account Sets the groups associated with the account. Parameters: groups: An array of Group objects or their payloads. Returns: The updated Account object. setName(name: string): Account Sets the name of the account. Parameters: name: The new name for the account. Returns: The updated Account object. setProperties(properties: { [key: string]: string }): Account Sets all properties of the account. Parameters: properties: An object containing the properties to set. Returns: The updated Account object. setProperty(key: string, value: string | null): Account Sets or updates a property of the account. Parameters: key: The key of the property. value: The value of the property (can be null to remove). Returns: The updated Account object. setType(type: AccountType): Account Sets the type of the account. Parameters: type: The AccountType enum value. Returns: The updated Account object. update(): Promise Updates the account in Bkper with its current properties. Returns: A Promise that resolves with the updated Account object. ``` -------------------------------- ### Build and Development Commands Source: https://github.com/bkper/bkper-js/blob/main/CLAUDE.md Commands for building, compiling, testing, and managing the project using Bun. Includes full build pipeline, TypeScript compilation, watch mode, cleaning, and running tests. ```bash bun run build bun run build:compile bun run dev bun run clean ``` -------------------------------- ### Package Management and Versioning Source: https://github.com/bkper/bkper-js/blob/main/CLAUDE.md Commands for managing project dependencies, updating API types, version bumping, and publishing. Utilizes Bun as the package manager. ```bash bun run upgrade:api bun run patch bun run minor bun run major bun run preversion bun run postversion ``` -------------------------------- ### App Configuration and Management Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Enables the creation, updating, and retrieval of Bkper applications, including settings for menus, events, and developer information. ```APIDOC App: __init__(payload?: bkper.App) Initializes an App object. Parameters: payload: Optional payload for app data. create(): Promise Creates the app in Bkper. Returns: A Promise that resolves with the created App object. getDescription(): string | undefined Gets the description of the app. Returns: The app description or undefined. getEvents(): EventType[] | undefined Gets the event types associated with the app. Returns: An array of EventType or undefined. getFilePatterns(): string[] | undefined Gets the file patterns used by the app. Returns: An array of file patterns or undefined. getId(): string | undefined Gets the unique identifier of the app. Returns: The app ID or undefined if not set. getLogoUrl(): string | undefined Gets the URL for the app's logo. Returns: The logo URL or undefined. getLogoUrlDark(): string | undefined Gets the URL for the app's dark theme logo. Returns: The dark theme logo URL or undefined. getMenuPopupHeight(): string | undefined Gets the height of the app's menu popup. Returns: The menu popup height or undefined. getMenuPopupWidth(): string | undefined Gets the width of the app's menu popup. Returns: The menu popup width or undefined. getMenuText(): string | undefined Gets the text displayed for the app in the menu. Returns: The menu text or undefined. getMenuUrl(): string | undefined Gets the URL for the app's menu. Returns: The menu URL or undefined. getMenuUrlDev(): string | undefined Gets the development URL for the app's menu. Returns: The development menu URL or undefined. getName(): string | undefined Gets the name of the app. Returns: The app name or undefined if not set. getOwnerLogoUrl(): string | undefined Gets the URL for the owner's logo associated with the app. Returns: The owner logo URL or undefined. getOwnerName(): string | undefined Gets the name of the app's owner. Returns: The owner name or undefined. hasEvents(): boolean Checks if the app has any associated events. Returns: True if events are present, false otherwise. isConversational(): boolean Checks if the app is conversational. Returns: True if conversational, false otherwise. isPublished(): boolean Checks if the app is published. Returns: True if published, false otherwise. json(): bkper.App Returns the raw payload of the app. Returns: The bkper.App payload object. patch(): Promise Patches the app with its current properties. Returns: A Promise that resolves with the patched App object. setClientSecret(clientSecret?: string): App Sets the client secret for the app. Parameters: clientSecret: The client secret string. Returns: The updated App object. setConversationUrlDev(conversationUrlDev: string): App Sets the development URL for conversations. Parameters: conversationUrlDev: The development conversation URL. Returns: The updated App object. setDeveloperEmail(email?: string): App Sets the developer's email address for the app. Parameters: email: The developer's email address. Returns: The updated App object. setReadme(readme?: string): App Sets the README content for the app. Parameters: readme: The README content string. Returns: The updated App object. setUserEmails(emails?: string): App Sets the user emails associated with the app. Parameters: emails: A comma-separated string of user emails. Returns: The updated App object. setWebhookUrlDev(webhookUrlDev: string): App Sets the development webhook URL for the app. Parameters: webhookUrlDev: The development webhook URL. Returns: The updated App object. update(): Promise Updates the app in Bkper with its current properties. Returns: A Promise that resolves with the updated App object. ``` -------------------------------- ### Bkper.js API Documentation Source: https://github.com/bkper/bkper-js/blob/main/CLAUDE.md Documentation for the Bkper.js client library, detailing its core components, model layer, service layer, utilities, authentication methods, and build system. ```APIDOC Bkper.js Client Library Documentation Core Components: - src/index.ts: Main entry point, exports public classes and enums. - src/model/Bkper.ts: Bkper class, handles static configuration and resource access. Model Layer (src/model/): - Book: Represents accounting book entities. - Account, Transaction, Group: Core accounting entities. - App, User, Collection: Platform management entities. - Query, BalancesReport: Data querying and reporting. - Event, EventList, BotResponse: Event handling and bot integration. - Enums.ts: Enumeration types (Periodicity, DecimalSeparator, etc.). Service Layer (src/service/): - http-api-request.ts: Base HTTP client with authentication and error handling. - *-service.ts: Service classes for each resource type (e.g., book-service). - Uses axios for HTTP requests with OAuth2 Bearer token authentication. Utilities (src/utils.ts): - Date parsing, value parsing, text normalization, URL building. - Handles multiple date formats, decimal separators, and locale-specific formatting. Authentication & Configuration: - Global configuration: Bkper.setConfig(config) - Per-instance configuration: new Bkper(config) - Supports API key and OAuth2 authentication. - Default API base URL: https://app.bkper.com/_ah/api/bkper Build System: - TypeScript compilation with gts. - API Extractor for generating .d.ts files and API documentation. - Outputs ES modules (type: "module" in package.json). - Target: ES2015 with strict mode enabled. Dependencies: - Runtime: axios, big.js, dayjs/luxon, @google-cloud/local-auth - Peer: @bkper/bkper-api-types - Dev: TypeScript, Mocha, Chai, API Extractor, gts Key Patterns: - Consistent model class patterns with service layer delegation. - Async/await with Promise-based APIs. - Static configuration with instance-based resource access. - Flexible configuration (global or per-instance). - Fluent/chainable API design. - Comprehensive error handling with structured HTTP error responses. ``` -------------------------------- ### Bkper Class Configuration Source: https://github.com/bkper/bkper-js/blob/main/CLAUDE.md Demonstrates how to configure the Bkper client library, either globally using a static method or per-instance via the constructor. Supports API key and OAuth2 authentication. ```typescript import { Bkper } from "@bkper/bkper-js"; // Global configuration Bkper.setConfig({ apiKey: "YOUR_API_KEY", // or OAuth2 provider tokenProvider: async () => "YOUR_OAUTH2_TOKEN" }); // Per-instance configuration const bkper = new Bkper({ apiKey: "YOUR_API_KEY" }); ``` -------------------------------- ### Testing Commands Source: https://github.com/bkper/bkper-js/blob/main/CLAUDE.md Commands for executing tests using Mocha and Chai. Details how to run all tests or specific test files with custom TypeScript compiler options. ```bash bun run test env TS_NODE_COMPILER_OPTIONS='{"rootDir": "." }' mocha -r ts-node/register 'test/specific-file.spec.ts' ``` -------------------------------- ### Bkper Class Methods Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md The main class for interacting with the Bkper API, providing methods to manage books, users, and configurations. ```APIDOC Bkper: constructor() Initializes the Bkper client. getApps(): Promise Retrieves a list of available apps. getBillingPortalUrl(returnUrl: string): Promise Gets the URL for the billing portal. getBook(id: string, includeAccounts?: boolean, includeGroups?: boolean): Promise Retrieves a specific book by its ID. getBooks(query?: string): Promise Retrieves a list of books, optionally filtered by a query. getCollections(): Promise Retrieves a list of collections. getConversations(): Promise Retrieves a list of conversations. getTemplates(): Promise Retrieves a list of templates. getUser(): Promise Retrieves the current user's information. static setConfig(config: Config): void Sets the global configuration for the Bkper library. ``` -------------------------------- ### Template Class Methods Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Provides information about Bkper templates, including book links, categories, descriptions, image URLs, and usage statistics. ```APIDOC Template: constructor(json?: bkper.Template) Initializes a new Template instance. - json: Optional initial data for the template. getBookId(): string | undefined Gets the ID of the book associated with the template. getBookLink(): string | undefined Gets the URL to the book associated with the template. getCategory(): string | undefined Gets the category of the template. getDescription(): string | undefined Gets the description of the template. getImageUrl(): string | undefined Gets the URL of the template's image. getName(): string | undefined Gets the name of the template. getSheetsLink(): string | undefined Gets the link to the Google Sheets associated with the template. getTimesUsed(): number Gets the number of times the template has been used. json(): bkper.Template Returns the JSON representation of the template. payload: bkper.Template The raw payload of the template. ``` ```javascript export class Template { constructor(json?: bkper.Template); getBookId(): string | undefined; getBookLink(): string | undefined; getCategory(): string | undefined; getDescription(): string | undefined; getImageUrl(): string | undefined; getName(): string | undefined; getSheetsLink(): string | undefined; getTimesUsed(): number; json(): bkper.Template; payload: bkper.Template; } ``` -------------------------------- ### Bkper Connection Class Methods Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Provides methods for managing Bkper connections, including setting properties, retrieving connection details, and managing integrations. ```APIDOC Connection: constructor(payload?: bkper.Connection) Initializes a new Connection instance. clearTokenProperties(): void Clears all token-related properties from the connection. create(): Promise Creates a new connection. deleteProperty(key: string): Connection Deletes a specific property from the connection. getAgentId(): string | undefined Gets the agent ID associated with the connection. getDateAddedMs(): string | undefined Gets the date the connection was added (in milliseconds). getEmail(): string | undefined Gets the email address associated with the connection. getId(): string | undefined Gets the unique identifier of the connection. getIntegrations(): Promise Retrieves all integrations associated with the connection. getLogo(): string | undefined Gets the logo URL for the connection. getName(): string | undefined Gets the name of the connection. getProperties(): { [key: string]: string } Retrieves all custom properties of the connection. getProperty(...keys: string[]): string | undefined Retrieves a specific property value by its key(s). getPropertyKeys(): string[] Gets an array of all property keys for the connection. getType(): "APP" | "BANK" | undefined Gets the type of the connection (APP or BANK). getUUID(): string | undefined Gets the UUID of the connection. json(): bkper.Connection Returns the connection data in JSON format. payload: bkper.Connection The raw payload of the connection object. remove(): Promise Removes the connection. setAgentId(agentId: string): Connection Sets the agent ID for the connection. setName(name: string): Connection Sets the name of the connection. setProperties(properties: { [key: string]: string }): Connection Sets multiple custom properties for the connection. setProperty(key: string, value: string | null): Connection Sets a specific property for the connection. setType(type: "APP" | "BANK"): Connection Sets the type of the connection. ``` -------------------------------- ### BalancesDataTableBuilder Methods Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Provides methods to configure and build a data table for balances, allowing customization of display options. ```APIDOC BalancesDataTableBuilder: constructor(book: Book, balancesContainers: BalancesContainer[], periodicity: Periodicity) Initializes the builder with book, balances containers, and periodicity. build(): any[][] Builds and returns the data table. expanded(expanded: boolean | number): BalancesDataTableBuilder Sets whether the table should be expanded. formatDates(format: boolean): BalancesDataTableBuilder Enables or disables date formatting. formatValues(format: boolean): BalancesDataTableBuilder Enables or disables value formatting. hideDates(hide: boolean): BalancesDataTableBuilder Enables or disables hiding dates. hideNames(hide: boolean): BalancesDataTableBuilder Enables or disables hiding names. period(period: boolean): BalancesDataTableBuilder Sets the period display option. properties(include: boolean): BalancesDataTableBuilder Sets whether to include properties. raw(raw: boolean): BalancesDataTableBuilder Sets whether to display raw values. transposed(transposed: boolean): BalancesDataTableBuilder Sets whether the table should be transposed. trial(trial: boolean): BalancesDataTableBuilder Sets the trial balance option. type(type: BalanceType): BalancesDataTableBuilder Sets the type of balance to display (CUMULATIVE, PERIOD, TOTAL). ``` -------------------------------- ### Bkper Config Interface Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Defines the configuration options for the Bkper SDK, including API base URL, authentication providers, and request handlers. ```APIDOC Config: apiBaseUrl?: string The base URL for the Bkper API. apiKeyProvider?: () => Promise A function that provides the API key. oauthTokenProvider?: () => Promise A function that provides the OAuth token. requestErrorHandler?: (error: any) => any A handler for request errors. requestHeadersProvider?: () => Promise<{ [key: string]: string }> A function that provides custom request headers. requestRetryHandler?: (status?: number, error?: any, attempt?: number) => Promise A handler for retrying requests. ``` -------------------------------- ### User API Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Provides methods for retrieving and managing user information, including profile details, connections, and subscription status. ```APIDOC User: constructor(payload?: bkper.User) Initializes a new User object. getAvatarUrl(): string | undefined Retrieves the URL of the user's avatar. getConnection(id: string): Promise Retrieves a specific connection by its ID. getConnections(): Promise Retrieves all connections for the user. getDaysLeftInTrial(): number | undefined Retrieves the number of days remaining in the user's trial. getEmail(): string | undefined Retrieves the user's email address. getFullName(): string | undefined Retrieves the user's full name. getHostedDomain(): string | undefined Retrieves the user's hosted domain. getId(): string | undefined Retrieves the user's unique identifier. getName(): string | undefined Retrieves the user's name. getPlan(): string | undefined Retrieves the user's current plan. hasBillingEnabled(): boolean | undefined Checks if billing is enabled for the user. hasStartedTrial(): boolean | undefined Checks if the user has started their trial. hasUsedConnections(): boolean | undefined Checks if the user has used any connections. isFree(): boolean | undefined Checks if the user is on a free plan. json(): bkper.User Returns the raw user payload. payload: bkper.User The raw user payload. ``` -------------------------------- ### File Class Methods Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Represents a file within Bkper, allowing for creation, content retrieval, and access to file metadata like name, size, and URL. ```APIDOC File: constructor(book: Book, payload?: bkper.File) Initializes a new File instance. book: The Book associated with the file. payload: Optional payload for the file. create(): Promise Creates a new file. Returns: A Promise that resolves with the created File object. getContent(): Promise Retrieves the content of the file. Returns: A Promise that resolves with the file content or undefined. getContentType(): string | undefined Gets the content type of the file. Returns: The content type string or undefined. getId(): string | undefined Gets the unique identifier of the file. Returns: The file ID or undefined. getName(): string | undefined Gets the name of the file. Returns: The file name or undefined. getSize(): number | undefined Gets the size of the file in bytes. Returns: The file size or undefined. getUrl(): string | undefined Gets the URL of the file. Returns: The file URL or undefined. json(): bkper.File Converts the File object to its raw payload representation. Returns: The bkper.File payload object. payload: bkper.File The raw payload of the file. setContent(content: string): File Sets the content of the file. content: The file content. Returns: The updated File object. setContentType(contentType: string): File Sets the content type of the file. contentType: The content type. Returns: The updated File object. setName(name: string): File Sets the name of the file. name: The file name. Returns: The updated File object. ``` -------------------------------- ### Query Class Methods Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Manages query objects, allowing for creation, retrieval, updating, and deletion of queries associated with a book. ```APIDOC Query: constructor(book: Book, payload?: bkper.Query) Initializes a new Query instance. - book: The book this query belongs to. - payload: Optional initial data for the query. create(): Promise Creates the query. getId(): string | undefined Gets the unique ID of the query. getQuery(): string | undefined Gets the query string. getTitle(): string | undefined Gets the title of the query. json(): bkper.Query Returns the JSON representation of the query. payload: bkper.Query The raw payload of the query. remove(): Promise Removes the query. setQuery(query: string): Query Sets the query string. - query: The new query string. setTitle(title: string): Query Sets the title of the query. - title: The new title for the query. update(): Promise Updates the query. ``` ```javascript export class Query { constructor(book: Book, payload?: bkper.Query); create(): Promise; getId(): string | undefined; getQuery(): string | undefined; getTitle(): string | undefined; json(): bkper.Query; payload: bkper.Query; remove(): Promise; setQuery(query: string): Query; setTitle(title: string): Query; update(): Promise; } ``` -------------------------------- ### Bkper Book Class Methods Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Provides methods for retrieving and manipulating book data, including properties, transactions, and settings. It also includes methods for updating book information and managing integrations. ```APIDOC Book: getMostRecentLockDate_(): string | null Retrieves the most recent lock date for the book. getName(): string | undefined Gets the name of the book. getOwnerName(): string | undefined Gets the name of the book's owner. getPageSize(): number | undefined Gets the page size setting for the book. getPeriod(): Period Gets the accounting period for the book. getPeriodStartMonth(): Month Gets the starting month of the accounting period. getPermission(): Permission Gets the user's permission level for the book. getProperties(): { [key: string]: string } Retrieves all custom properties associated with the book. getProperty(...keys: string[]): string | undefined Retrieves a specific property value by its key(s). getSavedQueries(): Promise Fetches all saved queries associated with the book. getTimeZone(): string | undefined Gets the time zone configured for the book. getTimeZoneOffset(): number | undefined Gets the time zone offset in minutes. getTotalTransactions(): number Gets the total number of transactions in the book. getTotalTransactionsCurrentMonth(): number Gets the total number of transactions for the current month. getTotalTransactionsCurrentYear(): number Gets the total number of transactions for the current year. getTransaction(id: string): Promise Retrieves a specific transaction by its ID. getVisibility(): Visibility Gets the visibility setting of the book. json(): bkper.Book Returns the book data in JSON format. listEvents(afterDate: string | null, beforeDate: string | null, onError: boolean, resourceId: string | null, limit: number, cursor?: string): Promise Lists events associated with the book, with options for date range, error status, resource ID, and pagination. listTransactions(query?: string, limit?: number, cursor?: string): Promise Lists transactions in the book, with optional query filtering and pagination. parseDate(date: string): Date Parses a date string into a Date object. parseValue(value: string): Amount | undefined Parses a string value into an Amount object. payload: bkper.Book The raw payload of the book object. queries?: Query[] An optional array of saved queries. round(value: Amount | number): Amount Rounds a given value (Amount or number) to the book's precision. setAccount(account: bkper.Account, remove?: boolean): void Sets or removes an account for the book. setAutoPost(autoPost: boolean): Book Sets the auto-post status for the book. setClosingDate(closingDate: string | null): Book Sets the closing date for the book. setDatePattern(datePattern: string): Book Sets the date pattern for the book. setDecimalSeparator(decimalSeparator: DecimalSeparator): Book Sets the decimal separator for the book. setFractionDigits(fractionDigits: number): Book Sets the number of fraction digits for the book. setGroup(group: bkper.Group, remove?: boolean): void Sets or removes a group for the book. setLockDate(lockDate: string | null): Book Sets the lock date for the book. setName(name: string): Book Sets the name of the book. setPageSize(pageSize: number): Book Sets the page size for the book. setPeriod(period: Period): Book Sets the accounting period for the book. setPeriodStartMonth(month: Month): Book Sets the starting month of the accounting period. setProperties(properties: { [key: string]: string }): Book Sets multiple custom properties for the book. setProperty(key: string, value: string | null): Book Sets a specific property for the book. setTimeZone(timeZone: string): Book Sets the time zone for the book. update(): Promise Updates the book on the server. updateIntegration(integration: bkper.Integration): Promise Updates an integration associated with the book. ``` -------------------------------- ### Amount Handling Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Provides a robust way to handle monetary amounts, supporting arithmetic operations, comparisons, and formatting. ```APIDOC Amount: __init__(n: number | string | Amount) Initializes an Amount object. Parameters: n: The initial numeric value, string representation, or another Amount object. abs(): Amount Returns the absolute value of the amount. Returns: A new Amount object with the absolute value. cmp(n: number | string | Amount): -1 | 0 | 1 Compares this amount with another. Parameters: n: The value to compare against. Returns: -1 if less than, 0 if equal, 1 if greater than. static create(): Amount Internal method to create a new Amount instance. div(n: number | string | Amount): Amount Divides this amount by another. Parameters: n: The divisor. Returns: A new Amount object representing the result. eq(n: number | string | Amount): boolean Checks if this amount is equal to another. Parameters: n: The value to compare against. Returns: True if equal, false otherwise. gt(n: number | string | Amount): boolean Checks if this amount is greater than another. Parameters: n: The value to compare against. Returns: True if greater than, false otherwise. gte(n: number | string | Amount): boolean Checks if this amount is greater than or equal to another. Parameters: n: The value to compare against. Returns: True if greater than or equal to, false otherwise. lt(n: number | string | Amount): boolean Checks if this amount is less than another. Parameters: n: The value to compare against. Returns: True if less than, false otherwise. lte(n: number | string | Amount): boolean Checks if this amount is less than or equal to another. Parameters: n: The value to compare against. Returns: True if less than or equal to, false otherwise. minus(n: number | string | Amount): Amount Subtracts another amount from this one. Parameters: n: The amount to subtract. Returns: A new Amount object representing the result. mod(n: number | string | Amount): Amount Calculates the modulo of this amount with another. Parameters: n: The modulus. Returns: A new Amount object representing the remainder. plus(n: number | string | Amount): Amount Adds another amount to this one. Parameters: n: The amount to add. Returns: A new Amount object representing the sum. round(dp?: number): Amount Rounds the amount to a specified number of decimal places. Parameters: dp: The number of decimal places (defaults to 0). Returns: A new Amount object with the rounded value. times(n: number | string | Amount): Amount Multiplies this amount by another. Parameters: n: The multiplier. Returns: A new Amount object representing the product. toFixed(dp?: number): string Formats the amount as a string with a specified number of decimal places. Parameters: dp: The number of decimal places (defaults to 0). Returns: The formatted string representation. toNumber(): number Converts the amount to a standard JavaScript number. Returns: The numeric value. toString(): string Returns the string representation of the amount. Returns: The string value. ``` -------------------------------- ### BalancesContainer Interface Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Defines the interface for containers holding balance information, providing access to accounts, balances, and reports. ```APIDOC BalancesContainer: createDataTable(): BalancesDataTableBuilder Creates a builder for a data table of balances. Returns: A BalancesDataTableBuilder instance. getAccount: () => Promise Retrieves the Account associated with this balances container. Returns: A Promise resolving to the Account or null. getBalances: () => Balance[] Retrieves all Balance objects within this container. Returns: An array of Balance objects. getBalancesContainer: (name: string) => BalancesContainer Retrieves a nested BalancesContainer by name. Parameters: name: The name of the nested container. Returns: The requested BalancesContainer. getBalancesContainers: () => BalancesContainer[] Retrieves all nested BalancesContainer objects. Returns: An array of BalancesContainer objects. getBalancesReport: () => BalancesReport Retrieves the BalancesReport associated with this container. Returns: The BalancesReport object. getCumulativeBalance: () => Amount Gets the cumulative balance for the container. Returns: The cumulative balance as an Amount object. getCumulativeBalanceRaw: () => Amount Gets the raw cumulative balance for the container. Returns: The raw cumulative balance as an Amount object. getCumulativeBalanceRawText: () => string Gets the raw cumulative balance as a formatted string. Returns: The raw cumulative balance string. getCumulativeBalanceText: () => string Gets the cumulative balance as a formatted string. Returns: The cumulative balance string. ``` -------------------------------- ### BalancesReport Methods Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Represents a financial report containing balances, with methods to create data tables and access report details. ```APIDOC BalancesReport: constructor(book: Book, payload: bkper.Balances) Initializes the report with a book and payload. createDataTable(): BalancesDataTableBuilder Creates a BalancesDataTableBuilder for this report. getBalancesContainer(name: string): BalancesContainer Retrieves a specific balances container by name. getBalancesContainers(): BalancesContainer[] Returns all balances containers in the report. getBook(): Book Returns the book associated with this report. getPeriodicity(): Periodicity Returns the periodicity of the report. payload: bkper.Balances The underlying payload data for the balances report. ``` -------------------------------- ### Integration Class Methods Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Manages integration settings, including deleting properties, retrieving integration details like agent ID, book ID, logos, names, and updating properties. ```APIDOC Integration: constructor(payload?: bkper.Integration) Initializes a new Integration instance. - payload: Optional initial data for the integration. deleteProperty(key: string): Integration Deletes a specific property from the integration. - key: The key of the property to delete. getAddedBy(): string | undefined Gets the user who added the integration. getAgentId(): string | undefined Gets the ID of the associated agent. getBookId(): string | undefined Gets the ID of the book associated with the integration. getDateAddedMs(): string | undefined Gets the timestamp (in milliseconds) when the integration was added. getId(): string | undefined Gets the unique ID of the integration. getLastUpdateMs(): string | undefined Gets the timestamp (in milliseconds) of the last update. getLogo(): string | undefined Gets the URL of the integration's logo. getName(): string | undefined Gets the name of the integration. getProperties(): { [key: string]: string } Gets all properties of the integration. getProperty(...keys: string[]): string | undefined Gets the value of one or more properties. - keys: One or more property keys. json(): bkper.Integration Returns the JSON representation of the integration. payload: bkper.Integration The raw payload of the integration. remove(): Promise Removes the integration. setProperties(properties: { [key: string]: string }): Integration Sets multiple properties for the integration. - properties: An object containing key-value pairs of properties. setProperty(key: string, value: string | null): Integration Sets a single property for the integration. - key: The property key. - value: The property value, or null to remove the property. ``` ```javascript export class Integration { constructor(payload?: bkper.Integration); deleteProperty(key: string): Integration; getAddedBy(): string | undefined; getAgentId(): string | undefined; getBookId(): string | undefined; getDateAddedMs(): string | undefined; getId(): string | undefined; getLastUpdateMs(): string | undefined; getLogo(): string | undefined; getName(): string | undefined; getProperties(): { [key: string]: string; }; getProperty(...keys: string[]): string | undefined; json(): bkper.Integration; payload: bkper.Integration; remove(): Promise; setProperties(properties: { [key: string]: string; }): Integration; setProperty(key: string, value: string | null): Integration; } ``` -------------------------------- ### TransactionList API Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Provides methods for interacting with a list of transactions, including retrieving accounts, cursors, and individual transactions. ```APIDOC TransactionList: constructor(book: Book, payload: bkper.TransactionList) Initializes a new TransactionList. getAccount(): Promise Retrieves the account associated with the transaction list. getCursor(): string | undefined Retrieves the cursor for pagination. getFirst(): Transaction | undefined Retrieves the first transaction in the list. getItems(): Transaction[] Retrieves all transactions in the list. size(): number Returns the number of transactions in the list. ``` -------------------------------- ### BalancesContainer Methods Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Provides methods to retrieve cumulative and period balances, group information, and other properties of a balances container. ```APIDOC BalancesContainer: getCumulativeCredit(): Amount Returns the cumulative credit amount. getCumulativeCreditText(): string Returns the cumulative credit amount as a formatted string. getCumulativeDebit(): Amount Returns the cumulative debit amount. getCumulativeDebitText(): string Returns the cumulative debit amount as a formatted string. getDepth: () => number Returns the depth of the container. getGroup: () => Promise Asynchronously retrieves the associated group. getName: () => string Returns the name of the container. getNormalizedName: () => string Returns the normalized name of the container. getParent: () => BalancesContainer | null Returns the parent balances container, if any. getPeriodBalance: () => Amount Returns the balance for the current period. getPeriodBalanceRaw: () => Amount Returns the raw period balance amount. getPeriodBalanceRawText: () => string Returns the raw period balance amount as a formatted string. getPeriodBalanceText: () => string Returns the period balance amount as a formatted string. getPeriodCredit(): Amount Returns the credit amount for the current period. getPeriodCreditText(): string Returns the period credit amount as a formatted string. getPeriodDebit(): Amount Returns the debit amount for the current period. getPeriodDebitText(): string Returns the period debit amount as a formatted string. getProperties(): { [key: string]: string } Returns an object containing all properties. getProperty(...keys: string[]): string | undefined Retrieves the value of one or more properties. getPropertyKeys(): string[] Returns an array of property keys. hasGroupBalances: () => boolean Checks if the container has group balances. isCredit: () => boolean | undefined Checks if the container represents a credit balance. isFromAccount: () => boolean Checks if the container is from an account. isFromGroup: () => boolean Checks if the container is from a group. isPermanent: () => boolean Checks if the container is permanent. payload: bkper.AccountBalances | bkper.GroupBalances The underlying payload data for the balances container. ``` -------------------------------- ### Bkper Collection Class Methods Source: https://github.com/bkper/bkper-js/blob/main/etc/bkper-js.api.md Provides methods for managing collections of books, including creating, updating, and removing collections and their associated books. ```APIDOC Collection: constructor(payload?: bkper.Collection) Initializes a new Collection instance. addBooks(books: Book[]): Promise Adds multiple books to the collection. create(): Promise Creates a new collection. getBooks(): Book[] Retrieves all books within the collection. getId(): string | undefined Gets the unique identifier of the collection. getName(): string | undefined Gets the name of the collection. getOwnerUsername(): string | undefined Gets the username of the collection owner. getPermission(): Permission | undefined Gets the permission level for the collection. getUpdatedAt(): string | undefined Gets the timestamp when the collection was last updated. json(): bkper.Collection Returns the collection data in JSON format. payload: bkper.Collection The raw payload of the collection object. remove(): Promise Removes the collection and all its associated books. removeBooks(books: Book[]): Promise Removes multiple books from the collection. setName(name: string): Collection Sets the name of the collection. update(): Promise Updates the collection on the server. ```