From 7f40f5f6109bf1ff3f7766ccaa7152eebd62eab5 Mon Sep 17 00:00:00 2001 From: ruff Date: Thu, 6 Jun 2024 05:00:21 +0200 Subject: [PATCH] Fix SLO --- src/XmlConverterCiiToUbl.php | 48 +++++++++++++++++------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/src/XmlConverterCiiToUbl.php b/src/XmlConverterCiiToUbl.php index c17c5cd..12b602d 100644 --- a/src/XmlConverterCiiToUbl.php +++ b/src/XmlConverterCiiToUbl.php @@ -461,10 +461,16 @@ function ($DirectDebitMandateNode) use ($invoiceHeaderSettlement) { $this->source->whenExists( './ram:Name', $sellerTradePartyNode, - function ($sellerTradePartyNameNode) { - $this->destination->startElement('cac:PartyName'); - $this->destination->element('cbc:Name', $sellerTradePartyNameNode->nodeValue); - $this->destination->endElement(); + function ($sellerTradePartyNameNode) use ($sellerTradePartyNode) { + $this->source->whenExists( + './ram:SpecifiedLegalOrganization/ram:TradingBusinessName', + $sellerTradePartyNode, + function ($sellerTradePartyLegalOrgBusNameNode) { + $this->destination->startElement('cac:PartyName'); + $this->destination->element('cbc:Name', $sellerTradePartyLegalOrgBusNameNode->nodeValue); + $this->destination->endElement(); + } + ); } ); $this->source->whenExists( @@ -528,15 +534,7 @@ function ($sellerTradePartyTaxRegNode) { function ($sellerTradePartyLegalOrgNode) use ($sellerTradePartyNode) { $this->destination->startElement('cac:PartyLegalEntity'); $this->destination->element('cbc:RegistrationName', $this->source->queryValue('./ram:Name', $sellerTradePartyNode)); - $this->source->whenExists( - './ram:ID', - $sellerTradePartyLegalOrgNode, - function ($sellerTradePartyLegalOrgIdNode) { - $this->destination->startElement('cbc:CompanyID', $sellerTradePartyLegalOrgIdNode->nodeValue); - $this->destination->attribute('schemeID', $this->source->queryValue('./@schemeID', $sellerTradePartyLegalOrgIdNode)); - $this->destination->endElement(); - } - ); + $this->destination->elementWithAttribute('cbc:CompanyID', $this->source->queryValue('./ram:ID', $sellerTradePartyLegalOrgNode), 'schemeID', $this->source->queryValue('./ram:ID/@schemeID', $sellerTradePartyLegalOrgNode)); $this->destination->element('cbc:CompanyLegalForm', $this->source->queryValue('./ram:Description', $sellerTradePartyNode)); $this->destination->endElement(); }, @@ -614,10 +612,16 @@ function ($buyerTradePartyGlobalIdNode) { $this->source->whenExists( './ram:Name', $buyerTradePartyNode, - function ($buyerTradePartyNameNode) { - $this->destination->startElement('cac:PartyName'); - $this->destination->element('cbc:Name', $buyerTradePartyNameNode->nodeValue); - $this->destination->endElement(); + function ($buyerTradePartyNameNode) use ($buyerTradePartyNode) { + $this->source->whenExists( + './ram:SpecifiedLegalOrganization/ram:TradingBusinessName', + $buyerTradePartyNode, + function ($buyerTradePartyLegalOrgBusNameNode) { + $this->destination->startElement('cac:PartyName'); + $this->destination->element('cbc:Name', $buyerTradePartyLegalOrgBusNameNode->nodeValue); + $this->destination->endElement(); + } + ); } ); $this->source->whenExists( @@ -681,15 +685,7 @@ function ($sellerTradePartyTaxRegNode) { function ($buyerTradePartyLegalOrgNode) use ($buyerTradePartyNode) { $this->destination->startElement('cac:PartyLegalEntity'); $this->destination->element('cbc:RegistrationName', $this->source->queryValue('./ram:Name', $buyerTradePartyNode)); - $this->source->whenExists( - './ram:ID', - $buyerTradePartyLegalOrgNode, - function ($buyerTradePartyLegalOrgIdNode) { - $this->destination->startElement('cbc:CompanyID', $buyerTradePartyLegalOrgIdNode->nodeValue); - $this->destination->attribute('schemeID', $this->source->queryValue('./@schemeID', $buyerTradePartyLegalOrgIdNode)); - $this->destination->endElement(); - } - ); + $this->destination->elementWithAttribute('cbc:CompanyID', $this->source->queryValue('./ram:ID', $buyerTradePartyLegalOrgNode), 'schemeID', $this->source->queryValue('./ram:ID/@schemeID', $buyerTradePartyLegalOrgNode)); $this->destination->element('cbc:CompanyLegalForm', $this->source->queryValue('./ram:Description', $buyerTradePartyNode)); $this->destination->endElement(); },