Fiscal-position resolution
The account addon owns fiscal positions and their account mappings. Taxes carry
fiscal_position_ids and original_tax_ids; replacing_tax_ids reads the inverse
of the same replacement relation. There is no separate position-tax model.
A position’s company, sequence, automatic-selection flag, VAT requirement, country/group/states and ZIP bounds are record configuration. Sequence starts at zero and uses the signed integer field’s bounds. An unset criterion does not restrict matching. Archive a position to remove it from automatic selection.
Native methods
Section titled “Native methods”Use ordinary model dispatch in an environment whose active company is the document’s company:
# async fn example(tx: &mut erp_sdk::Transaction, company: i64, partner: i64, taxes: Vec<i64>) -> erp_sdk::Result<()> {let positions = tx.env().with_company(company)?.records("account.fiscal.position")?;let selected: Option<i64> = positions.call(tx, "_get_fiscal_position", (partner, None::<i64>)).await?;let rule = positions.browse(selected)?;let mapped: Vec<i64> = rule.call(tx, "map_tax", (taxes,)).await?;# let _ = mapped;# Ok(()) }_get_fiscal_position(partner_id, delivery_id) returns an optional id. Manual positions
on the selected delivery address take precedence over the invoice partner’s manual
position; a manual position wins before automatic predicates. The EU-prefix/address
exception can select the invoice address instead. Without a manual rule, an invoice
partner lacking a country yields no rule. Candidates come from the selected company’s
ancestor chain and sort by company depth, sequence and id.
_fpos_matches(partner_id) is a singleton predicate. An addon overrides it through
Super dispatch, retaining the previous result and conjoining its own condition.
Partners expose _get_vat_required_valid() for a similar extension. Both are internal
native methods; declaring an override does not expose a new RPC method.
map_tax(Vec<i64>) returns ordered, deduplicated destination ids. A global tax or a
tax linked to this position can map to itself; a tax linked exclusively elsewhere is
removed. Active replacements can be one-to-many. An empty position retains the input.
map_account(i64) returns a mapped account id or its original id. Read access is
checked on inputs, the position and outputs.
The client tax picker (web_name_search) applies dynamic_fiscal_position_id before
ordering and limiting. It accepts false or a positive position id, preserves the caller’s
own domain and access rules, and includes unassigned taxes. The generic native
Records::name_search helper does not pass through this web-specific override.
Derived state and installation
Section titled “Derived state and installation”Tax/account maps are derived from their relations. Company domestic selection prefers the lowest sequence and, on a tie, an explicit country over a group. The company’s address country comes from its representative partner. This differs from foreign-VAT validation, which uses the configured fiscal country. Partner manual positions are company-dependent and use the existing commercial-field propagation mechanism.
Install or upgrade account through the normal module lifecycle. Version 1.1 adds the
position/mapping tables, tax relations and company/partner/group fields. Existing
companies receive an internal zero revision for concurrency fencing. This field is
unavailable through field access and is never a configuration control; a company create or
write that supplies it is refused, in superuser mode too (data files, imports and sudo
callers included). Concurrent
writers with a stale snapshot can receive a serialization error; the existing whole-unit
transaction boundary controls retries.
Default country groups and their fiscal exception states are installed as editable, non-overwritten data. No universal company position or account mapping is installed; company-specific chart packs supply those defaults later. Internal users can read rules; accounting administrators can create, edit and delete them. Company and relation checks remain active under the normal ORM paths.
Not yet available
Section titled “Not yet available”National validation of foreign VAT identifiers is unavailable. Saving a string trims it, removes spaces, dots and hyphens, uppercases it and refuses a string that becomes empty. This normalization does not establish legal validity. Explicit null clears the optional identifier. Equal normalized foreign identifiers can be used by several positions; a different identifier in the checked ancestor scope is refused. A refusal names the existing position only when the caller can read it.
The dedicated configuration screens, document-line application, price adaptation, chart-driven foreign-tax creation, provider integration and optional date windows are separate deliveries. No process-global matching cache or measured speed claim is made.