Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* Added tracking of consumption data (eg. bandwith consumed)

* Added billing period start & end
  • Loading branch information...
commit 3f21e81167bf2db033af753faa67243107dd801f 1 parent 1ea6070
inspiran authored iampersistent committed
View
21 lib/Vespolina/Entity/Billing/BillingAgreement.php
@@ -1,7 +1,6 @@
<?php
namespace Vespolina\Entity\Billing;
-use Vespolina\Entity\Order\ItemInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Vespolina\Entity\Order\OrderInterface;
use Vespolina\Entity\Partner\PartnerInterface;
@@ -14,11 +13,11 @@ class BillingAgreement implements BillingAgreementInterface
protected $billingInterval;
protected $createdAt;
protected $id;
- protected $initialBillingDate;
+ protected $plannedBillingDate;
protected $nextBillingDate;
protected $order;
protected $orderItems;
- protected $partner;
+ protected $owner;
protected $paymentGateway;
protected $numberCyclesBilled;
protected $updatedAt;
@@ -116,16 +115,16 @@ public function setCreatedAt(\DateTime $createdAt)
$this->createdAt = $createdAt;
}
- public function setInitialBillingDate(\DateTime $initialBillingDate)
+ public function setPlannedBillingDate(\DateTime $plannedBillingDate)
{
- $this->initialBillingDate = $initialBillingDate;
+ $this->plannedBillingDate = $plannedBillingDate;
return $this;
}
- public function getInitialBillingDate()
+ public function getPlannedBillingDate()
{
- return $this->initialBillingDate;
+ return $this->plannedBillingDate;
}
public function setNextBillingDate(\DateTime $nextBillingDate)
@@ -169,16 +168,16 @@ public function addOrderItem(ItemInterface $item)
$this->orderItems->add($item);
}
- public function setPartner(PartnerInterface $partner)
+ public function setOwner(PartnerInterface $owner)
{
- $this->partner = $partner;
+ $this->owner = $owner;
return $this;
}
- public function getPartner()
+ public function getOwner()
{
- return $this->partner;
+ return $this->owner;
}
public function setPaymentGateway($paymentGateway)
View
10 lib/Vespolina/Entity/Billing/BillingAgreementInterface.php
@@ -52,14 +52,14 @@ function setBillingInterval($billingInterval);
*/
function getBillingInterval();
- function setInitialBillingDate(\DateTime $initialBillingDate);
+ function setPlannedBillingDate(\DateTime $plannedBillingDate);
/*
* Return the date when the first billing request should be created
*
* @return /DateTime
*/
- function getInitialBillingDate();
+ function getPlannedBillingDate();
function setOrder(OrderInterface $order);
@@ -69,11 +69,11 @@ function setOrderItems($items);
function getOrderItems();
- function setPartner(PartnerInterface $partner);
+ function setOwner(PartnerInterface $owner);
- function getPartner();
+ function getOwner();
function setPaymentGateway($paymentGateway);
function getPaymentGateway();
-}
+}
View
55 lib/Vespolina/Entity/Billing/BillingRequest.php
@@ -9,6 +9,7 @@
namespace Vespolina\Entity\Billing;
use Vespolina\Entity\Billing\BillingRequestInterface;
+use Vespolina\Entity\Partner\PartnerInterface;
use Vespolina\Entity\Partner\PaymentProfileInterface;
class BillingRequest implements BillingRequestInterface
@@ -33,23 +34,28 @@ class BillingRequest implements BillingRequestInterface
const STATE_PAID = 'paid'; //Cancelled by administration
const STATE_CLOSED = 'closed'; //(optional) processing after payment received was completed
- protected $billingAgreements;
protected $createdAt;
+ protected $billingAgreements;
protected $billingDate;
protected $plannedBillingDate;
protected $owner;
protected $paymentProfile;
+ protected $periodStart;
+ protected $periodEnd;
protected $pricingSet;
protected $state;
public function __construct()
{
$this->billingAgreements = array();
+ $this->consumption = array();
}
public function addBillingAgreement(BillingAgreementInterface $billingAgreement)
{
$this->billingAgreements[] = $billingAgreement;
+
+ return $this;
}
public function getBillingAgreements()
@@ -75,6 +81,24 @@ public function setBillingDate(\DateTime $date)
return $this;
}
+
+ public function addConsumption($key, $value)
+ {
+ $this->consumption[$key] = $value;
+
+ return $this;
+ }
+ public function getConsumption()
+ {
+ return $this->consumption;
+ }
+
+ public function setConsumption(array $consumption)
+ {
+ $this->consumption = $consumption;
+
+ return $this;
+ }
public function getPlannedBillingDate()
{
@@ -144,10 +168,31 @@ public function getPaymentProfile()
return $this->paymentProfile;
}
- /**
- * @param $pricingSet
- * @return BillingRequest
- */
+
+ public function setPeriodEnd(\DateTime $periodEnd)
+ {
+ $this->periodEnd = $periodEnd;
+
+ return $this;
+ }
+
+ public function getPeriodEnd()
+ {
+ return $this->periodEnd;
+ }
+
+ public function setPeriodStart(\DateTime $periodStart)
+ {
+ $this->periodStart = $periodStart;
+
+ return $this;
+ }
+
+ public function getPeriodStart()
+ {
+ return $this->periodStart;
+ }
+
public function setPricingSet($pricingSet)
{
$this->pricingSet = $pricingSet;
View
42 lib/Vespolina/Entity/Billing/BillingRequestInterface.php
@@ -41,6 +41,21 @@ function getBillingAgreements();
function getBillingDate();
function setBillingDate(\DateTime $billingDate);
+
+ /**
+ * Add a consumption for this billing request
+ * Eg. key = bandwith_consumed, $value = 800
+ */
+ function addConsumption($key, $value);
+
+ /**
+ * Get the consumption data for this billing request
+ * For instance, consumed server traffic, number of app downloads, ...
+ */
+ function getConsumption();
+
+ function setConsumption(array $consumption);
+
/**
* Return the partner we would like to bill
*
@@ -49,12 +64,33 @@ function setBillingDate(\DateTime $billingDate);
function getOwner();
function setOwner(PartnerInterface $partner);
-
+
/**
- * Get the earliest moment we can execute this billing request
+ * Return the start of period we are billing for
*
* @return \DateTime
*/
+ function getPeriodStart();
+
+ function setPeriodStart(\DateTime $periodStart);
+ /**
+ * Return the end of period we are billing for
+ * The period covers the billing request including the end date.
+ *
+ * Typical use cases:
+ * - From 1/1 to 31/1 (European notation) includes 31/1 if only the date is relevant
+ * - From 1/1 00:00 to 30/1 : 23:59:59 if time is relevant as well
+ * @return \DateTime
+ */
+
+ function getPeriodEnd();
+
+ function setPeriodEnd(\DateTime $periodEnd);
+ /**
+ * Get the earliest moment we can startexecuting this billing request
+ *
+ * @return \DateTime
+ */
function getPlannedBillingDate();
function setPlannedBillingDate(\DateTime $plannedBillingDate);
@@ -65,4 +101,4 @@ function setPlannedBillingDate(\DateTime $plannedBillingDate);
* @return boolean
*/
function isBlocked();
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.