Skip to content

Commit

Permalink
Added "RequestedDespatchSupplyChainEvent" on document level
Browse files Browse the repository at this point in the history
  • Loading branch information
ruff committed Dec 28, 2022
1 parent 5e169e1 commit 762160d
Show file tree
Hide file tree
Showing 18 changed files with 1,239 additions and 271 deletions.
17 changes: 12 additions & 5 deletions doc/doc-index.html

Large diffs are not rendered by default.

238 changes: 179 additions & 59 deletions doc/horstoeko/orderx/OrderDocumentBuilder.html

Large diffs are not rendered by default.

452 changes: 299 additions & 153 deletions doc/horstoeko/orderx/OrderDocumentReader.html

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions doc/sami.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion examples/OrderBuilderComfortSimple.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$dt = \DateTime::createFromFormat("Ymd", "20221225");

$document = OrderDocumentBuilder::CreateNew(
OrderProfiles::PROFILE_COMFORT
OrderProfiles::PROFILE_EXTENDED
);

$document
Expand Down Expand Up @@ -79,6 +79,7 @@
->setDocumentShipFromElectronicAddress("EM", "warehouse@seller.com")

->setDocumentRequestedDeliverySupplyChainEvent($dt, $dt, $dt)
->setDocumentRequestedDespatchSupplyChainEvent($dt, $dt, $dt)

->setDocumentInvoicee("INVOICEE_NAME", "INVOICEE_ID_9587456")
->addDocumentInvoiceeGlobalId("98765432179", "0088")
Expand Down
36 changes: 36 additions & 0 deletions src/OrderDocumentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1818,6 +1818,42 @@ public function addDocumentRequestedDeliverySupplyChainEvent(?DateTime $occurren
return $this;
}

/**
* Set the requested date or period on which Pick up is requested
*
* @param DateTime|null $occurrenceDateTime
* A Requested Date on which Pick up is requested
* @param DateTime|null $startDateTime
* The Start Date of he Requested Period on which Pick up is requested
* @param DateTime|null $endDateTime
* The End Date of he Requested Period on which Pick up is requested
* @return OrderDocumentBuilder
*/
public function setDocumentRequestedDespatchSupplyChainEvent(?DateTime $occurrenceDateTime = null, ?DateTime $startDateTime = null, ?DateTime $endDateTime = null): OrderDocumentBuilder
{
$supplychainevent = $this->objectHelper->getDeliverySupplyChainEvent($occurrenceDateTime, $startDateTime, $endDateTime);
$this->objectHelper->tryCallIfMethodExists($this->headerTradeDelivery, "addToRequestedDespatchSupplyChainEvent", "setRequestedDespatchSupplyChainEvent", [$supplychainevent], $supplychainevent);
return $this;
}

/**
* Add an additional requested date or period on which Pick up is requested
*
* @param DateTime|null $occurrenceDateTime
* A Requested Date on which Pick up is requested
* @param DateTime|null $startDateTime
* The Start Date of he Requested Period on which Pick up is requested
* @param DateTime|null $endDateTime
* The End Date of he Requested Period on which Pick up is requested
* @return OrderDocumentBuilder
*/
public function addDocumentRequestedDespatchSupplyChainEvent(?DateTime $occurrenceDateTime = null, ?DateTime $startDateTime = null, ?DateTime $endDateTime = null): OrderDocumentBuilder
{
$supplychainevent = $this->objectHelper->getDeliverySupplyChainEvent($occurrenceDateTime, $startDateTime, $endDateTime);
$this->objectHelper->tryCall($this->headerTradeDelivery, "addToRequestedDespatchSupplyChainEvent", $supplychainevent);
return $this;
}

/**
* Set detailed information on the Party to which the invoice must be sent
*
Expand Down
67 changes: 67 additions & 0 deletions src/OrderDocumentReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ class OrderDocumentReader extends OrderDocument
*/
private $documentRequestedDeliverySupplyChainEventPointer = 0;

/**
* @var integer
*/
private $documentRequestedDespatchSupplyChainEventPointer = 0;

/**
* @var integer
*/
Expand Down Expand Up @@ -1873,6 +1878,68 @@ public function getDocumentRequestedDeliverySupplyChainEvent(?DateTime &$occurre
return $this;
}

/**
* Seek to the first document requested despatch supply chain event of the document.
* Returns true if a first event is available, otherwise false
* You may use this together with OrderDocumentReader::getRequestedDespatchSupplyChainEvent
*
* @return boolean
*/
public function firstDocumentRequestedDespatchSupplyChainEvent(): bool
{
$this->documentRequestedDespatchSupplyChainEventPointer = 0;
$events = $this->objectHelper->ensureArray($this->getInvoiceValueByPath("getSupplyChainTradeTransaction.getApplicableHeaderTradeDelivery.getRequestedDespatchSupplyChainEvent", []));
return isset($events[$this->documentRequestedDespatchSupplyChainEventPointer]);
}

/**
* Seek to the next document requested despatch supply chain event of the document.
* Returns true if a event is available, otherwise false
* You may use this together with OrderDocumentReader::getRequestedDespatchSupplyChainEvent
*
* @return boolean
*/
public function nextDocumentRequestedDespatchSupplyChainEvent(): bool
{
$this->documentRequestedDespatchSupplyChainEventPointer++;
$events = $this->objectHelper->ensureArray($this->getInvoiceValueByPath("getSupplyChainTradeTransaction.getApplicableHeaderTradeDelivery.getRequestedDespatchSupplyChainEvent", []));
return isset($events[$this->documentRequestedDespatchSupplyChainEventPointer]);
}

/**
* Get the requested date or period on which delivery is requested
* This method should be used together with __OrderDocumentReader::firstDocumentRequestedDespatchSupplyChainEvent__
* and __OrderDocumentReader::nextDocumentRequestedDespatchSupplyChainEvent__
*
* @param DateTime $occurrenceDateTime
* A Requested Date on which Pick up is requested
* @param DateTime|null $startDateTime
* The Start Date of he Requested Period on which Pick up is requested
* @param DateTime|null $endDateTime
* The End Date of he Requested Period on which Pick up is requested
* @return OrderDocumentReader
*/
public function getDocumentRequestedDespatchSupplyChainEvent(?DateTime &$occurrenceDateTime, ?DateTime &$startDateTime, ?DateTime &$endDateTime): OrderDocumentReader
{
$events = $this->objectHelper->ensureArray($this->getInvoiceValueByPath("getSupplyChainTradeTransaction.getApplicableHeaderTradeDelivery.getRequestedDespatchSupplyChainEvent", []));
$event = $this->objectHelper->getArrayIndex($events, $this->documentRequestedDeliverySupplyChainEventPointer);

$occurrenceDateTime = $this->objectHelper->toDateTime(
$this->getInvoiceValueByPathFrom($event, "getOccurrenceDateTime.getDateTimeString", ""),
$this->getInvoiceValueByPathFrom($event, "getOccurrenceDateTime.getDateTimeString.getFormat", "")
);
$startDateTime = $this->objectHelper->toDateTime(
$this->getInvoiceValueByPathFrom($event, "getOccurrenceSpecifiedPeriod.getStartDateTime.getDateTimeString", ""),
$this->getInvoiceValueByPathFrom($event, "getOccurrenceSpecifiedPeriod.getStartDateTime.getDateTimeString.getFormat", "")
);
$endDateTime = $this->objectHelper->toDateTime(
$this->getInvoiceValueByPathFrom($event, "getOccurrenceSpecifiedPeriod.getEndDateTime.getDateTimeString", ""),
$this->getInvoiceValueByPathFrom($event, "getOccurrenceSpecifiedPeriod.getEndDateTime.getDateTimeString.getFormat", "")
);

return $this;
}

/**
* Get detailed information on the Party to which the invoice must be sent
*
Expand Down
Binary file modified tests/assets/reader-order-x-comfort.pdf
Binary file not shown.
13 changes: 13 additions & 0 deletions tests/assets/reader-order-x-comfort.xml
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,19 @@
</ram:EndDateTime>
</ram:OccurrenceSpecifiedPeriod>
</ram:RequestedDeliverySupplyChainEvent>
<ram:RequestedDespatchSupplyChainEvent>
<ram:OccurrenceDateTime>
<udt:DateTimeString format="102">20221225</udt:DateTimeString>
</ram:OccurrenceDateTime>
<ram:OccurrenceSpecifiedPeriod>
<ram:StartDateTime>
<udt:DateTimeString format="102">20221225</udt:DateTimeString>
</ram:StartDateTime>
<ram:EndDateTime>
<udt:DateTimeString format="102">20221225</udt:DateTimeString>
</ram:EndDateTime>
</ram:OccurrenceSpecifiedPeriod>
</ram:RequestedDespatchSupplyChainEvent>
</ram:ApplicableHeaderTradeDelivery>
<ram:ApplicableHeaderTradeSettlement>
<ram:OrderCurrencyCode>EUR</ram:OrderCurrencyCode>
Expand Down
Binary file modified tests/assets/reader-order-x-extended.pdf
Binary file not shown.
Loading

0 comments on commit 762160d

Please sign in to comment.