Skip to content

Commit

Permalink
Minor fixes subjecting IDs, Fix TaxPointDate
Browse files Browse the repository at this point in the history
  • Loading branch information
ruff committed Jul 16, 2024
1 parent 4d4ff3c commit cfe2d0d
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/XmlConverterUblToCii.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,7 @@ function ($invoiceAccountingSupplierPartyIdNode) {
);
$this->source->queryAll('./cac:PartyIdentification/cbc:ID[@schemeID != \'\' and @schemeID != \'SEPA\']', $invoiceAccountingSupplierPartyNode)->forEach(
function ($invoiceAccountingSupplierPartyIdNode) {
//if (strcasecmp($invoiceAccountingSupplierPartyIdNode->getAttribute('schemeID'), 'SEPA') !== 0) {
$this->destination->elementWithAttribute('ram:GlobalID', $invoiceAccountingSupplierPartyIdNode->nodeValue, 'schemeID', $invoiceAccountingSupplierPartyIdNode->getAttribute('schemeID'));
//}
$this->destination->elementWithAttribute('ram:GlobalID', $invoiceAccountingSupplierPartyIdNode->nodeValue, 'schemeID', $invoiceAccountingSupplierPartyIdNode->getAttribute('schemeID'));
}
);
$this->source->whenExists(
Expand Down Expand Up @@ -490,12 +488,8 @@ function ($invoiceAccountingSupplierPartyTaxSchemeNode) {
$docRootElement,
function ($invoiceAccountingCustomerPartyNode) {
$this->destination->startElement('ram:BuyerTradeParty');
$this->source->queryAll('./cac:PartyIdentification/cbc:ID[not(@schemeID)]', $invoiceAccountingCustomerPartyNode)->forEach(
function ($invoiceAccountingCustomerPartyIdNode) {
$this->destination->element('ram:ID', $invoiceAccountingCustomerPartyIdNode->nodeValue);
}
);
$this->source->queryAll('./cac:PartyIdentification/cbc:ID[@schemeID]', $invoiceAccountingCustomerPartyNode)->forEach(
$this->destination->element('ram:ID', $this->source->queryValue('./cbc:ID[not(@schemeID)]', $invoiceAccountingCustomerPartyNode));
$this->source->queryAll('./cac:PartyIdentification/cbc:ID[@schemeID != \'\' and @schemeID != \'SEPA\']', $invoiceAccountingCustomerPartyNode)->forEach(
function ($invoiceAccountingCustomerPartyIdNode) {
$this->destination->elementWithAttribute('ram:GlobalID', $invoiceAccountingCustomerPartyIdNode->nodeValue, 'schemeID', $invoiceAccountingCustomerPartyIdNode->getAttribute('schemeID'));
}
Expand Down Expand Up @@ -613,12 +607,8 @@ function ($invoiceAccountingCustomerPartyTaxSchemeNode) {
$docRootElement,
function ($invoiceTaxRepresentativePartyNode) {
$this->destination->startElement('ram:SellerTaxRepresentativeTradeParty');
$this->source->queryAll('./cac:PartyIdentification/cbc:ID[not(@schemeID)]', $invoiceTaxRepresentativePartyNode)->forEach(
function ($invoiceAccountingCustomerPartyIdNode) {
$this->destination->element('ram:ID', $invoiceAccountingCustomerPartyIdNode->nodeValue);
}
);
$this->source->queryAll('./cac:PartyIdentification/cbc:ID[@schemeID]', $invoiceTaxRepresentativePartyNode)->forEach(
$this->destination->element('ram:ID', $this->source->queryValue('./cbc:ID[not(@schemeID)]', $invoiceTaxRepresentativePartyNode));
$this->source->queryAll('./cac:PartyIdentification/cbc:ID[@schemeID != \'\' and @schemeID != \'SEPA\']', $invoiceTaxRepresentativePartyNode)->forEach(
function ($invoiceAccountingCustomerPartyIdNode) {
$this->destination->elementWithAttribute('ram:GlobalID', $invoiceAccountingCustomerPartyIdNode->nodeValue, 'schemeID', $invoiceAccountingCustomerPartyIdNode->getAttribute('schemeID'));
}
Expand Down Expand Up @@ -755,7 +745,12 @@ private function convertApplicableHeaderTradeDelivery(): void
$docRootElement,
function ($deliveryLocationNode, $deliveryNode) {
$this->destination->startElement('ram:ShipToTradeParty');
$this->destination->element('ram:ID', $this->source->queryValue('./cbc:ID', $deliveryLocationNode));
$this->destination->element('ram:ID', $this->source->queryValue('./cbc:ID[not(@schemeID)]', $deliveryLocationNode));
$this->source->queryAll('./cbc:ID[@schemeID != \'\' and @schemeID != \'SEPA\']', $deliveryLocationNode)->forEach(
function ($deliveryLocationIdNode) {
$this->destination->elementWithAttribute('ram:GlobalID', $deliveryLocationIdNode->nodeValue, 'schemeID', $deliveryLocationIdNode->getAttribute('schemeID'));
}
);
$this->destination->element('ram:Name', $this->source->queryValue('./cac:DeliveryParty/cac:PartyName/cbc:Name', $deliveryNode));
$this->source->whenExists(
'./cac:Address',
Expand Down Expand Up @@ -838,7 +833,7 @@ function ($invoiceAccountingCustomerPartyIdNode) {
$this->destination->element('ram:ID', $invoiceAccountingCustomerPartyIdNode->nodeValue);
}
);
$this->source->queryAll('./cac:PartyIdentification/cbc:ID[@schemeID]', $invoicePayeePartyNode)->forEach(
$this->source->queryAll('./cac:PartyIdentification/cbc:ID[@schemeID != \'\' and @schemeID != \'SEPA\']', $invoicePayeePartyNode)->forEach(
function ($invoiceAccountingCustomerPartyIdNode) {
$this->destination->elementWithAttribute('ram:GlobalID', $invoiceAccountingCustomerPartyIdNode->nodeValue, 'schemeID', $invoiceAccountingCustomerPartyIdNode->getAttribute('schemeID'));
}
Expand Down Expand Up @@ -979,6 +974,15 @@ function ($taxSubtotalNode) use ($docRootElement) {
$this->destination->element('ram:TypeCode', $this->source->queryValue('./cac:TaxCategory/cac:TaxScheme/cbc:ID', $taxSubtotalNode));
$this->destination->element('ram:BasisAmount', $this->source->queryValue('./cbc:TaxableAmount', $taxSubtotalNode));
$this->destination->element('ram:CategoryCode', $this->source->queryValue('./cac:TaxCategory/cbc:ID', $taxSubtotalNode));
if ($this->source->queryValue('./cac:TaxCategory/cbc:ID', $taxSubtotalNode) == "E") {
$this->source->whenExists(
'./cbc:TaxPointDate', $docRootElement, function ($taxPointDateNode) {
$this->destination->startElement('ram:TaxPointDate');
$this->destination->elementWithAttribute('udt:DateString', $this->convertDateTime($taxPointDateNode->nodeValue), 'format', '102');
$this->destination->endElement();
}
);
}
$this->destination->element('ram:ExemptionReasonCode', $this->source->queryValue('./cac:TaxCategory/cbc:TaxExemptionReasonCode', $taxSubtotalNode));
$this->destination->element('ram:RateApplicablePercent', $this->source->queryValue('./cac:TaxCategory/cbc:Percent', $taxSubtotalNode));
$this->destination->endElement();
Expand Down

0 comments on commit cfe2d0d

Please sign in to comment.