Skip to content

FacturX > Cii#5511

Open
mariohd wants to merge 5 commits into
mainfrom
facturx-cii
Open

FacturX > Cii#5511
mariohd wants to merge 5 commits into
mainfrom
facturx-cii

Conversation

@mariohd
Copy link
Copy Markdown
Contributor

@mariohd mariohd commented May 14, 2026

The serializers and services under app/serializers/e_invoices/factur_x/ and app/services/e_invoices/*/factur_x/ were named after Factur-X, but they actually produce Cross Industry Invoice (CII) XML. Factur-X is the hybrid output format — a PDF/A-3 file with a CII XML stream embedded as an attachment — and is assembled one level up in Invoices::GeneratePdfService#attach_facturx (and its credit-note and payment-receipt equivalents), where the PDF is generated and the XML is embedded. The XML-producing namespace itself produces pure CII, so the directory and module names should reflect that.

This PR is a cosmetic rename. The classes, generated XML, env vars, schema, and operator-facing API are all unchanged — only file paths and Ruby constants move.

What moved

Before After
Component serializers app/serializers/e_invoices/factur_x/* app/serializers/e_invoices/cii/*
Per-document builders app/serializers/e_invoices/{invoices,credit_notes,payments}/factur_x/builder.rb …/cii/builder.rb
Per-document create services app/services/e_invoices/{invoices,credit_notes,payments}/factur_x/create_service.rb …/cii/create_service.rb
All spec mirrors spec/{serializers,services}/e_invoices/.../factur_x/* …/cii/*
Module names EInvoices::FacturX::* EInvoices::Cii::*
Helper key XMLHelper::NAMESPACES[:factur_x] XMLHelper::NAMESPACES[:cii]
PDF service callers (constant references only) EInvoices::*::FacturX::CreateService EInvoices::*::Cii::CreateService

What did not move

The attach_facturx method in Invoices::GeneratePdfService, CreditNotes::GeneratePdfService, and PaymentReceipts::GeneratePdfService keeps its name. That method's job — embedding CII XML inside a PDF/A-3 — is genuinely Factur-X, so the name is still accurate at the call site even though the inner serializer namespace is now Cii.

Test plan

  • bundle exec rspec spec/serializers/e_invoices/ (every CII and UBL serializer spec — both load the shared spec/support/xml_helper.rb)
  • bundle exec rspec spec/services/e_invoices/ (the renamed cii/create_service.rb files)
  • bundle exec rspec spec/services/{invoices,credit_notes,payment_receipts}/generate_pdf_service_spec.rb (PDF callers stubbing the renamed constants)
  • grep -rn 'FacturX\|factur_x' app/ spec/ lib/ returns no results
  • bundle exec rubocop clean on the 44 changed files

Migration

None. Pure internal rename with no behavior change, no schema change, no env-var change, and no public-API change. Operators see nothing.

mariohd added 5 commits May 14, 2026 10:34
The serializers and services under `factur_x/` produce Cross Industry
Invoice (CII) XML — the UN/CEFACT XML standard — not Factur-X itself.
Factur-X is the hybrid output format: a PDF/A-3 wrapping CII XML as
an embedded attachment. The directory names were therefore
semantically wrong; this commit renames them to match what their
contents actually produce.

Move 14 directories from `factur_x` to `cii` under
`app/serializers/e_invoices/`, `app/services/e_invoices/`, and the
corresponding spec mirrors. File contents are unchanged in this
commit, so the `FacturX` module names inside still mismatch the new
directory structure; the codebase will not load until the follow-up
commit renames the modules to `Cii`.

The PDF-embedding step in `Invoices::GeneratePdfService#attach_facturx`
and its credit-note and payment-receipt equivalents are intentionally
left under their current names — that operation genuinely is Factur-X
(CII XML embedded in a PDF/A-3 wrapper).
The previous commit moved the `factur_x` directories to `cii` but
left the `FacturX` module name unchanged inside the files, so the
constants no longer matched the file paths and Rails autoloading was
broken. This commit completes the inside-the-namespace rename.

Rewrite every `FacturX` reference within the moved directories to
`Cii`, and every `factur_x` reference to `cii` — module declarations,
nested constants, and spec `describe` headers. Files outside the
renamed directories are untouched in this commit.

The three PDF-service callers
(`Invoices::GeneratePdfService`, `CreditNotes::GeneratePdfService`,
`PaymentReceipts::GeneratePdfService`) still reference
`EInvoices::*::FacturX::CreateService`, so the build remains broken
until the follow-up commit updates them.
The previous two commits renamed the `factur_x` directories and
modules to `cii`, but the three PDF-generation services still
referenced the old `EInvoices::*::FacturX::CreateService` constants
and could not load them. This commit updates those references and
brings the build back to green.

Update the `attach_facturx` method in `Invoices::GeneratePdfService`,
`CreditNotes::GeneratePdfService`, and
`PaymentReceipts::GeneratePdfService` to call
`EInvoices::*::Cii::CreateService` instead of the old `FacturX`
constant. The method names (`attach_facturx`) stay — the operation
they perform genuinely is Factur-X (embedding a CII XML attachment
into a PDF/A-3 wrapper), so the name remains accurate at the call
site even though the inner serializer namespace is now `Cii`.
Two follow-on places still referenced the old `FacturX` name after
the source-side rename: the namespace lookup in
`spec/support/xml_helper.rb` keyed on `:factur_x`, and the three
PDF-service specs (`Invoices::GeneratePdfService`,
`CreditNotes::GeneratePdfService`, `PaymentReceipts::GeneratePdfService`)
that stub `EInvoices::*::FacturX::CreateService`. With these updated,
no `FacturX` or `factur_x` references remain anywhere in `app/`,
`spec/`, or `lib/`.

Rename the `:factur_x` key in `XMLHelper::NAMESPACES` to `:cii` and
point its value at `EInvoices::Cii::BaseSerializer::ROOT_NAMESPACES`;
the spec files that consume the helper already call
`xml_document(:cii)` after the earlier sweep.

Update the three PDF-service specs to stub
`EInvoices::*::Cii::CreateService` instead of the old `FacturX`
constant. All e-invoice and PDF-service specs pass; the `grep`
sanity check across `app/`, `spec/`, and `lib/` returns no results.
  ## Context

  The earlier commits renamed the FacturX namespace to Cii but left
  the `attach_facturx` and `should_generate_facturx_einvoice_xml?`
  methods (and their spec descriptions) under the old name. With the
  serializer namespace now uniformly `Cii`, the helper-method names
  were the only remaining `facturx` references in the codebase.

  ## Description

  Rename `attach_facturx` to `attach_cii` and
  `should_generate_facturx_einvoice_xml?` to
  `should_generate_cii_einvoice_xml?` in
  `Invoices::GeneratePdfService`, `CreditNotes::GeneratePdfService`,
  and `PaymentReceipts::GeneratePdfService`. Update the matching
  spec descriptions. No behavior change; a `grep` for `facturx`,
  `FacturX`, or `factur_x` across `app/`, `spec/`, and `lib/` now
  returns nothing.
@mariohd mariohd changed the title FacturX => Cii FacturX > Cii May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant