beancount
    Preparing search index...

    Class Custom

    Represents a Custom entry for user-defined directives. Custom directives allow for extensibility with arbitrary types and values.

    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 Custom

    Properties

    comment?: string

    Optional comment text associated with this entry

    customType: Value

    The custom directive type

    date: PlainDate

    The date of this entry as a Temporal.PlainDate object

    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

    metadata?: Record<string, Value>

    Optional metadata key-value pairs associated with this entry

    type: "custom" = ...

    The type of this dated entry

    values?: Value[]

    Optional array of values associated with the custom directive

    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 an Entry instance. Default implementation returns the input unchanged. Subclasses can override this to handle custom deserialization logic (e.g., converting nested objects, handling dates, etc.).

      Parameters

      • json: Record<string, unknown>

        The JSON data to transform

      Returns Record<string, unknown>

      The transformed data ready for the constructor

    • 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