Skip to content

Commit dd56b89

Browse files
committed
refactor: Support multiple tax categories in AllowanceCharge and improve XML serialization
1 parent d5d66c7 commit dd56b89

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/AllowanceCharge.php

+10-8
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class AllowanceCharge implements XmlSerializable
3333
/** @var TaxTotal|null Tax total information. */
3434
private ?TaxTotal $taxTotal = null;
3535

36-
/** @var TaxCategory|null Tax category information. */
37-
private ?TaxCategory $taxCategory = null;
36+
/** @var array|null List of tax categories. */
37+
private ?array $taxCategory = null;
3838

3939
/**
4040
* Get the charge indicator.
@@ -191,7 +191,7 @@ public function setAmount(?float $amount): self
191191
/**
192192
* Get the tax category.
193193
*
194-
* @return TaxCategory|null
194+
* @return array|null
195195
*/
196196
public function getTaxCategory(): ?TaxCategory
197197
{
@@ -204,7 +204,7 @@ public function getTaxCategory(): ?TaxCategory
204204
* @param TaxCategory|null $taxCategory
205205
* @return self
206206
*/
207-
public function setTaxCategory(?TaxCategory $taxCategory): self
207+
public function setTaxCategory(?array $taxCategory): self
208208
{
209209
$this->taxCategory = $taxCategory;
210210
return $this;
@@ -276,9 +276,11 @@ public function xmlSerialize(Writer $writer): void
276276
}
277277

278278
if ($this->taxCategory !== null) {
279-
$writer->write([
280-
Schema::CAC . 'TaxCategory' => $this->taxCategory,
281-
]);
279+
foreach($this->taxCategory as $taxCategory){
280+
$writer->write([
281+
Schema::CAC . 'TaxCategory' => $taxCategory
282+
]);
283+
}
282284
}
283285

284286
if ($this->taxTotal !== null) {
@@ -299,4 +301,4 @@ public function xmlSerialize(Writer $writer): void
299301
]);
300302
}
301303
}
302-
}
304+
}

0 commit comments

Comments
 (0)