Hi,
In InvoiceLine::deserializedTag() at line 399:
->setInvoicedQuantity(ReaderHelper::getTagValue(Schema::CBC . 'InvoicedQuantity', $collection) !== null ? floatval(ReaderHelper::getTagValue(Schema::CBC . 'InvoicedQuantity', $collection)) : null)
This line reads the text content of cbc:InvoicedQuantity (e.g., "1"), converts it to a float and stores it as a scalar float value.
BUT it completely ignores the unitCode attribute on that element.
If you then look at L407, it tries to read unitCode as a child element instead as reading it as an attribute from InvoicedQuantity.
While writing it is properly programmed to write unitCode as an attribute of InvoiceQuantity.
This causes an issue when an UBL is read from and then trying to write it back to XML.
As during reading it will read and store in variable as null. And during writing the XML it tries to write NULL instead of a string.
I think we need an extra function in the ReaderHelper.php:
public static function getTagAttributeValue(string $name, string $attribute, ArrayCollection $collection): ?string
{
$tag = self::getTag($name, $collection);
if (isset($tag['attributes']) && isset($tag['attributes'][$attribute])) {
return $tag['attributes'][$attribute];
}
return null;
}
As far as I can tell from the code, so far, there's no attribute reading at all in the current library version.
PS: I'm sorry, I am not familiar with how I can do code suggestions properly.
Hi,
In InvoiceLine::deserializedTag() at line 399:
->setInvoicedQuantity(ReaderHelper::getTagValue(Schema::CBC . 'InvoicedQuantity', $collection) !== null ? floatval(ReaderHelper::getTagValue(Schema::CBC . 'InvoicedQuantity', $collection)) : null)This line reads the text content of cbc:InvoicedQuantity (e.g., "1"), converts it to a float and stores it as a scalar float value.
BUT it completely ignores the unitCode attribute on that element.
If you then look at L407, it tries to read unitCode as a child element instead as reading it as an attribute from InvoicedQuantity.
While writing it is properly programmed to write unitCode as an attribute of InvoiceQuantity.
This causes an issue when an UBL is read from and then trying to write it back to XML.
As during reading it will read and store in variable as null. And during writing the XML it tries to write NULL instead of a string.
I think we need an extra function in the ReaderHelper.php:
As far as I can tell from the code, so far, there's no attribute reading at all in the current library version.
PS: I'm sorry, I am not familiar with how I can do code suggestions properly.