beancount
    Preparing search index...

    Class Transaction

    Represents a Beancount transaction entry. Transactions record financial movements between accounts with postings.

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a new DateEntry instance.

      Parameters

      • obj: { date: string | PlainDate; [key: string]: unknown }

        Object containing entry properties

        • [key: string]: unknown
        • date: string | PlainDate

          The date string in YYYY-MM-DD format

      Returns Transaction

    Properties

    comment?: string

    Optional comment text associated with this entry

    date: PlainDate

    The date of this entry as a Temporal.PlainDate object

    flag?: string

    Optional transaction flag (e.g., '*' for cleared, '!' for pending)

    internalMetadata: Record<string, unknown> = {}

    Internal metadata key-value pairs associated with this entry. These can be anything, are not used in the output, and are meant to be used to allow your pipeline to keep track of an internal property

    links: Set<string>

    Set of link identifiers associated with this transaction

    metadata?: Record<string, Value>

    Optional metadata key-value pairs associated with this entry

    narration?: string

    Optional narration/description of the transaction

    payee: string

    The payee of the transaction

    postingComments: PostingComment[]

    Array of comments under this transaction (mixed in with the postings)

    postings: Posting[]

    Array of postings (account movements) in this transaction

    tags: Tag[]

    Array of tags associated with this transaction (from inline tags and tag stack)

    type: "transaction" = ...

    The type of this dated entry

    Methods

    • Converts metadata and comment to a formatted string. If metadata exists, each key-value pair is formatted on separate indented lines.

      Returns string

      The formatted metadata and comment string, or empty string if neither exists

    • Transforms JSON data before creating a Transaction instance. Deserializes transaction-specific properties including postings, tags, links, and metadata.

      Parameters

      • json: Record<string, unknown>

        The JSON data to transform

      Returns Record<string, unknown>

      The transformed data with:

      • postings converted to Posting instances
      • tags converted to Tag instances
      • links converted from array to Set
      • metadata values converted to Value instances
    • Converts this entry to a formatted string with aligned columns. Default implementation delegates to toString(). Subclasses can override for custom formatting.

      Parameters

      • formatOptions: FormatOptions = defaultFormatOptions

        Formatting options (unused in base implementation)

      Returns string

      The formatted string representation of this entry

    • Creates an Entry instance from JSON data. Calls fromJSONData to allow subclasses to transform the data before construction.

      Type Parameters

      Parameters

      • this: new (obj: any) => T
      • jsonString: string

        JSON data representing an entry

      Returns T

      A new instance of the Entry subclass

      Warning: No validation is performed on the JSON input. We assume the JSON is valid and well-formed.

    • Creates an Entry instance from JSON data. Calls fromJSONData to allow subclasses to transform the data before construction.

      Type Parameters

      Parameters

      • this: new (obj: any) => T
      • jsonData: Record<string, unknown>

        object representing an entry

      Returns T

      A new instance of the Entry subclass

      Warning: No validation is performed on the input. We assume the input is valid and well-formed.

    • Creates an Entry instance from a Beancount string. Parses the input string and constructs the appropriate Entry subclass.

      Type Parameters

      Parameters

      • this: EntryConstructor<T>
      • input: string

        A single Beancount entry as a string

      Returns T

      A new instance of the Entry subclass