diff --git a/src/ClaimingOrganisation.php b/src/ClaimingOrganisation.php index 6ad6454..6508d76 100644 --- a/src/ClaimingOrganisation.php +++ b/src/ClaimingOrganisation.php @@ -6,7 +6,7 @@ class ClaimingOrganisation { private $name = ''; private $hmrcRef = ''; - private ?string $regulator; + private ?string $regulator = null; private $regNo = ''; private $hasConnectedCharities = false; private $connectedCharities = []; @@ -51,7 +51,7 @@ public function setHmrcRef($value) $this->hmrcRef = $value; } - public function getRegulator() + public function getRegulator(): ?string { return $this->regulator; } diff --git a/src/GiftAid.php b/src/GiftAid.php index 256f313..dd55329 100644 --- a/src/GiftAid.php +++ b/src/GiftAid.php @@ -1036,7 +1036,11 @@ protected function writeClaimStartData(XMLWriter $package, ClaimingOrganisation } else { $package->writeElement('OtherReg', $org->getRegulator()); } - $package->writeElement('RegNo', $org->getRegNo()); + + if ($org->getRegulator() !== null && !empty($org->getRegNo())) { + $package->writeElement('RegNo', $org->getRegNo()); + } + $package->endElement(); # Regulator $package->startElement('Repayment');