| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- /**
- * @property InvoiceLineItem[] $lineItems
- */
- class Invoice {
- private $lineItems = [];
- private $taxRate = 0.2;
- private $reference = "";
- public function addLineItem(InvoiceLineItem $item) {
- $this->lineItems[] = $item;
- }
- public function addLineItems(array $items) {
- foreach($items as $item) {
- $this->addLineItem($item);
- }
- }
- /**
- * @return InvoiceLineItem[]
- */
- public function getLineItems(): array {
- return $this->lineItems;
- }
- public function getTotal() {
- $total = 0;
- foreach($this->lineItems as $item) {
- $total += $item->getTotal();
- }
- return $total;
- }
- public function getTaxRate(): float {
- return $this->taxRate;
- }
- public function setTaxRate(float $tax_rate): void {
- $this->taxRate = $tax_rate;
- }
- public function getTax(): float {
- return round($this->getTotal() * $this->taxRate, 2);
- }
- public function getTotalIncTax() {
- return $this->getTotal() + $this->getTax();
- }
- public function setReference(string $reference): void {
- $this->reference = $reference;
- }
- public function getReference(): string {
- return $this->reference;
- }
- }
|