Expand description
Shared implicit-price extraction logic.
Mirrors Python beancount’s implicit_prices plugin behavior. Used
by BOTH the BQL query path (rustledger-query::price) and the
native implicit_prices plugin (rustledger-plugin). Centralizing
avoids the parallel-implementations divergence that produced
issue #992: the plugin emitted @@ total amounts as per-unit
prices, while the query path correctly divided them.
The helper is generic over the currency type (T) because the
plugin and query paths use different transaction representations
(crate::Transaction with InternedStr vs
rustledger_plugin_types::TransactionData with String). Each
caller assembles its annotation/cost descriptors with its own
currency type and the helper returns the per-unit price already
paired with the matching currency — making mismatched
(number, currency) pairs impossible to construct.
Functions§
- extract_
per_ unit_ price - Decide the per-unit price implied by a posting and the quote currency to pair with it.