Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add methods to invoice class

  • Loading branch information...
commit 7a43444375ba710a08b4bfa5c2843576526f6a90 1 parent 1ae5616
@iampersistent iampersistent authored
View
107 lib/Vespolina/Entity/Invoice/Invoice.php
@@ -10,6 +10,7 @@
use Vespolina\Entity\Invoice\InvoiceInterface;
use Vespolina\Entity\Order\OrderInterface;
+use Vespolina\Entity\Partner\PartnerInterface;
/**
* Invoice for an order
@@ -19,18 +20,62 @@
class Invoice implements InvoiceInterface
{
protected $dueDate;
+ protected $id;
protected $issuedDate;
protected $orders;
protected $partner;
protected $payment;
protected $previousInvoice;
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setDueDate(\DateTime $dueDate)
+ {
+ $this->dueDate = $dueDate;
+
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDueDate()
+ {
+ return $this->dueDate;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setIssuedDate(\DateTime $issuedDate)
+ {
+ $this->issuedDate = $issuedDate;
+
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getIssuedDate()
+ {
+ return $this->issuedDate;
+ }
+
/**
* @inheritdoc
*/
public function addOrder(OrderInterface $order)
{
$this->orders[] = $order;
+
+ return $this;
}
/**
@@ -39,6 +84,8 @@ public function addOrder(OrderInterface $order)
public function clearOrders()
{
$this->orders = array();
+
+ return $this;
}
/**
@@ -55,6 +102,8 @@ public function getOrders()
public function mergeOrders(array $orders)
{
$this->orders = array_merge($this->orders, $orders);
+
+ return $this;
}
/**
@@ -68,6 +117,8 @@ public function removeOrder(OrderInterface $order)
break;
};
}
+
+ return $this;
}
/**
@@ -76,5 +127,61 @@ public function removeOrder(OrderInterface $order)
public function setOrders($orders)
{
$this->orders = $orders;
+
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setPartner(PartnerInterface $partner)
+ {
+ $this->partner = $partner;
+
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getPartner()
+ {
+ return $this->partner;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setPayment($payment)
+ {
+ $this->payment = $payment;
+
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getPayment()
+ {
+ return $this->payment;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setPreviousInvoice(InvoiceInterface $previousInvoice)
+ {
+ $this->previousInvoice = $previousInvoice;
+
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getPreviousInvoice()
+ {
+ return $this->previousInvoice;
}
}
View
120 lib/Vespolina/Entity/Invoice/InvoiceInterface.php
@@ -9,6 +9,7 @@
namespace Vespolina\Entity\Invoice;
use Vespolina\Entity\Order\OrderInterface;
+use Vespolina\Entity\Partner\PartnerInterface;
/**
* An interface for an invoice for an order
@@ -17,5 +18,124 @@
*/
interface InvoiceInterface
{
+ /**
+ * Set the due date of this invoice
+ *
+ * @param \DateTime $dueDate
+ * @return $this
+ */
+ function setDueDate(\DateTime $dueDate);
+ /**
+ * Return the due date of this invoice
+ *
+ * @return \DateTime $dueDate
+ */
+ function getDueDate();
+
+ /**
+ * Set the issued date of this invoice
+ *
+ * @param \DateTime $issuedDate
+ * @return $this
+ */
+ function setIssuedDate(\DateTime $issuedDate);
+
+ /**
+ * Return the issue date of this invoice
+ *
+ * @return \DateTime $dueDate
+ */
+ function getIssuedDate();
+
+ /**
+ * Add an order to be billed in this invoice
+ *
+ * @param \Vespolina\Entity\Order\OrderInterface $order
+ * @return $this
+ */
+ function addOrder(OrderInterface $order);
+
+ /**
+ * Remove all orders from this invoice
+ *
+ * @return $this
+ */
+ function clearOrders();
+
+ /**
+ * Return the orders with this invoice
+ *
+ * @return array
+ */
+ function getOrders();
+
+ /**
+ * Merge a group of orders with the orders in this invoice
+ *
+ * @param array $orders
+ * @return $this
+ */
+ function mergeOrders(array $orders);
+
+ /**
+ * Remove a specific order from the invoice
+ *
+ * @param \Vespolina\Entity\Order\OrderInterface $order
+ * @return $this
+ */
+ function removeOrder(OrderInterface $order);
+
+ /**
+ * Set a group of orders for this invoice
+ *
+ * @param array $orders
+ * @return $this
+ */
+ function setOrders(array $orders);
+
+ /**
+ * Set the Partner getting billed with this invoice
+ *
+ * @param \Vespolina\Entity\Partner\PartnerInterface $partner
+ * @return $this
+ */
+ function setPartner(PartnerInterface $partner);
+
+ /**
+ * Return the partner getting billed in this invoice
+ *
+ * @return \Vespolina\Entity\Partner\PartnerInterface
+ */
+ function getPartner();
+
+ /**
+ * Set the payment information from the billing
+ *
+ * @param $payment
+ * @return $this
+ */
+ function setPayment($payment);
+
+ /**
+ * Return the payment information for this billing
+ *
+ * @return
+ */
+ function getPayment();
+
+ /**
+ * Set previously created Invoice for the Partner, can be used for reporting
+ *
+ * @param \Vespolina\Entity\Partner\InvoiceInterface $previousInvoice
+ * @return $this
+ */
+ function setPreviousInvoice(InvoiceInterface $previousInvoice);
+
+ /**
+ * Return the previous invoice for the Partner
+ *
+ * @return \Vespolina\Entity\Partner\InvoiceInterface
+ */
+ function getPreviousInvoice();
}
View
2  tests/Entity/Invoice/InvoiceTest.php
@@ -11,7 +11,6 @@
class InvoiceTest extends \PHPUnit_Framework_TestCase
{
-
public function testOrders()
{
$invoice = new Invoice();
@@ -41,5 +40,4 @@ public function testOrders()
$this->assertNotContains($order, $invoice->getOrders(), 'this should have been removed on setting a new array of orders');
$this->assertCount(2, $invoice->getOrders());
}
-
}
Please sign in to comment.
Something went wrong with that request. Please try again.