From 4eb1f57eec9304f2a4d6f204ff4702ab11c4c430 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 28 Jul 2016 17:27:43 +0200 Subject: Removed duplicate code --- classes/OfferItem.php | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 classes/OfferItem.php (limited to 'classes/OfferItem.php') diff --git a/classes/OfferItem.php b/classes/OfferItem.php new file mode 100644 index 0000000..5753eb2 --- /dev/null +++ b/classes/OfferItem.php @@ -0,0 +1,51 @@ +. + */ + +/** + * An abstract interface to a database table related to offers + */ +abstract class OfferItem extends Model implements Calculatable { + /** + * Get the offer that this assignment is linked to + * + * @return offer The offer + */ + public function getOffer() { + return new Offer($this->pdo, $this->offerId); + } + + /** + * The description after having parsed markdown + * + * @return string The description in HTML format + */ + public function getHTMLDescription() { + $pd = new Parsedown; + return $pd->text($this->description); + } + + public function calculateVAT() { + return $this->calculateSubtotal() * $this->VAT_percentage / 100; + } +} -- cgit v1.2.3