Skip to content

Commit

Permalink
Merge pull request #6 from easybill/billing-period
Browse files Browse the repository at this point in the history
added BillingSpecifiedPeriod to model
  • Loading branch information
PATROMO authored Jul 3, 2019
2 parents b2c8803 + 6d025b5 commit 8b14ca6
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 1 deletion.
73 changes: 73 additions & 0 deletions src/Easybill/ZUGFeRD/Model/Trade/BillingPeriod.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace Easybill\ZUGFeRD\Model\Trade;

use Easybill\ZUGFeRD\Model\Date;
use JMS\Serializer\Annotation as JMS;

class BillingPeriod
{

/**
* @var Date
* @JMS\Type("Easybill\ZUGFeRD\Model\Date")
* @JMS\XmlElement(cdata=false,namespace="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12")
* @JMS\SerializedName("StartDateTime")
*/
private $start;

/**
* @var Date
* @JMS\Type("Easybill\ZUGFeRD\Model\Date")
* @JMS\XmlElement(cdata=false,namespace="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12")
* @JMS\SerializedName("EndDateTime")
*/
private $end;

/**
* @param Date $start
* @param Date $end
*/
public function __construct(Date $start, Date $end)
{
$this->start = $start;
$this->end = $end;
}

/**
* @return Date
*/
public function getStart()
{
return $this->start;
}

/**
* @param Date $start
* @return self
*/
public function setStart($start)
{
$this->start = $start;
return $this;
}

/**
* @return Date
*/
public function getEnd()
{
return $this->end;
}

/**
* @param Date $end
* @return self
*/
public function setEnd($end)
{
$this->end = $end;
return $this;
}

}
28 changes: 27 additions & 1 deletion src/Easybill/ZUGFeRD/Model/Trade/Settlement.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use JMS\Serializer\Annotation\XmlList;

/**
* @AccessorOrder("custom", custom = {"paymentReference", "currency", "paymentMeans", "tradeTaxes", "paymentTerms", "monetarySummation"})
* @AccessorOrder("custom", custom = {"paymentReference", "currency", "paymentMeans", "tradeTaxes", "billingPeriod", "paymentTerms", "monetarySummation"})
*/
class Settlement
{
Expand Down Expand Up @@ -44,6 +44,14 @@ class Settlement
*/
private $tradeTaxes = array();

/**
* @var BillingPeriod
* @Type("Easybill\ZUGFeRD\Model\Trade\BillingPeriod")
* @XmlElement(cdata = false, namespace = "urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12")
* @SerializedName("BillingSpecifiedPeriod")
*/
private $billingPeriod;

/**
* @var MonetarySummation
* @Type("Easybill\ZUGFeRD\Model\Trade\MonetarySummation")
Expand Down Expand Up @@ -187,4 +195,22 @@ public function setPaymentTerms($paymentTerms)
return $this;
}

/**
* @return \Easybill\ZUGFeRD\Model\Trade\BillingPeriod
*/
public function getBillingPeriod()
{
return $this->billingPeriod;
}

/**
* @param \Easybill\ZUGFeRD\Model\Trade\BillingPeriod $billingPeriod
* @return self
*/
public function setBillingPeriod($billingPeriod)
{
$this->billingPeriod = $billingPeriod;
return $this;
}

}
14 changes: 14 additions & 0 deletions src/Easybill/ZUGFeRD/Tests/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ public function testGetXML()
<ram:BasisAmount currencyID="EUR">198.00</ram:BasisAmount>
<ram:ApplicablePercent>19.00</ram:ApplicablePercent>
</ram:ApplicableTradeTax>
<ram:BillingSpecifiedPeriod>
<ram:StartDateTime>
<udt:DateTimeString format="102">20130104</udt:DateTimeString>
</ram:StartDateTime>
<ram:EndDateTime>
<udt:DateTimeString format="102">20130204</udt:DateTimeString>
</ram:EndDateTime>
</ram:BillingSpecifiedPeriod>
<ram:SpecifiedTradePaymentTerms>
<ram:Description>Zahlbar innerhalb von 20 Tagen (bis zum 05.10.2016) unter Abzug von 3% Skonto (Zahlungsbetrag = 1.766,03 €). Bis zum 29.09.2016 ohne Abzug.</ram:Description>
<ram:DueDateDateTime>
Expand Down Expand Up @@ -294,6 +302,12 @@ private function setSettlement(\Easybill\ZUGFeRD\Model\Trade\Trade $trade)
new \Easybill\ZUGFeRD\Model\Trade\MonetarySummation(198.00, 0.00, 0.00, 198.00, 37.62, 235.62, 'EUR')
);

$billingPeriod = new \Easybill\ZUGFeRD\Model\Trade\BillingPeriod(
new \Easybill\ZUGFeRD\Model\Date('20130104'),
new \Easybill\ZUGFeRD\Model\Date('20130204')
);
$settlement->setBillingPeriod($billingPeriod);

$trade->setSettlement($settlement);
}

Expand Down
12 changes: 12 additions & 0 deletions src/Easybill/ZUGFeRD/Tests/ReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ public function testGetDocument()
<ram:BasisAmount currencyID="EUR">198.00</ram:BasisAmount>
<ram:ApplicablePercent>19.00</ram:ApplicablePercent>
</ram:ApplicableTradeTax>
<ram:BillingSpecifiedPeriod>
<ram:StartDateTime>
<udt:DateTimeString format="102">20130104</udt:DateTimeString>
</ram:StartDateTime>
<ram:EndDateTime>
<udt:DateTimeString format="102">20130204</udt:DateTimeString>
</ram:EndDateTime>
</ram:BillingSpecifiedPeriod>
<ram:SpecifiedTradePaymentTerms>
<ram:Description>Zahlbar innerhalb 30 Tagen netto bis 04.04.2013, 3% Skonto innerhalb 10 Tagen bis 15.03.2013</ram:Description>
<ram:DueDateDateTime>
Expand Down Expand Up @@ -308,6 +316,10 @@ private function checkTradeSettlement(\Easybill\ZUGFeRD\Model\Trade\Settlement $
$this->assertSame(198.00, $tradeTax2->getBasisAmount()->getValue());
$this->assertSame(19.00, $tradeTax2->getPercent());

$billingPeriod = $settlement->getBillingPeriod();
$this->assertSame('20130104', $billingPeriod->getStart()->getDate());
$this->assertSame('20130204', $billingPeriod->getEnd()->getDate());

$monetarySummation = $settlement->getMonetarySummation();
$this->assertSame(198.00, $monetarySummation->getLineTotal()->getValue());
$this->assertSame('EUR', $monetarySummation->getLineTotal()->getCurrency());
Expand Down

0 comments on commit 8b14ca6

Please sign in to comment.