Skip to content

Zero-net standard-rated lines mutate VAT rate to 0% during XML serialization #53

Description

@douglasward

Summary

Secretariat::LineItem#to_xml currently changes tax_percent to 0 when net_amount is zero:

if net_price&.zero?
  self.tax_percent = 0
end

This makes zero-value standard-rated invoice lines serialize as 0% VAT even when the supplied tax category/rate is standard VAT, for example 19%.

Why this matters

A fully discounted or zero-consideration line can still be a standard-rated taxable item. In that case the taxable base and tax amount are 0.00, but the VAT category/rate should remain the applicable rate, for example S / 19.00, not 0.00.

Changing the rate to zero conflates standard-rated zero-value lines with zero-rated or non-taxable lines.

Expected behavior

If a caller supplies:

  • tax_category: :STANDARDRATE
  • tax_percent: 19
  • net_amount: 0
  • tax_amount: 0

the XML should preserve RateApplicablePercent as 19.00.

Actual behavior

LineItem#to_xml mutates tax_percent to 0, so the generated XML contains RateApplicablePercent as 0.00.

Suggested fix

Avoid mutating tax_percent for zero-net lines. If some profiles need zero-rate normalization, make it opt-in or tied to an explicit zero-rated/untaxed tax category rather than inferred from net_amount == 0.

Environment

Observed with secretariat 3.9.0.
Relevant commit: 321657a80a71c08c0fb82b3865622a92e2cd49e1.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions