Skip to content

Question about account_map #171

@F-TD5X

Description

@F-TD5X

For code in https://github.com/beancount/beangulp/blob/35fea180ed65dbe9113e1566c88ba34b38d1fcb5/beangulp/similar.py#L221C1-L222C21 which skips interpolated posting.

def amounts_map(entry):
    """Compute a mapping of (account, currency) -> Decimal balances.

    Args:
      entry: A Transaction instance.
    Returns:
      A dict of account -> Amount balance.
    """
    amounts = collections.defaultdict(Decimal)
    for posting in entry.postings:
        # Skip interpolated postings.
        if posting.meta and interpolate.AUTOMATIC_META in posting.meta:
            continue
        currency = isinstance(posting.units, amount.Amount) and posting.units.currency
        if isinstance(currency, str):
            key = (posting.account, currency)
            amounts[key] += posting.units.number
    return amounts

If there are some hand write transaction in history like:

2000-01-01 * 
    Assets:A -100 USD
    Expenses:B

And when importer generates something and let smart_importer to predict another posting, the transaction in deduplicate progress would be like:

2000-01-01 *
    Expenses:B 100 USD

The heuristic_comparator() will not consider these two transaction as duplicated because the account is not same.
One is {"Assets:A": "-100"}, and another one is {"Expenses:B": "100"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions