Adds golden_helpers (dados_from_json/serialize_infnfe, package modules so
the auto's parity test and the future service can import them directly) and
6 golden cases under src/sowai_fiscal/goldens/ as package data:
- caso_padrao_intra: preset Padrao, PR->PR, CSOSN 102/CFOP 5102, 2 itens
- caso_padrao_inter: PR->SP, CFOP 6102, idDest=2
- caso_st_intra: Oleos, CSOSN 500/CFOP 5405, grupo ICMSSN500 (vBCSTRet/pST/vICMSSTRet)
- caso_devolucao_intra: tipo_operacao devolucao, CFOP 1202
- caso_com_ub: FiscalResult com linhas ibs/cbs (grupo UB presente -- builder
suporta estruturalmente mesmo com o guard de emissao do auto bloqueando hoje)
- caso_fracao_centavo: qty 1.5 x 0.01, 2 linhas -- prova o arredondamento
por-item (soma_itens_quantizados) contra a soma bruta
Every input pins dh_emi/cnf/chave_acesso for determinism. serialize_infnfe
replicates the exact SerializerConfig(xml_declaration=False, indent=None) +
ns_map used by the auto's emissao.py::_serialize_nfe before signing.
scripts/gen_goldens.py regenerates the .expected.xml files; test_goldens.py
compares byte-for-byte (parametrized per case, readable first-divergent-byte
diff on failure). Verified the comparison has real detection power by
corrupting one expected file and confirming the test fails, then restored.
62 tests pass locally via `uv run pytest`.
Copies the 6 pure fiscal modules (domains, chave_acesso, tpag, presets,
resolver, xml_builder) from sowai-auto's backend/app/modules/fiscal/ into
this standalone lib, with only the two mechanical changes required to drop
the app.* dependency: import prefix rename, and TaxRule (ORM) -> TaxRuleLike
(structural Protocol) in the resolver. No other line changes -- byte-level
parity with the auto is the point.
Ports the pure test suites (domains, chave_acesso, resolver with a local
FakeTaxRule satisfying TaxRuleLike, xml_builder) plus a new test_presets_data
covering the PRESETS dict directly (the auto's equivalent test exercises the
apply-preset HTTP/DB flow, which isn't part of the extracted pure core).
55 tests pass locally via `uv run pytest`, no Postgres/k8s required.