Skip to content

Commit

Permalink
Docs, Checked cardinallity of party IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed Nov 7, 2024
1 parent c4393db commit 9b110fa
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/XmlConverterCiiToUbl.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ function ($sellerTradePartyUniversalCommNode) {
}
);

// Set the IDs of the seller
// ID's cardinallity
// CII - ID is 0..unbounded, GlobalID is 0..unbounded
// UBL - PartyIdentification is 0..unbounded

$this->source->queryAll('./ram:ID', $sellerTradePartyNode)->forEach(
function ($sellerTradePartyIdNode) {
$this->destination->startElement('cac:PartyIdentification');
Expand All @@ -430,9 +435,7 @@ function ($sellerTradePartyGlobalIdNode) {
$invoiceHeaderSettlement,
function ($DirectDebitMandateNode) {
$this->destination->startElement('cac:PartyIdentification');
$this->destination->startElement('cbc:ID', $DirectDebitMandateNode->nodeValue);
$this->destination->attribute('schemeID', 'SEPA');
$this->destination->endElement();
$this->destination->elementWithAttribute('cbc:ID', $DirectDebitMandateNode->nodeValue, 'schemeID', 'SEPA');
$this->destination->endElement();
}
);
Expand Down Expand Up @@ -559,6 +562,11 @@ function ($buyerTradePartyUniversalCommNode) {
}
);

// Set the IDs of the buyer
// ID's cardinallity
// CII - ID is 0..1, GlobalID is 0..1
// UBL - PartyIdentification is 0..1

$this->source->whenExists(
'./ram:GlobalID',
$buyerTradePartyNode,
Expand Down Expand Up @@ -702,6 +710,11 @@ function ($payeeTradePartyUniversalCommNode) {
}
);

// Set the IDs of the payee
// ID's cardinallity
// CII - ID is 0..1, GlobalID is 0..1
// UBL - PartyIdentification is 0..1

$this->source->whenExists(
'./ram:GlobalID',
$payeeTradePartyNode,
Expand Down Expand Up @@ -835,16 +848,6 @@ private function convertTaxRepresentativeParty(): void
function ($sellerTaxRepresentativePartyNode) {
$this->destination->startElement('cac:TaxRepresentativeParty');

$this->source->whenExists(
'./ram:URIUniversalCommunication/ram:URIID',
$sellerTaxRepresentativePartyNode,
function ($sellerTaxRepresentativePartyUniversalCommNode) {
$this->destination->startElement('cbc:EndpointID', $sellerTaxRepresentativePartyUniversalCommNode->nodeValue);
$this->destination->attribute('schemeID', $this->source->queryValue('./@schemeID', $sellerTaxRepresentativePartyUniversalCommNode));
$this->destination->endElement();
}
);

$this->source->whenExists(
'./ram:Name',
$sellerTaxRepresentativePartyNode,
Expand Down Expand Up @@ -945,6 +948,11 @@ function ($shipToTradePartyNode) use ($invoiceHeaderDelivery) {

$this->destination->startElement('cac:DeliveryLocation');

// Set the IDs of the ship to party
// ID's cardinallity
// CII - ID is 0..1, GlobalID is 0..1
// UBL - PartyIdentification is 0..1

$this->source->whenExists(
'./ram:GlobalID',
$shipToTradePartyNode,
Expand Down
33 changes: 33 additions & 0 deletions src/XmlConverterUblToCii.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,30 +385,40 @@ private function convertApplicableHeaderTradeAgreement(): void
$docRootElement,
function ($invoiceAccountingSupplierPartyNode) {
$this->destination->startElement('ram:SellerTradeParty');

// Set the IDs of the seller
// ID's cardinallity
// UBL - PartyIdentification is 0..unbounded
// CII - ID is 0..unbounded, GlobalID is 0..unbounded

$this->source->queryAll('./cac:PartyIdentification/cbc:ID[not(@schemeID)]', $invoiceAccountingSupplierPartyNode)->forEach(
function ($invoiceAccountingSupplierPartyIdNode) {
$this->destination->element('ram:ID', $invoiceAccountingSupplierPartyIdNode->nodeValue);
}
);

$this->source->queryAll('./cac:PartyIdentification/cbc:ID[@schemeID != \'\' and @schemeID != \'SEPA\']', $invoiceAccountingSupplierPartyNode)->forEach(
function ($invoiceAccountingSupplierPartyIdNode) {
$this->destination->elementWithAttribute('ram:GlobalID', $invoiceAccountingSupplierPartyIdNode->nodeValue, 'schemeID', $invoiceAccountingSupplierPartyIdNode->getAttribute('schemeID'));
}
);

$this->source->whenExists(
'./cac:PartyLegalEntity/cbc:RegistrationName',
$invoiceAccountingSupplierPartyNode,
function ($invoiceAccountingSupplierPartyNodeRegNameNode) {
$this->destination->element('ram:Name', $invoiceAccountingSupplierPartyNodeRegNameNode->nodeValue);
}
);

$this->source->whenExists(
'./cac:PartyLegalEntity/cbc:CompanyLegalForm',
$invoiceAccountingSupplierPartyNode,
function ($invoiceAccountingSupplierPartyLegalEntityNode) {
$this->destination->element('ram:Description', $invoiceAccountingSupplierPartyLegalEntityNode->nodeValue);
}
);

$this->source->whenOneExists(
['./cac:PartyLegalEntity/cbc:CompanyID', './cac:PartyName/cbc:Name'],
[$invoiceAccountingSupplierPartyNode, $invoiceAccountingSupplierPartyNode],
Expand All @@ -419,6 +429,7 @@ function () use ($invoiceAccountingSupplierPartyNode) {
$this->destination->endElement();
}
);

$this->source->whenExists(
'./cac:Contact',
$invoiceAccountingSupplierPartyNode,
Expand Down Expand Up @@ -446,6 +457,7 @@ function ($invoiceAccountingSupplierPartyContactMailNode) {
$this->destination->endElement();
}
);

$this->source->whenExists(
'./cac:PostalAddress',
$invoiceAccountingSupplierPartyNode,
Expand All @@ -460,6 +472,7 @@ function ($invoiceAccountingSupplierPartyPostalAddressNode) {
$this->destination->endElement();
}
);

$this->source->whenExists(
'./cbc:EndpointID[@schemeID=\'EM\']',
$invoiceAccountingSupplierPartyNode,
Expand All @@ -469,6 +482,7 @@ function ($invoiceAccountingSupplierPartyEndpointNode) {
$this->destination->endElement();
}
);

$this->source->whenExists(
'./cac:PartyTaxScheme/cac:TaxScheme/cbc:ID[text() = \'VAT\']',
$invoiceAccountingSupplierPartyNode,
Expand All @@ -478,6 +492,7 @@ function ($invoiceAccountingSupplierPartyTaxSchemeNode) {
$this->destination->endElement();
}
);

$this->source->whenExists(
'./cac:PartyTaxScheme/cac:TaxScheme/cbc:ID[text() = \'TAX\']',
$invoiceAccountingSupplierPartyNode,
Expand All @@ -487,6 +502,7 @@ function ($invoiceAccountingSupplierPartyTaxSchemeNode) {
$this->destination->endElement();
}
);

$this->source->whenExists(
'./cac:PartyTaxScheme/cac:TaxScheme/cbc:ID[text() = \'FC\']',
$invoiceAccountingSupplierPartyNode,
Expand All @@ -496,6 +512,7 @@ function ($invoiceAccountingSupplierPartyTaxSchemeNode) {
$this->destination->endElement();
}
);

$this->source->whenExists(
'./cac:PartyTaxScheme/cac:TaxScheme/cbc:ID[text() = \'???\']',
$invoiceAccountingSupplierPartyNode,
Expand All @@ -505,6 +522,7 @@ function ($invoiceAccountingSupplierPartyTaxSchemeNode) {
$this->destination->endElement();
}
);

$this->destination->endElement();
}
);
Expand All @@ -515,6 +533,11 @@ function ($invoiceAccountingSupplierPartyTaxSchemeNode) {
function ($invoiceAccountingCustomerPartyNode) {
$this->destination->startElement('ram:BuyerTradeParty');

// Set the IDs of the buyer
// ID's cardinallity
// UBL - PartyIdentification is 0..1
// CII - ID is 0..1, GlobalID is 0..1

$this->source->whenExists(
'./cac:PartyIdentification/cbc:ID[not(@schemeID)]',
$invoiceAccountingCustomerPartyNode,
Expand Down Expand Up @@ -809,6 +832,11 @@ private function convertApplicableHeaderTradeDelivery(): void
function ($deliveryLocationNode, $deliveryNode) {
$this->destination->startElement('ram:ShipToTradeParty');

// Set the IDs of the ship to party
// ID's cardinallity
// UBL - PartyIdentification is 0..1
// CII - ID is 0..1, GlobalID is 0..1

$this->source->whenExists(
'./cbc:ID[not(@schemeID)]',
$deliveryLocationNode,
Expand Down Expand Up @@ -910,6 +938,11 @@ function ($documentCUrrencyNode) {
function ($invoicePayeePartyNode) {
$this->destination->startElement('ram:PayeeTradeParty');

// Set the IDs of the payee
// ID's cardinallity
// UBL - PartyIdentification is 0..1
// CII - ID is 0..1, GlobalID is 0..1

$this->source->whenExists(
'./cac:PartyIdentification/cbc:ID[not(@schemeID)]',
$invoicePayeePartyNode,
Expand Down

0 comments on commit 9b110fa

Please sign in to comment.