Skip to content

Commit

Permalink
Added method "setDocumentBusinessProcess" to ZugferdDocumentBuilder f…
Browse files Browse the repository at this point in the history
…or setting the BusinessProcessSpecifiedDocumentContextParameter-Element
  • Loading branch information
HorstOeko committed Apr 5, 2024
1 parent a4acca4 commit 47730d3
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/ZugferdDocumentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,29 @@ public function setDocumentInformation(string $documentno, string $documenttypec
return $this;
}

/**
* Set grouping of business process information
*
* @param string $id
* Identifies the context of a business process where the transaction is taking place, thus allowing the buyer to
* process the invoice in an appropriate manner.
* __Note__: These data make it possible to define the purpose of the settlement (invoice of the authorised person,
* contractual partner, subcontractor, settlement document for a building contract etc.).
* @return ZugferdDocumentBuilder
*/
public function setDocumentBusinessProcess(string $id): ZugferdDocumentBuilder
{
if ($this->getObjectHelper()->isNullOrEmpty($id)) {
return $this;
}

$busProcessCtxParameter = $this->getObjectHelper()->createClassInstance('ram\DocumentContextParameterType');
$this->getObjectHelper()->tryCall($busProcessCtxParameter, 'setID', $this->getObjectHelper()->getIdType($id));
$this->getObjectHelper()->tryCall($this->getInvoiceObject()->getExchangedDocumentContext(), 'setBusinessProcessSpecifiedDocumentContextParameter', $busProcessCtxParameter);

return $this;
}

/**
* Set general payment information
*
Expand Down
17 changes: 17 additions & 0 deletions tests/testcases/BuilderEn16931Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ public function testSetDocumentInformation(): void
$this->assertXPathValue('/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:InvoiceCurrencyCode', "EUR");
}

/**
* @covers \horstoeko\zugferd\ZugferdDocumentBuilder::setDocumentBusinessProcess
*/
public function testSetDocumentBusinessProcess(): void
{
$this->disableRenderXmlContent();
$this->assertXPathNotExists('/rsm:CrossIndustryInvoice/rsm:ExchangedDocumentContext/ram:BusinessProcessSpecifiedDocumentContextParameter/ram:ID');

(self::$document)->setDocumentBusinessProcess("");
$this->disableRenderXmlContent();
$this->assertXPathNotExists('/rsm:CrossIndustryInvoice/rsm:ExchangedDocumentContext/ram:BusinessProcessSpecifiedDocumentContextParameter/ram:ID');

(self::$document)->setDocumentBusinessProcess("GENERAL INVOICE");
$this->disableRenderXmlContent();
$this->assertXPathValue('/rsm:CrossIndustryInvoice/rsm:ExchangedDocumentContext/ram:BusinessProcessSpecifiedDocumentContextParameter/ram:ID', "GENERAL INVOICE");
}

/**
* @covers \horstoeko\zugferd\ZugferdDocumentBuilder::setDocumentGeneralPaymentInformation
*/
Expand Down
17 changes: 17 additions & 0 deletions tests/testcases/BuilderExtendedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ public function testSetDocumentInformation(): void
$this->assertXPathValue('/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:InvoiceCurrencyCode', "EUR");
}

/**
* @covers \horstoeko\zugferd\ZugferdDocumentBuilder::setDocumentBusinessProcess
*/
public function testSetDocumentBusinessProcess(): void
{
$this->disableRenderXmlContent();
$this->assertXPathNotExists('/rsm:CrossIndustryInvoice/rsm:ExchangedDocumentContext/ram:BusinessProcessSpecifiedDocumentContextParameter/ram:ID');

(self::$document)->setDocumentBusinessProcess("");
$this->disableRenderXmlContent();
$this->assertXPathNotExists('/rsm:CrossIndustryInvoice/rsm:ExchangedDocumentContext/ram:BusinessProcessSpecifiedDocumentContextParameter/ram:ID');

(self::$document)->setDocumentBusinessProcess("GENERAL INVOICE");
$this->disableRenderXmlContent();
$this->assertXPathValue('/rsm:CrossIndustryInvoice/rsm:ExchangedDocumentContext/ram:BusinessProcessSpecifiedDocumentContextParameter/ram:ID', "GENERAL INVOICE");
}

/**
* @covers \horstoeko\zugferd\ZugferdDocumentBuilder::setDocumentGeneralPaymentInformation
*/
Expand Down
17 changes: 17 additions & 0 deletions tests/testcases/BuilderMinimumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,23 @@ public function testSetDocumentInformation(): void
$this->assertXPathValue('/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeSettlement/ram:InvoiceCurrencyCode', "EUR");
}

/**
* @covers \horstoeko\zugferd\ZugferdDocumentBuilder::setDocumentBusinessProcess
*/
public function testSetDocumentBusinessProcess(): void
{
$this->disableRenderXmlContent();
$this->assertXPathNotExists('/rsm:CrossIndustryInvoice/rsm:ExchangedDocumentContext/ram:BusinessProcessSpecifiedDocumentContextParameter/ram:ID');

(self::$document)->setDocumentBusinessProcess("");
$this->disableRenderXmlContent();
$this->assertXPathNotExists('/rsm:CrossIndustryInvoice/rsm:ExchangedDocumentContext/ram:BusinessProcessSpecifiedDocumentContextParameter/ram:ID');

(self::$document)->setDocumentBusinessProcess("GENERAL INVOICE");
$this->disableRenderXmlContent();
$this->assertXPathValue('/rsm:CrossIndustryInvoice/rsm:ExchangedDocumentContext/ram:BusinessProcessSpecifiedDocumentContextParameter/ram:ID', "GENERAL INVOICE");
}

/**
* @covers \horstoeko\zugferd\ZugferdDocumentBuilder::setDocumentGeneralPaymentInformation
*/
Expand Down

0 comments on commit 47730d3

Please sign in to comment.