-
Notifications
You must be signed in to change notification settings - Fork 83
Description
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
- Create an AllowanceCharge instance with
(new AllowanceCharge())
->setChargeIndicator(false)
->setBaseAmount(15.76)
->setAmount(1.59)
->setMultiplierFactorNumeric(0.0997);
- 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!