Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typed metadata not handled on commodities #271

Open
zacchiro opened this issue Jan 21, 2025 · 1 comment
Open

Typed metadata not handled on commodities #271

zacchiro opened this issue Jan 21, 2025 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@zacchiro
Copy link
Collaborator

zacchiro commented Jan 21, 2025

Typed metadata are handled like regular metadata (and hence always rendered as string literals) when used on commodities (at least), whereas they work properly on transactions.

For example, the following ledger snippet:

commodity EUR
    note Euro
    format 1000.00 EUR
    ; normal_metadata: 42.0
    ; typed_metadata:: 42.0

2025-01-21 * salary
    ; normal_metadata: 42.0
    ; typed_metadata:: 42.0
    Income:Salary                                               -1000.00 EUR
    Assets:Checking                                              1000.00 EUR

is translated by ledger2beancount to the following beancount snippet:

1970-01-01 commodity EUR
    name: "Euro"
    normal_metadata: "42.0"
    typed_metadata: "42.0"

2025-01-21 * "salary"
    normal_metadata: "42.0"
    typed_metadata: 42.0
    Income:Salary                                               -1000.00 EUR
    Assets:Checking                                              1000.00 EUR

Note the (incorrect) double quotes around typed_metadata value in the EUR commodity, which are (correctly) missing in the transaction case.

@zacchiro zacchiro added the bug Something isn't working label Jan 21, 2025
@tbm
Copy link
Collaborator

tbm commented Jan 23, 2025

Nice catch.

The problem is that we use pp_metadata to print this (line 2625) which doesn't handle typed metadata where for transactions we create a metadata object using create_metadata_from_regex (line 1143) and that is printed correctly.

I need to check how to harmonize/unify this.

I'm away for 10 days starting on Saturday, so this will have to wait until February.

@tbm tbm added this to the 2.8 milestone Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants