src/Entity/Embeddable/BillingItemPrice.php line 13

Open in your IDE?
  1. <?php
  2. namespace MedBrief\MSR\Entity\Embeddable;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use MedBrief\MSR\Entity\BillingItem;
  5. /**
  6. * BillingItemPrice
  7. *
  8. * @ORM\Embeddable
  9. */
  10. class BillingItemPrice
  11. {
  12. // Unit options
  13. public const UNIT_MINUTES = 1;
  14. public const UNIT_MATTER = 2;
  15. public const UNIT_PAGE = 3;
  16. public const UNIT_DISC = 4;
  17. public const UNIT_CENTRE = 5;
  18. public const UNIT_METRE = 6;
  19. public const UNIT_FILM = 7;
  20. public const UNIT_DISBURSEMENT = 8;
  21. public const UNIT_XRAY = 9;
  22. public const UNIT_UNIT = 10;
  23. public const UNIT_HOUR = 11;
  24. public const UNIT_BATCH = 12;
  25. public const UNIT_CLIENT = 13;
  26. public const UNIT_INVOICE = 14;
  27. public const UNIT_CHRONOLOGY = 15;
  28. public const UNIT_ITEM = 16;
  29. /**
  30. * @var string
  31. *
  32. * @ORM\Column(name="amount", type="decimal", precision=7, scale=2)
  33. */
  34. protected $amount;
  35. /**
  36. * @var string
  37. *
  38. * @ORM\Column(name="unit", type="string")
  39. */
  40. protected $unit;
  41. /**
  42. * @var string
  43. *
  44. * @ORM\Column(name="unitDescription", type="string")
  45. */
  46. protected $unitDescription;
  47. /**
  48. * @var int
  49. *
  50. * @ORM\Column(name="unitQuantity", type="integer")
  51. */
  52. protected $unitQuantity;
  53. /**
  54. * @var bool
  55. *
  56. * @ORM\Column(name="vatInclusive", type="boolean", options={"default"=false})
  57. */
  58. protected $vatInclusive;
  59. /**
  60. * Option to hide this billing item from invoices.
  61. *
  62. * @var bool
  63. *
  64. * @ORM\Column(name="hideFromInvoice", type="boolean")
  65. */
  66. protected $hideFromInvoice;
  67. /**
  68. * Constructor
  69. */
  70. public function __construct()
  71. {
  72. // Assign default values to booleans
  73. $this->vatInclusive = false;
  74. $this->hideFromInvoice = false;
  75. }
  76. /**
  77. * __toString
  78. *
  79. * @return string
  80. */
  81. public function __toString()
  82. {
  83. return (string) '£' . $this->amount . ' per ' . $this->getUnitDescription();
  84. }
  85. /**
  86. * Set amount
  87. *
  88. * @param string $amount
  89. *
  90. * @return self
  91. */
  92. public function setAmount($amount)
  93. {
  94. $this->amount = $amount;
  95. return $this;
  96. }
  97. /**
  98. * Get amount
  99. *
  100. * @return string
  101. */
  102. public function getAmount()
  103. {
  104. return $this->amount;
  105. }
  106. /**
  107. * Set unit
  108. *
  109. * @param string $unit
  110. *
  111. * @return self
  112. */
  113. public function setUnit($unit)
  114. {
  115. $this->unit = $unit;
  116. return $this;
  117. }
  118. /**
  119. * Get unit
  120. *
  121. * @return string
  122. */
  123. public function getUnit()
  124. {
  125. return $this->unit;
  126. }
  127. /**
  128. * Get unit options
  129. *
  130. * @return string
  131. */
  132. public static function getUnitOptions()
  133. {
  134. return [
  135. self::UNIT_MINUTES => 'Minutes',
  136. self::UNIT_MATTER => 'Matter',
  137. self::UNIT_PAGE => 'Page',
  138. self::UNIT_DISC => 'Disc',
  139. self::UNIT_CENTRE => 'Centre',
  140. self::UNIT_METRE => 'Metre',
  141. self::UNIT_FILM => 'Film',
  142. self::UNIT_DISBURSEMENT => 'Disbursement',
  143. self::UNIT_XRAY => 'Xray',
  144. self::UNIT_UNIT => 'Unit',
  145. self::UNIT_HOUR => 'Hour',
  146. self::UNIT_BATCH => 'Batch',
  147. self::UNIT_CLIENT => 'Client',
  148. self::UNIT_INVOICE => 'Invoice',
  149. self::UNIT_CHRONOLOGY => 'Chronology',
  150. self::UNIT_ITEM => 'Item',
  151. ];
  152. }
  153. /**
  154. * Get unit label
  155. *
  156. * @return string
  157. */
  158. public function getUnitLabel()
  159. {
  160. $options = self::getUnitOptions();
  161. return $options[$this->getUnit()] ?? '';
  162. }
  163. /**
  164. * Set unitDescription
  165. *
  166. * @param string $unitDescription
  167. *
  168. * @return self
  169. */
  170. public function setUnitDescription($unitDescription)
  171. {
  172. $this->unitDescription = $unitDescription;
  173. return $this;
  174. }
  175. /**
  176. * Get unitDescription
  177. *
  178. * @return string
  179. */
  180. public function getUnitDescription()
  181. {
  182. return $this->unitDescription;
  183. }
  184. /**
  185. * Set unitQuantity
  186. *
  187. * @param int $unitQuantity
  188. *
  189. * @return self
  190. */
  191. public function setUnitQuantity($unitQuantity)
  192. {
  193. $this->unitQuantity = $unitQuantity;
  194. return $this;
  195. }
  196. /**
  197. * Get unitQuantity
  198. *
  199. * @return int
  200. */
  201. public function getUnitQuantity()
  202. {
  203. return $this->unitQuantity;
  204. }
  205. /**
  206. * Set vatInclusive
  207. *
  208. * @param bool $vatInclusive
  209. *
  210. * @return BillingItemPrice
  211. */
  212. public function setVatInclusive($vatInclusive)
  213. {
  214. $this->vatInclusive = $vatInclusive;
  215. return $this;
  216. }
  217. /**
  218. * Get vatInclusive
  219. *
  220. * @return bool
  221. */
  222. public function getVatInclusive()
  223. {
  224. return $this->vatInclusive;
  225. }
  226. /**
  227. * Get vatInclusiveLabel
  228. *
  229. * @return bool
  230. */
  231. public function getVatInclusiveLabel()
  232. {
  233. return $this->vatInclusive ? 'Yes' : 'No';
  234. }
  235. /**
  236. * Set hideFromInvoice
  237. *
  238. * @param bool $hideFromInvoice
  239. *
  240. * @return BillingItem
  241. */
  242. public function setHideFromInvoice($hideFromInvoice)
  243. {
  244. $this->hideFromInvoice = $hideFromInvoice;
  245. return $this;
  246. }
  247. /**
  248. * Get hideFromInvoice
  249. *
  250. * @return bool
  251. */
  252. public function getHideFromInvoice()
  253. {
  254. return $this->hideFromInvoice;
  255. }
  256. /**
  257. * Returns the label for the hideFromInvoice field.
  258. *
  259. * @return string
  260. */
  261. public function getHideFromInvoiceLabel()
  262. {
  263. return $this->getHideFromInvoice() ? 'Yes' : 'No';
  264. }
  265. }