Skip to content

Commit

Permalink
added AssociatedDocumentLineDocument>IncludedNote element (#47)
Browse files Browse the repository at this point in the history
* added AssociatedDocumentLineDocument>IncludedNote element
added Note@ContentCode property
* added LineTradeDelivery>ActualDeliverySupplyChainEvent element for extended format
  • Loading branch information
upsite4k authored Apr 25, 2023
1 parent 5803d08 commit a927d84
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/zugferd211/Model/DocumentLineDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use JMS\Serializer\Annotation\SerializedName;
use JMS\Serializer\Annotation\Type;
use JMS\Serializer\Annotation\XmlElement;
use JMS\Serializer\Annotation\XmlList;

class DocumentLineDocument
{
Expand All @@ -15,6 +16,13 @@ class DocumentLineDocument
*/
public string $lineId;

/**
* @var Note[]
* @Type("array<Easybill\ZUGFeRD211\Model\Note>")
* @XmlList(inline=true, entry="IncludedNote", namespace="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100")
*/
public array $notes = [];

public static function create(string $lineId): self
{
$self = new self();
Expand Down
7 changes: 7 additions & 0 deletions src/zugferd211/Model/LineTradeDelivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,11 @@ class LineTradeDelivery
* @SerializedName("BilledQuantity")
*/
public Quantity $billedQuantity;

/**
* @Type("Easybill\ZUGFeRD211\Model\SupplyChainEvent")
* @XmlElement(cdata=false, namespace="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100")
* @SerializedName("ActualDeliverySupplyChainEvent")
*/
public ?SupplyChainEvent $chainEvent = null;
}
10 changes: 9 additions & 1 deletion src/zugferd211/Model/Note.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

class Note
{
/**
* @Type("string")
* @XmlElement(cdata=false, namespace="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100")
* @SerializedName("ContentCode")
*/
public ?string $contentCode = null;

/**
* @Type("string")
* @XmlElement(cdata=false, namespace="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100")
Expand All @@ -22,11 +29,12 @@ class Note
*/
public ?string $subjectCode = null;

public static function create(string $content, ?string $subjectCode = null): self
public static function create(string $content, ?string $subjectCode = null, ?string $contentCode = null): self
{
$self = new self();
$self->content = $content;
$self->subjectCode = $subjectCode;
$self->contentCode = $contentCode;
return $self;
}
}
3 changes: 3 additions & 0 deletions tests/zugferd211/Tests/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ public function testBuildXRechnungExtendedExample(): void
$invoice->supplyChainTradeTransaction = new SupplyChainTradeTransaction();
$invoice->supplyChainTradeTransaction->lineItems[] = $item1 = new SupplyChainTradeLineItem();
$item1->associatedDocumentLineDocument = DocumentLineDocument::create('1');
$item1->associatedDocumentLineDocument->notes[] = Note::create('Neutrale Umverpackung', 'AAI', 'Umverpackung');

$item1->specifiedTradeProduct = new TradeProduct();
$item1->specifiedTradeProduct->name = 'Trennblätter A4';
Expand All @@ -242,6 +243,8 @@ public function testBuildXRechnungExtendedExample(): void

$item1->delivery = new LineTradeDelivery();
$item1->delivery->billedQuantity = Quantity::create('20.0000', 'H87');
$item1->delivery->chainEvent = new SupplyChainEvent();
$item1->delivery->chainEvent->date = DateTime::create('102', '20180305');

$item1->specifiedLineTradeSettlement = new LineTradeSettlement();
$item1->specifiedLineTradeSettlement->tradeTax[] = $item1tax = new TradeTax();
Expand Down
10 changes: 10 additions & 0 deletions tests/zugferd211/Tests/zugferd_2p1_XRECHNUNG_Extended.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ Handelsregisternummer: H A 123
<ram:IncludedSupplyChainTradeLineItem>
<ram:AssociatedDocumentLineDocument>
<ram:LineID>1</ram:LineID>
<ram:IncludedNote>
<ram:ContentCode>Umverpackung</ram:ContentCode>
<ram:Content>Neutrale Umverpackung</ram:Content>
<ram:SubjectCode>AAI</ram:SubjectCode>
</ram:IncludedNote>
</ram:AssociatedDocumentLineDocument>
<ram:SpecifiedTradeProduct>
<ram:GlobalID schemeID="0160">4012345001235</ram:GlobalID>
Expand All @@ -137,6 +142,11 @@ Handelsregisternummer: H A 123
</ram:SpecifiedLineTradeAgreement>
<ram:SpecifiedLineTradeDelivery>
<ram:BilledQuantity unitCode="H87">20.0000</ram:BilledQuantity>
<ram:ActualDeliverySupplyChainEvent>
<ram:OccurrenceDateTime>
<udt:DateTimeString format="102">20180305</udt:DateTimeString>
</ram:OccurrenceDateTime>
</ram:ActualDeliverySupplyChainEvent>
</ram:SpecifiedLineTradeDelivery>
<ram:SpecifiedLineTradeSettlement>
<ram:ApplicableTradeTax>
Expand Down

0 comments on commit a927d84

Please sign in to comment.