278 lines
5.4 KiB
PHP
278 lines
5.4 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use DateTime;
|
|
use App\Ramcar\InvoiceStatus;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="invoice")
|
|
*/
|
|
class Invoice
|
|
{
|
|
// unique id
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\Column(type="integer")
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
*/
|
|
protected $id;
|
|
|
|
// date invoice was created
|
|
/**
|
|
* @ORM\Column(type="datetime")
|
|
*/
|
|
protected $date_create;
|
|
|
|
// date that the invoice was paid
|
|
/**
|
|
* @ORM\Column(type="datetime", nullable=true)
|
|
*/
|
|
protected $date_paid;
|
|
|
|
// date that the invoice was cancelled
|
|
/**
|
|
* @ORM\Column(type="datetime", nullable=true)
|
|
*/
|
|
protected $date_cancel;
|
|
|
|
// user that created the invoice
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="User", inversedBy="invoices")
|
|
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true)
|
|
*/
|
|
protected $created_by;
|
|
|
|
// the job order the invoice was created from
|
|
/**
|
|
* @ORM\OneToOne(targetEntity="JobOrder", inversedBy="invoice")
|
|
* @ORM\JoinColumn(name="job_order_id", referencedColumnName="id")
|
|
*/
|
|
protected $job_order;
|
|
|
|
// invoice items
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="InvoiceItem", mappedBy="invoice", cascade={"persist", "remove"})
|
|
*/
|
|
protected $items;
|
|
|
|
// total discount (amount, not %)
|
|
/**
|
|
* @ORM\Column(type="decimal", precision=9, scale=2)
|
|
*/
|
|
protected $discount;
|
|
|
|
// total trade in (amount)
|
|
/**
|
|
* @ORM\Column(type="decimal", precision=9, scale=2)
|
|
*/
|
|
protected $trade_in;
|
|
|
|
// total vat (amount, not %)
|
|
/**
|
|
* @ORM\Column(type="decimal", precision=9, scale=2)
|
|
*/
|
|
protected $vat;
|
|
|
|
// vat exclusive price (amount)
|
|
/**
|
|
* @ORM\Column(type="decimal", precision=9, scale=2)
|
|
*/
|
|
protected $vat_exclusive_price;
|
|
|
|
// total price (amount)
|
|
/**
|
|
* @ORM\Column(type="decimal", precision=9, scale=2)
|
|
*/
|
|
protected $total_price;
|
|
|
|
// status
|
|
/**
|
|
* @ORM\Column(type="string", length=40)
|
|
*/
|
|
protected $status;
|
|
|
|
// promo used by this invoice
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="Promo")
|
|
* @ORM\JoinColumn(name="promo_id", referencedColumnName="id")
|
|
*/
|
|
protected $promo;
|
|
|
|
// customer tag used by this invoice
|
|
/**
|
|
* @ORM\Column(type="string", length=80, nullable=true)
|
|
*/
|
|
protected $used_customer_tag_id;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->date_create = new DateTime();
|
|
$this->items = new ArrayCollection();
|
|
$this->status = InvoiceStatus::DRAFT;
|
|
}
|
|
|
|
public function getID()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getDateCreate()
|
|
{
|
|
return $this->date_create;
|
|
}
|
|
|
|
public function setDatePaid(DateTime $date)
|
|
{
|
|
$this->date_paid = $date;
|
|
return $this;
|
|
}
|
|
|
|
public function getDatePaid()
|
|
{
|
|
return $this->date_paid;
|
|
}
|
|
|
|
public function setDateCancel(DateTime $date)
|
|
{
|
|
$this->date_cancel = $date;
|
|
return $this;
|
|
}
|
|
|
|
public function getDateCancel()
|
|
{
|
|
return $this->date_cancel;
|
|
}
|
|
|
|
public function setCreatedBy(User $user)
|
|
{
|
|
$this->created_by = $user;
|
|
return $this;
|
|
}
|
|
|
|
public function getCreatedBy()
|
|
{
|
|
return $this->created_by;
|
|
}
|
|
|
|
public function setJobOrder(JobOrder $job_order)
|
|
{
|
|
$this->job_order = $job_order;
|
|
return $this;
|
|
}
|
|
|
|
public function getJobOrder()
|
|
{
|
|
return $this->job_order;
|
|
}
|
|
|
|
public function addItem(InvoiceItem $item)
|
|
{
|
|
$this->items->add($item);
|
|
$item->setInvoice($this);
|
|
return $this;
|
|
}
|
|
|
|
public function clearItems()
|
|
{
|
|
$this->items->clear();
|
|
return $this;
|
|
}
|
|
|
|
public function getItems()
|
|
{
|
|
return $this->items;
|
|
}
|
|
|
|
public function setDiscount($discount)
|
|
{
|
|
$this->discount = $discount;
|
|
return $this;
|
|
}
|
|
|
|
public function getDiscount()
|
|
{
|
|
return $this->discount;
|
|
}
|
|
|
|
public function setTradeIn($trade_in)
|
|
{
|
|
$this->trade_in = $trade_in;
|
|
return $this;
|
|
}
|
|
|
|
public function getTradeIn()
|
|
{
|
|
return $this->trade_in;
|
|
}
|
|
|
|
public function setVAT($vat)
|
|
{
|
|
$this->vat = $vat;
|
|
return $this;
|
|
}
|
|
|
|
public function getVAT()
|
|
{
|
|
return $this->vat;
|
|
}
|
|
|
|
public function setVATExclusivePrice($price)
|
|
{
|
|
$this->vat_exclusive_price = $price;
|
|
return $this;
|
|
}
|
|
|
|
public function getVATExclusivePrice()
|
|
{
|
|
return $this->vat_exclusive_price;
|
|
}
|
|
|
|
public function setTotalPrice($price)
|
|
{
|
|
$this->total_price = $price;
|
|
return $this;
|
|
}
|
|
|
|
public function getTotalPrice()
|
|
{
|
|
return $this->total_price;
|
|
}
|
|
|
|
public function setStatus($status)
|
|
{
|
|
$this->status = $status;
|
|
return $this;
|
|
}
|
|
|
|
public function getStatus()
|
|
{
|
|
return $this->status;
|
|
}
|
|
|
|
public function setPromo(Promo $promo)
|
|
{
|
|
$this->promo = $promo;
|
|
return $this;
|
|
}
|
|
|
|
public function getPromo()
|
|
{
|
|
return $this->promo;
|
|
}
|
|
|
|
public function setUsedCustomerTagId($used_customer_tag_id)
|
|
{
|
|
$this->used_customer_tag_id = $used_customer_tag_id;
|
|
return $this;
|
|
}
|
|
|
|
public function getUsedCustomerTagId()
|
|
{
|
|
return $this->used_customer_tag_id;
|
|
}
|
|
|
|
}
|