Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Missing cac:InvoiceLine/cac:Item/cac:AdditionalItemProperty #2

Closed
Freespacer opened this issue Dec 10, 2024 · 1 comment · Fixed by #3
Closed

[FEATURE] Missing cac:InvoiceLine/cac:Item/cac:AdditionalItemProperty #2

Freespacer opened this issue Dec 10, 2024 · 1 comment · Fixed by #3
Assignees
Labels
enhancement New feature or request

Comments

@Freespacer
Copy link

Thanks for the useful tool. It saves me work. ;-)

Describe the feature

When converting from UBL to CII, I noticed that the XML element <cac:AdditionalItemProperty> is not read. The following script is affected: src/XmlConverterUblToCii.php

The counterpart contains the reconversion:

$this->source->whenExists(

It would be nice if this could be expanded at this point.

Expected behavior

From UBL:

<?xml version="1.0" encoding="UTF-8"?>
<ubl:Invoice xmlns:ubl="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
  xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
  xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
...
  <cac:InvoiceLine>
...
    <cac:Item>
...
      <cac:AdditionalItemProperty>
        <cbc:Name>Color</cbc:Name>
        <cbc:Value>silver</cbc:Value>
      </cac:AdditionalItemProperty>
      <cac:AdditionalItemProperty>
        <cbc:Name>Length</cbc:Name>
        <cbc:Value>10 inch</cbc:Value>
      </cac:AdditionalItemProperty>
      <cac:AdditionalItemProperty>
        <cbc:Name>Width</cbc:Name>
        <cbc:Value>20 inch</cbc:Value>
      </cac:AdditionalItemProperty>
...
    </cac:Item>
...
  </cac:InvoiceLine>
...
</ubl:Invoice>

To CII:

<?xml version="1.0" encoding="UTF-8"?>
<rsm:CrossIndustryInvoice xmlns:a="urn:un:unece:uncefact:data:standard:QualifiedDataType:100" xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100" xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" xmlns:qdt="urn:un:unece:uncefact:data:Standard:QualifiedDataType:100" xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <rsm:SupplyChainTradeTransaction>
...
    <ram:IncludedSupplyChainTradeLineItem>
...
      <ram:SpecifiedTradeProduct>
...
        <ram:ApplicableProductCharacteristic>
          <ram:Description>Color</ram:Description>
          <ram:Value>silver</ram:Value>
        </ram:ApplicableProductCharacteristic>
        <ram:ApplicableProductCharacteristic>
          <ram:Description>Length</ram:Description>
          <ram:Value>10 inch</ram:Value>
        </ram:ApplicableProductCharacteristic>
        <ram:ApplicableProductCharacteristic>
          <ram:Description>Width</ram:Description>
          <ram:Value>20 inch</ram:Value>
        </ram:ApplicableProductCharacteristic>
      </ram:SpecifiedTradeProduct>
...
    </ram:IncludedSupplyChainTradeLineItem>
...
  </rsm:SupplyChainTradeTransaction>
</rsm:CrossIndustryInvoice>

Sample Code

If I add following at line 272 from the script src/XmlConverterUblToCii.php, then it works as expected:

                $this->source->queryAll('./cac:Item/cac:AdditionalItemProperty', $invoiceLineNode)->forEach(
                    function ($invoiceLineAdditionalItemPropertyNode) {
                        $this->destination->element('ram:Description', $this->source->queryValue('./cbc:Name', $invoiceLineAdditionalItemPropertyNode));
                        $this->destination->element('ram:Value', $this->source->queryValue('./cbc:Value', $invoiceLineAdditionalItemPropertyNode));
                    },
                    function () {
                        // Do nothing here
                    },
                    function () {
                        // Do nothing here
                    },
                    function () {
                        $this->destination->startElement('ram:ApplicableProductCharacteristic');
                    },
                    function () {
                        $this->destination->endElement();
                    }
                );

$this->source->queryAll('./cac:Item/cac:CommodityClassification/cbc:ItemClassificationCode', $invoiceLineNode)->forEach(

@Freespacer Freespacer added the enhancement New feature or request label Dec 10, 2024
@horstoeko
Copy link
Owner

Hi @Freespacer,

Many, many thanks for your very detailed request. If you like, you are welcome to send me a PullRequest. If this is not possible for you, then I will have to find the time to do so when the opportunity arises.

Many thanks again and best regards

horstoeko added a commit that referenced this issue Dec 10, 2024
#2 Added reading of AdditionalItemProperty in XmlConverterUblToCii
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants