Skip to content

Commit

Permalink
Renamed BT-17 (tender or lot reference)
Browse files Browse the repository at this point in the history
- Renamed originator document reference to tender or lot reference to match EN16931
  • Loading branch information
josemmo committed Sep 24, 2021
1 parent 411aeed commit 15f2dc5
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 25 deletions.
22 changes: 10 additions & 12 deletions src/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Invoice {
protected $buyerReference = null;
protected $purchaseOrderReference = null;
protected $salesOrderReference = null;
protected $originatorDocumentReference = null;
protected $tenderOrLotReference = null;
protected $paidAmount = 0;
protected $roundingAmount = 0;
protected $seller = null;
Expand Down Expand Up @@ -335,23 +335,21 @@ public function setSalesOrderReference(?string $salesOrderReference): self {


/**
* Get originator document reference
* @return string|null
* Get tender or lot reference
* @return string|null Tender or lot reference
*/
public function getOriginatorDocumentReference(): ?string
{
return $this->originatorDocumentReference;
public function getTenderOrLotReference(): ?string {
return $this->tenderOrLotReference;
}


/**
* Set originator document reference
* @param string|null $originatorDocumentReference
* @return Invoice
* @see https://docs.peppol.eu/poacc/billing/3.0/syntax/ubl-invoice/cac-OriginatorDocumentReference/
* Set tender or lot reference
* @param string|null $tenderOrLotReference Tender or lot reference
* @return self Invoice instance
*/
public function setOriginatorDocumentReference(?string $originatorDocumentReference): self {
$this->originatorDocumentReference = $originatorDocumentReference;
public function setTenderOrLotReference(?string $tenderOrLotReference): self {
$this->tenderOrLotReference = $tenderOrLotReference;
return $this;
}

Expand Down
8 changes: 4 additions & 4 deletions src/Readers/UblReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ public function import(string $document): Invoice {
$invoice->addPrecedingInvoiceReference($invoiceReference);
}

// Originator Document Reference
$originatorDocumentReference = $xml->get("{{$cac}}OriginatorDocumentReference/{{$cbc}}ID");
if ($originatorDocumentReference !== null) {
$invoice->setOriginatorDocumentReference($originatorDocumentReference->asText());
// BT-17: Tender or lot reference
$tenderOrLotReferenceNode = $xml->get("{{$cac}}OriginatorDocumentReference/{{$cbc}}ID");
if ($tenderOrLotReferenceNode !== null) {
$invoice->setTenderOrLotReference($tenderOrLotReferenceNode->asText());
}

// BG-24: Attachment nodes
Expand Down
9 changes: 4 additions & 5 deletions src/Writers/UblWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,10 @@ public function export(Invoice $invoice): string {
}
}

$originatorDocumentReference = $invoice->getOriginatorDocumentReference();
if ($originatorDocumentReference) {
$xml
->add('cac:OriginatorDocumentReference')
->add('cbc:ID', $originatorDocumentReference);
// BT-17: Tender or lot reference
$tenderOrLotReference = $invoice->getTenderOrLotReference();
if ($tenderOrLotReference !== null) {
$xml->add('cac:OriginatorDocumentReference')->add('cbc:ID', $tenderOrLotReference);
}

// BG-24: Attachments node
Expand Down
3 changes: 3 additions & 0 deletions tests/Integration/peppol-base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<cbc:ID>INV-123</cbc:ID>
</cac:InvoiceDocumentReference>
</cac:BillingReference>
<cac:OriginatorDocumentReference>
<cbc:ID>PPID-123</cbc:ID>
</cac:OriginatorDocumentReference>
<cac:AdditionalDocumentReference>
<cbc:ID>INV-123</cbc:ID>
<cbc:DocumentTypeCode>130</cbc:DocumentTypeCode>
Expand Down
3 changes: 0 additions & 3 deletions tests/Readers/peppol-example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
<ns:ID>INV-123</ns:ID>
</cac:InvoiceDocumentReference>
</cac:BillingReference>
<cac:OriginatorDocumentReference>
<ns:ID>PPID-123</ns:ID>
</cac:OriginatorDocumentReference>
<cac:AdditionalDocumentReference>
<ns:ID>ABC-123</ns:ID>
<ns:DocumentDescription>Invoice ABC-123</ns:DocumentDescription>
Expand Down
2 changes: 1 addition & 1 deletion tests/Writers/UblWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private function getSampleInvoice(): Invoice {
->setDueDate(new DateTime('+30 days'))
->setBuyerReference('REF-0172637')
->addPrecedingInvoiceReference(new InvoiceReference('INV-123'))
->setOriginatorDocumentReference('PPID-123')
->setTenderOrLotReference('PPID-123')
->setSeller($seller)
->setBuyer($buyer)
->addLine($complexLine)
Expand Down

0 comments on commit 15f2dc5

Please sign in to comment.