sale_id); } /** * @return Product * @throws \Exception */ public function getProduct(): Product { return Product::get($this->product_id); } public function getDisplayPrice(): string { return (new NumberFormatter("en_GB", NumberFormatter::CURRENCY))->formatCurrency($this->unit_price * $this->quantity, $this->getCurrency()); } private function getCurrency(): string { return $this->getSale()->getCurrency(); } public function getAmount(): string { return bcmul($this->unit_price, $this->quantity, 2); } public function jsonSerialize(): array { return [ "id" => (int) $this->id, "saleId" => (int) $this->sale_id, "productId" => (int) $this->product_id, "quantity" => (int) $this->quantity, "unitPrice" => $this->unit_price ]; } }