Skip to content

MultiplierFactorNumeric serializes BaseAmount instead of the percentage factor #105

@Picaland

Description

@Picaland

Issue Description
Hi! I noticed that in the current release, NumNum\UBL\AllowanceCharge::xmlSerialize() writes the BaseAmount value into cbc:MultiplierFactorNumeric whenever the multiplier is set. This produces PEPPOL validation errors
(R040/R042) because the field should contain a factor such as 0.10 or 10, not the base amount (e.g. 15.76).

Steps to Reproduce

  1. Create an AllowanceCharge instance with
     (new AllowanceCharge())
         ->setChargeIndicator(false)
         ->setBaseAmount(15.76)
         ->setAmount(1.59)
         ->setMultiplierFactorNumeric(0.0997);
  1. Serialize it via the UBL invoice generator.

Expected Result
The XML contains cbc:MultiplierFactorNumeric0.0997</cbc:MultiplierFactorNumeric> (or 9.97 depending on convention), matching the PEPPOL requirement.

Actual Result
The generated XML contains cbc:MultiplierFactorNumeric15.76</cbc:MultiplierFactorNumeric>—the base amount value—triggering PEPPOL validation failures such as:

[PEPPOL-EN16931-R040] Allowance/charge amount must equal base amount * percentage/100
[PEPPOL-EN16931-R042] Allowance/charge percentage MUST be provided when allowance/charge base amount is provided.

Suggestion
In AllowanceCharge::xmlSerialize(), replace:

Schema::CBC . 'MultiplierFactorNumeric' => NumberFormatter::format($this->baseAmount)

with:

Schema::CBC . 'MultiplierFactorNumeric' => NumberFormatter::format($this->multiplierFactorNumeric)

(or the equivalent using the getter), so the correct factor is written.

Let me know if you need a full reproducer—happy to help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions