Skip to content

Commit

Permalink
[FEAT] Added methods ZugferdDocumentReader::getDocumentQuotationRefer…
Browse files Browse the repository at this point in the history
…encedDocument and ZugferdDocumentReader::getDocumentPositionQuotationReferencedDocument
  • Loading branch information
HorstOeko committed Dec 1, 2024
1 parent f408494 commit 513d3b8
Show file tree
Hide file tree
Showing 13 changed files with 290 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/ZugferdDocumentReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2394,6 +2394,24 @@ public function getDocumentBuyerOrderReferencedDocument(?string &$issuerassigned
return $this;
}

/**
* Get details of the associated offer
*
* @param string|null $issuerassignedid __BT-X-403, From EXTENDED__ Offer number
* @param DateTime|null $issueddate __BT-X-404, From EXTENDED__ Date of offer
* @return ZugferdDocumentReader
*/
public function getDocumentQuotationReferencedDocument(?string &$issuerassignedid, ?DateTime &$issueddate): ZugferdDocumentReader
{
$issuerassignedid = $this->getInvoiceValueByPath("getSupplyChainTradeTransaction.getApplicableHeaderTradeAgreement.getQuotationReferencedDocument.getIssuerAssignedID.value", "");
$issueddate = $this->getObjectHelper()->toDateTime(
$this->getInvoiceValueByPath("getSupplyChainTradeTransaction.getApplicableHeaderTradeAgreement.getQuotationReferencedDocument.getFormattedIssueDateTime.getDateTimeString.value", ""),
$this->getInvoiceValueByPath("getSupplyChainTradeTransaction.getApplicableHeaderTradeAgreement.getQuotationReferencedDocument.getFormattedIssueDateTime.getDateTimeString.getFormat", "")
);

return $this;
}

/**
* Get details of the associated contract
*
Expand Down Expand Up @@ -3700,6 +3718,29 @@ public function getDocumentPositionBuyerOrderReferencedDocument(?string &$issuer
return $this;
}

/**
* Get details of the associated offer position
*
* @param string|null $issuerassignedid __BT-X-310, From EXTENDED__ Offer number
* @param string|null $lineid __BT-X-311, From EXTENDED__ Position identifier within the offer
* @param DateTime|null $issueddate __BT-X-312, From EXTENDED__ Date of offder
* @return ZugferdDocumentReader
*/
public function getDocumentPositionQuotationReferencedDocument(?string &$issuerassignedid, ?string &$lineid, ?DateTime &$issueddate): ZugferdDocumentReader
{
$tradeLineItem = $this->getInvoiceValueByPath("getSupplyChainTradeTransaction.getIncludedSupplyChainTradeLineItem", []);
$tradeLineItem = $tradeLineItem[$this->positionPointer];

$issuerassignedid = $this->getInvoiceValueByPathFrom($tradeLineItem, "getSpecifiedLineTradeAgreement.getQuotationReferencedDocument.getIssuerAssignedID.value", "");
$lineid = $this->getInvoiceValueByPathFrom($tradeLineItem, "getSpecifiedLineTradeAgreement.getQuotationReferencedDocument.getLineID.value", "");
$issueddate = $this->getObjectHelper()->toDateTime(
$this->getInvoiceValueByPathFrom($tradeLineItem, "getSpecifiedLineTradeAgreement.getQuotationReferencedDocument.getFormattedIssueDateTime.getDateTimeString.value", null),
$this->getInvoiceValueByPathFrom($tradeLineItem, "getSpecifiedLineTradeAgreement.getQuotationReferencedDocument.getFormattedIssueDateTime.getDateTimeString.getFormat", null)
);

return $this;
}

/**
* Get details of the related contract position
*
Expand Down
27 changes: 27 additions & 0 deletions tests/testcases/PdfReaderEn16931AllowanceChargeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,13 @@ public function testDocumentBuyerOrderReferencedDocument(): void
$this->assertNull($buyerorderrefdocdate);
}

public function testDocumentQuotationReferencedDocument(): void
{
self::$document->getDocumentQuotationReferencedDocument($quotationrefdocid, $quotationrefdocdate);
$this->assertEquals("", $quotationrefdocid);
$this->assertNull($quotationrefdocdate);
}

public function testDocumentContractReferencedDocument(): void
{
self::$document->getDocumentContractReferencedDocument($contractrefdocid, $contractrefdocdate);
Expand Down Expand Up @@ -1006,6 +1013,11 @@ public function testDocumentPositionFirst(): void
$this->assertEquals("", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down Expand Up @@ -1148,6 +1160,11 @@ public function testDocumentPositionSecond(): void
$this->assertEquals("", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down Expand Up @@ -1257,6 +1274,11 @@ public function testDocumentPositionThird(): void
$this->assertEquals("", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down Expand Up @@ -1366,6 +1388,11 @@ public function testDocumentPositionFourth(): void
$this->assertEquals("", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down
17 changes: 17 additions & 0 deletions tests/testcases/PdfReaderEn16931Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,13 @@ public function testDocumentBuyerOrderReferencedDocument(): void
$this->assertNull($buyerorderrefdocdate);
}

public function testDocumentQuotationReferencedDocument(): void
{
self::$document->getDocumentQuotationReferencedDocument($quotationrefdocid, $quotationrefdocdate);
$this->assertEquals("", $quotationrefdocid);
$this->assertNull($quotationrefdocdate);
}

public function testDocumentContractReferencedDocument(): void
{
self::$document->getDocumentContractReferencedDocument($contractrefdocid, $contractrefdocdate);
Expand Down Expand Up @@ -946,6 +953,11 @@ public function testDocumentPositionFirst(): void
$this->assertEquals("", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down Expand Up @@ -1049,6 +1061,11 @@ public function testDocumentPositionSecond(): void
$this->assertEquals("", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down
22 changes: 22 additions & 0 deletions tests/testcases/PdfReaderExtended2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,13 @@ public function testDocumentBuyerOrderReferencedDocument(): void
$this->assertNull($buyerorderrefdocdate);
}

public function testDocumentQuotationReferencedDocument(): void
{
self::$document->getDocumentQuotationReferencedDocument($quotationrefdocid, $quotationrefdocdate);
$this->assertEquals("", $quotationrefdocid);
$this->assertNull($quotationrefdocdate);
}

public function testDocumentContractReferencedDocument(): void
{
self::$document->getDocumentContractReferencedDocument($contractrefdocid, $contractrefdocdate);
Expand Down Expand Up @@ -1011,6 +1018,11 @@ public function testDocumentPositionFirst(): void
$this->assertEquals("1", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down Expand Up @@ -1116,6 +1128,11 @@ public function testDocumentPositionSecond(): void
$this->assertEquals("3", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down Expand Up @@ -1220,6 +1237,11 @@ public function testDocumentPositionThird(): void
$this->assertEquals("", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down
32 changes: 32 additions & 0 deletions tests/testcases/PdfReaderExtendedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,13 @@ public function testDocumentBuyerOrderReferencedDocument(): void
$this->assertNull($buyerorderrefdocdate);
}

public function testDocumentQuotationReferencedDocument(): void
{
self::$document->getDocumentQuotationReferencedDocument($quotationrefdocid, $quotationrefdocdate);
$this->assertEquals("", $quotationrefdocid);
$this->assertNull($quotationrefdocdate);
}

public function testDocumentContractReferencedDocument(): void
{
self::$document->getDocumentContractReferencedDocument($contractrefdocid, $contractrefdocdate);
Expand Down Expand Up @@ -1011,6 +1018,11 @@ public function testDocumentPositionFirst(): void
$this->assertEquals("", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down Expand Up @@ -1114,6 +1126,11 @@ public function testDocumentPositionSecond(): void
$this->assertEquals("", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down Expand Up @@ -1217,6 +1234,11 @@ public function testDocumentPositionThird(): void
$this->assertEquals("", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down Expand Up @@ -1348,6 +1370,11 @@ public function testDocumentPositionFourth(): void
$this->assertEquals("", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down Expand Up @@ -1451,6 +1478,11 @@ public function testDocumentPositionFifth(): void
$this->assertEquals("", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down
7 changes: 7 additions & 0 deletions tests/testcases/PdfReaderMinimumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,13 @@ public function testDocumentBuyerOrderReferencedDocument(): void
$this->assertNull($buyerorderrefdocdate);
}

public function testDocumentQuotationReferencedDocument(): void
{
self::$document->getDocumentQuotationReferencedDocument($quotationrefdocid, $quotationrefdocdate);
$this->assertEquals("", $quotationrefdocid);
$this->assertNull($quotationrefdocdate);
}

public function testDocumentContractReferencedDocument(): void
{
self::$document->getDocumentContractReferencedDocument($contractrefdocid, $contractrefdocdate);
Expand Down
17 changes: 17 additions & 0 deletions tests/testcases/PdfReaderXRechnungTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,13 @@ public function testDocumentBuyerOrderReferencedDocument(): void
$this->assertNull($buyerorderrefdocdate);
}

public function testDocumentQuotationReferencedDocument(): void
{
self::$document->getDocumentQuotationReferencedDocument($quotationrefdocid, $quotationrefdocdate);
$this->assertEquals("", $quotationrefdocid);
$this->assertNull($quotationrefdocdate);
}

public function testDocumentContractReferencedDocument(): void
{
self::$document->getDocumentContractReferencedDocument($contractrefdocid, $contractrefdocdate);
Expand Down Expand Up @@ -962,6 +969,11 @@ public function testDocumentPositionFirst(): void
$this->assertEquals("", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down Expand Up @@ -1065,6 +1077,11 @@ public function testDocumentPositionSecond(): void
$this->assertEquals("", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down
12 changes: 12 additions & 0 deletions tests/testcases/ReaderBasicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,13 @@ public function testDocumentBuyerOrderReferencedDocument(): void
$this->assertNull($buyerorderrefdocdate);
}

public function testDocumentQuotationReferencedDocument(): void
{
self::$document->getDocumentQuotationReferencedDocument($quotationrefdocid, $quotationrefdocdate);
$this->assertEquals("", $quotationrefdocid);
$this->assertNull($quotationrefdocdate);
}

public function testDocumentContractReferencedDocument(): void
{
self::$document->getDocumentContractReferencedDocument($contractrefdocid, $contractrefdocdate);
Expand Down Expand Up @@ -955,6 +962,11 @@ public function testDocumentPositionFirst(): void
$this->assertEquals("", $doclineorderlineid);
$this->assertNull($doclineorderdate);

self::$document->getDocumentPositionQuotationReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
$this->assertNull($doclinecontdate);

self::$document->getDocumentPositionContractReferencedDocument($doclinecontid, $doclinecontlineid, $doclinecontdate);
$this->assertEquals("", $doclinecontid);
$this->assertEquals("", $doclinecontlineid);
Expand Down
Loading

0 comments on commit 513d3b8

Please sign in to comment.